@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/abstract/Array.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HexString } from '@polkadot/util/types';
|
|
2
|
-
import type { AnyJson, Codec, Inspect, IU8a, IVec, Registry } from '../types';
|
|
2
|
+
import type { AnyJson, Codec, Inspect, IU8a, IVec, Registry } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* @name AbstractArray
|
|
5
5
|
* @description
|
package/abstract/Array.js
CHANGED
|
@@ -8,10 +8,6 @@ import { compareArray } from '../utils/compareArray.js';
|
|
|
8
8
|
* @noInheritDoc
|
|
9
9
|
*/
|
|
10
10
|
export class AbstractArray extends Array {
|
|
11
|
-
registry;
|
|
12
|
-
createdAtHash;
|
|
13
|
-
initialU8aLength;
|
|
14
|
-
isStorageFallback;
|
|
15
11
|
/**
|
|
16
12
|
* @description This ensures that operators such as clice, filter, map, etc. return
|
|
17
13
|
* new Array instances (without this we need to apply overrides)
|
package/abstract/Base.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HexString } from '@polkadot/util/types';
|
|
2
|
-
import type { AnyJson, BareOpts, Codec, Inspect, IU8a, Registry } from '../types';
|
|
2
|
+
import type { AnyJson, BareOpts, Codec, Inspect, IU8a, Registry } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* @name Base
|
|
5
5
|
* @description A type extends the Base class, when it holds a value
|
package/abstract/Base.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
var _AbstractBase_raw;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
/**
|
|
2
4
|
* @name Base
|
|
3
5
|
* @description A type extends the Base class, when it holds a value
|
|
4
6
|
*/
|
|
5
7
|
export class AbstractBase {
|
|
6
|
-
registry;
|
|
7
|
-
createdAtHash;
|
|
8
|
-
initialU8aLength;
|
|
9
|
-
isStorageFallback;
|
|
10
|
-
#raw;
|
|
11
8
|
constructor(registry, value, initialU8aLength) {
|
|
9
|
+
_AbstractBase_raw.set(this, void 0);
|
|
12
10
|
this.initialU8aLength = initialU8aLength;
|
|
13
|
-
this
|
|
11
|
+
__classPrivateFieldSet(this, _AbstractBase_raw, value, "f");
|
|
14
12
|
this.registry = registry;
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
@@ -29,73 +27,74 @@ export class AbstractBase {
|
|
|
29
27
|
* @description returns the inner (wrapped value)
|
|
30
28
|
*/
|
|
31
29
|
get inner() {
|
|
32
|
-
return this
|
|
30
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f");
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* @description Checks if the value is an empty value
|
|
36
34
|
*/
|
|
37
35
|
get isEmpty() {
|
|
38
|
-
return this
|
|
36
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").isEmpty;
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
39
|
* @description Compares the value of the input to see if there is a match
|
|
42
40
|
*/
|
|
43
41
|
eq(other) {
|
|
44
|
-
return this
|
|
42
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").eq(other);
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
47
45
|
* @description Returns a breakdown of the hex encoding for this Codec
|
|
48
46
|
*/
|
|
49
47
|
inspect() {
|
|
50
|
-
return this
|
|
48
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").inspect();
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
51
|
* @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
|
|
54
52
|
*/
|
|
55
53
|
toHex(isLe) {
|
|
56
|
-
return this
|
|
54
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").toHex(isLe);
|
|
57
55
|
}
|
|
58
56
|
/**
|
|
59
57
|
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
60
58
|
*/
|
|
61
59
|
toHuman(isExtended) {
|
|
62
|
-
return this
|
|
60
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").toHuman(isExtended);
|
|
63
61
|
}
|
|
64
62
|
/**
|
|
65
63
|
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
66
64
|
*/
|
|
67
65
|
toJSON() {
|
|
68
|
-
return this
|
|
66
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").toJSON();
|
|
69
67
|
}
|
|
70
68
|
/**
|
|
71
69
|
* @description Converts the value in a best-fit primitive form
|
|
72
70
|
*/
|
|
73
71
|
toPrimitive() {
|
|
74
|
-
return this
|
|
72
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").toPrimitive();
|
|
75
73
|
}
|
|
76
74
|
/**
|
|
77
75
|
* @description Returns the string representation of the value
|
|
78
76
|
*/
|
|
79
77
|
toString() {
|
|
80
|
-
return this
|
|
78
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").toString();
|
|
81
79
|
}
|
|
82
80
|
/**
|
|
83
81
|
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
84
82
|
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
85
83
|
*/
|
|
86
84
|
toU8a(isBare) {
|
|
87
|
-
return this
|
|
85
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f").toU8a(isBare);
|
|
88
86
|
}
|
|
89
87
|
/**
|
|
90
88
|
* @description Returns the inner wrapped value (equivalent to valueOf)
|
|
91
89
|
*/
|
|
92
90
|
unwrap() {
|
|
93
|
-
return this
|
|
91
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f");
|
|
94
92
|
}
|
|
95
93
|
/**
|
|
96
94
|
* @description Returns the inner wrapped value
|
|
97
95
|
*/
|
|
98
96
|
valueOf() {
|
|
99
|
-
return this
|
|
97
|
+
return __classPrivateFieldGet(this, _AbstractBase_raw, "f");
|
|
100
98
|
}
|
|
101
|
-
}
|
|
99
|
+
}
|
|
100
|
+
_AbstractBase_raw = new WeakMap();
|
package/abstract/Int.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import type { HexString } from '@polkadot/util/types';
|
|
3
|
-
import type { AnyNumber, Inspect, INumber, IU8a, Registry, UIntBitLength } from '../types';
|
|
3
|
+
import type { AnyNumber, Inspect, INumber, IU8a, Registry, UIntBitLength } from '../types/index.js';
|
|
4
4
|
import { BN } from '@polkadot/util';
|
|
5
5
|
export declare const DEFAULT_UINT_BITS = 64;
|
|
6
6
|
/**
|
package/abstract/Int.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
var _AbstractInt_bitLength;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBigInt, isBn, isFunction, isHex, isNumber, isObject, isString, isU8a, u8aToBn, u8aToNumber } from '@polkadot/util';
|
|
2
4
|
export const DEFAULT_UINT_BITS = 64;
|
|
3
5
|
const MAX_NUMBER_BITS = 52;
|
|
4
|
-
const MUL_P = new BN(
|
|
6
|
+
const MUL_P = new BN(10000);
|
|
5
7
|
const FORMATTERS = [
|
|
6
8
|
['Perquintill', BN_QUINTILL],
|
|
7
9
|
['Perbill', BN_BILLION],
|
|
@@ -58,13 +60,6 @@ function decodeAbstractInt(value, isNegative) {
|
|
|
58
60
|
* @noInheritDoc
|
|
59
61
|
*/
|
|
60
62
|
export class AbstractInt extends BN {
|
|
61
|
-
registry;
|
|
62
|
-
encodedLength;
|
|
63
|
-
isUnsigned;
|
|
64
|
-
createdAtHash;
|
|
65
|
-
initialU8aLength;
|
|
66
|
-
isStorageFallback;
|
|
67
|
-
#bitLength;
|
|
68
63
|
constructor(registry, value = 0, bitLength = DEFAULT_UINT_BITS, isSigned = false) {
|
|
69
64
|
// Construct via a string/number, which will be passed in the BN constructor.
|
|
70
65
|
// It would be ideal to actually return a BN, but there is an issue:
|
|
@@ -76,10 +71,11 @@ export class AbstractInt extends BN {
|
|
|
76
71
|
? u8aToNumber(value.subarray(0, bitLength / 8), { isNegative: isSigned })
|
|
77
72
|
: u8aToBn(value.subarray(0, bitLength / 8), { isLe: true, isNegative: isSigned }).toString()
|
|
78
73
|
: decodeAbstractInt(value, isSigned));
|
|
74
|
+
_AbstractInt_bitLength.set(this, void 0);
|
|
79
75
|
this.registry = registry;
|
|
80
|
-
this
|
|
81
|
-
this.encodedLength = this
|
|
82
|
-
this.initialU8aLength = this
|
|
76
|
+
__classPrivateFieldSet(this, _AbstractInt_bitLength, bitLength, "f");
|
|
77
|
+
this.encodedLength = __classPrivateFieldGet(this, _AbstractInt_bitLength, "f") / 8;
|
|
78
|
+
this.initialU8aLength = __classPrivateFieldGet(this, _AbstractInt_bitLength, "f") / 8;
|
|
83
79
|
this.isUnsigned = !isSigned;
|
|
84
80
|
const isNegative = this.isNeg();
|
|
85
81
|
const maxBits = bitLength - (isSigned && !isNegative ? 1 : 0);
|
|
@@ -106,7 +102,7 @@ export class AbstractInt extends BN {
|
|
|
106
102
|
* @description Returns the number of bits in the value
|
|
107
103
|
*/
|
|
108
104
|
bitLength() {
|
|
109
|
-
return this
|
|
105
|
+
return __classPrivateFieldGet(this, _AbstractInt_bitLength, "f");
|
|
110
106
|
}
|
|
111
107
|
/**
|
|
112
108
|
* @description Compares the value of the input to see if there is a match
|
|
@@ -132,7 +128,7 @@ export class AbstractInt extends BN {
|
|
|
132
128
|
*/
|
|
133
129
|
isMax() {
|
|
134
130
|
const u8a = this.toU8a().filter((b) => b === 0xff);
|
|
135
|
-
return u8a.length === (this
|
|
131
|
+
return u8a.length === (__classPrivateFieldGet(this, _AbstractInt_bitLength, "f") / 8);
|
|
136
132
|
}
|
|
137
133
|
/**
|
|
138
134
|
* @description Returns a BigInt representation of the number
|
|
@@ -226,4 +222,5 @@ export class AbstractInt extends BN {
|
|
|
226
222
|
isNegative: !this.isUnsigned
|
|
227
223
|
});
|
|
228
224
|
}
|
|
229
|
-
}
|
|
225
|
+
}
|
|
226
|
+
_AbstractInt_bitLength = new WeakMap();
|
package/abstract/Object.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HexString } from '@polkadot/util/types';
|
|
2
|
-
import type { AnyJson, BareOpts, CodecObject, Inspect, IU8a, Registry, ToString } from '../types';
|
|
2
|
+
import type { AnyJson, BareOpts, CodecObject, Inspect, IU8a, Registry, ToString } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* @name Object
|
|
5
5
|
* @description A type extends the Base class, when it holds a value
|
package/abstract/Object.js
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
* @description A type extends the Base class, when it holds a value
|
|
4
4
|
*/
|
|
5
5
|
export class AbstractObject {
|
|
6
|
-
registry;
|
|
7
|
-
createdAtHash;
|
|
8
|
-
initialU8aLength;
|
|
9
|
-
isStorageFallback;
|
|
10
|
-
$;
|
|
11
6
|
constructor(registry, value, initialU8aLength) {
|
|
12
7
|
this.$ = value;
|
|
13
8
|
this.initialU8aLength = initialU8aLength;
|
package/abstract/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AbstractArray } from './Array';
|
|
2
|
-
export { AbstractBase } from './Base';
|
|
3
|
-
export { AbstractInt } from './Int';
|
|
1
|
+
export { AbstractArray } from './Array.js';
|
|
2
|
+
export { AbstractBase } from './Base.js';
|
|
3
|
+
export { AbstractInt } from './Int.js';
|
package/base/Compact.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import type { BN } from '@polkadot/util';
|
|
3
3
|
import type { HexString } from '@polkadot/util/types';
|
|
4
|
-
import type { AnyJson, AnyNumber, CodecClass, ICompact, Inspect, INumber, IU8a, Registry } from '../types';
|
|
4
|
+
import type { AnyJson, AnyNumber, CodecClass, ICompact, Inspect, INumber, IU8a, Registry } from '../types/index.js';
|
|
5
5
|
interface Options<T> {
|
|
6
6
|
definition?: CodecClass<T>;
|
|
7
7
|
setDefinition?: (d: CodecClass<T>) => CodecClass<T>;
|
package/base/Compact.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
var _Compact_Type, _Compact_raw;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
import { compactFromU8a, compactFromU8aLim, compactToU8a, isU8a } from '@polkadot/util';
|
|
2
4
|
import { typeToConstructor } from '../utils/index.js';
|
|
3
5
|
function noopSetDefinition(d) {
|
|
@@ -30,18 +32,14 @@ function decodeCompact(registry, Type, value) {
|
|
|
30
32
|
* a number and making the compact representation thereof
|
|
31
33
|
*/
|
|
32
34
|
export class Compact {
|
|
33
|
-
registry;
|
|
34
|
-
createdAtHash;
|
|
35
|
-
initialU8aLength;
|
|
36
|
-
isStorageFallback;
|
|
37
|
-
#Type;
|
|
38
|
-
#raw;
|
|
39
35
|
constructor(registry, Type, value = 0, { definition, setDefinition = noopSetDefinition } = {}) {
|
|
36
|
+
_Compact_Type.set(this, void 0);
|
|
37
|
+
_Compact_raw.set(this, void 0);
|
|
40
38
|
this.registry = registry;
|
|
41
|
-
this
|
|
42
|
-
const [raw, decodedLength] = decodeCompact(registry, this
|
|
39
|
+
__classPrivateFieldSet(this, _Compact_Type, definition || setDefinition(typeToConstructor(registry, Type)), "f");
|
|
40
|
+
const [raw, decodedLength] = decodeCompact(registry, __classPrivateFieldGet(this, _Compact_Type, "f"), value);
|
|
43
41
|
this.initialU8aLength = decodedLength;
|
|
44
|
-
this
|
|
42
|
+
__classPrivateFieldSet(this, _Compact_raw, raw, "f");
|
|
45
43
|
}
|
|
46
44
|
static with(Type) {
|
|
47
45
|
let definition;
|
|
@@ -69,20 +67,20 @@ export class Compact {
|
|
|
69
67
|
* @description Checks if the value is an empty value
|
|
70
68
|
*/
|
|
71
69
|
get isEmpty() {
|
|
72
|
-
return this
|
|
70
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").isEmpty;
|
|
73
71
|
}
|
|
74
72
|
/**
|
|
75
73
|
* @description Returns the number of bits in the value
|
|
76
74
|
*/
|
|
77
75
|
bitLength() {
|
|
78
|
-
return this
|
|
76
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").bitLength();
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
79
|
* @description Compares the value of the input to see if there is a match
|
|
82
80
|
*/
|
|
83
81
|
eq(other) {
|
|
84
|
-
return this
|
|
85
|
-
? other
|
|
82
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").eq(other instanceof Compact
|
|
83
|
+
? __classPrivateFieldGet(other, _Compact_raw, "f")
|
|
86
84
|
: other);
|
|
87
85
|
}
|
|
88
86
|
/**
|
|
@@ -97,55 +95,55 @@ export class Compact {
|
|
|
97
95
|
* @description Returns a BigInt representation of the number
|
|
98
96
|
*/
|
|
99
97
|
toBigInt() {
|
|
100
|
-
return this
|
|
98
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toBigInt();
|
|
101
99
|
}
|
|
102
100
|
/**
|
|
103
101
|
* @description Returns the BN representation of the number
|
|
104
102
|
*/
|
|
105
103
|
toBn() {
|
|
106
|
-
return this
|
|
104
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toBn();
|
|
107
105
|
}
|
|
108
106
|
/**
|
|
109
107
|
* @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
|
|
110
108
|
*/
|
|
111
109
|
toHex(isLe) {
|
|
112
|
-
return this
|
|
110
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toHex(isLe);
|
|
113
111
|
}
|
|
114
112
|
/**
|
|
115
113
|
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
116
114
|
*/
|
|
117
115
|
toHuman(isExtended) {
|
|
118
|
-
return this
|
|
116
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toHuman(isExtended);
|
|
119
117
|
}
|
|
120
118
|
/**
|
|
121
119
|
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
122
120
|
*/
|
|
123
121
|
toJSON() {
|
|
124
|
-
return this
|
|
122
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toJSON();
|
|
125
123
|
}
|
|
126
124
|
/**
|
|
127
125
|
* @description Returns the number representation for the value
|
|
128
126
|
*/
|
|
129
127
|
toNumber() {
|
|
130
|
-
return this
|
|
128
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toNumber();
|
|
131
129
|
}
|
|
132
130
|
/**
|
|
133
131
|
* @description Converts the value in a best-fit primitive form
|
|
134
132
|
*/
|
|
135
133
|
toPrimitive() {
|
|
136
|
-
return this
|
|
134
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toPrimitive();
|
|
137
135
|
}
|
|
138
136
|
/**
|
|
139
137
|
* @description Returns the base runtime type name for this instance
|
|
140
138
|
*/
|
|
141
139
|
toRawType() {
|
|
142
|
-
return `Compact<${this.registry.getClassName(this
|
|
140
|
+
return `Compact<${this.registry.getClassName(__classPrivateFieldGet(this, _Compact_Type, "f")) || __classPrivateFieldGet(this, _Compact_raw, "f").toRawType()}>`;
|
|
143
141
|
}
|
|
144
142
|
/**
|
|
145
143
|
* @description Returns the string representation of the value
|
|
146
144
|
*/
|
|
147
145
|
toString() {
|
|
148
|
-
return this
|
|
146
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f").toString();
|
|
149
147
|
}
|
|
150
148
|
/**
|
|
151
149
|
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
@@ -153,12 +151,13 @@ export class Compact {
|
|
|
153
151
|
*/
|
|
154
152
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
155
153
|
toU8a(isBare) {
|
|
156
|
-
return compactToU8a(this
|
|
154
|
+
return compactToU8a(__classPrivateFieldGet(this, _Compact_raw, "f").toBn());
|
|
157
155
|
}
|
|
158
156
|
/**
|
|
159
157
|
* @description Returns the embedded [[UInt]] or [[Moment]] value
|
|
160
158
|
*/
|
|
161
159
|
unwrap() {
|
|
162
|
-
return this
|
|
160
|
+
return __classPrivateFieldGet(this, _Compact_raw, "f");
|
|
163
161
|
}
|
|
164
|
-
}
|
|
162
|
+
}
|
|
163
|
+
_Compact_Type = new WeakMap(), _Compact_raw = new WeakMap();
|
package/base/DoNotConstruct.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HexString } from '@polkadot/util/types';
|
|
2
|
-
import type { AnyJson, Codec, CodecClass, Inspect, IU8a, Registry } from '../types';
|
|
2
|
+
import type { AnyJson, Codec, CodecClass, Inspect, IU8a, Registry } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* @name DoNotConstruct
|
|
5
5
|
* @description
|
package/base/DoNotConstruct.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
var _DoNotConstruct_neverError;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
1
3
|
/**
|
|
2
4
|
* @name DoNotConstruct
|
|
3
5
|
* @description
|
|
4
6
|
* An unknown type that fails on construction with the type info
|
|
5
7
|
*/
|
|
6
8
|
export class DoNotConstruct {
|
|
7
|
-
registry;
|
|
8
|
-
createdAtHash;
|
|
9
|
-
isStorageFallback;
|
|
10
|
-
#neverError;
|
|
11
9
|
constructor(registry, typeName = 'DoNotConstruct') {
|
|
10
|
+
_DoNotConstruct_neverError.set(this, void 0);
|
|
12
11
|
this.registry = registry;
|
|
13
|
-
this
|
|
14
|
-
throw this
|
|
12
|
+
__classPrivateFieldSet(this, _DoNotConstruct_neverError, new Error(`DoNotConstruct: Cannot construct unknown type ${typeName}`), "f");
|
|
13
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
15
14
|
}
|
|
16
15
|
static with(typeName) {
|
|
17
16
|
return class extends DoNotConstruct {
|
|
@@ -24,45 +23,46 @@ export class DoNotConstruct {
|
|
|
24
23
|
* @description The length of the value when encoded as a Uint8Array
|
|
25
24
|
*/
|
|
26
25
|
get encodedLength() {
|
|
27
|
-
throw this
|
|
26
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* @description returns a hash of the contents
|
|
31
30
|
*/
|
|
32
31
|
get hash() {
|
|
33
|
-
throw this
|
|
32
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
35
|
* @description Checks if the value is an empty value (always true)
|
|
37
36
|
*/
|
|
38
37
|
get isEmpty() {
|
|
39
|
-
throw this
|
|
38
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
40
39
|
}
|
|
41
40
|
eq() {
|
|
42
|
-
throw this
|
|
41
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
43
42
|
}
|
|
44
43
|
inspect() {
|
|
45
|
-
throw this
|
|
44
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
46
45
|
}
|
|
47
46
|
toHex() {
|
|
48
|
-
throw this
|
|
47
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
49
48
|
}
|
|
50
49
|
toHuman() {
|
|
51
|
-
throw this
|
|
50
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
52
51
|
}
|
|
53
52
|
toJSON() {
|
|
54
|
-
throw this
|
|
53
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
55
54
|
}
|
|
56
55
|
toPrimitive() {
|
|
57
|
-
throw this
|
|
56
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
58
57
|
}
|
|
59
58
|
toRawType() {
|
|
60
|
-
throw this
|
|
59
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
61
60
|
}
|
|
62
61
|
toString() {
|
|
63
|
-
throw this
|
|
62
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
64
63
|
}
|
|
65
64
|
toU8a() {
|
|
66
|
-
throw this
|
|
65
|
+
throw __classPrivateFieldGet(this, _DoNotConstruct_neverError, "f");
|
|
67
66
|
}
|
|
68
|
-
}
|
|
67
|
+
}
|
|
68
|
+
_DoNotConstruct_neverError = new WeakMap();
|
package/base/Enum.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HexString } from '@polkadot/util/types';
|
|
2
|
-
import type { AnyJson, Codec, CodecClass, IEnum, Inspect, IU8a, Registry } from '../types';
|
|
2
|
+
import type { AnyJson, Codec, CodecClass, IEnum, Inspect, IU8a, Registry } from '../types/index.js';
|
|
3
3
|
export interface EnumCodecClass<T = Codec> {
|
|
4
4
|
new (registry: Registry, value?: any, index?: number): T;
|
|
5
5
|
}
|