@polkadot/types-codec 7.4.2-9 → 7.5.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.js +0 -4
- package/abstract/AbstractInt.js +10 -24
- package/base/Base.js +15 -29
- package/base/Compact.js +20 -34
- package/base/DoNotConstruct.js +14 -23
- package/base/Enum.js +36 -70
- package/base/Null.js +2 -3
- package/base/Option.js +19 -37
- package/base/Tuple.js +5 -11
- package/base/Vec.js +6 -12
- package/base/VecFixed.js +4 -10
- package/extended/BTreeSet.js +4 -13
- package/extended/BitVec.js +5 -11
- package/extended/Map.js +8 -27
- package/extended/Range.js +4 -10
- package/extended/WrapperKeepOpaque.js +10 -21
- package/native/Bool.js +0 -2
- package/native/Date.js +0 -2
- package/native/Json.js +0 -2
- package/native/Raw.js +0 -3
- package/native/Set.js +18 -32
- package/native/Struct.js +12 -30
- package/native/Text.js +7 -20
- package/package.json +2 -2
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
- package/primitive/I128.js +2 -5
- package/primitive/I16.js +2 -5
- package/primitive/I256.js +2 -5
- package/primitive/I32.js +2 -5
- package/primitive/I64.js +2 -5
- package/primitive/I8.js +2 -5
- package/primitive/U128.js +2 -5
- package/primitive/U16.js +2 -5
- package/primitive/U256.js +2 -5
- package/primitive/U32.js +2 -5
- package/primitive/U64.js +2 -5
- package/primitive/U8.js +2 -5
package/extended/Map.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
|
@@ -81,36 +79,19 @@ function decodeMap(registry, keyType, valType, value) {
|
|
|
81
79
|
throw new Error('Map: cannot decode type');
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
var _KeyClass = /*#__PURE__*/_classPrivateFieldLooseKey("KeyClass");
|
|
85
|
-
|
|
86
|
-
var _ValClass = /*#__PURE__*/_classPrivateFieldLooseKey("ValClass");
|
|
87
|
-
|
|
88
|
-
var _type = /*#__PURE__*/_classPrivateFieldLooseKey("type");
|
|
89
|
-
|
|
90
82
|
export class CodecMap extends Map {
|
|
83
|
+
#KeyClass;
|
|
84
|
+
#ValClass;
|
|
85
|
+
#type;
|
|
86
|
+
|
|
91
87
|
constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
|
|
92
88
|
const [decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
|
|
93
89
|
super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
|
|
94
|
-
this.registry = void 0;
|
|
95
|
-
this.createdAtHash = void 0;
|
|
96
|
-
Object.defineProperty(this, _KeyClass, {
|
|
97
|
-
writable: true,
|
|
98
|
-
value: void 0
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(this, _ValClass, {
|
|
101
|
-
writable: true,
|
|
102
|
-
value: void 0
|
|
103
|
-
});
|
|
104
|
-
this.initialU8aLength = void 0;
|
|
105
|
-
Object.defineProperty(this, _type, {
|
|
106
|
-
writable: true,
|
|
107
|
-
value: void 0
|
|
108
|
-
});
|
|
109
90
|
this.registry = registry;
|
|
110
91
|
this.initialU8aLength = decodedLength;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
this.#KeyClass = typeToConstructor(registry, keyType);
|
|
93
|
+
this.#ValClass = typeToConstructor(registry, valType);
|
|
94
|
+
this.#type = type;
|
|
114
95
|
}
|
|
115
96
|
/**
|
|
116
97
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -192,7 +173,7 @@ export class CodecMap extends Map {
|
|
|
192
173
|
|
|
193
174
|
|
|
194
175
|
toRawType() {
|
|
195
|
-
return `${
|
|
176
|
+
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()}>`;
|
|
196
177
|
}
|
|
197
178
|
/**
|
|
198
179
|
* @description Returns the string representation of the value
|
package/extended/Range.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { Tuple } from "../base/Tuple.js";
|
|
6
4
|
|
|
7
|
-
var _rangeName = /*#__PURE__*/_classPrivateFieldLooseKey("rangeName");
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* @name Range
|
|
11
7
|
* @description
|
|
12
8
|
* Rust `Range<T>` representation
|
|
13
9
|
*/
|
|
14
10
|
export class Range extends Tuple {
|
|
11
|
+
#rangeName;
|
|
12
|
+
|
|
15
13
|
constructor(registry, Type, value, rangeName = 'Range') {
|
|
16
14
|
super(registry, {
|
|
17
15
|
end: Type,
|
|
18
16
|
start: Type
|
|
19
17
|
}, value);
|
|
20
|
-
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
_classPrivateFieldLooseBase(this, _rangeName)[_rangeName] = rangeName;
|
|
18
|
+
this.#rangeName = rangeName;
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
static with(Types) {
|
|
@@ -54,7 +48,7 @@ export class Range extends Tuple {
|
|
|
54
48
|
|
|
55
49
|
|
|
56
50
|
toRawType() {
|
|
57
|
-
return `${
|
|
51
|
+
return `${this.#rangeName}<${this.start.toRawType()}>`;
|
|
58
52
|
}
|
|
59
53
|
|
|
60
54
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { assertReturn, compactStripLength, isHex, isU8a } from '@polkadot/util';
|
|
@@ -23,24 +21,15 @@ function decodeRaw(registry, typeName, value) {
|
|
|
23
21
|
return [Type, instance, instance.toHex()];
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
var _Type = /*#__PURE__*/_classPrivateFieldLooseKey("Type");
|
|
27
|
-
|
|
28
|
-
var _decoded = /*#__PURE__*/_classPrivateFieldLooseKey("decoded");
|
|
29
|
-
|
|
30
24
|
export class WrapperKeepOpaque extends Bytes {
|
|
25
|
+
#Type;
|
|
26
|
+
#decoded;
|
|
27
|
+
|
|
31
28
|
constructor(registry, typeName, value) {
|
|
32
29
|
const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
|
|
33
30
|
super(registry, u8a);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
value: void 0
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, _decoded, {
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
_classPrivateFieldLooseBase(this, _Type)[_Type] = Type;
|
|
43
|
-
_classPrivateFieldLooseBase(this, _decoded)[_decoded] = decoded;
|
|
31
|
+
this.#Type = Type;
|
|
32
|
+
this.#decoded = decoded;
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
static with(Type) {
|
|
@@ -57,7 +46,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
57
46
|
|
|
58
47
|
|
|
59
48
|
get isDecoded() {
|
|
60
|
-
return !!
|
|
49
|
+
return !!this.#decoded;
|
|
61
50
|
}
|
|
62
51
|
/**
|
|
63
52
|
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
@@ -65,7 +54,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
65
54
|
|
|
66
55
|
|
|
67
56
|
toHuman(isExtended) {
|
|
68
|
-
return
|
|
57
|
+
return this.#decoded ? this.#decoded.toHuman(isExtended) : super.toHuman();
|
|
69
58
|
}
|
|
70
59
|
/**
|
|
71
60
|
* @description Returns the base runtime type name for this instance
|
|
@@ -73,7 +62,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
73
62
|
|
|
74
63
|
|
|
75
64
|
toRawType() {
|
|
76
|
-
return `WrapperKeepOpaque<${this.registry.getClassName(
|
|
65
|
+
return `WrapperKeepOpaque<${this.registry.getClassName(this.#Type) || (this.#decoded ? this.#decoded.toRawType() : new this.#Type(this.registry).toRawType())}>`;
|
|
77
66
|
}
|
|
78
67
|
/**
|
|
79
68
|
* @description Converts the Object to to a string (either decoded or bytes)
|
|
@@ -81,7 +70,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
81
70
|
|
|
82
71
|
|
|
83
72
|
toString() {
|
|
84
|
-
return
|
|
73
|
+
return this.#decoded ? this.#decoded.toString() : super.toString();
|
|
85
74
|
}
|
|
86
75
|
/**
|
|
87
76
|
* @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
|
|
@@ -89,7 +78,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
89
78
|
|
|
90
79
|
|
|
91
80
|
unwrap() {
|
|
92
|
-
return assertReturn(
|
|
81
|
+
return assertReturn(this.#decoded, 'WrapperKeepOpaque: unwrapping an undecodable value');
|
|
93
82
|
}
|
|
94
83
|
|
|
95
84
|
}
|
package/native/Bool.js
CHANGED
|
@@ -24,8 +24,6 @@ export class bool extends Boolean {
|
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
25
25
|
constructor(registry, value = false) {
|
|
26
26
|
super(decodeBool(value));
|
|
27
|
-
this.registry = void 0;
|
|
28
|
-
this.createdAtHash = void 0;
|
|
29
27
|
this.registry = registry;
|
|
30
28
|
}
|
|
31
29
|
/**
|
package/native/Date.js
CHANGED
package/native/Json.js
CHANGED
|
@@ -21,8 +21,6 @@ export class Json extends Map {
|
|
|
21
21
|
constructor(registry, value) {
|
|
22
22
|
const decoded = decodeJson(value);
|
|
23
23
|
super(decoded);
|
|
24
|
-
this.registry = void 0;
|
|
25
|
-
this.createdAtHash = void 0;
|
|
26
24
|
this.registry = registry;
|
|
27
25
|
objectProperties(this, decoded.map(([k]) => k), k => this.get(k));
|
|
28
26
|
}
|
package/native/Raw.js
CHANGED
|
@@ -14,9 +14,6 @@ import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a }
|
|
|
14
14
|
export class Raw extends Uint8Array {
|
|
15
15
|
constructor(registry, value, initialU8aLength) {
|
|
16
16
|
super(u8aToU8a(value));
|
|
17
|
-
this.registry = void 0;
|
|
18
|
-
this.createdAtHash = void 0;
|
|
19
|
-
this.initialU8aLength = void 0;
|
|
20
17
|
this.registry = registry;
|
|
21
18
|
this.initialU8aLength = initialU8aLength;
|
|
22
19
|
}
|
package/native/Set.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { assert, BN, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, objectProperties, stringify, stringPascalCase, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
|
|
@@ -76,36 +74,15 @@ function decodeSet(setValues, value = 0, bitLength) {
|
|
|
76
74
|
*/
|
|
77
75
|
|
|
78
76
|
|
|
79
|
-
var _allowed = /*#__PURE__*/_classPrivateFieldLooseKey("allowed");
|
|
80
|
-
|
|
81
|
-
var _byteLength = /*#__PURE__*/_classPrivateFieldLooseKey("byteLength");
|
|
82
|
-
|
|
83
77
|
export class CodecSet extends Set {
|
|
78
|
+
#allowed;
|
|
79
|
+
#byteLength;
|
|
80
|
+
|
|
84
81
|
constructor(registry, setValues, value, bitLength = 8) {
|
|
85
82
|
super(decodeSet(setValues, value, bitLength));
|
|
86
|
-
this.registry = void 0;
|
|
87
|
-
this.createdAtHash = void 0;
|
|
88
|
-
Object.defineProperty(this, _allowed, {
|
|
89
|
-
writable: true,
|
|
90
|
-
value: void 0
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(this, _byteLength, {
|
|
93
|
-
writable: true,
|
|
94
|
-
value: void 0
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
this.add = key => {
|
|
98
|
-
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
|
99
|
-
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
|
100
|
-
// in the Set constructor (so it is undefined at this point, and should allow)
|
|
101
|
-
assert(isUndefined(_classPrivateFieldLooseBase(this, _allowed)[_allowed]) || !isUndefined(_classPrivateFieldLooseBase(this, _allowed)[_allowed][key]), () => `Set: Invalid key '${key}' on add`);
|
|
102
|
-
super.add(key);
|
|
103
|
-
return this;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
83
|
this.registry = registry;
|
|
107
|
-
|
|
108
|
-
|
|
84
|
+
this.#allowed = setValues;
|
|
85
|
+
this.#byteLength = bitLength / 8;
|
|
109
86
|
}
|
|
110
87
|
|
|
111
88
|
static with(values, bitLength) {
|
|
@@ -130,7 +107,7 @@ export class CodecSet extends Set {
|
|
|
130
107
|
|
|
131
108
|
|
|
132
109
|
get encodedLength() {
|
|
133
|
-
return
|
|
110
|
+
return this.#byteLength;
|
|
134
111
|
}
|
|
135
112
|
/**
|
|
136
113
|
* @description returns a hash of the contents
|
|
@@ -162,16 +139,25 @@ export class CodecSet extends Set {
|
|
|
162
139
|
|
|
163
140
|
|
|
164
141
|
get valueEncoded() {
|
|
165
|
-
return encodeSet(
|
|
142
|
+
return encodeSet(this.#allowed, this.strings);
|
|
166
143
|
}
|
|
167
144
|
/**
|
|
168
145
|
* @description adds a value to the Set (extended to allow for validity checking)
|
|
169
146
|
*/
|
|
170
147
|
|
|
171
148
|
|
|
149
|
+
add = key => {
|
|
150
|
+
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
|
151
|
+
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
|
152
|
+
// in the Set constructor (so it is undefined at this point, and should allow)
|
|
153
|
+
assert(isUndefined(this.#allowed) || !isUndefined(this.#allowed[key]), () => `Set: Invalid key '${key}' on add`);
|
|
154
|
+
super.add(key);
|
|
155
|
+
return this;
|
|
156
|
+
};
|
|
172
157
|
/**
|
|
173
158
|
* @description Compares the value of the input to see if there is a match
|
|
174
159
|
*/
|
|
160
|
+
|
|
175
161
|
eq(other) {
|
|
176
162
|
if (Array.isArray(other)) {
|
|
177
163
|
// we don't actually care about the order, sort the values
|
|
@@ -223,7 +209,7 @@ export class CodecSet extends Set {
|
|
|
223
209
|
|
|
224
210
|
toRawType() {
|
|
225
211
|
return stringify({
|
|
226
|
-
_set:
|
|
212
|
+
_set: this.#allowed
|
|
227
213
|
});
|
|
228
214
|
}
|
|
229
215
|
/**
|
|
@@ -243,7 +229,7 @@ export class CodecSet extends Set {
|
|
|
243
229
|
|
|
244
230
|
toU8a(isBare) {
|
|
245
231
|
return bnToU8a(this.valueEncoded, {
|
|
246
|
-
bitLength:
|
|
232
|
+
bitLength: this.#byteLength * 8,
|
|
247
233
|
isLe: true
|
|
248
234
|
});
|
|
249
235
|
}
|
package/native/Struct.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { assert, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, objectProperties, stringCamelCase, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
|
@@ -70,35 +68,19 @@ function decodeStructFromObject(registry, Types, value, jsonMap) {
|
|
|
70
68
|
*/
|
|
71
69
|
|
|
72
70
|
|
|
73
|
-
var _registry = /*#__PURE__*/_classPrivateFieldLooseKey("registry");
|
|
74
|
-
|
|
75
|
-
var _jsonMap = /*#__PURE__*/_classPrivateFieldLooseKey("jsonMap");
|
|
76
|
-
|
|
77
|
-
var _Types = /*#__PURE__*/_classPrivateFieldLooseKey("Types");
|
|
78
|
-
|
|
79
71
|
export class Struct extends Map {
|
|
72
|
+
#registry;
|
|
73
|
+
#jsonMap;
|
|
74
|
+
#Types;
|
|
75
|
+
|
|
80
76
|
constructor(registry, Types, value, jsonMap = new Map()) {
|
|
81
77
|
const typeMap = mapToTypeMap(registry, Types);
|
|
82
78
|
const [decoded, decodedLength] = isU8a(value) ? decodeU8a(registry, value, typeMap, true) : isHex(value) ? decodeU8a(registry, u8aToU8a(value), typeMap, true) : value instanceof Struct ? [value, 0] : decodeStructFromObject(registry, typeMap, value || {}, jsonMap);
|
|
83
79
|
super(decoded);
|
|
84
|
-
|
|
85
|
-
writable: true,
|
|
86
|
-
value: void 0
|
|
87
|
-
});
|
|
88
|
-
this.createdAtHash = void 0;
|
|
89
|
-
this.initialU8aLength = void 0;
|
|
90
|
-
Object.defineProperty(this, _jsonMap, {
|
|
91
|
-
writable: true,
|
|
92
|
-
value: void 0
|
|
93
|
-
});
|
|
94
|
-
Object.defineProperty(this, _Types, {
|
|
95
|
-
writable: true,
|
|
96
|
-
value: void 0
|
|
97
|
-
});
|
|
98
|
-
_classPrivateFieldLooseBase(this, _registry)[_registry] = registry;
|
|
80
|
+
this.#registry = registry;
|
|
99
81
|
this.initialU8aLength = decodedLength;
|
|
100
|
-
|
|
101
|
-
|
|
82
|
+
this.#jsonMap = jsonMap;
|
|
83
|
+
this.#Types = typeMap;
|
|
102
84
|
}
|
|
103
85
|
|
|
104
86
|
static with(Types, jsonMap) {
|
|
@@ -117,7 +99,7 @@ export class Struct extends Map {
|
|
|
117
99
|
|
|
118
100
|
|
|
119
101
|
get defKeys() {
|
|
120
|
-
return Object.keys(
|
|
102
|
+
return Object.keys(this.#Types);
|
|
121
103
|
}
|
|
122
104
|
|
|
123
105
|
getT(key) {
|
|
@@ -144,7 +126,7 @@ export class Struct extends Map {
|
|
|
144
126
|
|
|
145
127
|
get Type() {
|
|
146
128
|
const result = {};
|
|
147
|
-
const defs = Object.entries(
|
|
129
|
+
const defs = Object.entries(this.#Types);
|
|
148
130
|
|
|
149
131
|
for (let i = 0; i < defs.length; i++) {
|
|
150
132
|
const [key, Type] = defs[i];
|
|
@@ -177,7 +159,7 @@ export class Struct extends Map {
|
|
|
177
159
|
}
|
|
178
160
|
|
|
179
161
|
get registry() {
|
|
180
|
-
return
|
|
162
|
+
return this.#registry;
|
|
181
163
|
}
|
|
182
164
|
/**
|
|
183
165
|
* @description Compares the value of the input to see if there is a match
|
|
@@ -243,7 +225,7 @@ export class Struct extends Map {
|
|
|
243
225
|
const json = {};
|
|
244
226
|
|
|
245
227
|
for (const [k, v] of this.entries()) {
|
|
246
|
-
const jsonKey =
|
|
228
|
+
const jsonKey = this.#jsonMap.get(k) || k;
|
|
247
229
|
json[jsonKey] = v && v.toJSON();
|
|
248
230
|
}
|
|
249
231
|
|
|
@@ -255,7 +237,7 @@ export class Struct extends Map {
|
|
|
255
237
|
|
|
256
238
|
|
|
257
239
|
toRawType() {
|
|
258
|
-
return stringify(typesToMap(this.registry,
|
|
240
|
+
return stringify(typesToMap(this.registry, this.#Types));
|
|
259
241
|
}
|
|
260
242
|
/**
|
|
261
243
|
* @description Returns the string representation of the value
|
package/native/Text.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { assert, compactAddLength, compactFromU8a, hexToU8a, isHex, isString, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
|
|
@@ -42,26 +40,15 @@ function decodeText(value) {
|
|
|
42
40
|
// - Strings should probably be trimmed (docs do come through with extra padding)
|
|
43
41
|
|
|
44
42
|
|
|
45
|
-
var _initialU8aLength = /*#__PURE__*/_classPrivateFieldLooseKey("initialU8aLength");
|
|
46
|
-
|
|
47
|
-
var _override = /*#__PURE__*/_classPrivateFieldLooseKey("override");
|
|
48
|
-
|
|
49
43
|
export class Text extends String {
|
|
44
|
+
#initialU8aLength;
|
|
45
|
+
#override = null;
|
|
46
|
+
|
|
50
47
|
constructor(registry, value) {
|
|
51
48
|
const [str, decodedLength] = decodeText(value);
|
|
52
49
|
super(str);
|
|
53
|
-
this.registry = void 0;
|
|
54
|
-
this.createdAtHash = void 0;
|
|
55
|
-
Object.defineProperty(this, _initialU8aLength, {
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, _override, {
|
|
60
|
-
writable: true,
|
|
61
|
-
value: null
|
|
62
|
-
});
|
|
63
50
|
this.registry = registry;
|
|
64
|
-
|
|
51
|
+
this.#initialU8aLength = decodedLength;
|
|
65
52
|
}
|
|
66
53
|
/**
|
|
67
54
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -77,7 +64,7 @@ export class Text extends String {
|
|
|
77
64
|
|
|
78
65
|
|
|
79
66
|
get initialU8aLength() {
|
|
80
|
-
return
|
|
67
|
+
return this.#initialU8aLength;
|
|
81
68
|
}
|
|
82
69
|
/**
|
|
83
70
|
* @description returns a hash of the contents
|
|
@@ -118,7 +105,7 @@ export class Text extends String {
|
|
|
118
105
|
|
|
119
106
|
|
|
120
107
|
setOverride(override) {
|
|
121
|
-
|
|
108
|
+
this.#override = override;
|
|
122
109
|
}
|
|
123
110
|
/**
|
|
124
111
|
* @description Returns a hex string representation of the value
|
|
@@ -160,7 +147,7 @@ export class Text extends String {
|
|
|
160
147
|
|
|
161
148
|
|
|
162
149
|
toString() {
|
|
163
|
-
return
|
|
150
|
+
return this.#override || super.toString();
|
|
164
151
|
}
|
|
165
152
|
/**
|
|
166
153
|
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./detectPackage.cjs"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "7.
|
|
23
|
+
"version": "7.5.1",
|
|
24
24
|
"main": "index.cjs",
|
|
25
25
|
"module": "index.js",
|
|
26
26
|
"types": "index.d.ts",
|
|
@@ -400,6 +400,6 @@
|
|
|
400
400
|
},
|
|
401
401
|
"dependencies": {
|
|
402
402
|
"@babel/runtime": "^7.16.7",
|
|
403
|
-
"@polkadot/util": "^8.3.
|
|
403
|
+
"@polkadot/util": "^8.3.3"
|
|
404
404
|
}
|
|
405
405
|
}
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED
package/primitive/I128.js
CHANGED
|
@@ -8,9 +8,6 @@ import { Int } from "../base/Int.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class i128 extends Int.with(128) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__IntType = 'i128';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i128';
|
|
16
13
|
}
|
package/primitive/I16.js
CHANGED
package/primitive/I256.js
CHANGED
|
@@ -8,9 +8,6 @@ import { Int } from "../base/Int.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class i256 extends Int.with(256) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__IntType = 'i256';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__IntType = 'i256';
|
|
16
13
|
}
|
package/primitive/I32.js
CHANGED
package/primitive/I64.js
CHANGED
package/primitive/I8.js
CHANGED
package/primitive/U128.js
CHANGED
|
@@ -8,9 +8,6 @@ import { UInt } from "../base/UInt.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class u128 extends UInt.with(128) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__UIntType = 'u128';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u128';
|
|
16
13
|
}
|
package/primitive/U16.js
CHANGED
|
@@ -8,9 +8,6 @@ import { UInt } from "../base/UInt.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class u16 extends UInt.with(16) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__UIntType = 'u16';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u16';
|
|
16
13
|
}
|
package/primitive/U256.js
CHANGED
|
@@ -8,9 +8,6 @@ import { UInt } from "../base/UInt.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class u256 extends UInt.with(256) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__UIntType = 'u256';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u256';
|
|
16
13
|
}
|
package/primitive/U32.js
CHANGED
|
@@ -8,9 +8,6 @@ import { UInt } from "../base/UInt.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class u32 extends UInt.with(32) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__UIntType = 'u32';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u32';
|
|
16
13
|
}
|
package/primitive/U64.js
CHANGED
|
@@ -8,9 +8,6 @@ import { UInt } from "../base/UInt.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class u64 extends UInt.with(64) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__UIntType = 'u64';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u64';
|
|
16
13
|
}
|
package/primitive/U8.js
CHANGED
|
@@ -8,9 +8,6 @@ import { UInt } from "../base/UInt.js";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class u8 extends UInt.with(8) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.__UIntType = 'u8';
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
// NOTE without this, we cannot properly determine extensions
|
|
12
|
+
__UIntType = 'u8';
|
|
16
13
|
}
|