Set default global encoding prefix (#224)

This commit is contained in:
Jaco Greeff
2018-10-13 20:43:17 +02:00
committed by GitHub
parent 4fbdeee00e
commit 62553296e1
3 changed files with 34 additions and 1 deletions
+3 -1
View File
@@ -4,10 +4,12 @@
import { Prefix } from './types';
export default {
const defaults = {
allowedDecodedLengths: [1, 2, 4, 8, 32],
// publicKey has prefix + 2 checksum bytes, short only prefix + 1 checksum byte
allowedEncodedLengths: [3, 4, 6, 10, 35],
allowedPrefix: [0, 1, 42, 43, 68, 69] as Array<Prefix>,
prefix: 42 as Prefix
};
export default defaults;
@@ -0,0 +1,20 @@
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import encode from './encode';
import setPrefix from './setPrefix';
describe('setPrefix', () => {
beforeEach(() => {
setPrefix(68);
});
it('sets and allows encoding using', () => {
expect(
encode(
new Uint8Array([1])
)
).toEqual('Pqt7');
});
});
+11
View File
@@ -0,0 +1,11 @@
// Copyright 2017-2018 @polkadot/util-keyring authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { Prefix } from './types';
import defaults from './defaults';
export default function setPrefix (prefix: Prefix): void {
defaults.prefix = prefix;
}