ss58Format option for Keyring (#471)

* ss58Format option  for Keyring

* Expose setSS58Format everywhere

* Remove setAddressPrefix

* 1.4.0
This commit is contained in:
Jaco Greeff
2019-09-12 13:59:03 +02:00
committed by GitHub
parent 00374effc5
commit 16d077c87d
21 changed files with 74 additions and 49 deletions
+4 -2
View File
@@ -7,13 +7,15 @@ import { Prefix } from './types';
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L34
import bs58 from 'bs58';
import { assert, u8aConcat, u8aToBuffer, u8aToU8a } from '@polkadot/util';
import { assert, u8aConcat, u8aToBuffer } from '@polkadot/util';
import decode from './decode';
import defaults from './defaults';
import sshash from './sshash';
export default function encode (_key: Uint8Array | string, prefix: Prefix = defaults.prefix): string {
const key = u8aToU8a(_key);
// decode it, this means we can re-encode an address
const key = decode(_key);
assert(defaults.allowedDecodedLengths.includes(key.length), `Expected a valid key to convert, with length ${defaults.allowedDecodedLengths}`);