diff --git a/packages/keyring/src/index.spec.ts b/packages/keyring/src/index.spec.ts index 74e2f244c..24db97347 100644 --- a/packages/keyring/src/index.spec.ts +++ b/packages/keyring/src/index.spec.ts @@ -3,10 +3,9 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { hexToU8a, stringToU8a } from '@polkadot/util'; -import { cryptoWaitReady } from '@polkadot/util-crypto'; +import { cryptoWaitReady, setAddressPrefix } from '@polkadot/util-crypto'; import Keyring from '.'; -import setPrefix from './address/setPrefix'; describe('keypair', () => { beforeEach(async () => { @@ -41,7 +40,7 @@ describe('keypair', () => { }); it('adds from a mnemonic', () => { - setPrefix(68); + setAddressPrefix(68); expect( keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address() @@ -107,7 +106,7 @@ describe('keypair', () => { }); it('adds from a mnemonic', () => { - setPrefix(68); + setAddressPrefix(68); expect( keypair.addFromMnemonic('moral movie very draw assault whisper awful rebuild speed purity repeat card', {}).address() diff --git a/packages/keyring/src/index.ts b/packages/keyring/src/index.ts index 074c44b60..ffdd45fcd 100644 --- a/packages/keyring/src/index.ts +++ b/packages/keyring/src/index.ts @@ -3,8 +3,8 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { assertSingletonPackage } from '@polkadot/util'; +import { decodeAddress, encodeAddress, setAddressPrefix } from '@polkadot/util-crypto'; -import { decodeAddress, encodeAddress, setAddressPrefix } from './address'; import { default as Keyring } from './keyring'; assertSingletonPackage('@polkadot/keyring'); diff --git a/packages/keyring/src/keyring.ts b/packages/keyring/src/keyring.ts index 7b03fc9c5..bc78cbf3e 100644 --- a/packages/keyring/src/keyring.ts +++ b/packages/keyring/src/keyring.ts @@ -6,9 +6,8 @@ import { KeypairType } from '@polkadot/util-crypto/types'; import { KeyringInstance, KeyringPair, KeyringPair$Json, KeyringPair$Meta, KeyringOptions } from './types'; import { assert, hexToU8a, isNumber, isHex, stringToU8a } from '@polkadot/util'; -import { keyExtractSuri, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, mnemonicToMiniSecret, keyFromPath } from '@polkadot/util-crypto'; +import { decodeAddress, encodeAddress, keyExtractSuri, keyFromPath, naclKeypairFromSeed as naclFromSeed, schnorrkelKeypairFromSeed as schnorrkelFromSeed, mnemonicToMiniSecret, setAddressPrefix } from '@polkadot/util-crypto'; -import { decodeAddress, encodeAddress, setAddressPrefix } from './address'; import { DEV_PHRASE } from './defaults'; import createPair from './pair'; import Pairs from './pairs'; diff --git a/packages/keyring/src/pair/index.ts b/packages/keyring/src/pair/index.ts index 3aee03a9d..ada44618b 100644 --- a/packages/keyring/src/pair/index.ts +++ b/packages/keyring/src/pair/index.ts @@ -6,9 +6,8 @@ import { Keypair, KeypairType } from '@polkadot/util-crypto/types'; import { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types'; import { PairInfo } from './types'; -import { naclKeypairFromSeed as naclFromSeed, naclSign, naclVerify, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, schnorrkelVerify } from '@polkadot/util-crypto'; +import { encodeAddress, naclKeypairFromSeed as naclFromSeed, naclSign, naclVerify, schnorrkelKeypairFromSeed as schnorrkelFromSeed, schnorrkelSign, schnorrkelVerify } from '@polkadot/util-crypto'; -import { encodeAddress } from '../address'; import decode from './decode'; import encode from './encode'; import toJson from './toJson'; diff --git a/packages/keyring/src/pair/nobody.ts b/packages/keyring/src/pair/nobody.ts index 85e77e75d..e51acb44f 100644 --- a/packages/keyring/src/pair/nobody.ts +++ b/packages/keyring/src/pair/nobody.ts @@ -4,10 +4,10 @@ import { KeyringPair, KeyringPair$Json, KeyringPair$Meta } from '../types'; -import addressEncode from '../address/encode'; +import { encodeAddress } from '@polkadot/util-crypto'; const publicKey = new Uint8Array(32); -const address = addressEncode(publicKey); +const address = encodeAddress(publicKey); const meta = { isTesting: true, name: 'nobody' diff --git a/packages/keyring/src/pair/toJson.ts b/packages/keyring/src/pair/toJson.ts index 1ebdcb3d4..1ecc76114 100644 --- a/packages/keyring/src/pair/toJson.ts +++ b/packages/keyring/src/pair/toJson.ts @@ -6,8 +6,7 @@ import { KeypairType } from '@polkadot/util-crypto/types'; import { KeyringPair$Json, KeyringPair$Meta } from '../types'; import { u8aToHex } from '@polkadot/util'; - -import { encodeAddress } from '../address'; +import { encodeAddress } from '@polkadot/util-crypto'; type PairStateJson = KeyringPair$Meta & { publicKey: Uint8Array diff --git a/packages/keyring/src/pairs.ts b/packages/keyring/src/pairs.ts index 45883b7bf..75cbbe215 100644 --- a/packages/keyring/src/pairs.ts +++ b/packages/keyring/src/pairs.ts @@ -5,8 +5,7 @@ import { KeyringPairs, KeyringPair } from './types'; import { assert, isHex, isU8a, u8aToHex, u8aToU8a } from '@polkadot/util'; - -import addressDecode from './address/decode'; +import { decodeAddress } from '@polkadot/util-crypto'; type KeyringPairMap = { // @ts-ignore we use coercion :( @@ -33,7 +32,7 @@ export default class Pairs implements KeyringPairs { get (address: string | Uint8Array): KeyringPair { // @ts-ignore we use coercion :( - const pair = this._map[addressDecode(address)]; + const pair = this._map[decodeAddress(address)]; assert(pair, () => { const formatted: string = isU8a(address) || isHex(address) @@ -48,6 +47,6 @@ export default class Pairs implements KeyringPairs { remove (address: string | Uint8Array): void { // @ts-ignore we use coercion :( - delete this._map[addressDecode(address)]; + delete this._map[decodeAddress(address)]; } } diff --git a/packages/keyring/src/types.ts b/packages/keyring/src/types.ts index 6848ecf0e..47fcf6f92 100644 --- a/packages/keyring/src/types.ts +++ b/packages/keyring/src/types.ts @@ -2,8 +2,8 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { Prefix } from '@polkadot/util-crypto/address/types'; import { KeypairType } from '@polkadot/util-crypto/types'; -import { Prefix } from './address/types'; export type KeyringOptions = { addressPrefix?: Prefix, diff --git a/packages/trie-db/src/index.ts b/packages/trie-db/src/index.ts index 09b14a679..59ffac25a 100644 --- a/packages/trie-db/src/index.ts +++ b/packages/trie-db/src/index.ts @@ -135,7 +135,7 @@ export default class Trie extends Impl implements TrieDb { } entries (): Array { - l.debug(() => 'retreiving trie entries'); + l.debug(() => 'retrieving trie entries'); const start = Date.now(); const entries = this._entries(this.rootHash); diff --git a/packages/keyring/src/address/decode.spec.ts b/packages/util-crypto/src/address/decode.spec.ts similarity index 94% rename from packages/keyring/src/address/decode.spec.ts rename to packages/util-crypto/src/address/decode.spec.ts index f985de54b..c077968b6 100644 --- a/packages/keyring/src/address/decode.spec.ts +++ b/packages/util-crypto/src/address/decode.spec.ts @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. // @flow -import testingPairs from '../testingPairs'; +import testingPairs from '../../../keyring/src/testingPairs'; import decode from './decode'; describe('decode', () => { diff --git a/packages/keyring/src/address/decode.ts b/packages/util-crypto/src/address/decode.ts similarity index 96% rename from packages/keyring/src/address/decode.ts rename to packages/util-crypto/src/address/decode.ts index f6a3f52ce..7c1a2c911 100644 --- a/packages/keyring/src/address/decode.ts +++ b/packages/util-crypto/src/address/decode.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/keyring/src/address/defaults.ts b/packages/util-crypto/src/address/defaults.ts similarity index 87% rename from packages/keyring/src/address/defaults.ts rename to packages/util-crypto/src/address/defaults.ts index 0d7861c2b..559388f3d 100644 --- a/packages/keyring/src/address/defaults.ts +++ b/packages/util-crypto/src/address/defaults.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/keyring/src/address/encode.spec.ts b/packages/util-crypto/src/address/encode.spec.ts similarity index 91% rename from packages/keyring/src/address/encode.spec.ts rename to packages/util-crypto/src/address/encode.spec.ts index 2e39dfb24..cc8edf718 100644 --- a/packages/keyring/src/address/encode.spec.ts +++ b/packages/util-crypto/src/address/encode.spec.ts @@ -1,9 +1,9 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. // @flow -import testingPairs from '../testingPairs'; +import testingPairs from '../../../keyring/src/testingPairs'; import encode from './encode'; const keyring = testingPairs({ type: 'ed25519' }, false); diff --git a/packages/keyring/src/address/encode.ts b/packages/util-crypto/src/address/encode.ts similarity index 93% rename from packages/keyring/src/address/encode.ts rename to packages/util-crypto/src/address/encode.ts index b71797054..84f25d8dc 100644 --- a/packages/keyring/src/address/encode.ts +++ b/packages/util-crypto/src/address/encode.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/keyring/src/address/index.ts b/packages/util-crypto/src/address/index.ts similarity index 82% rename from packages/keyring/src/address/index.ts rename to packages/util-crypto/src/address/index.ts index 5197a7169..25cbce0bc 100644 --- a/packages/keyring/src/address/index.ts +++ b/packages/util-crypto/src/address/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/keyring/src/address/setPrefix.spec.ts b/packages/util-crypto/src/address/setPrefix.spec.ts similarity index 86% rename from packages/keyring/src/address/setPrefix.spec.ts rename to packages/util-crypto/src/address/setPrefix.spec.ts index 8e915f2fe..c75e1e825 100644 --- a/packages/keyring/src/address/setPrefix.spec.ts +++ b/packages/util-crypto/src/address/setPrefix.spec.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/keyring/src/address/setPrefix.ts b/packages/util-crypto/src/address/setPrefix.ts similarity index 81% rename from packages/keyring/src/address/setPrefix.ts rename to packages/util-crypto/src/address/setPrefix.ts index a2d9c7135..0e4ef7f0d 100644 --- a/packages/keyring/src/address/setPrefix.ts +++ b/packages/util-crypto/src/address/setPrefix.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/keyring/src/address/sshash.ts b/packages/util-crypto/src/address/sshash.ts similarity index 75% rename from packages/keyring/src/address/sshash.ts rename to packages/util-crypto/src/address/sshash.ts index d97ce2bb9..004708218 100644 --- a/packages/keyring/src/address/sshash.ts +++ b/packages/util-crypto/src/address/sshash.ts @@ -1,9 +1,10 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { stringToU8a, u8aConcat } from '@polkadot/util'; -import { blake2AsU8a } from '@polkadot/util-crypto'; + +import blake2AsU8a from '../blake2/asU8a'; const SS58_PREFIX = stringToU8a('SS58PRE'); diff --git a/packages/keyring/src/address/types.ts b/packages/util-crypto/src/address/types.ts similarity index 72% rename from packages/keyring/src/address/types.ts rename to packages/util-crypto/src/address/types.ts index 02aaf6165..2e2c225b7 100644 --- a/packages/keyring/src/address/types.ts +++ b/packages/util-crypto/src/address/types.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2019 @polkadot/keyring authors & contributors +// Copyright 2017-2019 @polkadot/util-crypto authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/util-crypto/src/index.ts b/packages/util-crypto/src/index.ts index de0a655a8..9582557eb 100644 --- a/packages/util-crypto/src/index.ts +++ b/packages/util-crypto/src/index.ts @@ -6,6 +6,7 @@ import './polyfill'; import wasmCrypto from '@polkadot/wasm-crypto'; +export * from './address'; export * from './blake2'; export * from './keccak'; export * from './key';