From 6b8ecb26f2d26fe7925e4462fe04a6fc5a324385 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 29 Mar 2019 22:11:48 +0100 Subject: [PATCH] 0.75 --- CHANGELOG.md | 10 +++++--- lerna.json | 2 +- packages/api-derive/package.json | 6 ++--- packages/api/package.json | 16 ++++++------- packages/api/test/e2e/promise-tx.spec.js | 23 +++++++++++------- packages/rpc-core/package.json | 10 ++++---- packages/rpc-provider/package.json | 10 ++++---- packages/rpc-rx/package.json | 6 ++--- packages/type-extrinsics/package.json | 6 ++--- packages/type-jsonrpc/package.json | 2 +- packages/type-storage/package.json | 10 ++++---- packages/types/package.json | 6 ++--- packages/types/src/codec/EnumType.ts | 25 ++++++++++---------- yarn.lock | 30 ++++++++++++------------ 14 files changed, 86 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad2989749..9931e9d468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,19 @@ +# 0.75.1 + +- Start journey to 1.0 + # 0.53.1 - 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 this to `subscribeFinalizedHeads` (likewise `'getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`) + - 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.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`) + - 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 - Support queries to linked mapped storage (found in new staking interfaces) -- Add derive.staking.controllers to retrieve all active staking controllers +- Add `derive.staking.controllers` to retrieve all active staking controllers - Align types as per latest substrate master - PeerInfo from system_peers does not have the index field anymore (dropped in substrate) - Allow parsing of V3 metadata with DoubleMap support diff --git a/lerna.json b/lerna.json index bccdfb8098..bc043b78d8 100644 --- a/lerna.json +++ b/lerna.json @@ -9,5 +9,5 @@ "packages": [ "packages/*" ], - "version": "0.53.1" + "version": "0.75.0" } diff --git a/packages/api-derive/package.json b/packages/api-derive/package.json index 81bbf3ecb3..73edeef80e 100644 --- a/packages/api-derive/package.json +++ b/packages/api-derive/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/api-derive", - "version": "0.53.1", + "version": "0.75.0", "description": "Common functions used across Polkadot, derived from RPC calls and storage queries.", "main": "index.js", "keywords": [ @@ -31,8 +31,8 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme", "dependencies": { "@babel/runtime": "^7.4.0", - "@polkadot/api": "^0.53.1", - "@polkadot/types": "^0.53.1", + "@polkadot/api": "^0.75.0", + "@polkadot/types": "^0.75.0", "@types/memoizee": "^0.4.2", "memoizee": "^0.4.14" } diff --git a/packages/api/package.json b/packages/api/package.json index 8e6e0e9edd..dae5dc3beb 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/api", - "version": "0.53.1", + "version": "0.75.0", "description": "Promise and RxJS wrappers around the Polkadot JS RPC", "main": "index.js", "keywords": [ @@ -30,12 +30,12 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme", "dependencies": { "@babel/runtime": "^7.4.0", - "@polkadot/api-derive": "^0.53.1", - "@polkadot/extrinsics": "^0.53.1", - "@polkadot/rpc-provider": "^0.53.1", - "@polkadot/rpc-rx": "^0.53.1", - "@polkadot/storage": "^0.53.1", - "@polkadot/types": "^0.53.1", - "@polkadot/util-crypto": "^0.43.1" + "@polkadot/api-derive": "^0.75.0", + "@polkadot/extrinsics": "^0.75.0", + "@polkadot/rpc-provider": "^0.75.0", + "@polkadot/rpc-rx": "^0.75.0", + "@polkadot/storage": "^0.75.0", + "@polkadot/types": "^0.75.0", + "@polkadot/util-crypto": "^0.75.1" } } diff --git a/packages/api/test/e2e/promise-tx.spec.js b/packages/api/test/e2e/promise-tx.spec.js index 723ec4f7aa..6566161a19 100644 --- a/packages/api/test/e2e/promise-tx.spec.js +++ b/packages/api/test/e2e/promise-tx.spec.js @@ -33,7 +33,7 @@ describe.skip('e2e transactions', () => { const nonce = await api.query.system.accountNonce(keyring.dave.address()); return api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .sign(keyring.dave, { nonce }) .send(({ events, status }) => { console.log('Transaction status:', status.type); @@ -57,7 +57,7 @@ describe.skip('e2e transactions', () => { const nonce = await api.query.system.accountNonce(keyring.dave.address()); return api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .sign(keyring.dave, nonce) .send(({ events, status }) => { console.log('Transaction status:', status.type); @@ -79,7 +79,7 @@ describe.skip('e2e transactions', () => { it('makes a transfer (signAndSend)', async (done) => { return api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .signAndSend(keyring.dave, ({ events, status }) => { console.log('Transaction status:', status.type); @@ -100,9 +100,11 @@ describe.skip('e2e transactions', () => { it('makes a transfer (signAndSend via Signer)', async (done) => { const signer = new SingleAccountSigner(keyring.dave); + api.setSigner(signer); + return api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .signAndSend(keyring.dave.address(), ({ events, status }) => { console.log('Transaction status:', status.type); @@ -124,25 +126,30 @@ describe.skip('e2e transactions', () => { it('makes a transfer (signAndSend via Signer) - sad path', async () => { //no signer api.setSigner(); + await expect(api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .signAndSend(keyring.alice.address())).rejects.toThrow('no signer exists'); + const signer = new SingleAccountSigner(keyring.dave); + api.setSigner(signer); + //no callback await expect(api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .signAndSend(keyring.alice.address())).rejects.toThrow('does not have the keyringPair'); + //with callback await expect(api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .signAndSend(keyring.alice.address(), ({ events, status }) => { })).rejects.toThrow('does not have the keyringPair'); }); it('makes a transfer (no callback)', async () => { const hash = await api.tx.balances - .transfer('12ghjsRJpeJpUQaCQeHcBv9pRQA3tdcMxeL8cVk9JHWJGHjd', 12345) + .transfer(keyring.eve.address(), 12345) .signAndSend(keyring.dave); expect(hash.toHex()).toHaveLength(66); diff --git a/packages/rpc-core/package.json b/packages/rpc-core/package.json index a781c393ca..3262202d0c 100644 --- a/packages/rpc-core/package.json +++ b/packages/rpc-core/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/rpc-core", - "version": "0.53.1", + "version": "0.75.0", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "main": "index.js", "keywords": [ @@ -30,9 +30,9 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme", "dependencies": { "@babel/runtime": "^7.4.0", - "@polkadot/jsonrpc": "^0.53.1", - "@polkadot/rpc-provider": "^0.53.1", - "@polkadot/types": "^0.53.1", - "@polkadot/util": "^0.43.1" + "@polkadot/jsonrpc": "^0.75.0", + "@polkadot/rpc-provider": "^0.75.0", + "@polkadot/types": "^0.75.0", + "@polkadot/util": "^0.75.1" } } diff --git a/packages/rpc-provider/package.json b/packages/rpc-provider/package.json index 21f989e702..94795e75b3 100644 --- a/packages/rpc-provider/package.json +++ b/packages/rpc-provider/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/rpc-provider", - "version": "0.53.1", + "version": "0.75.0", "description": "Transport providers for the API", "main": "index.js", "keywords": [ @@ -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.43.1", - "@polkadot/storage": "^0.53.1", - "@polkadot/util": "^0.43.1", - "@polkadot/util-crypto": "^0.43.1", + "@polkadot/keyring": "^0.75.1", + "@polkadot/storage": "^0.75.0", + "@polkadot/util": "^0.75.1", + "@polkadot/util-crypto": "^0.75.1", "@types/nock": "^9.3.1", "eventemitter3": "^3.1.0", "isomorphic-fetch": "^2.2.1", diff --git a/packages/rpc-rx/package.json b/packages/rpc-rx/package.json index 65ff2e3fad..8d1837233d 100644 --- a/packages/rpc-rx/package.json +++ b/packages/rpc-rx/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/rpc-rx", - "version": "0.53.1", + "version": "0.75.0", "description": "An RxJs wrapper around the Polkadot JS API", "main": "index.js", "keywords": [ @@ -30,8 +30,8 @@ "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-rx#readme", "dependencies": { "@babel/runtime": "^7.4.0", - "@polkadot/rpc-core": "^0.53.1", - "@polkadot/rpc-provider": "^0.53.1", + "@polkadot/rpc-core": "^0.75.0", + "@polkadot/rpc-provider": "^0.75.0", "@types/memoizee": "^0.4.2", "@types/rx": "^4.1.1", "memoizee": "^0.4.14", diff --git a/packages/type-extrinsics/package.json b/packages/type-extrinsics/package.json index e09343fc20..5d312b3978 100644 --- a/packages/type-extrinsics/package.json +++ b/packages/type-extrinsics/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/extrinsics", - "version": "0.53.1", + "version": "0.75.0", "main": "index.js", "repository": "https://github.com/polkadot-js/api.git", "author": "Jaco Greeff ", @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.4.0", - "@polkadot/types": "^0.53.1", - "@polkadot/util": "^0.43.1" + "@polkadot/types": "^0.75.0", + "@polkadot/util": "^0.75.1" } } diff --git a/packages/type-jsonrpc/package.json b/packages/type-jsonrpc/package.json index ddd81016ed..41e70f5662 100644 --- a/packages/type-jsonrpc/package.json +++ b/packages/type-jsonrpc/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/jsonrpc", - "version": "0.53.1", + "version": "0.75.0", "description": "Method definitions for the Polkadot RPC layer", "main": "index.js", "engines": { diff --git a/packages/type-storage/package.json b/packages/type-storage/package.json index ca7000ecea..cc56cc9ec4 100644 --- a/packages/type-storage/package.json +++ b/packages/type-storage/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/storage", - "version": "0.53.1", + "version": "0.75.0", "description": "Generic wrapper wrapper around state storage", "main": "index.js", "engines": { @@ -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.43.1", - "@polkadot/types": "^0.53.1", - "@polkadot/util": "^0.43.1", - "@polkadot/util-crypto": "^0.43.1" + "@polkadot/keyring": "^0.75.1", + "@polkadot/types": "^0.75.0", + "@polkadot/util": "^0.75.1", + "@polkadot/util-crypto": "^0.75.1" } } diff --git a/packages/types/package.json b/packages/types/package.json index ea94ca7a82..256f05c4f7 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/types", - "version": "0.53.1", + "version": "0.75.0", "description": "Implementation of the Parity codec", "main": "index.js", "keywords": [ @@ -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.43.1", - "@polkadot/util": "^0.43.1" + "@polkadot/keyring": "^0.75.1", + "@polkadot/util": "^0.75.1" } } diff --git a/packages/types/src/codec/EnumType.ts b/packages/types/src/codec/EnumType.ts index 7fec8c0f5a..9054e3e5e4 100644 --- a/packages/types/src/codec/EnumType.ts +++ b/packages/types/src/codec/EnumType.ts @@ -83,23 +83,22 @@ export default class EnumType extends Base implements Codec { return EnumType.createValue(def, 0); } - private static createViaJSON (def: TypesDef, aliasses: Aliasses, key: string, value?: any) { + private static createViaJSON (def: TypesDef, _aliasses: Aliasses, key: string, value?: any) { // JSON comes in the form of { "": "" }, here we // additionally force to lower to ensure forward compat - const keys = Object.keys(def).map((u) => u.toLowerCase()); - const index = keys - .map((k) => { - const a = Object - .keys(aliasses) - .find((a) => aliasses[a].toLowerCase() === k); + const keys = Object.keys(def).map((k) => k.toLowerCase()); - return a - ? a.toLowerCase() - : k; - }) - .indexOf(key.toLowerCase()); + // FIXME This whole lookup process is not vey efficient + const keyLower = key.toLowerCase(); + const aliasses = Object.keys(_aliasses).reduce((aliasses, a) => { + aliasses[a.toLowerCase()] = _aliasses[a].toLowerCase(); - assert(index !== -1, `Unable to reliably map input on JSON, cannot find '${key}' in ${keys.join(', ')}`); + return aliasses; + }, {} as Aliasses); + const aliasKey = aliasses[keyLower] || keyLower; + const index = keys.indexOf(aliasKey); + + assert(index !== -1, `Cannot map input on JSON, unable to find '${key}' in ${keys.join(', ')}`); return EnumType.createValue(def, index, value); } diff --git a/yarn.lock b/yarn.lock index 6a99e7a385..232436b848 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1579,14 +1579,14 @@ typescript "^3.3.4000" vuepress "^1.0.0-alpha.44" -"@polkadot/keyring@^0.43.1": - version "0.43.1" - resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.43.1.tgz#08a4bca4c68a45ad897878e1451353eb77b34404" - integrity sha512-PzWTQAm8cKSGjRkYWQe0XMWKL4wQnfsJWL2GIFdyNH9z9JYmFmz9kSG8VqZw2CfQe8qiUsxtq7pnZNQ5yK005Q== +"@polkadot/keyring@^0.75.1": + version "0.75.1" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.75.1.tgz#9b3c32f5f403ba2b7f6aed760750111f49240cdd" + integrity sha512-TdwtrEnTG0U7Ecnduuoi3ON2K2k+DMdsKWPjZmooaXb8x2piudDzg+ouVnU17uOWTWAOeofRrLZENzMfiXfKZA== dependencies: "@babel/runtime" "^7.4.0" - "@polkadot/util" "^0.43.1" - "@polkadot/util-crypto" "^0.43.1" + "@polkadot/util" "^0.75.1" + "@polkadot/util-crypto" "^0.75.1" "@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.43.1": - version "0.43.1" - resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.43.1.tgz#01514f9af0e53f1115db7b547939d12b997df9ee" - integrity sha512-uf0CiagIggkXQWNO6E02Fqp8s2t10EIOhgIvScCvcv1aUrRP7BZgQoJ/cs0OvJygSB30Q1+OeL8C7lJlzuD9sw== +"@polkadot/util-crypto@^0.75.1": + version "0.75.1" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.75.1.tgz#9f2e85c3283a53248de7ac97cb08b82d6f13ea25" + integrity sha512-8LIRUzXY96H0cv5YA4r/+GYJB4f/gM+SGz6OaEv6NKBagaQpA6MOEJIgMFQ7tsB6eDh2dwYouDrKHT+qIFNsCw== dependencies: "@babel/runtime" "^7.4.0" - "@polkadot/util" "^0.43.1" + "@polkadot/util" "^0.75.1" "@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.43.1": - version "0.43.1" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.43.1.tgz#defa098ed2030e53633e849c38c832bc23c42c5a" - integrity sha512-pxZ4O+qk7u2rgF4PkRwf3LAv2gje5fwc4454/lMYpafCap5U8WeARMEtJ2UAxK1+npTWCwgXJkFXCI2CfdbyIw== +"@polkadot/util@^0.75.1": + version "0.75.1" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.75.1.tgz#f1719b7ac416e73d0683e443498b9693d7ac42f4" + integrity sha512-rXd8J6MR0MLFoi1duddUNL0ftKBtpuysgxUU4hGuVq335jS7xqNAV//nwwLXSLCsOkd3rlLJSz6mxbFXH/PfrQ== dependencies: "@babel/runtime" "^7.4.0" "@types/bn.js" "^4.11.4"