@polkadot/types-codec 7.8.2-8 → 7.9.2-1
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 +5 -18
- package/extended/BTreeSet.js +1 -1
- 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/base/Enum.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.Enum = 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");
|
|
@@ -144,47 +138,15 @@ function decodeEnum(registry, def, value, index) {
|
|
|
144
138
|
*/
|
|
145
139
|
|
|
146
140
|
|
|
147
|
-
var _def2 = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("def");
|
|
148
|
-
|
|
149
|
-
var _entryIndex = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("entryIndex");
|
|
150
|
-
|
|
151
|
-
var _indexes = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("indexes");
|
|
152
|
-
|
|
153
|
-
var _isBasic = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("isBasic");
|
|
154
|
-
|
|
155
|
-
var _isIndexed = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("isIndexed");
|
|
156
|
-
|
|
157
|
-
var _raw = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("raw");
|
|
158
|
-
|
|
159
141
|
class Enum {
|
|
142
|
+
#def;
|
|
143
|
+
#entryIndex;
|
|
144
|
+
#indexes;
|
|
145
|
+
#isBasic;
|
|
146
|
+
#isIndexed;
|
|
147
|
+
#raw;
|
|
148
|
+
|
|
160
149
|
constructor(registry, Types, value, index) {
|
|
161
|
-
this.registry = void 0;
|
|
162
|
-
this.createdAtHash = void 0;
|
|
163
|
-
Object.defineProperty(this, _def2, {
|
|
164
|
-
writable: true,
|
|
165
|
-
value: void 0
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(this, _entryIndex, {
|
|
168
|
-
writable: true,
|
|
169
|
-
value: void 0
|
|
170
|
-
});
|
|
171
|
-
this.initialU8aLength = void 0;
|
|
172
|
-
Object.defineProperty(this, _indexes, {
|
|
173
|
-
writable: true,
|
|
174
|
-
value: void 0
|
|
175
|
-
});
|
|
176
|
-
Object.defineProperty(this, _isBasic, {
|
|
177
|
-
writable: true,
|
|
178
|
-
value: void 0
|
|
179
|
-
});
|
|
180
|
-
Object.defineProperty(this, _isIndexed, {
|
|
181
|
-
writable: true,
|
|
182
|
-
value: void 0
|
|
183
|
-
});
|
|
184
|
-
Object.defineProperty(this, _raw, {
|
|
185
|
-
writable: true,
|
|
186
|
-
value: void 0
|
|
187
|
-
});
|
|
188
150
|
const {
|
|
189
151
|
def,
|
|
190
152
|
isBasic,
|
|
@@ -193,20 +155,20 @@ class Enum {
|
|
|
193
155
|
|
|
194
156
|
const decoded = (0, _util.isU8a)(value) && value.length && !(0, _util.isNumber)(index) ? createFromValue(registry, def, value[0], value.subarray(1)) : decodeEnum(registry, def, value, index);
|
|
195
157
|
this.registry = registry;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
158
|
+
this.#def = def;
|
|
159
|
+
this.#isBasic = isBasic;
|
|
160
|
+
this.#isIndexed = isIndexed;
|
|
161
|
+
this.#indexes = Object.values(def).map(_ref2 => {
|
|
200
162
|
let {
|
|
201
163
|
index
|
|
202
164
|
} = _ref2;
|
|
203
165
|
return index;
|
|
204
166
|
});
|
|
205
|
-
|
|
206
|
-
|
|
167
|
+
this.#entryIndex = this.#indexes.indexOf(decoded.index) || 0;
|
|
168
|
+
this.#raw = decoded.value;
|
|
207
169
|
|
|
208
|
-
if (
|
|
209
|
-
this.initialU8aLength = 1 +
|
|
170
|
+
if (this.#raw.initialU8aLength) {
|
|
171
|
+
this.initialU8aLength = 1 + this.#raw.initialU8aLength;
|
|
210
172
|
}
|
|
211
173
|
}
|
|
212
174
|
|
|
@@ -239,7 +201,7 @@ class Enum {
|
|
|
239
201
|
|
|
240
202
|
|
|
241
203
|
get encodedLength() {
|
|
242
|
-
return 1 +
|
|
204
|
+
return 1 + this.#raw.encodedLength;
|
|
243
205
|
}
|
|
244
206
|
/**
|
|
245
207
|
* @description returns a hash of the contents
|
|
@@ -255,7 +217,7 @@ class Enum {
|
|
|
255
217
|
|
|
256
218
|
|
|
257
219
|
get index() {
|
|
258
|
-
return
|
|
220
|
+
return this.#indexes[this.#entryIndex];
|
|
259
221
|
}
|
|
260
222
|
/**
|
|
261
223
|
* @description The value of the enum
|
|
@@ -263,7 +225,7 @@ class Enum {
|
|
|
263
225
|
|
|
264
226
|
|
|
265
227
|
get inner() {
|
|
266
|
-
return
|
|
228
|
+
return this.#raw;
|
|
267
229
|
}
|
|
268
230
|
/**
|
|
269
231
|
* @description true if this is a basic enum (no values)
|
|
@@ -271,7 +233,7 @@ class Enum {
|
|
|
271
233
|
|
|
272
234
|
|
|
273
235
|
get isBasic() {
|
|
274
|
-
return
|
|
236
|
+
return this.#isBasic;
|
|
275
237
|
}
|
|
276
238
|
/**
|
|
277
239
|
* @description Checks if the value is an empty value
|
|
@@ -279,7 +241,7 @@ class Enum {
|
|
|
279
241
|
|
|
280
242
|
|
|
281
243
|
get isEmpty() {
|
|
282
|
-
return
|
|
244
|
+
return this.#raw.isEmpty;
|
|
283
245
|
}
|
|
284
246
|
/**
|
|
285
247
|
* @description Checks if the Enum points to a [[Null]] type
|
|
@@ -287,7 +249,7 @@ class Enum {
|
|
|
287
249
|
|
|
288
250
|
|
|
289
251
|
get isNone() {
|
|
290
|
-
return
|
|
252
|
+
return this.#raw instanceof _Null.Null;
|
|
291
253
|
}
|
|
292
254
|
/**
|
|
293
255
|
* @description Checks if the Enum points to a [[Null]] type
|
|
@@ -296,7 +258,7 @@ class Enum {
|
|
|
296
258
|
|
|
297
259
|
|
|
298
260
|
get isNull() {
|
|
299
|
-
return
|
|
261
|
+
return this.#raw instanceof _Null.Null;
|
|
300
262
|
}
|
|
301
263
|
/**
|
|
302
264
|
* @description The available keys for this enum
|
|
@@ -304,7 +266,7 @@ class Enum {
|
|
|
304
266
|
|
|
305
267
|
|
|
306
268
|
get defIndexes() {
|
|
307
|
-
return
|
|
269
|
+
return this.#indexes;
|
|
308
270
|
}
|
|
309
271
|
/**
|
|
310
272
|
* @description The available keys for this enum
|
|
@@ -312,7 +274,7 @@ class Enum {
|
|
|
312
274
|
|
|
313
275
|
|
|
314
276
|
get defKeys() {
|
|
315
|
-
return Object.keys(
|
|
277
|
+
return Object.keys(this.#def);
|
|
316
278
|
}
|
|
317
279
|
/**
|
|
318
280
|
* @description The name of the type this enum value represents
|
|
@@ -320,7 +282,7 @@ class Enum {
|
|
|
320
282
|
|
|
321
283
|
|
|
322
284
|
get type() {
|
|
323
|
-
return this.defKeys[
|
|
285
|
+
return this.defKeys[this.#entryIndex];
|
|
324
286
|
}
|
|
325
287
|
/**
|
|
326
288
|
* @description The value of the enum
|
|
@@ -328,7 +290,7 @@ class Enum {
|
|
|
328
290
|
|
|
329
291
|
|
|
330
292
|
get value() {
|
|
331
|
-
return
|
|
293
|
+
return this.#raw;
|
|
332
294
|
}
|
|
333
295
|
/**
|
|
334
296
|
* @description Compares the value of the input to see if there is a match
|
|
@@ -341,7 +303,7 @@ class Enum {
|
|
|
341
303
|
return !this.toU8a().some((entry, index) => entry !== other[index]);
|
|
342
304
|
} else if ((0, _util.isNumber)(other)) {
|
|
343
305
|
return this.toNumber() === other;
|
|
344
|
-
} else if (
|
|
306
|
+
} else if (this.#isBasic && (0, _util.isString)(other)) {
|
|
345
307
|
return this.type === other;
|
|
346
308
|
} else if ((0, _util.isHex)(other)) {
|
|
347
309
|
return this.toHex() === other;
|
|
@@ -369,8 +331,7 @@ class Enum {
|
|
|
369
331
|
const {
|
|
370
332
|
inner,
|
|
371
333
|
outer = []
|
|
372
|
-
} =
|
|
373
|
-
|
|
334
|
+
} = this.#raw.inspect();
|
|
374
335
|
return {
|
|
375
336
|
inner,
|
|
376
337
|
outer: [new Uint8Array([this.index]), ...outer]
|
|
@@ -390,8 +351,8 @@ class Enum {
|
|
|
390
351
|
|
|
391
352
|
|
|
392
353
|
toHuman(isExtended) {
|
|
393
|
-
return
|
|
394
|
-
[this.type]:
|
|
354
|
+
return this.#isBasic || this.isNone ? this.type : {
|
|
355
|
+
[this.type]: this.#raw.toHuman(isExtended)
|
|
395
356
|
};
|
|
396
357
|
}
|
|
397
358
|
/**
|
|
@@ -400,8 +361,8 @@ class Enum {
|
|
|
400
361
|
|
|
401
362
|
|
|
402
363
|
toJSON() {
|
|
403
|
-
return
|
|
404
|
-
[(0, _util.stringCamelCase)(this.type)]:
|
|
364
|
+
return this.#isBasic ? this.type : {
|
|
365
|
+
[(0, _util.stringCamelCase)(this.type)]: this.#raw.toJSON()
|
|
405
366
|
};
|
|
406
367
|
}
|
|
407
368
|
/**
|
|
@@ -418,14 +379,14 @@ class Enum {
|
|
|
418
379
|
|
|
419
380
|
|
|
420
381
|
_toRawStruct() {
|
|
421
|
-
if (
|
|
422
|
-
return
|
|
423
|
-
out[key] =
|
|
382
|
+
if (this.#isBasic) {
|
|
383
|
+
return this.#isIndexed ? this.defKeys.reduce((out, key, index) => {
|
|
384
|
+
out[key] = this.#indexes[index];
|
|
424
385
|
return out;
|
|
425
386
|
}, {}) : this.defKeys;
|
|
426
387
|
}
|
|
427
388
|
|
|
428
|
-
const typeMap = Object.entries(
|
|
389
|
+
const typeMap = Object.entries(this.#def).reduce((out, _ref3) => {
|
|
429
390
|
let [key, {
|
|
430
391
|
Type
|
|
431
392
|
}] = _ref3;
|
|
@@ -459,7 +420,7 @@ class Enum {
|
|
|
459
420
|
|
|
460
421
|
|
|
461
422
|
toU8a(isBare) {
|
|
462
|
-
return (0, _util.u8aConcat)(new Uint8Array(isBare ? [] : [this.index]),
|
|
423
|
+
return (0, _util.u8aConcat)(new Uint8Array(isBare ? [] : [this.index]), this.#raw.toU8a(isBare));
|
|
463
424
|
}
|
|
464
425
|
|
|
465
426
|
}
|
package/base/Null.cjs
CHANGED
|
@@ -17,10 +17,9 @@ var _util = require("@polkadot/util");
|
|
|
17
17
|
*/
|
|
18
18
|
class Null {
|
|
19
19
|
// Added for compatibility reasons, e.g. see Option
|
|
20
|
+
initialU8aLength = 0;
|
|
21
|
+
|
|
20
22
|
constructor(registry) {
|
|
21
|
-
this.registry = void 0;
|
|
22
|
-
this.createdAtHash = void 0;
|
|
23
|
-
this.initialU8aLength = 0;
|
|
24
23
|
this.registry = registry;
|
|
25
24
|
}
|
|
26
25
|
/**
|
package/base/Option.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.Option = 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");
|
|
@@ -50,36 +44,20 @@ function decodeOption(registry, Type, value) {
|
|
|
50
44
|
*/
|
|
51
45
|
|
|
52
46
|
|
|
53
|
-
var _Type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Type");
|
|
54
|
-
|
|
55
|
-
var _initialU8aLength = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("initialU8aLength");
|
|
56
|
-
|
|
57
|
-
var _raw = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("raw");
|
|
58
|
-
|
|
59
47
|
class Option {
|
|
48
|
+
#Type;
|
|
49
|
+
#initialU8aLength;
|
|
50
|
+
#raw;
|
|
51
|
+
|
|
60
52
|
constructor(registry, typeName, value) {
|
|
61
|
-
this.registry = void 0;
|
|
62
|
-
this.createdAtHash = void 0;
|
|
63
|
-
Object.defineProperty(this, _Type, {
|
|
64
|
-
writable: true,
|
|
65
|
-
value: void 0
|
|
66
|
-
});
|
|
67
|
-
Object.defineProperty(this, _initialU8aLength, {
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(this, _raw, {
|
|
72
|
-
writable: true,
|
|
73
|
-
value: void 0
|
|
74
|
-
});
|
|
75
53
|
const Type = (0, _index.typeToConstructor)(registry, typeName);
|
|
76
54
|
const decoded = (0, _util.isU8a)(value) && value.length && !(0, _util.isCodec)(value) ? value[0] === 0 ? new _Null.Null(registry) : new Type(registry, value.subarray(1)) : decodeOption(registry, Type, value);
|
|
77
55
|
this.registry = registry;
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
this.#Type = Type;
|
|
57
|
+
this.#raw = decoded;
|
|
80
58
|
|
|
81
59
|
if (decoded.initialU8aLength) {
|
|
82
|
-
|
|
60
|
+
this.#initialU8aLength = 1 + decoded.initialU8aLength;
|
|
83
61
|
}
|
|
84
62
|
}
|
|
85
63
|
|
|
@@ -98,7 +76,7 @@ class Option {
|
|
|
98
76
|
|
|
99
77
|
get encodedLength() {
|
|
100
78
|
// boolean byte (has value, doesn't have) along with wrapped length
|
|
101
|
-
return 1 +
|
|
79
|
+
return 1 + this.#raw.encodedLength;
|
|
102
80
|
}
|
|
103
81
|
/**
|
|
104
82
|
* @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
|
|
@@ -106,7 +84,7 @@ class Option {
|
|
|
106
84
|
|
|
107
85
|
|
|
108
86
|
get initialU8aLength() {
|
|
109
|
-
return
|
|
87
|
+
return this.#initialU8aLength;
|
|
110
88
|
}
|
|
111
89
|
/**
|
|
112
90
|
* @description returns a hash of the contents
|
|
@@ -130,7 +108,7 @@ class Option {
|
|
|
130
108
|
|
|
131
109
|
|
|
132
110
|
get isNone() {
|
|
133
|
-
return
|
|
111
|
+
return this.#raw instanceof _Null.Null;
|
|
134
112
|
}
|
|
135
113
|
/**
|
|
136
114
|
* @description Checks if the Option has a value
|
|
@@ -146,7 +124,7 @@ class Option {
|
|
|
146
124
|
|
|
147
125
|
|
|
148
126
|
get value() {
|
|
149
|
-
return
|
|
127
|
+
return this.#raw;
|
|
150
128
|
}
|
|
151
129
|
/**
|
|
152
130
|
* @description Compares the value of the input to see if there is a match
|
|
@@ -175,8 +153,7 @@ class Option {
|
|
|
175
153
|
const {
|
|
176
154
|
inner,
|
|
177
155
|
outer = []
|
|
178
|
-
} =
|
|
179
|
-
|
|
156
|
+
} = this.#raw.inspect();
|
|
180
157
|
return {
|
|
181
158
|
inner,
|
|
182
159
|
outer: [new Uint8Array([1]), ...outer]
|
|
@@ -198,7 +175,7 @@ class Option {
|
|
|
198
175
|
|
|
199
176
|
|
|
200
177
|
toHuman(isExtended) {
|
|
201
|
-
return
|
|
178
|
+
return this.#raw.toHuman(isExtended);
|
|
202
179
|
}
|
|
203
180
|
/**
|
|
204
181
|
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
@@ -206,7 +183,7 @@ class Option {
|
|
|
206
183
|
|
|
207
184
|
|
|
208
185
|
toJSON() {
|
|
209
|
-
return this.isNone ? null :
|
|
186
|
+
return this.isNone ? null : this.#raw.toJSON();
|
|
210
187
|
}
|
|
211
188
|
/**
|
|
212
189
|
* @description Returns the base runtime type name for this instance
|
|
@@ -214,7 +191,7 @@ class Option {
|
|
|
214
191
|
|
|
215
192
|
|
|
216
193
|
toRawType(isBare) {
|
|
217
|
-
const wrapped = this.registry.getClassName(
|
|
194
|
+
const wrapped = this.registry.getClassName(this.#Type) || new this.#Type(this.registry).toRawType();
|
|
218
195
|
return isBare ? wrapped : `Option<${wrapped}>`;
|
|
219
196
|
}
|
|
220
197
|
/**
|
|
@@ -223,7 +200,7 @@ class Option {
|
|
|
223
200
|
|
|
224
201
|
|
|
225
202
|
toString() {
|
|
226
|
-
return
|
|
203
|
+
return this.#raw.toString();
|
|
227
204
|
}
|
|
228
205
|
/**
|
|
229
206
|
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
@@ -233,14 +210,14 @@ class Option {
|
|
|
233
210
|
|
|
234
211
|
toU8a(isBare) {
|
|
235
212
|
if (isBare) {
|
|
236
|
-
return
|
|
213
|
+
return this.#raw.toU8a(true);
|
|
237
214
|
}
|
|
238
215
|
|
|
239
216
|
const u8a = new Uint8Array(this.encodedLength);
|
|
240
217
|
|
|
241
218
|
if (this.isSome) {
|
|
242
219
|
u8a.set([1]);
|
|
243
|
-
u8a.set(
|
|
220
|
+
u8a.set(this.#raw.toU8a(), 1);
|
|
244
221
|
}
|
|
245
222
|
|
|
246
223
|
return u8a;
|
|
@@ -252,7 +229,7 @@ class Option {
|
|
|
252
229
|
|
|
253
230
|
unwrap() {
|
|
254
231
|
(0, _util.assert)(this.isSome, 'Option: unwrapping a None value');
|
|
255
|
-
return
|
|
232
|
+
return this.#raw;
|
|
256
233
|
}
|
|
257
234
|
/**
|
|
258
235
|
* @description Returns the value that the Option represents (if available) or defaultValue if none
|
|
@@ -270,7 +247,7 @@ class Option {
|
|
|
270
247
|
|
|
271
248
|
|
|
272
249
|
unwrapOrDefault() {
|
|
273
|
-
return this.isSome ? this.unwrap() : new
|
|
250
|
+
return this.isSome ? this.unwrap() : new this.#Type(this.registry);
|
|
274
251
|
}
|
|
275
252
|
|
|
276
253
|
}
|
package/base/Tuple.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.Tuple = 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");
|
|
@@ -49,18 +43,14 @@ function decodeTuple(registry, Classes, value) {
|
|
|
49
43
|
*/
|
|
50
44
|
|
|
51
45
|
|
|
52
|
-
var _Types = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Types");
|
|
53
|
-
|
|
54
46
|
class Tuple extends _AbstractArray.AbstractArray {
|
|
47
|
+
#Types;
|
|
48
|
+
|
|
55
49
|
constructor(registry, Types, value) {
|
|
56
50
|
const Classes = Array.isArray(Types) ? Types.map(t => (0, _index.typeToConstructor)(registry, t)) : (0, _util.isFunction)(Types) || (0, _util.isString)(Types) ? [(0, _index.typeToConstructor)(registry, Types)] : (0, _index.mapToTypeMap)(registry, Types);
|
|
57
51
|
const [values, decodedLength] = (0, _util.isU8a)(value) ? (0, _index.decodeU8a)(registry, value, Classes) : decodeTuple(registry, Classes, value);
|
|
58
52
|
super(registry, values, decodedLength);
|
|
59
|
-
|
|
60
|
-
writable: true,
|
|
61
|
-
value: void 0
|
|
62
|
-
});
|
|
63
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _Types)[_Types] = Classes;
|
|
53
|
+
this.#Types = Classes;
|
|
64
54
|
}
|
|
65
55
|
|
|
66
56
|
static with(Types) {
|
|
@@ -91,7 +81,7 @@ class Tuple extends _AbstractArray.AbstractArray {
|
|
|
91
81
|
|
|
92
82
|
|
|
93
83
|
get Types() {
|
|
94
|
-
return Array.isArray(
|
|
84
|
+
return Array.isArray(this.#Types) ? this.#Types.map(T => new T(this.registry).toRawType()) : Object.keys(this.#Types);
|
|
95
85
|
}
|
|
96
86
|
/**
|
|
97
87
|
* @description Returns a breakdown of the hex encoding for this Codec
|
|
@@ -109,7 +99,7 @@ class Tuple extends _AbstractArray.AbstractArray {
|
|
|
109
99
|
|
|
110
100
|
|
|
111
101
|
toRawType() {
|
|
112
|
-
const types = (Array.isArray(
|
|
102
|
+
const types = (Array.isArray(this.#Types) ? this.#Types : Object.values(this.#Types)).map(T => this.registry.getClassName(T) || new T(this.registry).toRawType());
|
|
113
103
|
return `(${types.join(',')})`;
|
|
114
104
|
}
|
|
115
105
|
/**
|
package/base/Vec.cjs
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
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.Vec = void 0;
|
|
9
7
|
exports.decodeVec = decodeVec;
|
|
10
8
|
|
|
11
|
-
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
12
|
-
|
|
13
|
-
var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
|
|
14
|
-
|
|
15
9
|
var _util = require("@polkadot/util");
|
|
16
10
|
|
|
17
11
|
var _AbstractArray = require("../abstract/AbstractArray.cjs");
|
|
@@ -64,19 +58,15 @@ function decodeVec(registry, Type, value) {
|
|
|
64
58
|
*/
|
|
65
59
|
|
|
66
60
|
|
|
67
|
-
var _Type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Type");
|
|
68
|
-
|
|
69
61
|
class Vec extends _AbstractArray.AbstractArray {
|
|
62
|
+
#Type;
|
|
63
|
+
|
|
70
64
|
constructor(registry, Type) {
|
|
71
65
|
let value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
72
66
|
const Clazz = (0, _index.typeToConstructor)(registry, Type);
|
|
73
67
|
const [values, decodedLength] = decodeVec(registry, Clazz, value);
|
|
74
68
|
super(registry, values, decodedLength);
|
|
75
|
-
|
|
76
|
-
writable: true,
|
|
77
|
-
value: void 0
|
|
78
|
-
});
|
|
79
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type] = Clazz;
|
|
69
|
+
this.#Type = Clazz;
|
|
80
70
|
}
|
|
81
71
|
|
|
82
72
|
static with(Type) {
|
|
@@ -93,7 +83,7 @@ class Vec extends _AbstractArray.AbstractArray {
|
|
|
93
83
|
|
|
94
84
|
|
|
95
85
|
get Type() {
|
|
96
|
-
return
|
|
86
|
+
return this.#Type.name;
|
|
97
87
|
}
|
|
98
88
|
/**
|
|
99
89
|
* @description Finds the index of the value in the array
|
|
@@ -102,7 +92,7 @@ class Vec extends _AbstractArray.AbstractArray {
|
|
|
102
92
|
|
|
103
93
|
indexOf(_other) {
|
|
104
94
|
// convert type first, this removes overhead from the eq
|
|
105
|
-
const other = _other instanceof
|
|
95
|
+
const other = _other instanceof this.#Type ? _other : new this.#Type(this.registry, _other);
|
|
106
96
|
|
|
107
97
|
for (let i = 0; i < this.length; i++) {
|
|
108
98
|
if (other.eq(this[i])) {
|
|
@@ -118,7 +108,7 @@ class Vec extends _AbstractArray.AbstractArray {
|
|
|
118
108
|
|
|
119
109
|
|
|
120
110
|
toRawType() {
|
|
121
|
-
return `Vec<${this.registry.getClassName(
|
|
111
|
+
return `Vec<${this.registry.getClassName(this.#Type) || new this.#Type(this.registry).toRawType()}>`;
|
|
122
112
|
}
|
|
123
113
|
|
|
124
114
|
}
|
package/base/VecFixed.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.VecFixed = 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");
|
|
@@ -40,19 +34,15 @@ function decodeVecFixed(registry, value, Type, length) {
|
|
|
40
34
|
*/
|
|
41
35
|
|
|
42
36
|
|
|
43
|
-
var _Type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Type");
|
|
44
|
-
|
|
45
37
|
class VecFixed extends _AbstractArray.AbstractArray {
|
|
38
|
+
#Type;
|
|
39
|
+
|
|
46
40
|
constructor(registry, Type, length) {
|
|
47
41
|
let value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
48
42
|
const Clazz = (0, _index.typeToConstructor)(registry, Type);
|
|
49
43
|
const [values,, decodedLengthNoOffset] = (0, _util.isU8a)(value) ? (0, _index.decodeU8aVec)(registry, value, 0, Clazz, length) : decodeVecFixed(registry, value, Clazz, length);
|
|
50
44
|
super(registry, values, decodedLengthNoOffset);
|
|
51
|
-
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
(0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type] = Clazz;
|
|
45
|
+
this.#Type = Clazz;
|
|
56
46
|
}
|
|
57
47
|
|
|
58
48
|
static with(Type, length) {
|
|
@@ -69,7 +59,7 @@ class VecFixed extends _AbstractArray.AbstractArray {
|
|
|
69
59
|
|
|
70
60
|
|
|
71
61
|
get Type() {
|
|
72
|
-
return new
|
|
62
|
+
return new this.#Type(this.registry).toRawType();
|
|
73
63
|
}
|
|
74
64
|
/**
|
|
75
65
|
* @description The length of the value when encoded as a Uint8Array
|
package/extended/BTreeSet.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.BTreeSet = 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");
|
|
@@ -29,7 +23,7 @@ function decodeSetFromU8a(registry, ValClass, u8a) {
|
|
|
29
23
|
output.add(values[i]);
|
|
30
24
|
}
|
|
31
25
|
|
|
32
|
-
return [output, decodedLength
|
|
26
|
+
return [output, decodedLength];
|
|
33
27
|
}
|
|
34
28
|
/** @internal */
|
|
35
29
|
|
|
@@ -78,22 +72,15 @@ function decodeSet(registry, valType, value) {
|
|
|
78
72
|
throw new Error('BTreeSet: cannot decode type');
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
var _ValClass = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("ValClass");
|
|
82
|
-
|
|
83
75
|
class BTreeSet extends Set {
|
|
76
|
+
#ValClass;
|
|
77
|
+
|
|
84
78
|
constructor(registry, valType, rawValue) {
|
|
85
79
|
const [values, decodedLength] = decodeSet(registry, valType, rawValue);
|
|
86
80
|
super((0, _index.sortSet)(values));
|
|
87
|
-
this.registry = void 0;
|
|
88
|
-
this.createdAtHash = void 0;
|
|
89
|
-
this.initialU8aLength = void 0;
|
|
90
|
-
Object.defineProperty(this, _ValClass, {
|
|
91
|
-
writable: true,
|
|
92
|
-
value: void 0
|
|
93
|
-
});
|
|
94
81
|
this.registry = registry;
|
|
95
82
|
this.initialU8aLength = decodedLength;
|
|
96
|
-
|
|
83
|
+
this.#ValClass = (0, _index.typeToConstructor)(registry, valType);
|
|
97
84
|
}
|
|
98
85
|
|
|
99
86
|
static with(valType) {
|
|
@@ -209,7 +196,7 @@ class BTreeSet extends Set {
|
|
|
209
196
|
|
|
210
197
|
|
|
211
198
|
toRawType() {
|
|
212
|
-
return `BTreeSet<${this.registry.getClassName(
|
|
199
|
+
return `BTreeSet<${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
|
213
200
|
}
|
|
214
201
|
/**
|
|
215
202
|
* @description Returns the string representation of the value
|