Set default global encoding prefix (#224)
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user