diff --git a/CHANGELOG.md b/CHANGELOG.md index 66ab2b07..b7bfd906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.33.1 + +- Rename createUri and createExternal to addExternal and addUr +- Rename addAccountPair to addPair +- Add additional createFromUri function to create pair, but not add it + # 0.32.1 - Add createUri to create an account from a path uri diff --git a/packages/ui-identicon/package.json b/packages/ui-identicon/package.json index d83e1876..361b37fa 100644 --- a/packages/ui-identicon/package.json +++ b/packages/ui-identicon/package.json @@ -24,8 +24,8 @@ "react": "*" }, "devDependencies": { - "@polkadot/keyring": "^0.39.1", - "@polkadot/util-crypto": "^0.39.1", + "@polkadot/keyring": "^0.40.0-beta.0", + "@polkadot/util-crypto": "^0.40.0-beta.0", "xmlserializer": "^0.6.1" } } diff --git a/packages/ui-keyring/package.json b/packages/ui-keyring/package.json index ed8e09c6..6c5a8cda 100644 --- a/packages/ui-keyring/package.json +++ b/packages/ui-keyring/package.json @@ -17,9 +17,9 @@ "styled-components": "^4.1.3" }, "devDependencies": { - "@polkadot/keyring": "^0.39.1", + "@polkadot/keyring": "^0.40.0-beta.0", "@polkadot/types": "^0.49.1", - "@polkadot/util": "^0.39.1" + "@polkadot/util": "^0.40.0-beta.0" }, "peerDependencies": { "@polkadot/keyring": "*", diff --git a/packages/ui-keyring/src/Keyring.ts b/packages/ui-keyring/src/Keyring.ts index ce3b03f8..49b6389c 100644 --- a/packages/ui-keyring/src/Keyring.ts +++ b/packages/ui-keyring/src/Keyring.ts @@ -20,11 +20,34 @@ import keyringOption from './options'; // Chain determination occurs outside of Keyring. Loading `keyring.loadAll({ type: 'ed25519' | 'sr25519' })` is triggered // from the API after the chain is received export class Keyring extends Base implements KeyringStruct { - addAccountPair (pair: KeyringPair, password: string): KeyringPair { - this.keyring.addPair(pair); - this.saveAccount(pair, password); + addExternal (publicKey: Uint8Array, meta: KeyringPair$Meta = {}): CreateResult { + const pair = this.keyring.addFromAddress(publicKey, { ...meta, isExternal: true }, null); + const json = this.saveAccount(pair); - return pair; + return { + json, + pair + }; + } + + addPair (pair: KeyringPair, password: string): CreateResult { + this.keyring.addPair(pair); + const json = this.saveAccount(pair, password); + + return { + json, + pair + }; + } + + addUri (suri: string, password?: string, meta: KeyringPair$Meta = {}, type?: KeypairType): CreateResult { + const pair = this.keyring.addFromUri(suri, meta, type); + const json = this.saveAccount(pair, password); + + return { + json, + pair + }; } backupAccount (pair: KeyringPair, password: string): KeyringPair$Json { @@ -38,41 +61,25 @@ export class Keyring extends Base implements KeyringStruct { } createAccount (seed: Uint8Array, password?: string, meta?: KeyringPair$Meta): KeyringPair { - console.warn('createAccount deprecated, use createUri instead'); + console.warn('createAccount deprecated, use addUri instead'); - return this.createUri(u8aToHex(seed), password, meta).pair; + return this.addUri(u8aToHex(seed), password, meta).pair; } createAccountExternal (publicKey: Uint8Array, meta?: KeyringPair$Meta): KeyringPair { - console.warn('createAccountExternal deprecated, use createUri instead'); + console.warn('createAccountExternal deprecated, use addExternal instead'); - return this.createExternal(publicKey, meta).pair; + return this.addExternal(publicKey, meta).pair; } createAccountMnemonic (seed: string, password?: string, meta?: KeyringPair$Meta): KeyringPair { console.warn('createAccountMnemonic deprecated, use createUri instead'); - return this.createUri(seed, password, meta).pair; + return this.addUri(seed, password, meta).pair; } - createExternal (publicKey: Uint8Array, meta: KeyringPair$Meta = {}): CreateResult { - const pair = this.keyring.addFromAddress(publicKey, { ...meta, isExternal: true }, null); - const json = this.saveAccount(pair); - - return { - json, - pair - }; - } - - createUri (suri: string, password?: string, meta: KeyringPair$Meta = {}, type?: KeypairType): CreateResult { - const pair = this.keyring.addFromUri(suri, meta, type); - const json = this.saveAccount(pair, password); - - return { - json, - pair - }; + createFromUri (suri: string, meta: KeyringPair$Meta = {}, type?: KeypairType): KeyringPair { + return this.keyring.createFromUri(suri, meta, type); } encryptAccount (pair: KeyringPair, password: string): void { @@ -194,7 +201,7 @@ export class Keyring extends Base implements KeyringStruct { // unlock, save account and then lock (locking cleans secretKey, so needs to be last) pair.decodePkcs8(password); - this.addAccountPair(pair, password); + this.addPair(pair, password); pair.lock(); return pair; diff --git a/packages/ui-keyring/src/types.ts b/packages/ui-keyring/src/types.ts index ec07ee34..eb854b0a 100644 --- a/packages/ui-keyring/src/types.ts +++ b/packages/ui-keyring/src/types.ts @@ -42,13 +42,14 @@ export interface KeyringStruct { readonly addresses: AddressSubject; readonly keyring: BaseKeyringInstance | undefined; - addAccountPair: (pair: KeyringPair, password: string) => KeyringPair; + addExternal: (publicKey: Uint8Array, meta?: KeyringPair$Meta) => CreateResult; + addPair: (pair: KeyringPair, password: string) => CreateResult; + addUri: (suri: string, password?: string, meta?: KeyringPair$Meta, type?: KeypairType) => CreateResult; backupAccount: (pair: KeyringPair, password: string) => KeyringPair$Json; createAccount: (seed: Uint8Array, password?: string, meta?: KeyringPair$Meta) => KeyringPair; createAccountExternal: (publicKey: Uint8Array, meta?: KeyringPair$Meta) => KeyringPair; createAccountMnemonic: (seed: string, password?: string, meta?: KeyringPair$Meta) => KeyringPair; - createExternal: (publicKey: Uint8Array, meta?: KeyringPair$Meta) => CreateResult; - createUri: (suri: string, password?: string, meta?: KeyringPair$Meta, type?: KeypairType) => CreateResult; + createFromUri (suri: string, meta?: KeyringPair$Meta, type?: KeypairType): KeyringPair; decodeAddress: (key: string | Uint8Array) => Uint8Array; encodeAddress: (key: string | Uint8Array) => string; encryptAccount: (pair: KeyringPair, password: string) => void; diff --git a/packages/ui-settings/package.json b/packages/ui-settings/package.json index b22e3db9..4bcecaec 100644 --- a/packages/ui-settings/package.json +++ b/packages/ui-settings/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.3.4", - "@polkadot/util": "^0.39.1", + "@polkadot/util": "^0.40.0-beta.0", "@types/store": "^2.0.1", "store": "^2.0.12" } diff --git a/yarn.lock b/yarn.lock index 4d31ebec..b11713c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1694,6 +1694,17 @@ "@types/bs58" "^4.0.0" bs58 "^4.0.1" +"@polkadot/keyring@^0.40.0-beta.0": + version "0.40.0-beta.0" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.40.0-beta.0.tgz#6091a65a77614e96bd6c0f5e8d2eea5b4d6a465e" + integrity sha512-4xvrWJ6jUXVaOpOvBJMRLfhwH33S6saAwA45pEHg9hOMvORfsWQzSOE/wqHsLKxnkDJwxih2SsRz+/lC3ARBLg== + dependencies: + "@babel/runtime" "^7.4.0" + "@polkadot/util" "^0.40.0-beta.0" + "@polkadot/util-crypto" "^0.40.0-beta.0" + "@types/bs58" "^4.0.0" + bs58 "^4.0.1" + "@polkadot/ts@^0.1.56": version "0.1.56" resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.56.tgz#ffd6e9c95704a7fb90b918193b9dc5c440114b27" @@ -1729,6 +1740,27 @@ tweetnacl "^1.0.1" xxhashjs "^0.2.2" +"@polkadot/util-crypto@^0.40.0-beta.0": + version "0.40.0-beta.0" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.40.0-beta.0.tgz#96684763846047e5eb8054f80e32756b214fa042" + integrity sha512-jlcHOUGKzdXCyAPz3owpLgWuXUHY0XdGlbGZFkb9Mh7bKvXjoF/uHfIODj/7l9lwstWA2iVpeGsKWAYjLM1h3Q== + dependencies: + "@babel/runtime" "^7.4.0" + "@polkadot/util" "^0.40.0-beta.0" + "@polkadot/wasm-crypto" "^0.2.1" + "@polkadot/wasm-schnorrkel" "^0.2.1" + "@types/bip39" "^2.4.2" + "@types/pbkdf2" "^3.0.0" + "@types/secp256k1" "^3.5.0" + "@types/webassembly-js-api" "^0.0.2" + "@types/xxhashjs" "^0.2.1" + bip39 "^2.5.0" + blakejs "^1.1.0" + js-sha3 "^0.8.0" + secp256k1 "^3.6.2" + tweetnacl "^1.0.1" + xxhashjs "^0.2.2" + "@polkadot/util@^0.39.1": version "0.39.1" resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.39.1.tgz#553155a0610e879abf51210a4f99af9c1e3ce25b" @@ -1744,6 +1776,21 @@ ip-regex "^4.0.0" moment "^2.24.0" +"@polkadot/util@^0.40.0-beta.0": + version "0.40.0-beta.0" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.40.0-beta.0.tgz#d68c73b720a92ae29a13659f1181ffed72fe5b80" + integrity sha512-pc+RCbxlOgZnag0OiDgd73HeUqClCQj4TuoxTMDgitbI53EkaMualSaPQ/DqlXWXUtG8frjKEEwF9QXUlQhpPw== + dependencies: + "@babel/runtime" "^7.4.0" + "@types/bn.js" "^4.11.4" + "@types/deasync" "^0.1.0" + "@types/ip-regex" "^3.0.0" + bn.js "^4.11.8" + camelcase "^5.2.0" + chalk "^2.4.2" + ip-regex "^4.0.0" + moment "^2.24.0" + "@polkadot/wasm-crypto@^0.2.1": version "0.2.1" resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-0.2.1.tgz#ba5eedf02f762d38fd705c57cba31db7f6e7eb1c"