This commit is contained in:
Jaco Greeff
2019-09-25 12:37:59 +02:00
committed by GitHub
parent b11b42e2b6
commit a512766bfb
17 changed files with 352 additions and 347 deletions
+3 -2
View File
@@ -1,7 +1,8 @@
# 1.5.1
- Fix typings on the Keyring-exposed encode & decodeAddress
- Allow ss58Format = 0 to not fallback to addressPrefix
- Fix typings on the Keyring-exposed encode & decodeAddress
- Allow ss58Format = 0 as a valid value
- Loosen type definitions for allowed ss58format values (still checked against allowed array)
# 1.4.1
+3 -3
View File
@@ -21,9 +21,9 @@
"test:one": "jest"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@polkadot/dev": "^0.31.0-beta.8",
"@polkadot/ts": "^0.1.72",
"@babel/core": "^7.6.2",
"@polkadot/dev": "^0.31.1",
"@polkadot/ts": "^0.1.73",
"gh-pages": "^2.1.1"
}
}
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/chainspec#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/util": "^1.5.0-beta.0"
}
}
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/db#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/trie-hash": "^1.5.0-beta.0",
"@polkadot/util": "^1.5.0-beta.0",
"lru_map": "^0.3.3"
+1 -1
View File
@@ -27,7 +27,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/util": "^1.5.0-beta.0",
"@polkadot/util-crypto": "^1.5.0-beta.0"
}
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/trie-codec#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/util": "^1.5.0-beta.0"
}
}
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/trie-db#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/db": "^1.5.0-beta.0",
"@polkadot/trie-codec": "^1.5.0-beta.0",
"@polkadot/trie-hash": "^1.5.0-beta.0",
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/trie-hash#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/util": "^1.5.0-beta.0"
},
"devDependencies": {
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/util": "^1.5.0-beta.0",
"@polkadot/wasm-crypto": "^0.14.1",
"@types/bip39": "^2.4.2",
+1 -1
View File
@@ -12,7 +12,7 @@ import sshash from './sshash';
export default function check (address: string, prefix: Prefix): [boolean, string | null] {
const decoded = bs58.decode(address);
if (decoded[0] as Prefix !== prefix) {
if (decoded[0] !== prefix) {
return [false, `Prefix mismatch, expected ${prefix}, found ${decoded[0]}`];
} else if (!defaults.allowedEncodedLengths.includes(decoded.length)) {
return [false, 'Invalid decoded address length'];
+1 -1
View File
@@ -13,7 +13,7 @@ import defaults from './defaults';
import sshash from './sshash';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default function decode (encoded: string | Uint8Array, ignoreChecksum?: boolean, ss58Format: Prefix = defaults.prefix): Uint8Array {
export default function decode (encoded: string | Uint8Array, ignoreChecksum?: boolean, ss58Format: Prefix = 99): Uint8Array {
if (isU8a(encoded) || isHex(encoded)) {
return u8aToU8a(encoded);
}
+3 -3
View File
@@ -2,14 +2,14 @@
// 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 './types';
import { allowedSS58 } from './ss58';
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, 3, 42, 43, 68, 69] as Prefix[],
prefix: 42 as Prefix
allowedPrefix: allowedSS58,
prefix: 42
};
export default defaults;
+16
View File
@@ -0,0 +1,16 @@
// 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.
export const allowedSS58 = [
// Polkadot
0, 1,
// Kusama
2, 3,
// Dothereum
20,
// Substrate default
42, 43,
// Substrate BBQ (deprecated)
68, 69
];
+3 -6
View File
@@ -2,9 +2,6 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
type PrefixPolkadot = 0;
type PrefixKusama = 2;
type PrefixSubstrate = 42;
type DeprecatedPrefixBBQ = 68;
export type Prefix = PrefixPolkadot | PrefixKusama | PrefixSubstrate | DeprecatedPrefixBBQ;
// FIXME we really want this to map with what is in the allowedSS58 array... i.e. the
// values there. As of now, we just map to number.
export type Prefix = number;
+1 -1
View File
@@ -27,7 +27,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-rlp#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@polkadot/util": "^1.5.0-beta.0"
},
"devDependencies": {
+1 -1
View File
@@ -25,7 +25,7 @@
},
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
"dependencies": {
"@babel/runtime": "^7.6.0",
"@babel/runtime": "^7.6.2",
"@types/bn.js": "^4.11.5",
"bn.js": "^4.11.8",
"camelcase": "^5.3.1",
+313 -322
View File
File diff suppressed because it is too large Load Diff