@polkadot/types-codec 10.10.1 → 10.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstract/Array.js +4 -0
- package/abstract/Base.js +5 -0
- package/abstract/Int.js +7 -0
- package/abstract/Object.js +5 -0
- package/base/Compact.js +6 -0
- package/base/DoNotConstruct.js +4 -0
- package/base/Enum.js +19 -11
- package/base/Null.js +6 -3
- package/base/Option.js +7 -1
- package/base/Tuple.js +1 -0
- package/base/Vec.js +1 -0
- package/base/VecFixed.js +1 -0
- package/cjs/abstract/Array.js +4 -0
- package/cjs/abstract/Base.js +5 -0
- package/cjs/abstract/Int.js +7 -0
- package/cjs/abstract/Object.js +5 -0
- package/cjs/base/Compact.js +6 -0
- package/cjs/base/DoNotConstruct.js +4 -0
- package/cjs/base/Enum.js +19 -11
- package/cjs/base/Null.js +6 -3
- package/cjs/base/Option.js +7 -1
- package/cjs/base/Tuple.js +1 -0
- package/cjs/base/Vec.js +1 -0
- package/cjs/base/VecFixed.js +1 -0
- package/cjs/extended/BTreeSet.js +5 -0
- package/cjs/extended/BitVec.js +2 -0
- package/cjs/extended/Map.js +7 -0
- package/cjs/extended/Range.js +1 -0
- package/cjs/extended/WrapperKeepOpaque.js +3 -0
- package/cjs/native/Bool.js +4 -1
- package/cjs/native/Date.js +4 -1
- package/cjs/native/Float.js +6 -0
- package/cjs/native/Json.js +4 -0
- package/cjs/native/Raw.js +4 -0
- package/cjs/native/Set.js +27 -23
- package/cjs/native/Struct.js +14 -10
- package/cjs/native/Text.js +5 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/primitive/F32.js +2 -5
- package/cjs/primitive/F64.js +2 -5
- package/cjs/primitive/I128.js +2 -5
- package/cjs/primitive/I16.js +2 -5
- package/cjs/primitive/I256.js +2 -5
- package/cjs/primitive/I32.js +2 -5
- package/cjs/primitive/I64.js +2 -5
- package/cjs/primitive/I8.js +2 -5
- package/cjs/primitive/U128.js +2 -5
- package/cjs/primitive/U16.js +2 -5
- package/cjs/primitive/U256.js +2 -5
- package/cjs/primitive/U32.js +2 -5
- package/cjs/primitive/U64.js +2 -5
- package/cjs/primitive/U8.js +2 -5
- package/extended/BTreeSet.js +5 -0
- package/extended/BitVec.js +2 -0
- package/extended/Map.js +7 -0
- package/extended/Range.js +1 -0
- package/extended/WrapperKeepOpaque.js +3 -0
- package/native/Bool.js +4 -1
- package/native/Date.js +4 -1
- package/native/Float.js +6 -0
- package/native/Json.js +4 -0
- package/native/Raw.js +4 -0
- package/native/Set.js +27 -23
- package/native/Struct.js +14 -10
- package/native/Text.js +5 -1
- package/package.json +4 -4
- package/packageInfo.js +1 -1
- package/primitive/F32.js +2 -5
- package/primitive/F64.js +2 -5
- package/primitive/I128.js +2 -5
- package/primitive/I16.js +2 -5
- package/primitive/I256.js +2 -5
- package/primitive/I32.js +2 -5
- package/primitive/I64.js +2 -5
- package/primitive/I8.js +2 -5
- package/primitive/U128.js +2 -5
- package/primitive/U16.js +2 -5
- package/primitive/U256.js +2 -5
- package/primitive/U32.js +2 -5
- package/primitive/U64.js +2 -5
- package/primitive/U8.js +2 -5
- package/types/registry.d.ts +1 -0
package/cjs/native/Text.js
CHANGED
|
@@ -39,10 +39,14 @@ function decodeText(value) {
|
|
|
39
39
|
* @noInheritDoc
|
|
40
40
|
*/
|
|
41
41
|
class Text extends String {
|
|
42
|
+
registry;
|
|
43
|
+
createdAtHash;
|
|
44
|
+
initialU8aLength;
|
|
45
|
+
isStorageFallback;
|
|
46
|
+
__internal__override = null;
|
|
42
47
|
constructor(registry, value) {
|
|
43
48
|
const [str, decodedLength] = decodeText(value);
|
|
44
49
|
super(str);
|
|
45
|
-
this.__internal__override = null;
|
|
46
50
|
this.registry = registry;
|
|
47
51
|
this.initialU8aLength = decodedLength;
|
|
48
52
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.
|
|
4
|
+
exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.11.2' };
|
package/cjs/primitive/F32.js
CHANGED
|
@@ -8,10 +8,7 @@ const Float_js_1 = require("../native/Float.js");
|
|
|
8
8
|
* A 32-bit float
|
|
9
9
|
*/
|
|
10
10
|
class f32 extends Float_js_1.Float.with(32) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__FloatType = 'f32';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__FloatType = 'f32';
|
|
16
13
|
}
|
|
17
14
|
exports.f32 = f32;
|
package/cjs/primitive/F64.js
CHANGED
|
@@ -8,10 +8,7 @@ const Float_js_1 = require("../native/Float.js");
|
|
|
8
8
|
* A 64-bit float
|
|
9
9
|
*/
|
|
10
10
|
class f64 extends Float_js_1.Float.with(64) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__FloatType = 'f64';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__FloatType = 'f64';
|
|
16
13
|
}
|
|
17
14
|
exports.f64 = f64;
|
package/cjs/primitive/I128.js
CHANGED
|
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
|
|
|
8
8
|
* A 128-bit signed integer
|
|
9
9
|
*/
|
|
10
10
|
class i128 extends Int_js_1.Int.with(128) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__IntType = 'i128';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i128';
|
|
16
13
|
}
|
|
17
14
|
exports.i128 = i128;
|
package/cjs/primitive/I16.js
CHANGED
|
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
|
|
|
8
8
|
* A 16-bit signed integer
|
|
9
9
|
*/
|
|
10
10
|
class i16 extends Int_js_1.Int.with(16) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__IntType = 'i16';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i16';
|
|
16
13
|
}
|
|
17
14
|
exports.i16 = i16;
|
package/cjs/primitive/I256.js
CHANGED
|
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
|
|
|
8
8
|
* A 256-bit signed integer
|
|
9
9
|
*/
|
|
10
10
|
class i256 extends Int_js_1.Int.with(256) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__IntType = 'i256';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i256';
|
|
16
13
|
}
|
|
17
14
|
exports.i256 = i256;
|
package/cjs/primitive/I32.js
CHANGED
|
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
|
|
|
8
8
|
* A 32-bit signed integer
|
|
9
9
|
*/
|
|
10
10
|
class i32 extends Int_js_1.Int.with(32) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__IntType = 'i32';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i32';
|
|
16
13
|
}
|
|
17
14
|
exports.i32 = i32;
|
package/cjs/primitive/I64.js
CHANGED
|
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
|
|
|
8
8
|
* A 64-bit signed integer
|
|
9
9
|
*/
|
|
10
10
|
class i64 extends Int_js_1.Int.with(64) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__IntType = 'i64';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i64';
|
|
16
13
|
}
|
|
17
14
|
exports.i64 = i64;
|
package/cjs/primitive/I8.js
CHANGED
|
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
|
|
|
8
8
|
* An 8-bit signed integer
|
|
9
9
|
*/
|
|
10
10
|
class i8 extends Int_js_1.Int.with(8) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__IntType = 'i8';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i8';
|
|
16
13
|
}
|
|
17
14
|
exports.i8 = i8;
|
package/cjs/primitive/U128.js
CHANGED
|
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
|
|
|
8
8
|
* A 128-bit unsigned integer
|
|
9
9
|
*/
|
|
10
10
|
class u128 extends UInt_js_1.UInt.with(128) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__UIntType = 'u128';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u128';
|
|
16
13
|
}
|
|
17
14
|
exports.u128 = u128;
|
package/cjs/primitive/U16.js
CHANGED
|
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
|
|
|
8
8
|
* A 16-bit unsigned integer
|
|
9
9
|
*/
|
|
10
10
|
class u16 extends UInt_js_1.UInt.with(16) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__UIntType = 'u16';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u16';
|
|
16
13
|
}
|
|
17
14
|
exports.u16 = u16;
|
package/cjs/primitive/U256.js
CHANGED
|
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
|
|
|
8
8
|
* A 256-bit unsigned integer
|
|
9
9
|
*/
|
|
10
10
|
class u256 extends UInt_js_1.UInt.with(256) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__UIntType = 'u256';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u256';
|
|
16
13
|
}
|
|
17
14
|
exports.u256 = u256;
|
package/cjs/primitive/U32.js
CHANGED
|
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
|
|
|
8
8
|
* A 32-bit unsigned integer
|
|
9
9
|
*/
|
|
10
10
|
class u32 extends UInt_js_1.UInt.with(32) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__UIntType = 'u32';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u32';
|
|
16
13
|
}
|
|
17
14
|
exports.u32 = u32;
|
package/cjs/primitive/U64.js
CHANGED
|
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
|
|
|
8
8
|
* A 64-bit unsigned integer
|
|
9
9
|
*/
|
|
10
10
|
class u64 extends UInt_js_1.UInt.with(64) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__UIntType = 'u64';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u64';
|
|
16
13
|
}
|
|
17
14
|
exports.u64 = u64;
|
package/cjs/primitive/U8.js
CHANGED
|
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
|
|
|
8
8
|
* An 8-bit unsigned integer
|
|
9
9
|
*/
|
|
10
10
|
class u8 extends UInt_js_1.UInt.with(8) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// NOTE without this, we cannot properly determine extensions
|
|
14
|
-
this.__UIntType = 'u8';
|
|
15
|
-
}
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u8';
|
|
16
13
|
}
|
|
17
14
|
exports.u8 = u8;
|
package/extended/BTreeSet.js
CHANGED
|
@@ -54,6 +54,11 @@ function decodeSet(registry, valType, value) {
|
|
|
54
54
|
throw new Error('BTreeSet: cannot decode type');
|
|
55
55
|
}
|
|
56
56
|
export class BTreeSet extends Set {
|
|
57
|
+
registry;
|
|
58
|
+
createdAtHash;
|
|
59
|
+
initialU8aLength;
|
|
60
|
+
isStorageFallback;
|
|
61
|
+
__internal__ValClass;
|
|
57
62
|
constructor(registry, valType, rawValue) {
|
|
58
63
|
const [ValClass, values, decodedLength] = decodeSet(registry, valType, rawValue);
|
|
59
64
|
super(sortSet(values));
|
package/extended/BitVec.js
CHANGED
|
@@ -28,6 +28,8 @@ function decodeBitVec(value) {
|
|
|
28
28
|
* and a normal Bytes would be that the length prefix indicates the number of bits encoded, not the bytes
|
|
29
29
|
*/
|
|
30
30
|
export class BitVec extends Raw {
|
|
31
|
+
__internal__decodedLength;
|
|
32
|
+
__internal__isMsb;
|
|
31
33
|
// In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
|
|
32
34
|
// we are dealing with Lsb, which is the default (as of writing) BitVec format used
|
|
33
35
|
// in the Polkadot code (this only affects the toHuman displays)
|
package/extended/Map.js
CHANGED
|
@@ -73,6 +73,13 @@ function decodeMap(registry, keyType, valType, value) {
|
|
|
73
73
|
throw new Error('Map: cannot decode type');
|
|
74
74
|
}
|
|
75
75
|
export class CodecMap extends Map {
|
|
76
|
+
registry;
|
|
77
|
+
createdAtHash;
|
|
78
|
+
initialU8aLength;
|
|
79
|
+
isStorageFallback;
|
|
80
|
+
__internal__KeyClass;
|
|
81
|
+
__internal__ValClass;
|
|
82
|
+
__internal__type;
|
|
76
83
|
constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
|
|
77
84
|
const [KeyClass, ValClass, decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
|
|
78
85
|
super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
|
package/extended/Range.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Tuple } from '../base/Tuple.js';
|
|
|
5
5
|
* Rust `Range<T>` representation
|
|
6
6
|
*/
|
|
7
7
|
export class Range extends Tuple {
|
|
8
|
+
__internal__rangeName;
|
|
8
9
|
constructor(registry, Type, value, { rangeName = 'Range' } = {}) {
|
|
9
10
|
super(registry, [Type, Type], value);
|
|
10
11
|
this.__internal__rangeName = rangeName;
|
|
@@ -21,6 +21,9 @@ function decodeRaw(registry, typeName, value) {
|
|
|
21
21
|
return [Type, instance, compactAddLength(instance.toU8a())];
|
|
22
22
|
}
|
|
23
23
|
export class WrapperKeepOpaque extends Bytes {
|
|
24
|
+
__internal__Type;
|
|
25
|
+
__internal__decoded;
|
|
26
|
+
__internal__opaqueName;
|
|
24
27
|
constructor(registry, typeName, value, { opaqueName = 'WrapperKeepOpaque' } = {}) {
|
|
25
28
|
const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
|
|
26
29
|
super(registry, u8a);
|
package/native/Bool.js
CHANGED
|
@@ -6,13 +6,16 @@ import { isU8a, u8aToHex } from '@polkadot/util';
|
|
|
6
6
|
* @noInheritDoc
|
|
7
7
|
*/
|
|
8
8
|
export class bool extends Boolean {
|
|
9
|
+
registry;
|
|
10
|
+
createdAtHash;
|
|
11
|
+
initialU8aLength = 1;
|
|
12
|
+
isStorageFallback;
|
|
9
13
|
constructor(registry, value = false) {
|
|
10
14
|
super(isU8a(value)
|
|
11
15
|
? value[0] === 1
|
|
12
16
|
: value instanceof Boolean
|
|
13
17
|
? value.valueOf()
|
|
14
18
|
: !!value);
|
|
15
|
-
this.initialU8aLength = 1;
|
|
16
19
|
this.registry = registry;
|
|
17
20
|
}
|
|
18
21
|
/**
|
package/native/Date.js
CHANGED
|
@@ -24,9 +24,12 @@ function decodeDate(value) {
|
|
|
24
24
|
* @noInheritDoc
|
|
25
25
|
*/
|
|
26
26
|
export class CodecDate extends Date {
|
|
27
|
+
registry;
|
|
28
|
+
createdAtHash;
|
|
29
|
+
initialU8aLength = BITLENGTH / 8;
|
|
30
|
+
isStorageFallback;
|
|
27
31
|
constructor(registry, value = 0) {
|
|
28
32
|
super(decodeDate(value));
|
|
29
|
-
this.initialU8aLength = BITLENGTH / 8;
|
|
30
33
|
this.registry = registry;
|
|
31
34
|
}
|
|
32
35
|
/**
|
package/native/Float.js
CHANGED
|
@@ -8,6 +8,12 @@ import { floatToU8a, isHex, isU8a, u8aToFloat, u8aToHex, u8aToU8a } from '@polka
|
|
|
8
8
|
* in some eth_* RPCs
|
|
9
9
|
*/
|
|
10
10
|
export class Float extends Number {
|
|
11
|
+
encodedLength;
|
|
12
|
+
registry;
|
|
13
|
+
createdAtHash;
|
|
14
|
+
initialU8aLength;
|
|
15
|
+
isStorageFallback;
|
|
16
|
+
__internal__bitLength;
|
|
11
17
|
constructor(registry, value, { bitLength = 32 } = {}) {
|
|
12
18
|
super(isU8a(value) || isHex(value)
|
|
13
19
|
? value.length === 0
|
package/native/Json.js
CHANGED
package/native/Raw.js
CHANGED
|
@@ -9,6 +9,10 @@ import { isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@
|
|
|
9
9
|
* @noInheritDoc
|
|
10
10
|
*/
|
|
11
11
|
export class Raw extends Uint8Array {
|
|
12
|
+
registry;
|
|
13
|
+
createdAtHash;
|
|
14
|
+
initialU8aLength;
|
|
15
|
+
isStorageFallback;
|
|
12
16
|
/**
|
|
13
17
|
* @description This ensures that operators such as clice, filter, map, etc. return
|
|
14
18
|
* new Array instances (without this we need to apply overrides)
|
package/native/Set.js
CHANGED
|
@@ -66,42 +66,33 @@ function decodeSet(setValues, value = 0, bitLength) {
|
|
|
66
66
|
* a bitwise representation of the values.
|
|
67
67
|
*/
|
|
68
68
|
export class CodecSet extends Set {
|
|
69
|
+
registry;
|
|
70
|
+
createdAtHash;
|
|
71
|
+
initialU8aLength;
|
|
72
|
+
isStorageFallback;
|
|
73
|
+
__internal__allowed;
|
|
74
|
+
__internal__byteLength;
|
|
69
75
|
constructor(registry, setValues, value, bitLength = 8) {
|
|
70
76
|
super(decodeSet(setValues, value, bitLength));
|
|
71
|
-
/**
|
|
72
|
-
* @description adds a value to the Set (extended to allow for validity checking)
|
|
73
|
-
*/
|
|
74
|
-
this.add = (key) => {
|
|
75
|
-
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
|
76
|
-
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
|
77
|
-
// in the Set constructor (so it is undefined at this point, and should allow)
|
|
78
|
-
if (this.__internal__allowed && isUndefined(this.__internal__allowed[key])) {
|
|
79
|
-
throw new Error(`Set: Invalid key '${key}' on add`);
|
|
80
|
-
}
|
|
81
|
-
super.add(key);
|
|
82
|
-
return this;
|
|
83
|
-
};
|
|
84
77
|
this.registry = registry;
|
|
85
78
|
this.__internal__allowed = setValues;
|
|
86
79
|
this.__internal__byteLength = bitLength / 8;
|
|
87
80
|
}
|
|
88
81
|
static with(values, bitLength) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
constructor(registry, value) {
|
|
92
|
-
super(registry, values, value, bitLength);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
(() => {
|
|
82
|
+
return class extends CodecSet {
|
|
83
|
+
static {
|
|
96
84
|
const keys = Object.keys(values);
|
|
97
85
|
const count = keys.length;
|
|
98
86
|
const isKeys = new Array(count);
|
|
99
87
|
for (let i = 0; i < count; i++) {
|
|
100
88
|
isKeys[i] = `is${stringPascalCase(keys[i])}`;
|
|
101
89
|
}
|
|
102
|
-
objectProperties(
|
|
103
|
-
}
|
|
104
|
-
|
|
90
|
+
objectProperties(this.prototype, isKeys, (_, i, self) => self.strings.includes(keys[i]));
|
|
91
|
+
}
|
|
92
|
+
constructor(registry, value) {
|
|
93
|
+
super(registry, values, value, bitLength);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
105
96
|
}
|
|
106
97
|
/**
|
|
107
98
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -133,6 +124,19 @@ export class CodecSet extends Set {
|
|
|
133
124
|
get valueEncoded() {
|
|
134
125
|
return encodeSet(this.__internal__allowed, this.strings);
|
|
135
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* @description adds a value to the Set (extended to allow for validity checking)
|
|
129
|
+
*/
|
|
130
|
+
add = (key) => {
|
|
131
|
+
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
|
132
|
+
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
|
133
|
+
// in the Set constructor (so it is undefined at this point, and should allow)
|
|
134
|
+
if (this.__internal__allowed && isUndefined(this.__internal__allowed[key])) {
|
|
135
|
+
throw new Error(`Set: Invalid key '${key}' on add`);
|
|
136
|
+
}
|
|
137
|
+
super.add(key);
|
|
138
|
+
return this;
|
|
139
|
+
};
|
|
136
140
|
/**
|
|
137
141
|
* @description Compares the value of the input to see if there is a match
|
|
138
142
|
*/
|
package/native/Struct.js
CHANGED
|
@@ -72,6 +72,12 @@ function decodeStructFromObject(registry, [Types, keys], value, jsonMap) {
|
|
|
72
72
|
* @noInheritDoc
|
|
73
73
|
*/
|
|
74
74
|
export class Struct extends Map {
|
|
75
|
+
registry;
|
|
76
|
+
createdAtHash;
|
|
77
|
+
initialU8aLength;
|
|
78
|
+
isStorageFallback;
|
|
79
|
+
__internal__jsonMap;
|
|
80
|
+
__internal__Types;
|
|
75
81
|
constructor(registry, Types, value, jsonMap = new Map(), { definition, setDefinition = noopSetDefinition } = {}) {
|
|
76
82
|
const typeMap = definition || setDefinition(mapToTypeMap(registry, Types));
|
|
77
83
|
const [decoded, decodedLength] = isU8a(value) || isHex(value)
|
|
@@ -86,20 +92,18 @@ export class Struct extends Map {
|
|
|
86
92
|
this.__internal__Types = typeMap;
|
|
87
93
|
}
|
|
88
94
|
static with(Types, jsonMap) {
|
|
89
|
-
var _a;
|
|
90
95
|
let definition;
|
|
91
96
|
// eslint-disable-next-line no-return-assign
|
|
92
97
|
const setDefinition = (d) => definition = d;
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
super(registry, Types, value, jsonMap, { definition, setDefinition });
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
(() => {
|
|
98
|
+
return class extends Struct {
|
|
99
|
+
static {
|
|
99
100
|
const keys = Object.keys(Types);
|
|
100
|
-
objectProperties(
|
|
101
|
-
}
|
|
102
|
-
|
|
101
|
+
objectProperties(this.prototype, keys, (k, _, self) => self.get(k));
|
|
102
|
+
}
|
|
103
|
+
constructor(registry, value) {
|
|
104
|
+
super(registry, Types, value, jsonMap, { definition, setDefinition });
|
|
105
|
+
}
|
|
106
|
+
};
|
|
103
107
|
}
|
|
104
108
|
/**
|
|
105
109
|
* @description The available keys for this struct
|
package/native/Text.js
CHANGED
|
@@ -36,10 +36,14 @@ function decodeText(value) {
|
|
|
36
36
|
* @noInheritDoc
|
|
37
37
|
*/
|
|
38
38
|
export class Text extends String {
|
|
39
|
+
registry;
|
|
40
|
+
createdAtHash;
|
|
41
|
+
initialU8aLength;
|
|
42
|
+
isStorageFallback;
|
|
43
|
+
__internal__override = null;
|
|
39
44
|
constructor(registry, value) {
|
|
40
45
|
const [str, decodedLength] = decodeText(value);
|
|
41
46
|
super(str);
|
|
42
|
-
this.__internal__override = null;
|
|
43
47
|
this.registry = registry;
|
|
44
48
|
this.initialU8aLength = decodedLength;
|
|
45
49
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
|
4
4
|
"description": "Implementation of the SCALE codec",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=18"
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-codec#readme",
|
|
9
9
|
"license": "Apache-2.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/detectPackage.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "10.
|
|
21
|
+
"version": "10.11.2",
|
|
22
22
|
"main": "./cjs/index.js",
|
|
23
23
|
"module": "./index.js",
|
|
24
24
|
"types": "./index.d.ts",
|
|
@@ -516,8 +516,8 @@
|
|
|
516
516
|
}
|
|
517
517
|
},
|
|
518
518
|
"dependencies": {
|
|
519
|
-
"@polkadot/util": "^12.
|
|
520
|
-
"@polkadot/x-bigint": "^12.
|
|
519
|
+
"@polkadot/util": "^12.6.2",
|
|
520
|
+
"@polkadot/x-bigint": "^12.6.2",
|
|
521
521
|
"tslib": "^2.6.2"
|
|
522
522
|
}
|
|
523
523
|
}
|
package/packageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@polkadot/types-codec', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.
|
|
1
|
+
export const packageInfo = { name: '@polkadot/types-codec', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.11.2' };
|
package/primitive/F32.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Float } from '../native/Float.js';
|
|
|
5
5
|
* A 32-bit float
|
|
6
6
|
*/
|
|
7
7
|
export class f32 extends Float.with(32) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__FloatType = 'f32';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__FloatType = 'f32';
|
|
13
10
|
}
|
package/primitive/F64.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Float } from '../native/Float.js';
|
|
|
5
5
|
* A 64-bit float
|
|
6
6
|
*/
|
|
7
7
|
export class f64 extends Float.with(64) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__FloatType = 'f64';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__FloatType = 'f64';
|
|
13
10
|
}
|
package/primitive/I128.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Int } from '../base/Int.js';
|
|
|
5
5
|
* A 128-bit signed integer
|
|
6
6
|
*/
|
|
7
7
|
export class i128 extends Int.with(128) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__IntType = 'i128';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__IntType = 'i128';
|
|
13
10
|
}
|
package/primitive/I16.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Int } from '../base/Int.js';
|
|
|
5
5
|
* A 16-bit signed integer
|
|
6
6
|
*/
|
|
7
7
|
export class i16 extends Int.with(16) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__IntType = 'i16';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__IntType = 'i16';
|
|
13
10
|
}
|
package/primitive/I256.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Int } from '../base/Int.js';
|
|
|
5
5
|
* A 256-bit signed integer
|
|
6
6
|
*/
|
|
7
7
|
export class i256 extends Int.with(256) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__IntType = 'i256';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__IntType = 'i256';
|
|
13
10
|
}
|
package/primitive/I32.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Int } from '../base/Int.js';
|
|
|
5
5
|
* A 32-bit signed integer
|
|
6
6
|
*/
|
|
7
7
|
export class i32 extends Int.with(32) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__IntType = 'i32';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__IntType = 'i32';
|
|
13
10
|
}
|
package/primitive/I64.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Int } from '../base/Int.js';
|
|
|
5
5
|
* A 64-bit signed integer
|
|
6
6
|
*/
|
|
7
7
|
export class i64 extends Int.with(64) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__IntType = 'i64';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__IntType = 'i64';
|
|
13
10
|
}
|
package/primitive/I8.js
CHANGED
|
@@ -5,9 +5,6 @@ import { Int } from '../base/Int.js';
|
|
|
5
5
|
* An 8-bit signed integer
|
|
6
6
|
*/
|
|
7
7
|
export class i8 extends Int.with(8) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__IntType = 'i8';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__IntType = 'i8';
|
|
13
10
|
}
|
package/primitive/U128.js
CHANGED
|
@@ -5,9 +5,6 @@ import { UInt } from '../base/UInt.js';
|
|
|
5
5
|
* A 128-bit unsigned integer
|
|
6
6
|
*/
|
|
7
7
|
export class u128 extends UInt.with(128) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// NOTE without this, we cannot properly determine extensions
|
|
11
|
-
this.__UIntType = 'u128';
|
|
12
|
-
}
|
|
8
|
+
// NOTE without this, we cannot properly determine extensions
|
|
9
|
+
__UIntType = 'u128';
|
|
13
10
|
}
|