Update keyring, new ss58 checksums (#812)
This commit is contained in:
+4
-3
@@ -1,9 +1,10 @@
|
||||
# 0.53.1
|
||||
|
||||
- Change spelling to US English as per substrate master (1.0-rc1), potential breaking
|
||||
- Change spelling to US English as per substrate master (1.0-rc1). Breaking changes as a result:
|
||||
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised` now check on the status for `result.status.isFinalized` or `result.status.isBoadcast`, ... (the `type` property is now accessible only on `result.status.type`)
|
||||
- If using `subscribeFinalisedHeads` update to `subscribeFinalizedHeads` (likewise `'getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
|
||||
- All examples have been updated with sr25519 addesses
|
||||
- If using `subscribeFinalisedHeads` update this to `subscribeFinalizedHeads` (likewise `'getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
|
||||
- The underlying ss58 addess checksums have changed in the keyring along with the latest specs
|
||||
- All examples have been updated with sr25519 addresses (with the new checksums)
|
||||
|
||||
# 0.52.1
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB';
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
async function main () {
|
||||
// Create an await for the API
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
|
||||
// Our address for Alice on the dev chain
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB';
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
async function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const { ApiPromise } = require('@polkadot/api');
|
||||
const { Keyring } = require('@polkadot/keyring');
|
||||
|
||||
const BOB_ADDR = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM696e4';
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Instantiate the API
|
||||
@@ -16,7 +16,7 @@ async function main () {
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
// Create a extrinsic, transferring 12345 units to Bob
|
||||
const transfer = api.tx.balances.transfer(BOB_ADDR, 12345);
|
||||
const transfer = api.tx.balances.transfer(BOB, 12345);
|
||||
|
||||
// Sign and send the transaction using our account
|
||||
const hash = await transfer.signAndSend(alice);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -9,7 +9,7 @@ const testKeyring = require('@polkadot/keyring/testing');
|
||||
const { randomAsU8a } = require('@polkadot/util-crypto');
|
||||
|
||||
// some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB';
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
async function main () {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -3,7 +3,7 @@ const { ApiRx } = require('@polkadot/api');
|
||||
const { pairwise, startWith } = require('rxjs/operators');
|
||||
|
||||
// Known account we want to use (available on dev chain, with funds)
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB';
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
async function main () {
|
||||
// Create an await for the API
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -5,7 +5,7 @@ const { combineLatest, of } = require('rxjs');
|
||||
const { first, switchMap } = require('rxjs/operators');
|
||||
|
||||
// Our address for Alice on the dev chain
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB';
|
||||
const Alice = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
function main () {
|
||||
// Create our API with a default connection to the local node
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
const { ApiRx } = require('@polkadot/api');
|
||||
const { Keyring } = require('@polkadot/keyring');
|
||||
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM696e4';
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
async function main () {
|
||||
// Instantiate the API
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -8,7 +8,7 @@ const testKeyring = require('@polkadot/keyring/testing');
|
||||
const { randomAsU8a } = require('@polkadot/util-crypto');
|
||||
|
||||
// some constants we are using in this sample
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKv3gB';
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const AMOUNT = 10000;
|
||||
|
||||
async function main () {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.52.1"
|
||||
"@polkadot/api": "^0.53.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
|
||||
@@ -48,7 +48,7 @@ describe.skip('derive e2e', () => {
|
||||
// these only work on localhost, not the poc-3 URL
|
||||
// (and it is assuming it sent at least 1 tx)
|
||||
describe('accounts', () => {
|
||||
const ID = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ';
|
||||
const ID = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const IX = 'F7Gh';
|
||||
|
||||
it('looks up id & index from id', async (done) => {
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
"@polkadot/rpc-rx": "^0.53.0-beta.1",
|
||||
"@polkadot/storage": "^0.53.0-beta.1",
|
||||
"@polkadot/types": "^0.53.0-beta.1",
|
||||
"@polkadot/util-crypto": "^0.42.1"
|
||||
"@polkadot/util-crypto": "^0.43.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,6 @@
|
||||
"@polkadot/jsonrpc": "^0.53.0-beta.1",
|
||||
"@polkadot/rpc-provider": "^0.53.0-beta.1",
|
||||
"@polkadot/types": "^0.53.0-beta.1",
|
||||
"@polkadot/util": "^0.42.1"
|
||||
"@polkadot/util": "^0.43.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import storage from '@polkadot/storage/static';
|
||||
|
||||
import Api from '.';
|
||||
|
||||
const ADDR_ONE = '5EhmTa7fL6SdjgKXo9g6hetR6nHnRAmrtisoGFWEESjzECtY';
|
||||
const ADDR_TWO = '5FjbQAHSptRU4Q7Py6zDsRnE7UkpZikJVg5nm1tmu3WuZXKd';
|
||||
const ADDR_ONE = '5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo';
|
||||
const ADDR_TWO = '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF';
|
||||
|
||||
const ENC_ONE = '0x24988a82b3bbaae58680bc9de5dea5aa';
|
||||
const ENC_TWO = '0xdb190750267d8849c35316ec9d342111';
|
||||
const ENC_ONE = '0x4af2c53fce3ec33c6ccccf22e926f1a7';
|
||||
const ENC_TWO = '0x3e62f7ed6e788e1337bce2a97b68a12a';
|
||||
|
||||
describe('formatting', () => {
|
||||
let api: Api;
|
||||
|
||||
@@ -7,7 +7,7 @@ import storage from '@polkadot/storage/static';
|
||||
|
||||
import Rpc from '../../src';
|
||||
|
||||
const ALICE = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ';
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
|
||||
describe.skip('e2e state', () => {
|
||||
let api;
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.0",
|
||||
"@polkadot/keyring": "^0.42.1",
|
||||
"@polkadot/keyring": "^0.43.0-beta.0",
|
||||
"@polkadot/storage": "^0.53.0-beta.1",
|
||||
"@polkadot/util": "^0.42.1",
|
||||
"@polkadot/util-crypto": "^0.42.1",
|
||||
"@polkadot/util": "^0.43.0-beta.0",
|
||||
"@polkadot/util-crypto": "^0.43.0-beta.0",
|
||||
"@types/nock": "^9.3.1",
|
||||
"eventemitter3": "^3.1.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.0",
|
||||
"@polkadot/types": "^0.53.0-beta.1",
|
||||
"@polkadot/util": "^0.42.1"
|
||||
"@polkadot/util": "^0.43.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('fromMetadata', () => {
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', () => {
|
||||
expect(() => newExtrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s', 2, 3)).not.toThrow();
|
||||
expect(() => newExtrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', 2, 3)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', () => {
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.0",
|
||||
"@polkadot/keyring": "^0.42.1",
|
||||
"@polkadot/keyring": "^0.43.0-beta.0",
|
||||
"@polkadot/types": "^0.53.0-beta.1",
|
||||
"@polkadot/util": "^0.42.1",
|
||||
"@polkadot/util-crypto": "^0.42.1"
|
||||
"@polkadot/util": "^0.43.0-beta.0",
|
||||
"@polkadot/util-crypto": "^0.43.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
import { Metadata } from '@polkadot/types';
|
||||
import json from '@polkadot/types/Metadata/v0/static';
|
||||
|
||||
@@ -20,11 +21,13 @@ describe('fromMetadata', () => {
|
||||
expect(() => newStorage.timestamp.now()).not.toThrow();
|
||||
});
|
||||
|
||||
// FIXME check again when we have a valid chain/UI
|
||||
it('should return the correct length-prefixed storage key', () => {
|
||||
expect(newStorage.balances.freeBalance('5GwPuAgYgP6q58uWTXp4uSg6FwfzQv9HfFZwAFEREUrQjCvy')).toEqual(
|
||||
// U8a is length-prefixed
|
||||
Uint8Array.from([64, 52, 103, 23, 10, 157, 95, 244, 9, 70, 215, 120, 149, 1, 238, 109, 69])
|
||||
expect(
|
||||
u8aToHex(
|
||||
newStorage.balances.freeBalance('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo')
|
||||
)
|
||||
).toEqual(
|
||||
'0x404af2c53fce3ec33c6ccccf22e926f1a7'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.4.0",
|
||||
"@polkadot/keyring": "^0.42.1",
|
||||
"@polkadot/util": "^0.42.1"
|
||||
"@polkadot/keyring": "^0.43.0-beta.0",
|
||||
"@polkadot/util": "^0.43.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,12 +129,12 @@ describe('Vector', () => {
|
||||
});
|
||||
|
||||
it('finds the index of an value', () => {
|
||||
const myId = '5GfWeNe33QeyzVMV2uENuvSXLVfVXCiuLvfEP6WCDHADZhen';
|
||||
const myId = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const vec = new Vector(AccountId, [
|
||||
'5H4787dXL43BaA6PvTwUTyA38JBbfC9r8QyK3ay8Nozc2Ta3', '5GeJHN5EcUGPoa5pUwYkXjymoDVN1DJHsBR4UGX4XRAwKBVk', '5Dn8F1SUX6SoLt1BTfKEPL5VY9wMvG1A6tEJTSCHpLsinThm', '5DPW1n4q2THUjKGj3QKkcqdh6oxY1bmLsSQ7t8FuiuNtRoUc', '5E8k3u7iRysqPPYsBK1UgetCquZznwRZxryTzynkDTzg3vNy', '5DteAmjoppNJ8rrBugKctCXM82UVWZSCHeU8pqFwQBbyAWyB', '5GfWeNe33QeyzVMV2uENuvSXLVfVXCiuLvfEP6WCDHADZhen'
|
||||
'5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw', '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty', '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'
|
||||
]);
|
||||
|
||||
expect(vec.indexOf(myId)).toEqual(6);
|
||||
expect(vec.indexOf(myId)).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { hexToU8a } from '@polkadot/util';
|
||||
import storage from '@polkadot/storage/static';
|
||||
|
||||
import StorageKey from './StorageKey';
|
||||
@@ -12,10 +13,10 @@ describe('StorageKey', () => {
|
||||
new StorageKey(
|
||||
storage
|
||||
.balances
|
||||
.freeBalance('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ')
|
||||
.freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
||||
)
|
||||
.toHex()
|
||||
).toBe('0xce3f3d8f09e3411403f5ca59d042a40e'); // FIXME OK this should be length-prefixed in reality
|
||||
).toBe('0xc99f5446efa57788f39ab529311f4550'); // FIXME OK this should be length-prefixed in reality
|
||||
});
|
||||
|
||||
it(`should correctly get Alice's freeBalance storage key (u8a)`, () => {
|
||||
@@ -23,11 +24,12 @@ describe('StorageKey', () => {
|
||||
new StorageKey(
|
||||
storage
|
||||
.balances
|
||||
.freeBalance('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ')
|
||||
.freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
||||
)
|
||||
.toU8a()
|
||||
).toEqual(
|
||||
Uint8Array.from([64, 206, 63, 61, 143, 9, 227, 65, 20, 3, 245, 202, 89, 208, 66, 164, 14]) // Length-prefixed
|
||||
// length prefix attached
|
||||
hexToU8a('0x40c99f5446efa57788f39ab529311f4550')
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('AccountId', () => {
|
||||
});
|
||||
|
||||
it('equals the empty address', () => {
|
||||
expect(id.eq('5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUppTZ')).toBe(true);
|
||||
expect(id.eq('5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,17 +36,17 @@ describe('AccountId', () => {
|
||||
testDecode(
|
||||
'AccountId',
|
||||
new AccountId('0x0102030405060708010203040506070801020304050607080102030405060708'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode('hex', '0x0102030405060708010203040506070801020304050607080102030405060708', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s');
|
||||
testDecode('string', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s');
|
||||
testDecode('hex', '0x0102030405060708010203040506070801020304050607080102030405060708', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF');
|
||||
testDecode('string', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF');
|
||||
testDecode(
|
||||
'U8a',
|
||||
new U8a([
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
]),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array',
|
||||
@@ -54,12 +54,12 @@ describe('AccountId', () => {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
]),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
});
|
||||
|
||||
describe('encoding', () => {
|
||||
const testEncode = (to: 'toHex' | 'toJSON' | 'toString' | 'toU8a', expected: Uint8Array | string, input: string = '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s') =>
|
||||
const testEncode = (to: 'toHex' | 'toJSON' | 'toString' | 'toU8a', expected: Uint8Array | string, input: string = '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF') =>
|
||||
it(`can encode ${to}`, () => {
|
||||
const a = new AccountId(input);
|
||||
|
||||
@@ -67,16 +67,16 @@ describe('AccountId', () => {
|
||||
});
|
||||
|
||||
testEncode('toHex', '0x0102030405060708010203040506070801020304050607080102030405060708');
|
||||
testEncode('toJSON', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s');
|
||||
testEncode('toString', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s');
|
||||
testEncode('toString', '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUppTZ', '0x00');
|
||||
testEncode('toJSON', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF');
|
||||
testEncode('toString', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF');
|
||||
testEncode('toString', '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM', '0x00');
|
||||
testEncode('toU8a', Uint8Array.from([
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
]));
|
||||
|
||||
it('decodes to a non-empty value', () => {
|
||||
expect(new AccountId('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s').isEmpty).toBe(false);
|
||||
expect(new AccountId('7qT1BvpawNbqb3BZaBTMFMMAKrpJKLPf1LmEHR1JyarWJdMX').isEmpty).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -88,14 +88,14 @@ describe('AccountId', () => {
|
||||
const list = new Vector(AccountId, data).map((accountId) => accountId.toString());
|
||||
|
||||
expect(list).toEqual([
|
||||
'7qVJujLF3EDbZt5WfQXWvueFedMS4Vfk2Hb4GyR8jwksTZQ5',
|
||||
'7pHyqeYaJjJPgxQgCXoS2EZMhBhtpm6BLCqQ4jJZTQB2kEDM',
|
||||
'7pYLWV6PTUmLTMQfHmmuBwBNLkhcKhRAnkM36CSJtjat9Cxe',
|
||||
'7qT1BvpawNbqb3BZaBTMFMMAKrpJKLPf1LmEHR1JyarWJpvA',
|
||||
'7rADc9JW5EUGFPWLjPMipH4c3bJ2GyAUedmqQHiaGucWVifb',
|
||||
'7oK5KRH6jt4p8auipnru9ptqeuRwbLMHA2tgCViZzhmW4Mo2',
|
||||
'7ndAVsHvonnzTg4AvRhpraNCKj9g4CGQXKoLrgkTZ91NaLgJ',
|
||||
'7oL7VfXgLA8L3pJJwi11v3sBYc1b5R3tLrweHwzMNxgEpWuv'
|
||||
'7qVJujLF3EDbZt5WfQXWvueFedMS4Vfk2Hb4GyR8jwksTLup',
|
||||
'7pHyqeYaJjJPgxQgCXoS2EZMhBhtpm6BLCqQ4jJZTQB2kMhw',
|
||||
'7pYLWV6PTUmLTMQfHmmuBwBNLkhcKhRAnkM36CSJtjat9ACb',
|
||||
'7qT1BvpawNbqb3BZaBTMFMMAKrpJKLPf1LmEHR1JyarWJdMX',
|
||||
'7rADc9JW5EUGFPWLjPMipH4c3bJ2GyAUedmqQHiaGucWVrsT',
|
||||
'7oK5KRH6jt4p8auipnru9ptqeuRwbLMHA2tgCViZzhmW4Lox',
|
||||
'7ndAVsHvonnzTg4AvRhpraNCKj9g4CGQXKoLrgkTZ91Na6PE',
|
||||
'7oL7VfXgLA8L3pJJwi11v3sBYc1b5R3tLrweHwzMNxgEpjxP'
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,28 +14,28 @@ describe('AccountIndex', () => {
|
||||
|
||||
it('creates a BN representation (from ss-58)', () => {
|
||||
expect(
|
||||
new AccountIndex('Mwz15xN8').toNumber()
|
||||
new AccountIndex('Mwz15xP2').toNumber()
|
||||
).toEqual(336794129);
|
||||
});
|
||||
|
||||
it('constructs 2-byte from number', () => {
|
||||
expect(
|
||||
new AccountIndex(256 * 1).toString()
|
||||
).toEqual('25GUyk');
|
||||
).toEqual('25GUyv');
|
||||
});
|
||||
|
||||
it('constructs from number', () => {
|
||||
expect(
|
||||
new AccountIndex(new BN(336794129)).toString()
|
||||
).toEqual('Mwz15xN8');
|
||||
).toEqual('Mwz15xP2');
|
||||
});
|
||||
|
||||
it('compares ss-58 values', () => {
|
||||
expect(new AccountIndex(256 * 1).eq('25GUyk')).toBe(true);
|
||||
expect(new AccountIndex(256 * 1).eq('25GUyv')).toBe(true);
|
||||
});
|
||||
|
||||
it('compares numbers', () => {
|
||||
expect(new AccountIndex('25GUyk').eq(256 * 1)).toBe(true);
|
||||
expect(new AccountIndex('2jpAFn').eq(256 * 1)).toBe(true);
|
||||
});
|
||||
|
||||
describe('calcLength', () => {
|
||||
|
||||
@@ -15,38 +15,38 @@ describe('Address', () => {
|
||||
|
||||
describe('utility', () => {
|
||||
it('equals on AccountId', () => {
|
||||
const addr = '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s';
|
||||
const addr = '5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo';
|
||||
|
||||
expect(new Address(addr).eq(addr)).toBe(true);
|
||||
});
|
||||
|
||||
it('equals on AccountIndex', () => {
|
||||
// see the test below - these are equivalent (with different prefix encoding)
|
||||
expect(new Address('PrF3').eq('F7ih')).toBe(true);
|
||||
expect(new Address('2jpAFn').eq('25GUyv')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decoding', () => {
|
||||
testDecode(
|
||||
'Address',
|
||||
new Address('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
new Address('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
'AccountId',
|
||||
new AccountId('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
new AccountId('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (mixed prefixes)',
|
||||
new Address('PrF3'),
|
||||
new Address('2jpAFn'),
|
||||
// NOTE Expected adress here is encoded with prefix 42, input above with 68
|
||||
'F7ih'
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (hex)',
|
||||
new AccountIndex('0x0100'),
|
||||
'25GUyk'
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'Array',
|
||||
@@ -55,7 +55,7 @@ describe('Address', () => {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
],
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 255)',
|
||||
@@ -64,22 +64,22 @@ describe('Address', () => {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8
|
||||
]),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 1 byte)',
|
||||
Uint8Array.from([1]),
|
||||
'F7L6'
|
||||
'F7NZ'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 2 bytes)',
|
||||
Uint8Array.from([0xfc, 0, 1]),
|
||||
'25GUyk'
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 4 bytes)',
|
||||
Uint8Array.from([0xfd, 17, 18, 19, 20]),
|
||||
'Mwz15xN8'
|
||||
'Mwz15xP2'
|
||||
);
|
||||
// FIXME The specification allows for 8 byte addresses, however since AccountIndex is u32 internally
|
||||
// (and defined that way in thd efault Substrate),this does not actually work since it is 8 bytes,
|
||||
@@ -94,7 +94,7 @@ describe('Address', () => {
|
||||
describe('encoding', () => {
|
||||
const testEncode = (to: 'toHex' | 'toString' | 'toU8a', expected: string | Uint8Array) =>
|
||||
it(`can encode ${to}`, () => {
|
||||
const a = new Address('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s');
|
||||
const a = new Address('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF');
|
||||
expect(a[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('Address', () => {
|
||||
);
|
||||
testEncode(
|
||||
'toString',
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCt72s'
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testEncode(
|
||||
'toU8a',
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('Extrinsic', () => {
|
||||
expect(extrinsic.signature.nonce.toNumber()).toEqual(3);
|
||||
expect(extrinsic.signature.era.toU8a()).toEqual(new Uint8Array([0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([3, 0]));
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5nni');
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo');
|
||||
});
|
||||
|
||||
it('decodes an actual transaction (old format)', () => {
|
||||
@@ -43,6 +43,6 @@ describe('Extrinsic', () => {
|
||||
expect(extrinsic.signature.nonce.toNumber()).toEqual(3);
|
||||
expect(extrinsic.signature.era.toU8a()).toEqual(new Uint8Array([0]));
|
||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([3, 0]));
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5nni');
|
||||
expect(extrinsic.args[0].toString()).toEqual('5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1579,14 +1579,14 @@
|
||||
typescript "^3.3.4000"
|
||||
vuepress "^1.0.0-alpha.44"
|
||||
|
||||
"@polkadot/keyring@^0.42.1":
|
||||
version "0.42.1"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.42.1.tgz#96b36543b7633d9aba3f9fe0ab5e69bafd73abae"
|
||||
integrity sha512-xY2e1FU6UDVO/OcMvz2Up7x27QexOQMOh9hy9dqIDfdwCGZrbsPRxiXTHFKUglAi5vUZhiSlGR/L0ealZaKD2Q==
|
||||
"@polkadot/keyring@^0.43.0-beta.0":
|
||||
version "0.43.0-beta.0"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.43.0-beta.0.tgz#d1f6edb24d9b9a817d48d6b180da8d0efb7c6121"
|
||||
integrity sha512-izJw9KxXpmewQw9aKIjmNpKiLnVNdvSY6fA55aXGLlCDLjkkufW1OXoZmhsGi3jWzto6wWWAFfnzBxvimzuPBQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.4.0"
|
||||
"@polkadot/util" "^0.42.1"
|
||||
"@polkadot/util-crypto" "^0.42.1"
|
||||
"@polkadot/util" "^0.43.0-beta.0"
|
||||
"@polkadot/util-crypto" "^0.43.0-beta.0"
|
||||
"@types/bs58" "^4.0.0"
|
||||
bs58 "^4.0.1"
|
||||
|
||||
@@ -1595,13 +1595,13 @@
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.56.tgz#ffd6e9c95704a7fb90b918193b9dc5c440114b27"
|
||||
integrity sha512-wnt4zXxZXyz6WaubTO/I+nUElwV2DogFzdl6CrKfVn2PTWp8uHN06W9s40FH57ORtmQfDr9rLRP8Nq+oIyElbg==
|
||||
|
||||
"@polkadot/util-crypto@^0.42.1":
|
||||
version "0.42.1"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.42.1.tgz#c19b1a8013ad40196a0384f82b92d18c3a63cfdf"
|
||||
integrity sha512-NmHUrR/ysxhLx/PpL/exF9X7pNEx4znOwNvXQ+ZCI1U2TGBXj0T8IomSkyVNuDUv0R+OYzmcJAFB0igTdiEqMw==
|
||||
"@polkadot/util-crypto@^0.43.0-beta.0":
|
||||
version "0.43.0-beta.0"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.43.0-beta.0.tgz#73440c789c83e7ff19d6ac7347a1573cd97b0da5"
|
||||
integrity sha512-840A3Dl+j6RHMeaQDwINM79VaVtBZdOSw2m7EuTkQXE1+705pLrwqpwUcXHNEo9fCz6Io6MkavJUm9nKZotjww==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.4.0"
|
||||
"@polkadot/util" "^0.42.1"
|
||||
"@polkadot/util" "^0.43.0-beta.0"
|
||||
"@polkadot/wasm-crypto" "^0.6.1"
|
||||
"@polkadot/wasm-dalek-ed25519" "^0.6.1"
|
||||
"@polkadot/wasm-schnorrkel" "^0.6.1"
|
||||
@@ -1617,10 +1617,10 @@
|
||||
tweetnacl "^1.0.1"
|
||||
xxhashjs "^0.2.2"
|
||||
|
||||
"@polkadot/util@^0.42.1":
|
||||
version "0.42.1"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.42.1.tgz#270f87c5370ab38e17d7aa77804686dc309328f7"
|
||||
integrity sha512-9Nd5VLl7SQjwjdWTWQZ978+7dc9AcXF5IfDe8JiS65i76YB7HPPS6bF4mYmbmrRXEWXi/DMx+A7FKHyz0BHgRg==
|
||||
"@polkadot/util@^0.43.0-beta.0":
|
||||
version "0.43.0-beta.0"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.43.0-beta.0.tgz#ec621344b690d49fec473c2a9b0d215b13d4decd"
|
||||
integrity sha512-XTHb3fowTO4fPTE+72xh1Cdy+/gdmi5ytsHuZtlNC1DH09TZ6R3GBi9NzX4mQZsH8dSUOzQkGHiHzCPRULE9fQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.4.0"
|
||||
"@types/bn.js" "^4.11.4"
|
||||
|
||||
Reference in New Issue
Block a user