Remove from* variants, move fromString to stringTo (#233)

* Remove from* variants, move fromString to stringTo

* Bump
This commit is contained in:
Jaco Greeff
2018-10-18 10:30:14 +02:00
committed by GitHub
parent 35579c4d70
commit 57eddba598
56 changed files with 69 additions and 378 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
// of the ISC license. See the LICENSE file for details.
import hexToU8a from '@polkadot/util/hex/toU8a';
import u8aFromString from '@polkadot/util/u8a/fromString';
import u8aFromString from '@polkadot/util/string/toU8a';
import Keyring from './index';
import setPrefix from './address/setPrefix';
+2 -2
View File
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import stringToU8a from '@polkadot/util/string/toU8a';
import u8aConcat from '@polkadot/util/u8a/concat';
import u8aFixLength from '@polkadot/util/u8a/fixLength';
import u8aFromString from '@polkadot/util/u8a/fromString';
import assert from '@polkadot/util/assert';
import naclDecrypt from '@polkadot/util-crypto/nacl/decrypt';
import naclFromSeed from '@polkadot/util-crypto/nacl/keypair/fromSeed';
@@ -24,7 +24,7 @@ export default function decode (passphrase?: string, _encrypted?: Uint8Array) {
? (naclDecrypt(
encrypted.subarray(24),
encrypted.subarray(0, 24),
u8aFixLength(u8aFromString(passphrase), 256, true)) as Uint8Array)
u8aFixLength(stringToU8a(passphrase), 256, true)) as Uint8Array)
: encrypted;
assert(encoded, `Unable to unencrypt using the supplied passphrase`);
+2 -2
View File
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import stringToU8a from '@polkadot/util/string/toU8a';
import u8aConcat from '@polkadot/util/u8a/concat';
import u8aFixLength from '@polkadot/util/u8a/fixLength';
import u8aFromString from '@polkadot/util/u8a/fromString';
import naclEncrypt from '@polkadot/util-crypto/nacl/encrypt';
import { PKCS8_DIVIDER, PKCS8_HEADER } from './defaults';
@@ -21,7 +21,7 @@ export default function encode (secretKey: Uint8Array, passphrase?: string): Uin
return encoded;
}
const { encrypted, nonce } = naclEncrypt(encoded, u8aFixLength(u8aFromString(passphrase), 256, true));
const { encrypted, nonce } = naclEncrypt(encoded, u8aFixLength(stringToU8a(passphrase), 256, true));
return u8aConcat(nonce, encrypted);
}
+2 -2
View File
@@ -4,12 +4,12 @@
import { KeyringInstance } from './types';
import u8aFromString from '@polkadot/util/u8a/fromString';
import stringToU8a from '@polkadot/util/string/toU8a';
import Keyring from './index';
function padSeed (seed: string): Uint8Array {
return u8aFromString(seed.padEnd(32, ' '));
return stringToU8a(seed.padEnd(32, ' '));
}
const SEEDS: { [index: string ]: Uint8Array } = {