Fix addFromMnemonic (#395)
* Fix addFromMnemonic * Fix errant (try-out) fn param * Update tests
This commit is contained in:
@@ -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`
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user