Bump util, fix constructors (#393)

This commit is contained in:
Jaco Greeff
2018-11-12 18:15:35 +01:00
committed by GitHub
parent ff8d5cc5bf
commit 8121aa2927
12 changed files with 133 additions and 84 deletions
+2 -2
View File
@@ -30,7 +30,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.1.2",
"@polkadot/keyring": "^0.32.13",
"@polkadot/util": "^0.32.13"
"@polkadot/keyring": "^0.32.15",
"@polkadot/util": "^0.32.15"
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ export default class Bytes extends U8a {
} else if (isHex(value)) {
// FIXME We manually add the length prefix for hex for now
// https://github.com/paritytech/substrate/issues/889
const u8a = hexToU8a(value as string);
const u8a = hexToU8a(value);
return Bytes.decodeBytes(
Compact.addLengthPrefix(u8a)
+1 -1
View File
@@ -52,7 +52,7 @@ export default class Extrinsic extends Struct {
// https://github.com/paritytech/substrate/issues/889
// Instead of the block below, it should simply be:
// return Extrinsic.decodeExtrinsic(hexToU8a(value as string));
const u8a = hexToU8a(value as string);
const u8a = hexToU8a(value);
return Extrinsic.decodeExtrinsic(
u8aConcat(
+1 -1
View File
@@ -331,7 +331,7 @@ export default class RuntimeMetadata extends Struct {
}, RuntimeMetadata.decodeMetadata(value));
}
static decodeMetadata (value: any): object | Uint8Array {
static decodeMetadata (value: string | Uint8Array | object): object | Uint8Array {
if (isHex(value)) {
// We receive this as an hex in the JSON output from the Node.
// Convert to u8a and use the U8a version to do the actual parsing.
+1 -1
View File
@@ -24,7 +24,7 @@ export default class Text extends Base<string> {
);
}
static decodeText (value: any): string {
static decodeText (value: Text | string | AnyU8a | { toString: () => string }): string {
if (isString(value)) {
return value;
} else if (value instanceof Text) {
+1 -1
View File
@@ -39,7 +39,7 @@ export default class UInt extends Base<BN> {
} else if (value instanceof U8a) {
return UInt.decodeUInt(value.raw, bitLength);
} else if (isHex(value)) {
return hexToBn(value as string);
return hexToBn(value);
} else if (isU8a(value)) {
// NOTE When passing u8a in (typically from decoded data), it is always LE
return u8aToBn(value.subarray(0, bitLength / 8), true);