@@ -4,8 +4,10 @@
|
||||
|
||||
import decodeAddress from './decode';
|
||||
import encodeAddress from './encode';
|
||||
import setAddressPrefix from './setPrefix';
|
||||
|
||||
export {
|
||||
decodeAddress,
|
||||
encodeAddress
|
||||
encodeAddress,
|
||||
setAddressPrefix
|
||||
};
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
import { KeyringInstance, KeyringPair, KeyringPair$Json, KeyringPair$Meta } from './types';
|
||||
|
||||
import mnemonicToSecret from '@polkadot/util-crypto/mnemonic/toSecret';
|
||||
import mnemonicToSeed from '@polkadot/util-crypto/mnemonic/toSeed';
|
||||
import naclKeypairFromSeed from '@polkadot/util-crypto/nacl/keypair/fromSeed';
|
||||
import hexToU8a from '@polkadot/util/hex/toU8a';
|
||||
|
||||
import addressDecode from './address/decode';
|
||||
import { decodeAddress, encodeAddress, setAddressPrefix } from './address';
|
||||
import createPair from './pair';
|
||||
import Pairs from './pairs';
|
||||
|
||||
@@ -25,7 +25,7 @@ export default class Keyring implements KeyringInstance {
|
||||
|
||||
addFromAddress (address: string | Uint8Array, meta?: KeyringPair$Meta, defaultEncoded?: Uint8Array): KeyringPair {
|
||||
// @ts-ignore no secretKey - cannot unlock
|
||||
return this.addPair(createPair({ publicKey: addressDecode(address) }, meta, defaultEncoded));
|
||||
return this.addPair(createPair({ publicKey: decodeAddress(address) }, meta, defaultEncoded));
|
||||
}
|
||||
|
||||
addFromJson ({ address, encoded, meta }: KeyringPair$Json): KeyringPair {
|
||||
@@ -33,7 +33,7 @@ export default class Keyring implements KeyringInstance {
|
||||
}
|
||||
|
||||
addFromMnemonic (mnemonic: string, meta?: KeyringPair$Meta): KeyringPair {
|
||||
return this.addFromSeed(mnemonicToSecret(mnemonic).subarray(0, 32), meta);
|
||||
return this.addFromSeed(mnemonicToSeed(mnemonic), meta);
|
||||
}
|
||||
|
||||
addFromSeed (seed: Uint8Array, meta?: KeyringPair$Meta): KeyringPair {
|
||||
@@ -65,4 +65,4 @@ export default class Keyring implements KeyringInstance {
|
||||
}
|
||||
}
|
||||
|
||||
export { Keyring };
|
||||
export { Keyring, decodeAddress, encodeAddress, setAddressPrefix };
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
export * from './blake2';
|
||||
export * from './keccak';
|
||||
export * from './mnemonic';
|
||||
export * from './nacl';
|
||||
export * from './random';
|
||||
export * from './sha512';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2018 @polkadot/util-crypto authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import mnemonicGenerate from './generate';
|
||||
import mnemonicToSeed from './toSeed';
|
||||
import mnemonicValidate from './validate';
|
||||
|
||||
export {
|
||||
mnemonicGenerate,
|
||||
mnemonicToSeed,
|
||||
mnemonicValidate
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2018 @polkadot/util-crypto authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import toSecret from './toSecret';
|
||||
|
||||
export default function toSeed (mnemonic: string): Uint8Array {
|
||||
return toSecret(mnemonic).subarray(0, 32);
|
||||
}
|
||||
Reference in New Issue
Block a user