diff --git a/CHANGELOG.md b/CHANGELOG.md index 869761ec5..48303d355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # 0.76.1 +- Fix `addFromMnemonic` to generate using new-style derivation. - Pull in formatBalance, formatDecimal, formatElapsed, formatNumber, calcSi, findSi & isTestChain util fuinctions from the originals in @polkadot/ui-util - Swap DB interfaces to optional LRU, removing transactionAsync (client-only changes) - Swap out `wasm-schnorrkel` & `wasm-ed25519` for combined version with `wasm-crypto` diff --git a/packages/keyring/src/index.spec.ts b/packages/keyring/src/index.spec.ts index e379d78b3..74e2f244c 100644 --- a/packages/keyring/src/index.spec.ts +++ b/packages/keyring/src/index.spec.ts @@ -45,7 +45,7 @@ describe('keypair', () => { expect( keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address() - ).toEqual('7pDZKLEixRnF6Q5jzr7DsCEiNPt3d6Rknc14SyUcnRwTQ8Jw'); + ).toEqual('7sPsxWPE5DzAyPT3VuoJYw5NTGscx9QYN9oddQx4kALKC3hH'); }); it('allows publicKeys retrieval', () => { @@ -111,7 +111,7 @@ describe('keypair', () => { expect( keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address() - ).toEqual('7nmZ1fkYHpnEz6tqR9cLkmwYRbqda9wPsiDq56JhgmNXq6uW'); + ).toEqual('7qQGarA4PWjPPVHG4USn1yuuVZvEHN7XZz8o7EbAp48jayZQ'); }); it('allows publicKeys retrieval', () => { diff --git a/packages/keyring/src/index.ts b/packages/keyring/src/index.ts index d18ef71c9..74121c45f 100644 --- a/packages/keyring/src/index.ts +++ b/packages/keyring/src/index.ts @@ -6,7 +6,7 @@ import { KeypairType } from '@polkadot/util-crypto/types'; import { KeyringInstance, KeyringPair, KeyringPair$Json, KeyringPair$Meta, KeyringOptions } from './types'; import { assert, assertSingletonPackage, hexToU8a, isNumber, isHex, stringToU8a } from '@polkadot/util'; -import { keyExtractSuri, mnemonicToSeed , naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, mnemonicToMiniSecret, keyFromPath } from '@polkadot/util-crypto'; +import { keyExtractSuri, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, mnemonicToMiniSecret, keyFromPath } from '@polkadot/util-crypto'; import { decodeAddress, encodeAddress, setAddressPrefix } from './address'; import { DEV_PHRASE } from './defaults'; @@ -104,6 +104,7 @@ export default class Keyring implements KeyringInstance { const type = version === '0' || !Array.isArray(content) ? this.type : content[1]; + return this.addFromAddress(address, meta, hexToU8a(encoded), type, ignoreChecksum); } @@ -116,7 +117,7 @@ export default class Keyring implements KeyringInstance { * `addPair` to stores in a keyring pair dictionary the public key of the generated pair as a key and the pair as the associated value. */ addFromMnemonic (mnemonic: string, meta: KeyringPair$Meta = {}, type: KeypairType = this.type): KeyringPair { - return this.addFromSeed(mnemonicToSeed(mnemonic), meta, type); + return this.addFromUri(mnemonic, meta, type); } /**