@polkadot/types-codec 7.8.2-7 → 7.9.2-0
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/AbstractArray.cjs +0 -4
- package/abstract/AbstractInt.cjs +10 -28
- package/base/Base.cjs +16 -33
- package/base/Compact.cjs +20 -37
- package/base/DoNotConstruct.cjs +15 -27
- package/base/Enum.cjs +37 -76
- package/base/Null.cjs +2 -3
- package/base/Option.cjs +20 -43
- package/base/Tuple.cjs +5 -15
- package/base/Vec.cjs +6 -16
- package/base/VecFixed.cjs +4 -14
- package/extended/BTreeSet.cjs +4 -17
- package/extended/BitVec.cjs +6 -16
- package/extended/Map.cjs +8 -31
- package/extended/Range.cjs +4 -13
- package/extended/WrapperKeepOpaque.cjs +14 -34
- package/native/Bool.cjs +0 -2
- package/native/Date.cjs +0 -2
- package/native/Json.cjs +0 -2
- package/native/Raw.cjs +0 -3
- package/native/Set.cjs +18 -36
- package/native/Struct.cjs +12 -34
- package/native/Text.cjs +7 -24
- package/package.json +1 -1
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
- package/primitive/I128.cjs +2 -5
- package/primitive/I16.cjs +2 -5
- package/primitive/I256.cjs +2 -5
- package/primitive/I32.cjs +2 -5
- package/primitive/I64.cjs +2 -5
- package/primitive/I8.cjs +2 -5
- package/primitive/U128.cjs +2 -5
- package/primitive/U16.cjs +2 -5
- package/primitive/U256.cjs +2 -5
- package/primitive/U32.cjs +2 -5
- package/primitive/U64.cjs +2 -5
- package/primitive/U8.cjs +2 -5
package/extended/BitVec.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.BitVec = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _util = require("@polkadot/util");
|
|
15
9
|
|
|
16
10
|
var _Raw = require("../native/Raw.cjs");
|
|
@@ -49,17 +43,13 @@ function decodeBitVec(value) {
|
|
|
49
43
|
*/
|
|
50
44
|
|
|
51
45
|
|
|
52
|
-
var _decodedLength = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("decodedLength");
|
|
53
|
-
|
|
54
46
|
class BitVec extends _Raw.Raw {
|
|
47
|
+
#decodedLength;
|
|
48
|
+
|
|
55
49
|
constructor(registry, value) {
|
|
56
50
|
const [decodedLength, u8a] = decodeBitVec(value);
|
|
57
51
|
super(registry, u8a);
|
|
58
|
-
|
|
59
|
-
writable: true,
|
|
60
|
-
value: void 0
|
|
61
|
-
});
|
|
62
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _decodedLength)[_decodedLength] = decodedLength;
|
|
52
|
+
this.#decodedLength = decodedLength;
|
|
63
53
|
}
|
|
64
54
|
/**
|
|
65
55
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -67,7 +57,7 @@ class BitVec extends _Raw.Raw {
|
|
|
67
57
|
|
|
68
58
|
|
|
69
59
|
get encodedLength() {
|
|
70
|
-
return this.length + (0, _util.compactToU8a)(
|
|
60
|
+
return this.length + (0, _util.compactToU8a)(this.#decodedLength).length;
|
|
71
61
|
}
|
|
72
62
|
/**
|
|
73
63
|
* @description Returns a breakdown of the hex encoding for this Codec
|
|
@@ -76,7 +66,7 @@ class BitVec extends _Raw.Raw {
|
|
|
76
66
|
|
|
77
67
|
inspect() {
|
|
78
68
|
return {
|
|
79
|
-
outer: [(0, _util.compactToU8a)(
|
|
69
|
+
outer: [(0, _util.compactToU8a)(this.#decodedLength), super.toU8a()]
|
|
80
70
|
};
|
|
81
71
|
}
|
|
82
72
|
|
|
@@ -99,7 +89,7 @@ class BitVec extends _Raw.Raw {
|
|
|
99
89
|
|
|
100
90
|
toU8a(isBare) {
|
|
101
91
|
const bitVec = super.toU8a();
|
|
102
|
-
return isBare ? bitVec : (0, _util.u8aConcat)((0, _util.compactToU8a)(
|
|
92
|
+
return isBare ? bitVec : (0, _util.u8aConcat)((0, _util.compactToU8a)(this.#decodedLength), bitVec);
|
|
103
93
|
}
|
|
104
94
|
|
|
105
95
|
}
|
package/extended/Map.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.CodecMap = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _util = require("@polkadot/util");
|
|
15
9
|
|
|
16
10
|
var _AbstractArray = require("../abstract/AbstractArray.cjs");
|
|
@@ -97,37 +91,20 @@ function decodeMap(registry, keyType, valType, value) {
|
|
|
97
91
|
throw new Error('Map: cannot decode type');
|
|
98
92
|
}
|
|
99
93
|
|
|
100
|
-
var _KeyClass = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("KeyClass");
|
|
101
|
-
|
|
102
|
-
var _ValClass = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("ValClass");
|
|
103
|
-
|
|
104
|
-
var _type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("type");
|
|
105
|
-
|
|
106
94
|
class CodecMap extends Map {
|
|
95
|
+
#KeyClass;
|
|
96
|
+
#ValClass;
|
|
97
|
+
#type;
|
|
98
|
+
|
|
107
99
|
constructor(registry, keyType, valType, rawValue) {
|
|
108
100
|
let type = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'HashMap';
|
|
109
101
|
const [decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
|
|
110
102
|
super(type === 'BTreeMap' ? (0, _index.sortMap)(decoded) : decoded);
|
|
111
|
-
this.registry = void 0;
|
|
112
|
-
this.createdAtHash = void 0;
|
|
113
|
-
Object.defineProperty(this, _KeyClass, {
|
|
114
|
-
writable: true,
|
|
115
|
-
value: void 0
|
|
116
|
-
});
|
|
117
|
-
Object.defineProperty(this, _ValClass, {
|
|
118
|
-
writable: true,
|
|
119
|
-
value: void 0
|
|
120
|
-
});
|
|
121
|
-
this.initialU8aLength = void 0;
|
|
122
|
-
Object.defineProperty(this, _type, {
|
|
123
|
-
writable: true,
|
|
124
|
-
value: void 0
|
|
125
|
-
});
|
|
126
103
|
this.registry = registry;
|
|
127
104
|
this.initialU8aLength = decodedLength;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
105
|
+
this.#KeyClass = (0, _index.typeToConstructor)(registry, keyType);
|
|
106
|
+
this.#ValClass = (0, _index.typeToConstructor)(registry, valType);
|
|
107
|
+
this.#type = type;
|
|
131
108
|
}
|
|
132
109
|
/**
|
|
133
110
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -227,7 +204,7 @@ class CodecMap extends Map {
|
|
|
227
204
|
|
|
228
205
|
|
|
229
206
|
toRawType() {
|
|
230
|
-
return `${
|
|
207
|
+
return `${this.#type}<${this.registry.getClassName(this.#KeyClass) || new this.#KeyClass(this.registry).toRawType()},${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
|
231
208
|
}
|
|
232
209
|
/**
|
|
233
210
|
* @description Returns the string representation of the value
|
package/extended/Range.cjs
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.Range = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _Tuple = require("../base/Tuple.cjs");
|
|
15
9
|
|
|
16
10
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
17
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
18
|
-
var _rangeName = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("rangeName");
|
|
19
12
|
|
|
20
13
|
/**
|
|
21
14
|
* @name Range
|
|
@@ -23,17 +16,15 @@ var _rangeName = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("rangeNam
|
|
|
23
16
|
* Rust `Range<T>` representation
|
|
24
17
|
*/
|
|
25
18
|
class Range extends _Tuple.Tuple {
|
|
19
|
+
#rangeName;
|
|
20
|
+
|
|
26
21
|
constructor(registry, Type, value) {
|
|
27
22
|
let rangeName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'Range';
|
|
28
23
|
super(registry, {
|
|
29
24
|
end: Type,
|
|
30
25
|
start: Type
|
|
31
26
|
}, value);
|
|
32
|
-
|
|
33
|
-
writable: true,
|
|
34
|
-
value: void 0
|
|
35
|
-
});
|
|
36
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _rangeName)[_rangeName] = rangeName;
|
|
27
|
+
this.#rangeName = rangeName;
|
|
37
28
|
}
|
|
38
29
|
|
|
39
30
|
static with(Types) {
|
|
@@ -66,7 +57,7 @@ class Range extends _Tuple.Tuple {
|
|
|
66
57
|
|
|
67
58
|
|
|
68
59
|
toRawType() {
|
|
69
|
-
return `${
|
|
60
|
+
return `${this.#rangeName}<${this.start.toRawType()}>`;
|
|
70
61
|
}
|
|
71
62
|
|
|
72
63
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.WrapperKeepOpaque = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _util = require("@polkadot/util");
|
|
15
9
|
|
|
16
10
|
var _Raw = require("../native/Raw.cjs");
|
|
@@ -37,32 +31,18 @@ function decodeRaw(registry, typeName, value) {
|
|
|
37
31
|
return [Type, instance, (0, _util.compactAddLength)(instance.toU8a())];
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
var _Type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Type");
|
|
41
|
-
|
|
42
|
-
var _decoded = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("decoded");
|
|
43
|
-
|
|
44
|
-
var _opaqueName = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("opaqueName");
|
|
45
|
-
|
|
46
34
|
class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
35
|
+
#Type;
|
|
36
|
+
#decoded;
|
|
37
|
+
#opaqueName;
|
|
38
|
+
|
|
47
39
|
constructor(registry, typeName, value) {
|
|
48
40
|
let opaqueName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'WrapperKeepOpaque';
|
|
49
41
|
const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
|
|
50
42
|
super(registry, u8a);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(this, _decoded, {
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, _opaqueName, {
|
|
60
|
-
writable: true,
|
|
61
|
-
value: void 0
|
|
62
|
-
});
|
|
63
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type] = Type;
|
|
64
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded] = decoded;
|
|
65
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName] = opaqueName;
|
|
43
|
+
this.#Type = Type;
|
|
44
|
+
this.#decoded = decoded;
|
|
45
|
+
this.#opaqueName = opaqueName;
|
|
66
46
|
}
|
|
67
47
|
|
|
68
48
|
static with(Type) {
|
|
@@ -79,7 +59,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
79
59
|
|
|
80
60
|
|
|
81
61
|
get isDecoded() {
|
|
82
|
-
return !!
|
|
62
|
+
return !!this.#decoded;
|
|
83
63
|
}
|
|
84
64
|
/**
|
|
85
65
|
* @description Returns a breakdown of the hex encoding for this Codec
|
|
@@ -87,8 +67,8 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
87
67
|
|
|
88
68
|
|
|
89
69
|
inspect() {
|
|
90
|
-
return
|
|
91
|
-
inner: [
|
|
70
|
+
return this.#decoded ? {
|
|
71
|
+
inner: [this.#decoded.inspect()],
|
|
92
72
|
outer: [(0, _util.compactToU8a)(this.length)]
|
|
93
73
|
} : {
|
|
94
74
|
outer: [(0, _util.compactToU8a)(this.length), this.toU8a(true)]
|
|
@@ -100,7 +80,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
100
80
|
|
|
101
81
|
|
|
102
82
|
toHuman(isExtended) {
|
|
103
|
-
return
|
|
83
|
+
return this.#decoded ? this.#decoded.toHuman(isExtended) : super.toHuman();
|
|
104
84
|
}
|
|
105
85
|
/**
|
|
106
86
|
* @description Returns the base runtime type name for this instance
|
|
@@ -108,7 +88,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
108
88
|
|
|
109
89
|
|
|
110
90
|
toRawType() {
|
|
111
|
-
return `${
|
|
91
|
+
return `${this.#opaqueName}<${this.registry.getClassName(this.#Type) || (this.#decoded ? this.#decoded.toRawType() : new this.#Type(this.registry).toRawType())}>`;
|
|
112
92
|
}
|
|
113
93
|
/**
|
|
114
94
|
* @description Converts the Object to to a string (either decoded or bytes)
|
|
@@ -116,7 +96,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
116
96
|
|
|
117
97
|
|
|
118
98
|
toString() {
|
|
119
|
-
return
|
|
99
|
+
return this.#decoded ? this.#decoded.toString() : super.toString();
|
|
120
100
|
}
|
|
121
101
|
/**
|
|
122
102
|
* @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
|
|
@@ -124,7 +104,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
124
104
|
|
|
125
105
|
|
|
126
106
|
unwrap() {
|
|
127
|
-
return (0, _util.assertReturn)(
|
|
107
|
+
return (0, _util.assertReturn)(this.#decoded, () => `${this.#opaqueName}: unwrapping an undecodable value`);
|
|
128
108
|
}
|
|
129
109
|
|
|
130
110
|
}
|
package/native/Bool.cjs
CHANGED
|
@@ -33,8 +33,6 @@ class bool extends Boolean {
|
|
|
33
33
|
constructor(registry) {
|
|
34
34
|
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
35
35
|
super(decodeBool(value));
|
|
36
|
-
this.registry = void 0;
|
|
37
|
-
this.createdAtHash = void 0;
|
|
38
36
|
this.registry = registry;
|
|
39
37
|
}
|
|
40
38
|
/**
|
package/native/Date.cjs
CHANGED
|
@@ -38,8 +38,6 @@ class CodecDate extends Date {
|
|
|
38
38
|
constructor(registry) {
|
|
39
39
|
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
40
40
|
super(decodeDate(value));
|
|
41
|
-
this.registry = void 0;
|
|
42
|
-
this.createdAtHash = void 0;
|
|
43
41
|
this.registry = registry;
|
|
44
42
|
}
|
|
45
43
|
/**
|
package/native/Json.cjs
CHANGED
|
@@ -30,8 +30,6 @@ class Json extends Map {
|
|
|
30
30
|
constructor(registry, value) {
|
|
31
31
|
const decoded = decodeJson(value);
|
|
32
32
|
super(decoded);
|
|
33
|
-
this.registry = void 0;
|
|
34
|
-
this.createdAtHash = void 0;
|
|
35
33
|
this.registry = registry;
|
|
36
34
|
(0, _util.objectProperties)(this, decoded.map(_ref => {
|
|
37
35
|
let [k] = _ref;
|
package/native/Raw.cjs
CHANGED
|
@@ -22,9 +22,6 @@ var _util = require("@polkadot/util");
|
|
|
22
22
|
class Raw extends Uint8Array {
|
|
23
23
|
constructor(registry, value, initialU8aLength) {
|
|
24
24
|
super((0, _util.u8aToU8a)(value));
|
|
25
|
-
this.registry = void 0;
|
|
26
|
-
this.createdAtHash = void 0;
|
|
27
|
-
this.initialU8aLength = void 0;
|
|
28
25
|
this.registry = registry;
|
|
29
26
|
this.initialU8aLength = initialU8aLength;
|
|
30
27
|
}
|
package/native/Set.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.CodecSet = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _util = require("@polkadot/util");
|
|
15
9
|
|
|
16
10
|
var _index = require("../utils/index.cjs");
|
|
@@ -90,37 +84,16 @@ function decodeSet(setValues) {
|
|
|
90
84
|
*/
|
|
91
85
|
|
|
92
86
|
|
|
93
|
-
var _allowed = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("allowed");
|
|
94
|
-
|
|
95
|
-
var _byteLength = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("byteLength");
|
|
96
|
-
|
|
97
87
|
class CodecSet extends Set {
|
|
88
|
+
#allowed;
|
|
89
|
+
#byteLength;
|
|
90
|
+
|
|
98
91
|
constructor(registry, setValues, value) {
|
|
99
92
|
let bitLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 8;
|
|
100
93
|
super(decodeSet(setValues, value, bitLength));
|
|
101
|
-
this.registry = void 0;
|
|
102
|
-
this.createdAtHash = void 0;
|
|
103
|
-
Object.defineProperty(this, _allowed, {
|
|
104
|
-
writable: true,
|
|
105
|
-
value: void 0
|
|
106
|
-
});
|
|
107
|
-
Object.defineProperty(this, _byteLength, {
|
|
108
|
-
writable: true,
|
|
109
|
-
value: void 0
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
this.add = key => {
|
|
113
|
-
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
|
114
|
-
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
|
115
|
-
// in the Set constructor (so it is undefined at this point, and should allow)
|
|
116
|
-
(0, _util.assert)((0, _util.isUndefined)((0, _classPrivateFieldLooseBase2.default)(this, _allowed)[_allowed]) || !(0, _util.isUndefined)((0, _classPrivateFieldLooseBase2.default)(this, _allowed)[_allowed][key]), () => `Set: Invalid key '${key}' on add`);
|
|
117
|
-
super.add(key);
|
|
118
|
-
return this;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
94
|
this.registry = registry;
|
|
122
|
-
|
|
123
|
-
|
|
95
|
+
this.#allowed = setValues;
|
|
96
|
+
this.#byteLength = bitLength / 8;
|
|
124
97
|
}
|
|
125
98
|
|
|
126
99
|
static with(values, bitLength) {
|
|
@@ -145,7 +118,7 @@ class CodecSet extends Set {
|
|
|
145
118
|
|
|
146
119
|
|
|
147
120
|
get encodedLength() {
|
|
148
|
-
return
|
|
121
|
+
return this.#byteLength;
|
|
149
122
|
}
|
|
150
123
|
/**
|
|
151
124
|
* @description returns a hash of the contents
|
|
@@ -177,16 +150,25 @@ class CodecSet extends Set {
|
|
|
177
150
|
|
|
178
151
|
|
|
179
152
|
get valueEncoded() {
|
|
180
|
-
return encodeSet(
|
|
153
|
+
return encodeSet(this.#allowed, this.strings);
|
|
181
154
|
}
|
|
182
155
|
/**
|
|
183
156
|
* @description adds a value to the Set (extended to allow for validity checking)
|
|
184
157
|
*/
|
|
185
158
|
|
|
186
159
|
|
|
160
|
+
add = key => {
|
|
161
|
+
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
|
162
|
+
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
|
163
|
+
// in the Set constructor (so it is undefined at this point, and should allow)
|
|
164
|
+
(0, _util.assert)((0, _util.isUndefined)(this.#allowed) || !(0, _util.isUndefined)(this.#allowed[key]), () => `Set: Invalid key '${key}' on add`);
|
|
165
|
+
super.add(key);
|
|
166
|
+
return this;
|
|
167
|
+
};
|
|
187
168
|
/**
|
|
188
169
|
* @description Compares the value of the input to see if there is a match
|
|
189
170
|
*/
|
|
171
|
+
|
|
190
172
|
eq(other) {
|
|
191
173
|
if (Array.isArray(other)) {
|
|
192
174
|
// we don't actually care about the order, sort the values
|
|
@@ -248,7 +230,7 @@ class CodecSet extends Set {
|
|
|
248
230
|
|
|
249
231
|
toRawType() {
|
|
250
232
|
return (0, _util.stringify)({
|
|
251
|
-
_set:
|
|
233
|
+
_set: this.#allowed
|
|
252
234
|
});
|
|
253
235
|
}
|
|
254
236
|
/**
|
|
@@ -268,7 +250,7 @@ class CodecSet extends Set {
|
|
|
268
250
|
|
|
269
251
|
toU8a(isBare) {
|
|
270
252
|
return (0, _util.bnToU8a)(this.valueEncoded, {
|
|
271
|
-
bitLength:
|
|
253
|
+
bitLength: this.#byteLength * 8,
|
|
272
254
|
isLe: true
|
|
273
255
|
});
|
|
274
256
|
}
|
package/native/Struct.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.Struct = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _util = require("@polkadot/util");
|
|
15
9
|
|
|
16
10
|
var _index = require("../utils/index.cjs");
|
|
@@ -83,36 +77,20 @@ function decodeStructFromObject(registry, Types, value, jsonMap) {
|
|
|
83
77
|
*/
|
|
84
78
|
|
|
85
79
|
|
|
86
|
-
var _registry = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("registry");
|
|
87
|
-
|
|
88
|
-
var _jsonMap = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("jsonMap");
|
|
89
|
-
|
|
90
|
-
var _Types = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Types");
|
|
91
|
-
|
|
92
80
|
class Struct extends Map {
|
|
81
|
+
#registry;
|
|
82
|
+
#jsonMap;
|
|
83
|
+
#Types;
|
|
84
|
+
|
|
93
85
|
constructor(registry, Types, value) {
|
|
94
86
|
let jsonMap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Map();
|
|
95
87
|
const typeMap = (0, _index.mapToTypeMap)(registry, Types);
|
|
96
88
|
const [decoded, decodedLength] = (0, _util.isU8a)(value) ? (0, _index.decodeU8a)(registry, value, typeMap, true) : (0, _util.isHex)(value) ? (0, _index.decodeU8a)(registry, (0, _util.u8aToU8a)(value), typeMap, true) : value instanceof Struct ? [value, 0] : decodeStructFromObject(registry, typeMap, value || {}, jsonMap);
|
|
97
89
|
super(decoded);
|
|
98
|
-
|
|
99
|
-
writable: true,
|
|
100
|
-
value: void 0
|
|
101
|
-
});
|
|
102
|
-
this.createdAtHash = void 0;
|
|
103
|
-
this.initialU8aLength = void 0;
|
|
104
|
-
Object.defineProperty(this, _jsonMap, {
|
|
105
|
-
writable: true,
|
|
106
|
-
value: void 0
|
|
107
|
-
});
|
|
108
|
-
Object.defineProperty(this, _Types, {
|
|
109
|
-
writable: true,
|
|
110
|
-
value: void 0
|
|
111
|
-
});
|
|
112
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _registry)[_registry] = registry;
|
|
90
|
+
this.#registry = registry;
|
|
113
91
|
this.initialU8aLength = decodedLength;
|
|
114
|
-
|
|
115
|
-
|
|
92
|
+
this.#jsonMap = jsonMap;
|
|
93
|
+
this.#Types = typeMap;
|
|
116
94
|
}
|
|
117
95
|
|
|
118
96
|
static with(Types, jsonMap) {
|
|
@@ -131,7 +109,7 @@ class Struct extends Map {
|
|
|
131
109
|
|
|
132
110
|
|
|
133
111
|
get defKeys() {
|
|
134
|
-
return Object.keys(
|
|
112
|
+
return Object.keys(this.#Types);
|
|
135
113
|
}
|
|
136
114
|
|
|
137
115
|
getT(key) {
|
|
@@ -158,7 +136,7 @@ class Struct extends Map {
|
|
|
158
136
|
|
|
159
137
|
get Type() {
|
|
160
138
|
const result = {};
|
|
161
|
-
const defs = Object.entries(
|
|
139
|
+
const defs = Object.entries(this.#Types);
|
|
162
140
|
|
|
163
141
|
for (let i = 0; i < defs.length; i++) {
|
|
164
142
|
const [key, Type] = defs[i];
|
|
@@ -191,7 +169,7 @@ class Struct extends Map {
|
|
|
191
169
|
}
|
|
192
170
|
|
|
193
171
|
get registry() {
|
|
194
|
-
return
|
|
172
|
+
return this.#registry;
|
|
195
173
|
}
|
|
196
174
|
/**
|
|
197
175
|
* @description Compares the value of the input to see if there is a match
|
|
@@ -275,7 +253,7 @@ class Struct extends Map {
|
|
|
275
253
|
const json = {};
|
|
276
254
|
|
|
277
255
|
for (const [k, v] of this.entries()) {
|
|
278
|
-
const jsonKey =
|
|
256
|
+
const jsonKey = this.#jsonMap.get(k) || k;
|
|
279
257
|
json[jsonKey] = v && v.toJSON();
|
|
280
258
|
}
|
|
281
259
|
|
|
@@ -287,7 +265,7 @@ class Struct extends Map {
|
|
|
287
265
|
|
|
288
266
|
|
|
289
267
|
toRawType() {
|
|
290
|
-
return (0, _util.stringify)((0, _index.typesToMap)(this.registry,
|
|
268
|
+
return (0, _util.stringify)((0, _index.typesToMap)(this.registry, this.#Types));
|
|
291
269
|
}
|
|
292
270
|
/**
|
|
293
271
|
* @description Returns the string representation of the value
|
package/native/Text.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.Text = void 0;
|
|
9
7
|
|
|
10
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
|
-
|
|
12
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
13
|
-
|
|
14
8
|
var _util = require("@polkadot/util");
|
|
15
9
|
|
|
16
10
|
var _Raw = require("./Raw.cjs");
|
|
@@ -55,26 +49,15 @@ function decodeText(value) {
|
|
|
55
49
|
// - Strings should probably be trimmed (docs do come through with extra padding)
|
|
56
50
|
|
|
57
51
|
|
|
58
|
-
var _initialU8aLength = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("initialU8aLength");
|
|
59
|
-
|
|
60
|
-
var _override = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("override");
|
|
61
|
-
|
|
62
52
|
class Text extends String {
|
|
53
|
+
#initialU8aLength;
|
|
54
|
+
#override = null;
|
|
55
|
+
|
|
63
56
|
constructor(registry, value) {
|
|
64
57
|
const [str, decodedLength] = decodeText(value);
|
|
65
58
|
super(str);
|
|
66
|
-
this.registry = void 0;
|
|
67
|
-
this.createdAtHash = void 0;
|
|
68
|
-
Object.defineProperty(this, _initialU8aLength, {
|
|
69
|
-
writable: true,
|
|
70
|
-
value: void 0
|
|
71
|
-
});
|
|
72
|
-
Object.defineProperty(this, _override, {
|
|
73
|
-
writable: true,
|
|
74
|
-
value: null
|
|
75
|
-
});
|
|
76
59
|
this.registry = registry;
|
|
77
|
-
|
|
60
|
+
this.#initialU8aLength = decodedLength;
|
|
78
61
|
}
|
|
79
62
|
/**
|
|
80
63
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -90,7 +73,7 @@ class Text extends String {
|
|
|
90
73
|
|
|
91
74
|
|
|
92
75
|
get initialU8aLength() {
|
|
93
|
-
return
|
|
76
|
+
return this.#initialU8aLength;
|
|
94
77
|
}
|
|
95
78
|
/**
|
|
96
79
|
* @description returns a hash of the contents
|
|
@@ -142,7 +125,7 @@ class Text extends String {
|
|
|
142
125
|
|
|
143
126
|
|
|
144
127
|
setOverride(override) {
|
|
145
|
-
|
|
128
|
+
this.#override = override;
|
|
146
129
|
}
|
|
147
130
|
/**
|
|
148
131
|
* @description Returns a hex string representation of the value
|
|
@@ -184,7 +167,7 @@ class Text extends String {
|
|
|
184
167
|
|
|
185
168
|
|
|
186
169
|
toString() {
|
|
187
|
-
return
|
|
170
|
+
return this.#override || super.toString();
|
|
188
171
|
}
|
|
189
172
|
/**
|
|
190
173
|
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
package/package.json
CHANGED
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED
package/primitive/I128.cjs
CHANGED
|
@@ -16,11 +16,8 @@ var _Int = require("../base/Int.cjs");
|
|
|
16
16
|
* A 128-bit signed integer
|
|
17
17
|
*/
|
|
18
18
|
class i128 extends _Int.Int.with(128) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.__IntType = 'i128';
|
|
22
|
-
}
|
|
23
|
-
|
|
19
|
+
// NOTE without this, we cannot properly determine extensions
|
|
20
|
+
__IntType = 'i128';
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
exports.i128 = i128;
|