@polkadot/types-codec 10.0.1 → 10.1.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.d.ts +1 -1
- package/abstract/Array.js +0 -4
- package/abstract/Base.d.ts +1 -1
- package/abstract/Base.js +18 -19
- package/abstract/Int.d.ts +1 -1
- package/abstract/Int.js +11 -14
- package/abstract/Object.d.ts +1 -1
- package/abstract/Object.js +0 -5
- package/abstract/index.d.ts +3 -3
- package/base/Compact.d.ts +1 -1
- package/base/Compact.js +24 -25
- package/base/DoNotConstruct.d.ts +1 -1
- package/base/DoNotConstruct.js +19 -19
- package/base/Enum.d.ts +1 -1
- package/base/Enum.js +54 -53
- package/base/Int.d.ts +2 -2
- package/base/Null.d.ts +1 -1
- package/base/Null.js +3 -6
- package/base/Option.d.ts +1 -1
- package/base/Option.js +21 -22
- package/base/Result.d.ts +2 -2
- package/base/Tuple.d.ts +2 -2
- package/base/Tuple.js +10 -7
- package/base/UInt.d.ts +2 -2
- package/base/Vec.d.ts +2 -2
- package/base/Vec.js +12 -9
- package/base/VecAny.d.ts +2 -2
- package/base/VecFixed.d.ts +2 -2
- package/base/VecFixed.js +9 -6
- package/base/index.d.ts +12 -12
- package/bundle.d.ts +7 -7
- package/cjs/abstract/Array.js +2 -2
- package/cjs/abstract/index.js +6 -6
- package/cjs/base/Compact.js +2 -2
- package/cjs/base/Enum.js +8 -8
- package/cjs/base/Int.js +2 -2
- package/cjs/base/Option.js +4 -4
- package/cjs/base/Result.js +2 -2
- package/cjs/base/Tuple.js +8 -8
- package/cjs/base/UInt.js +2 -2
- package/cjs/base/Vec.js +6 -6
- package/cjs/base/VecAny.js +2 -2
- package/cjs/base/VecFixed.js +7 -7
- package/cjs/base/index.js +24 -24
- package/cjs/bundle.js +8 -8
- package/cjs/detectPackage.js +3 -3
- package/cjs/extended/BTreeMap.js +2 -2
- package/cjs/extended/BTreeSet.js +5 -5
- package/cjs/extended/BitVec.js +2 -2
- package/cjs/extended/Bytes.js +3 -3
- package/cjs/extended/HashMap.js +2 -2
- package/cjs/extended/Linkage.js +10 -10
- package/cjs/extended/Map.js +15 -15
- package/cjs/extended/OptionBool.js +5 -5
- package/cjs/extended/Range.js +2 -2
- package/cjs/extended/RangeInclusive.js +2 -2
- package/cjs/extended/Type.js +4 -4
- package/cjs/extended/U8aFixed.js +2 -2
- package/cjs/extended/WrapperKeepOpaque.js +6 -6
- package/cjs/extended/WrapperOpaque.js +2 -2
- package/cjs/extended/index.js +29 -29
- package/cjs/index.js +2 -2
- package/cjs/native/Json.js +2 -2
- package/cjs/native/Set.js +2 -2
- package/cjs/native/Struct.js +5 -5
- package/cjs/native/Text.js +2 -2
- package/cjs/native/index.js +19 -19
- package/cjs/packageInfo.js +1 -1
- package/cjs/primitive/F32.js +2 -2
- package/cjs/primitive/F64.js +2 -2
- package/cjs/primitive/I128.js +2 -2
- package/cjs/primitive/I16.js +2 -2
- package/cjs/primitive/I256.js +2 -2
- package/cjs/primitive/I32.js +2 -2
- package/cjs/primitive/I64.js +2 -2
- package/cjs/primitive/I8.js +2 -2
- package/cjs/primitive/U128.js +2 -2
- package/cjs/primitive/U16.js +2 -2
- package/cjs/primitive/U256.js +2 -2
- package/cjs/primitive/U32.js +2 -2
- package/cjs/primitive/U64.js +2 -2
- package/cjs/primitive/U8.js +2 -2
- package/cjs/primitive/USize.js +2 -2
- package/cjs/primitive/index.js +45 -45
- package/cjs/types/index.js +4 -4
- package/cjs/utils/compareArray.js +2 -2
- package/cjs/utils/compareMap.js +2 -2
- package/cjs/utils/index.js +22 -22
- package/cjs/utils/mapToTypeMap.js +2 -2
- package/extended/BTreeMap.d.ts +2 -2
- package/extended/BTreeSet.d.ts +1 -1
- package/extended/BTreeSet.js +7 -8
- package/extended/BitVec.d.ts +2 -2
- package/extended/BitVec.js +12 -9
- package/extended/Bytes.d.ts +2 -2
- package/extended/HashMap.d.ts +2 -2
- package/extended/Linkage.d.ts +4 -4
- package/extended/Map.d.ts +1 -1
- package/extended/Map.js +11 -12
- package/extended/OptionBool.d.ts +3 -3
- package/extended/Range.d.ts +2 -2
- package/extended/Range.js +7 -4
- package/extended/RangeInclusive.d.ts +2 -2
- package/extended/Type.d.ts +2 -2
- package/extended/U8aFixed.d.ts +2 -2
- package/extended/WrapperKeepOpaque.d.ts +2 -2
- package/extended/WrapperKeepOpaque.js +23 -20
- package/extended/WrapperOpaque.d.ts +2 -2
- package/extended/index.d.ts +14 -14
- package/index.d.ts +2 -2
- package/native/Bool.d.ts +1 -1
- package/native/Bool.js +1 -4
- package/native/Date.d.ts +1 -1
- package/native/Date.js +1 -4
- package/native/Float.d.ts +1 -1
- package/native/Float.js +8 -10
- package/native/Json.d.ts +1 -1
- package/native/Json.js +0 -4
- package/native/Raw.d.ts +1 -1
- package/native/Raw.js +0 -4
- package/native/Set.d.ts +1 -1
- package/native/Set.js +35 -34
- package/native/Struct.d.ts +1 -1
- package/native/Struct.js +22 -21
- package/native/Text.d.ts +1 -1
- package/native/Text.js +7 -8
- package/native/index.d.ts +8 -8
- package/package.json +3 -3
- package/packageInfo.js +1 -1
- package/primitive/F32.d.ts +2 -2
- package/primitive/F32.js +5 -2
- package/primitive/F64.d.ts +2 -2
- package/primitive/F64.js +5 -2
- package/primitive/I128.d.ts +2 -2
- package/primitive/I128.js +5 -2
- package/primitive/I16.d.ts +2 -2
- package/primitive/I16.js +5 -2
- package/primitive/I256.d.ts +2 -2
- package/primitive/I256.js +5 -2
- package/primitive/I32.d.ts +2 -2
- package/primitive/I32.js +5 -2
- package/primitive/I64.d.ts +2 -2
- package/primitive/I64.js +5 -2
- package/primitive/I8.d.ts +2 -2
- package/primitive/I8.js +5 -2
- package/primitive/U128.d.ts +2 -2
- package/primitive/U128.js +5 -2
- package/primitive/U16.d.ts +2 -2
- package/primitive/U16.js +5 -2
- package/primitive/U256.d.ts +2 -2
- package/primitive/U256.js +5 -2
- package/primitive/U32.d.ts +2 -2
- package/primitive/U32.js +5 -2
- package/primitive/U64.d.ts +2 -2
- package/primitive/U64.js +5 -2
- package/primitive/U8.d.ts +2 -2
- package/primitive/U8.js +5 -2
- package/primitive/USize.d.ts +2 -2
- package/primitive/index.d.ts +15 -15
- package/types/codec.d.ts +3 -3
- package/types/helpers.d.ts +1 -1
- package/types/index.d.ts +4 -4
- package/types/interfaces.d.ts +2 -2
- package/types/registry.d.ts +3 -3
- package/utils/decodeU8a.d.ts +1 -1
- package/utils/index.d.ts +9 -9
- package/utils/mapToTypeMap.d.ts +1 -1
- package/utils/sanitize.d.ts +1 -1
- package/utils/sortValues.d.ts +1 -1
- package/utils/typeToConstructor.d.ts +1 -1
- package/utils/typesToMap.d.ts +1 -1
package/base/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { Compact } from './Compact';
|
|
2
|
-
export { DoNotConstruct } from './DoNotConstruct';
|
|
3
|
-
export { Enum } from './Enum';
|
|
4
|
-
export { Int } from './Int';
|
|
5
|
-
export { Null } from './Null';
|
|
6
|
-
export { Option } from './Option';
|
|
7
|
-
export { Result } from './Result';
|
|
8
|
-
export { Tuple } from './Tuple';
|
|
9
|
-
export { UInt } from './UInt';
|
|
10
|
-
export { Vec } from './Vec';
|
|
11
|
-
export { VecAny } from './VecAny';
|
|
12
|
-
export { VecFixed } from './VecFixed';
|
|
1
|
+
export { Compact } from './Compact.js';
|
|
2
|
+
export { DoNotConstruct } from './DoNotConstruct.js';
|
|
3
|
+
export { Enum } from './Enum.js';
|
|
4
|
+
export { Int } from './Int.js';
|
|
5
|
+
export { Null } from './Null.js';
|
|
6
|
+
export { Option } from './Option.js';
|
|
7
|
+
export { Result } from './Result.js';
|
|
8
|
+
export { Tuple } from './Tuple.js';
|
|
9
|
+
export { UInt } from './UInt.js';
|
|
10
|
+
export { Vec } from './Vec.js';
|
|
11
|
+
export { VecAny } from './VecAny.js';
|
|
12
|
+
export { VecFixed } from './VecFixed.js';
|
package/bundle.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { packageInfo } from './packageInfo';
|
|
2
|
-
export * from './abstract';
|
|
3
|
-
export * from './base';
|
|
4
|
-
export * from './extended';
|
|
5
|
-
export * from './native';
|
|
6
|
-
export * from './primitive';
|
|
7
|
-
export * from './utils';
|
|
1
|
+
export { packageInfo } from './packageInfo.js';
|
|
2
|
+
export * from './abstract/index.js';
|
|
3
|
+
export * from './base/index.js';
|
|
4
|
+
export * from './extended/index.js';
|
|
5
|
+
export * from './native/index.js';
|
|
6
|
+
export * from './primitive/index.js';
|
|
7
|
+
export * from './utils/index.js';
|
package/cjs/abstract/Array.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractArray = void 0;
|
|
4
4
|
const util_1 = require("@polkadot/util");
|
|
5
|
-
const
|
|
5
|
+
const compareArray_js_1 = require("../utils/compareArray.js");
|
|
6
6
|
/**
|
|
7
7
|
* @name AbstractArray
|
|
8
8
|
* @description
|
|
@@ -57,7 +57,7 @@ class AbstractArray extends Array {
|
|
|
57
57
|
* @description Compares the value of the input to see if there is a match
|
|
58
58
|
*/
|
|
59
59
|
eq(other) {
|
|
60
|
-
return (0,
|
|
60
|
+
return (0, compareArray_js_1.compareArray)(this, other);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* @description Returns a breakdown of the hex encoding for this Codec
|
package/cjs/abstract/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractInt = exports.AbstractBase = exports.AbstractArray = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "AbstractArray", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "AbstractBase", { enumerable: true, get: function () { return
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "AbstractInt", { enumerable: true, get: function () { return
|
|
4
|
+
var Array_js_1 = require("./Array.js");
|
|
5
|
+
Object.defineProperty(exports, "AbstractArray", { enumerable: true, get: function () { return Array_js_1.AbstractArray; } });
|
|
6
|
+
var Base_js_1 = require("./Base.js");
|
|
7
|
+
Object.defineProperty(exports, "AbstractBase", { enumerable: true, get: function () { return Base_js_1.AbstractBase; } });
|
|
8
|
+
var Int_js_1 = require("./Int.js");
|
|
9
|
+
Object.defineProperty(exports, "AbstractInt", { enumerable: true, get: function () { return Int_js_1.AbstractInt; } });
|
package/cjs/base/Compact.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Compact = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
7
|
+
const index_js_1 = require("../utils/index.js");
|
|
8
8
|
function noopSetDefinition(d) {
|
|
9
9
|
return d;
|
|
10
10
|
}
|
|
@@ -39,7 +39,7 @@ class Compact {
|
|
|
39
39
|
_Compact_Type.set(this, void 0);
|
|
40
40
|
_Compact_raw.set(this, void 0);
|
|
41
41
|
this.registry = registry;
|
|
42
|
-
tslib_1.__classPrivateFieldSet(this, _Compact_Type, definition || setDefinition((0,
|
|
42
|
+
tslib_1.__classPrivateFieldSet(this, _Compact_Type, definition || setDefinition((0, index_js_1.typeToConstructor)(registry, Type)), "f");
|
|
43
43
|
const [raw, decodedLength] = decodeCompact(registry, tslib_1.__classPrivateFieldGet(this, _Compact_Type, "f"), value);
|
|
44
44
|
this.initialU8aLength = decodedLength;
|
|
45
45
|
tslib_1.__classPrivateFieldSet(this, _Compact_raw, raw, "f");
|
package/cjs/base/Enum.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Enum = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const index_js_1 = require("../utils/index.js");
|
|
8
|
+
const Null_js_1 = require("./Null.js");
|
|
9
9
|
function noopSetDefinition(d) {
|
|
10
10
|
return d;
|
|
11
11
|
}
|
|
@@ -25,24 +25,24 @@ function extractDef(registry, _def) {
|
|
|
25
25
|
let isIndexed;
|
|
26
26
|
if (Array.isArray(_def)) {
|
|
27
27
|
for (let i = 0; i < _def.length; i++) {
|
|
28
|
-
def[_def[i]] = { Type:
|
|
28
|
+
def[_def[i]] = { Type: Null_js_1.Null, index: i };
|
|
29
29
|
}
|
|
30
30
|
isBasic = true;
|
|
31
31
|
isIndexed = false;
|
|
32
32
|
}
|
|
33
33
|
else if (isRustEnum(_def)) {
|
|
34
|
-
const [Types, keys] = (0,
|
|
34
|
+
const [Types, keys] = (0, index_js_1.mapToTypeMap)(registry, _def);
|
|
35
35
|
for (let i = 0; i < keys.length; i++) {
|
|
36
36
|
def[keys[i]] = { Type: Types[i], index: i };
|
|
37
37
|
}
|
|
38
|
-
isBasic = !Object.values(def).some(({ Type }) => Type !==
|
|
38
|
+
isBasic = !Object.values(def).some(({ Type }) => Type !== Null_js_1.Null);
|
|
39
39
|
isIndexed = false;
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
const entries = Object.entries(_def);
|
|
43
43
|
for (let i = 0; i < entries.length; i++) {
|
|
44
44
|
const [key, index] = entries[i];
|
|
45
|
-
def[key] = { Type:
|
|
45
|
+
def[key] = { Type: Null_js_1.Null, index };
|
|
46
46
|
}
|
|
47
47
|
isBasic = true;
|
|
48
48
|
isIndexed = true;
|
|
@@ -225,7 +225,7 @@ class Enum {
|
|
|
225
225
|
* @description Checks if the Enum points to a [[Null]] type
|
|
226
226
|
*/
|
|
227
227
|
get isNone() {
|
|
228
|
-
return tslib_1.__classPrivateFieldGet(this, _Enum_raw, "f") instanceof
|
|
228
|
+
return tslib_1.__classPrivateFieldGet(this, _Enum_raw, "f") instanceof Null_js_1.Null;
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
231
|
* @description The available keys for this enum
|
|
@@ -339,7 +339,7 @@ class Enum {
|
|
|
339
339
|
: this.defKeys;
|
|
340
340
|
}
|
|
341
341
|
const entries = Object.entries(tslib_1.__classPrivateFieldGet(this, _Enum_def, "f"));
|
|
342
|
-
return (0,
|
|
342
|
+
return (0, index_js_1.typesToMap)(this.registry, entries.reduce((out, [key, { Type }], i) => {
|
|
343
343
|
out[0][i] = Type;
|
|
344
344
|
out[1][i] = key;
|
|
345
345
|
return out;
|
package/cjs/base/Int.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Int = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Int_js_1 = require("../abstract/Int.js");
|
|
5
5
|
/**
|
|
6
6
|
* @name Int
|
|
7
7
|
* @description
|
|
@@ -12,7 +12,7 @@ const Int_1 = require("../abstract/Int");
|
|
|
12
12
|
* is available here.
|
|
13
13
|
* @noInheritDoc
|
|
14
14
|
*/
|
|
15
|
-
class Int extends
|
|
15
|
+
class Int extends Int_js_1.AbstractInt {
|
|
16
16
|
constructor(registry, value = 0, bitLength) {
|
|
17
17
|
super(registry, value, bitLength, true);
|
|
18
18
|
}
|
package/cjs/base/Option.js
CHANGED
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Option = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const index_js_1 = require("../utils/index.js");
|
|
8
|
+
const Null_js_1 = require("./Null.js");
|
|
9
9
|
function noopSetDefinition(d) {
|
|
10
10
|
return d;
|
|
11
11
|
}
|
|
12
|
-
class None extends
|
|
12
|
+
class None extends Null_js_1.Null {
|
|
13
13
|
/**
|
|
14
14
|
* @description Returns the base runtime type name for this instance
|
|
15
15
|
*/
|
|
@@ -60,7 +60,7 @@ class Option {
|
|
|
60
60
|
constructor(registry, typeName, value, { definition, setDefinition = noopSetDefinition } = {}) {
|
|
61
61
|
_Option_Type.set(this, void 0);
|
|
62
62
|
_Option_raw.set(this, void 0);
|
|
63
|
-
const Type = definition || setDefinition((0,
|
|
63
|
+
const Type = definition || setDefinition((0, index_js_1.typeToConstructor)(registry, typeName));
|
|
64
64
|
const decoded = (0, util_1.isU8a)(value) && value.length && !(0, util_1.isCodec)(value)
|
|
65
65
|
? value[0] === 0
|
|
66
66
|
? new None(registry)
|
package/cjs/base/Result.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Result = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Enum_js_1 = require("./Enum.js");
|
|
5
5
|
/**
|
|
6
6
|
* @name Result
|
|
7
7
|
* @description
|
|
8
8
|
* A Result maps to the Rust Result type, that can either wrap a success or error value
|
|
9
9
|
*/
|
|
10
|
-
class Result extends
|
|
10
|
+
class Result extends Enum_js_1.Enum {
|
|
11
11
|
constructor(registry, Ok, Err, value) {
|
|
12
12
|
// NOTE This is order-dependent, Ok (with index 0) needs to be first
|
|
13
13
|
// eslint-disable-next-line sort-keys
|
package/cjs/base/Tuple.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Tuple = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const Array_js_1 = require("../abstract/Array.js");
|
|
8
|
+
const index_js_1 = require("../utils/index.js");
|
|
9
9
|
function noopSetDefinition(d) {
|
|
10
10
|
return d;
|
|
11
11
|
}
|
|
@@ -27,7 +27,7 @@ function decodeTuple(registry, result, value, Classes) {
|
|
|
27
27
|
return [result, 0];
|
|
28
28
|
}
|
|
29
29
|
else if ((0, util_1.isHex)(value)) {
|
|
30
|
-
return (0,
|
|
30
|
+
return (0, index_js_1.decodeU8a)(registry, result, (0, util_1.u8aToU8a)(value), Classes);
|
|
31
31
|
}
|
|
32
32
|
else if (!value || !result.length) {
|
|
33
33
|
const Types = Classes[0];
|
|
@@ -44,17 +44,17 @@ function decodeTuple(registry, result, value, Classes) {
|
|
|
44
44
|
* A Tuple defines an anonymous fixed-length array, where each element has its
|
|
45
45
|
* own type. It extends the base JS `Array` object.
|
|
46
46
|
*/
|
|
47
|
-
class Tuple extends
|
|
47
|
+
class Tuple extends Array_js_1.AbstractArray {
|
|
48
48
|
constructor(registry, Types, value, { definition, setDefinition = noopSetDefinition } = {}) {
|
|
49
49
|
const Classes = definition || setDefinition(Array.isArray(Types)
|
|
50
|
-
? [Types.map((t) => (0,
|
|
50
|
+
? [Types.map((t) => (0, index_js_1.typeToConstructor)(registry, t)), []]
|
|
51
51
|
: (0, util_1.isFunction)(Types) || (0, util_1.isString)(Types)
|
|
52
|
-
? [[(0,
|
|
53
|
-
: (0,
|
|
52
|
+
? [[(0, index_js_1.typeToConstructor)(registry, Types)], []]
|
|
53
|
+
: (0, index_js_1.mapToTypeMap)(registry, Types));
|
|
54
54
|
super(registry, Classes[0].length);
|
|
55
55
|
_Tuple_Types.set(this, void 0);
|
|
56
56
|
this.initialU8aLength = ((0, util_1.isU8a)(value)
|
|
57
|
-
? (0,
|
|
57
|
+
? (0, index_js_1.decodeU8a)(registry, this, value, Classes)
|
|
58
58
|
: decodeTuple(registry, this, value, Classes))[1];
|
|
59
59
|
tslib_1.__classPrivateFieldSet(this, _Tuple_Types, Classes, "f");
|
|
60
60
|
}
|
package/cjs/base/UInt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UInt = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Int_js_1 = require("../abstract/Int.js");
|
|
5
5
|
/**
|
|
6
6
|
* @name UInt
|
|
7
7
|
* @description
|
|
@@ -12,7 +12,7 @@ const Int_1 = require("../abstract/Int");
|
|
|
12
12
|
* is available here.
|
|
13
13
|
* @noInheritDoc
|
|
14
14
|
*/
|
|
15
|
-
class UInt extends
|
|
15
|
+
class UInt extends Int_js_1.AbstractInt {
|
|
16
16
|
static with(bitLength, typeName) {
|
|
17
17
|
return class extends UInt {
|
|
18
18
|
constructor(registry, value) {
|
package/cjs/base/Vec.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.Vec = exports.decodeVec = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const Array_js_1 = require("../abstract/Array.js");
|
|
8
|
+
const index_js_1 = require("../utils/index.js");
|
|
9
9
|
const MAX_LENGTH = 64 * 1024;
|
|
10
10
|
const l = (0, util_1.logger)('Vec');
|
|
11
11
|
function noopSetDefinition(d) {
|
|
@@ -51,7 +51,7 @@ function decodeVec(registry, result, value, startAt, Type) {
|
|
|
51
51
|
return [0, 0];
|
|
52
52
|
}
|
|
53
53
|
// we don't need more checks, we already limited it via the length decoding
|
|
54
|
-
return (0,
|
|
54
|
+
return (0, index_js_1.decodeU8aVec)(registry, result, (0, util_1.u8aToU8a)(value), startAt, Type);
|
|
55
55
|
}
|
|
56
56
|
exports.decodeVec = decodeVec;
|
|
57
57
|
/**
|
|
@@ -61,14 +61,14 @@ exports.decodeVec = decodeVec;
|
|
|
61
61
|
* construction with the passed `Type` in the constructor. It is an extension to Array, providing
|
|
62
62
|
* specific encoding/decoding on top of the base type.
|
|
63
63
|
*/
|
|
64
|
-
class Vec extends
|
|
64
|
+
class Vec extends Array_js_1.AbstractArray {
|
|
65
65
|
constructor(registry, Type, value = [], { definition, setDefinition = noopSetDefinition } = {}) {
|
|
66
66
|
const [decodeFrom, length, startAt] = decodeVecLength(value);
|
|
67
67
|
super(registry, length);
|
|
68
68
|
_Vec_Type.set(this, void 0);
|
|
69
|
-
tslib_1.__classPrivateFieldSet(this, _Vec_Type, definition || setDefinition((0,
|
|
69
|
+
tslib_1.__classPrivateFieldSet(this, _Vec_Type, definition || setDefinition((0, index_js_1.typeToConstructor)(registry, Type)), "f");
|
|
70
70
|
this.initialU8aLength = ((0, util_1.isU8a)(decodeFrom)
|
|
71
|
-
? (0,
|
|
71
|
+
? (0, index_js_1.decodeU8aVec)(registry, this, decodeFrom, startAt, tslib_1.__classPrivateFieldGet(this, _Vec_Type, "f"))
|
|
72
72
|
: decodeVec(registry, this, decodeFrom, startAt, tslib_1.__classPrivateFieldGet(this, _Vec_Type, "f")))[0];
|
|
73
73
|
}
|
|
74
74
|
static with(Type) {
|
package/cjs/base/VecAny.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VecAny = void 0;
|
|
4
|
-
const
|
|
4
|
+
const Array_js_1 = require("../abstract/Array.js");
|
|
5
5
|
/**
|
|
6
6
|
* @name VecAny
|
|
7
7
|
* @description
|
|
@@ -9,7 +9,7 @@ const Array_1 = require("../abstract/Array");
|
|
|
9
9
|
* a vector, this can be used to manage array-like structures with variable arguments of
|
|
10
10
|
* any types
|
|
11
11
|
*/
|
|
12
|
-
class VecAny extends
|
|
12
|
+
class VecAny extends Array_js_1.AbstractArray {
|
|
13
13
|
/**
|
|
14
14
|
* @description Returns the base runtime type name for this instance
|
|
15
15
|
*/
|
package/cjs/base/VecFixed.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.VecFixed = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
const Array_js_1 = require("../abstract/Array.js");
|
|
8
|
+
const index_js_1 = require("../utils/index.js");
|
|
9
|
+
const Vec_js_1 = require("./Vec.js");
|
|
10
10
|
function noopSetDefinition(d) {
|
|
11
11
|
return d;
|
|
12
12
|
}
|
|
@@ -15,14 +15,14 @@ function noopSetDefinition(d) {
|
|
|
15
15
|
* @description
|
|
16
16
|
* This manages codec arrays of a fixed length
|
|
17
17
|
*/
|
|
18
|
-
class VecFixed extends
|
|
18
|
+
class VecFixed extends Array_js_1.AbstractArray {
|
|
19
19
|
constructor(registry, Type, length, value = [], { definition, setDefinition = noopSetDefinition } = {}) {
|
|
20
20
|
super(registry, length);
|
|
21
21
|
_VecFixed_Type.set(this, void 0);
|
|
22
|
-
tslib_1.__classPrivateFieldSet(this, _VecFixed_Type, definition || setDefinition((0,
|
|
22
|
+
tslib_1.__classPrivateFieldSet(this, _VecFixed_Type, definition || setDefinition((0, index_js_1.typeToConstructor)(registry, Type)), "f");
|
|
23
23
|
this.initialU8aLength = ((0, util_1.isU8a)(value)
|
|
24
|
-
? (0,
|
|
25
|
-
: (0,
|
|
24
|
+
? (0, index_js_1.decodeU8aVec)(registry, this, value, 0, tslib_1.__classPrivateFieldGet(this, _VecFixed_Type, "f"))
|
|
25
|
+
: (0, Vec_js_1.decodeVec)(registry, this, value, 0, tslib_1.__classPrivateFieldGet(this, _VecFixed_Type, "f")))[1];
|
|
26
26
|
}
|
|
27
27
|
static with(Type, length) {
|
|
28
28
|
let definition;
|
package/cjs/base/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VecFixed = exports.VecAny = exports.Vec = exports.UInt = exports.Tuple = exports.Result = exports.Option = exports.Null = exports.Int = exports.Enum = exports.DoNotConstruct = exports.Compact = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "Compact", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "DoNotConstruct", { enumerable: true, get: function () { return
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "Enum", { enumerable: true, get: function () { return
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return
|
|
16
|
-
var
|
|
17
|
-
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "Tuple", { enumerable: true, get: function () { return
|
|
20
|
-
var
|
|
21
|
-
Object.defineProperty(exports, "UInt", { enumerable: true, get: function () { return
|
|
22
|
-
var
|
|
23
|
-
Object.defineProperty(exports, "Vec", { enumerable: true, get: function () { return
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "VecAny", { enumerable: true, get: function () { return
|
|
26
|
-
var
|
|
27
|
-
Object.defineProperty(exports, "VecFixed", { enumerable: true, get: function () { return
|
|
4
|
+
var Compact_js_1 = require("./Compact.js");
|
|
5
|
+
Object.defineProperty(exports, "Compact", { enumerable: true, get: function () { return Compact_js_1.Compact; } });
|
|
6
|
+
var DoNotConstruct_js_1 = require("./DoNotConstruct.js");
|
|
7
|
+
Object.defineProperty(exports, "DoNotConstruct", { enumerable: true, get: function () { return DoNotConstruct_js_1.DoNotConstruct; } });
|
|
8
|
+
var Enum_js_1 = require("./Enum.js");
|
|
9
|
+
Object.defineProperty(exports, "Enum", { enumerable: true, get: function () { return Enum_js_1.Enum; } });
|
|
10
|
+
var Int_js_1 = require("./Int.js");
|
|
11
|
+
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return Int_js_1.Int; } });
|
|
12
|
+
var Null_js_1 = require("./Null.js");
|
|
13
|
+
Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return Null_js_1.Null; } });
|
|
14
|
+
var Option_js_1 = require("./Option.js");
|
|
15
|
+
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return Option_js_1.Option; } });
|
|
16
|
+
var Result_js_1 = require("./Result.js");
|
|
17
|
+
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return Result_js_1.Result; } });
|
|
18
|
+
var Tuple_js_1 = require("./Tuple.js");
|
|
19
|
+
Object.defineProperty(exports, "Tuple", { enumerable: true, get: function () { return Tuple_js_1.Tuple; } });
|
|
20
|
+
var UInt_js_1 = require("./UInt.js");
|
|
21
|
+
Object.defineProperty(exports, "UInt", { enumerable: true, get: function () { return UInt_js_1.UInt; } });
|
|
22
|
+
var Vec_js_1 = require("./Vec.js");
|
|
23
|
+
Object.defineProperty(exports, "Vec", { enumerable: true, get: function () { return Vec_js_1.Vec; } });
|
|
24
|
+
var VecAny_js_1 = require("./VecAny.js");
|
|
25
|
+
Object.defineProperty(exports, "VecAny", { enumerable: true, get: function () { return VecAny_js_1.VecAny; } });
|
|
26
|
+
var VecFixed_js_1 = require("./VecFixed.js");
|
|
27
|
+
Object.defineProperty(exports, "VecFixed", { enumerable: true, get: function () { return VecFixed_js_1.VecFixed; } });
|
package/cjs/bundle.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
var
|
|
6
|
-
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return
|
|
7
|
-
tslib_1.__exportStar(require("./abstract"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./base"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./extended"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./native"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./primitive"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./utils"), exports);
|
|
5
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
6
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
7
|
+
tslib_1.__exportStar(require("./abstract/index.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./base/index.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./extended/index.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./native/index.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./primitive/index.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./utils/index.js"), exports);
|
package/cjs/detectPackage.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const util_1 = require("@polkadot/util");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
(0, util_1.detectPackage)(
|
|
5
|
+
const detectOther_js_1 = tslib_1.__importDefault(require("./detectOther.js"));
|
|
6
|
+
const packageInfo_js_1 = require("./packageInfo.js");
|
|
7
|
+
(0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, detectOther_js_1.default);
|
package/cjs/extended/BTreeMap.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BTreeMap = void 0;
|
|
4
|
-
const
|
|
5
|
-
class BTreeMap extends
|
|
4
|
+
const Map_js_1 = require("./Map.js");
|
|
5
|
+
class BTreeMap extends Map_js_1.CodecMap {
|
|
6
6
|
static with(keyType, valType) {
|
|
7
7
|
return class extends BTreeMap {
|
|
8
8
|
constructor(registry, value) {
|
package/cjs/extended/BTreeSet.js
CHANGED
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.BTreeSet = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
7
|
+
const index_js_1 = require("../utils/index.js");
|
|
8
8
|
const l = (0, util_1.logger)('BTreeSet');
|
|
9
9
|
/** @internal */
|
|
10
10
|
function decodeSetFromU8a(registry, ValClass, u8a) {
|
|
11
11
|
const output = new Set();
|
|
12
12
|
const [offset, count] = (0, util_1.compactFromU8aLim)(u8a);
|
|
13
13
|
const result = new Array(count);
|
|
14
|
-
const [decodedLength] = (0,
|
|
14
|
+
const [decodedLength] = (0, index_js_1.decodeU8aVec)(registry, result, u8a, offset, ValClass);
|
|
15
15
|
for (let i = 0; i < count; i++) {
|
|
16
16
|
output.add(result[i]);
|
|
17
17
|
}
|
|
@@ -46,7 +46,7 @@ function decodeSetFromSet(registry, ValClass, value) {
|
|
|
46
46
|
* @internal
|
|
47
47
|
*/
|
|
48
48
|
function decodeSet(registry, valType, value) {
|
|
49
|
-
const ValClass = (0,
|
|
49
|
+
const ValClass = (0, index_js_1.typeToConstructor)(registry, valType);
|
|
50
50
|
if (!value) {
|
|
51
51
|
return [ValClass, new Set(), 0];
|
|
52
52
|
}
|
|
@@ -61,7 +61,7 @@ function decodeSet(registry, valType, value) {
|
|
|
61
61
|
class BTreeSet extends Set {
|
|
62
62
|
constructor(registry, valType, rawValue) {
|
|
63
63
|
const [ValClass, values, decodedLength] = decodeSet(registry, valType, rawValue);
|
|
64
|
-
super((0,
|
|
64
|
+
super((0, index_js_1.sortSet)(values));
|
|
65
65
|
_BTreeSet_ValClass.set(this, void 0);
|
|
66
66
|
this.registry = registry;
|
|
67
67
|
this.initialU8aLength = decodedLength;
|
|
@@ -106,7 +106,7 @@ class BTreeSet extends Set {
|
|
|
106
106
|
* @description Compares the value of the input to see if there is a match
|
|
107
107
|
*/
|
|
108
108
|
eq(other) {
|
|
109
|
-
return (0,
|
|
109
|
+
return (0, index_js_1.compareSet)(this, other);
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* @description Returns a breakdown of the hex encoding for this Codec
|
package/cjs/extended/BitVec.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.BitVec = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const util_1 = require("@polkadot/util");
|
|
7
|
-
const
|
|
7
|
+
const Raw_js_1 = require("../native/Raw.js");
|
|
8
8
|
/** @internal */
|
|
9
9
|
function decodeBitVecU8a(value) {
|
|
10
10
|
if (!value || !value.length) {
|
|
@@ -32,7 +32,7 @@ function decodeBitVec(value) {
|
|
|
32
32
|
* A BitVec that represents an array of bits. The bits are however stored encoded. The difference between this
|
|
33
33
|
* and a normal Bytes would be that the length prefix indicates the number of bits encoded, not the bytes
|
|
34
34
|
*/
|
|
35
|
-
class BitVec extends
|
|
35
|
+
class BitVec extends Raw_js_1.Raw {
|
|
36
36
|
// In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
|
|
37
37
|
// we are dealing with Lsb, which is the default (as of writing) BitVec format used
|
|
38
38
|
// in the Polkadot code (this only affects the toHuman displays)
|
package/cjs/extended/Bytes.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Bytes = void 0;
|
|
4
4
|
const util_1 = require("@polkadot/util");
|
|
5
|
-
const
|
|
5
|
+
const Raw_js_1 = require("../native/Raw.js");
|
|
6
6
|
const MAX_LENGTH = 10 * 1024 * 1024;
|
|
7
7
|
/** @internal */
|
|
8
8
|
function decodeBytesU8a(value) {
|
|
@@ -27,9 +27,9 @@ function decodeBytesU8a(value) {
|
|
|
27
27
|
* is that this version allows for length-encoding. (i.e. it is a variable-item codec, the same
|
|
28
28
|
* as what is found in [[Text]] and [[Vec]])
|
|
29
29
|
*/
|
|
30
|
-
class Bytes extends
|
|
30
|
+
class Bytes extends Raw_js_1.Raw {
|
|
31
31
|
constructor(registry, value) {
|
|
32
|
-
const [u8a, decodedLength] = (0, util_1.isU8a)(value) && !(value instanceof
|
|
32
|
+
const [u8a, decodedLength] = (0, util_1.isU8a)(value) && !(value instanceof Raw_js_1.Raw)
|
|
33
33
|
? decodeBytesU8a(value)
|
|
34
34
|
: Array.isArray(value) || (0, util_1.isString)(value)
|
|
35
35
|
? [(0, util_1.u8aToU8a)(value), 0]
|
package/cjs/extended/HashMap.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HashMap = void 0;
|
|
4
|
-
const
|
|
5
|
-
class HashMap extends
|
|
4
|
+
const Map_js_1 = require("./Map.js");
|
|
5
|
+
class HashMap extends Map_js_1.CodecMap {
|
|
6
6
|
static with(keyType, valType) {
|
|
7
7
|
return class extends HashMap {
|
|
8
8
|
constructor(registry, value) {
|
package/cjs/extended/Linkage.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkageResult = exports.Linkage = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const Option_js_1 = require("../base/Option.js");
|
|
5
|
+
const Tuple_js_1 = require("../base/Tuple.js");
|
|
6
|
+
const Vec_js_1 = require("../base/Vec.js");
|
|
7
|
+
const Struct_js_1 = require("../native/Struct.js");
|
|
8
8
|
const EMPTY = new Uint8Array();
|
|
9
9
|
/**
|
|
10
10
|
* @name Linkage
|
|
11
11
|
* @description The wrapper for the result from a LinkedMap
|
|
12
12
|
*/
|
|
13
|
-
class Linkage extends
|
|
13
|
+
class Linkage extends Struct_js_1.Struct {
|
|
14
14
|
constructor(registry, Type, value) {
|
|
15
15
|
super(registry, {
|
|
16
|
-
previous:
|
|
16
|
+
previous: Option_js_1.Option.with(Type),
|
|
17
17
|
// eslint-disable-next-line sort-keys
|
|
18
|
-
next:
|
|
18
|
+
next: Option_js_1.Option.with(Type)
|
|
19
19
|
}, value);
|
|
20
20
|
}
|
|
21
21
|
static withKey(Type) {
|
|
@@ -53,11 +53,11 @@ exports.Linkage = Linkage;
|
|
|
53
53
|
* @name LinkageResult
|
|
54
54
|
* @description A Linkage keys/Values tuple
|
|
55
55
|
*/
|
|
56
|
-
class LinkageResult extends
|
|
56
|
+
class LinkageResult extends Tuple_js_1.Tuple {
|
|
57
57
|
constructor(registry, [TypeKey, keys], [TypeValue, values]) {
|
|
58
58
|
super(registry, {
|
|
59
|
-
Keys:
|
|
60
|
-
Values:
|
|
59
|
+
Keys: Vec_js_1.Vec.with(TypeKey),
|
|
60
|
+
Values: Vec_js_1.Vec.with(TypeValue)
|
|
61
61
|
}, [keys, values]);
|
|
62
62
|
}
|
|
63
63
|
}
|