@polkadot/types-codec 10.0.1 → 10.1.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.
Files changed (171) hide show
  1. package/abstract/Array.d.ts +1 -1
  2. package/abstract/Array.js +0 -4
  3. package/abstract/Base.d.ts +1 -1
  4. package/abstract/Base.js +18 -19
  5. package/abstract/Int.d.ts +1 -1
  6. package/abstract/Int.js +11 -14
  7. package/abstract/Object.d.ts +1 -1
  8. package/abstract/Object.js +0 -5
  9. package/abstract/index.d.ts +3 -3
  10. package/base/Compact.d.ts +1 -1
  11. package/base/Compact.js +24 -25
  12. package/base/DoNotConstruct.d.ts +1 -1
  13. package/base/DoNotConstruct.js +19 -19
  14. package/base/Enum.d.ts +1 -1
  15. package/base/Enum.js +54 -53
  16. package/base/Int.d.ts +2 -2
  17. package/base/Null.d.ts +1 -1
  18. package/base/Null.js +3 -6
  19. package/base/Option.d.ts +1 -1
  20. package/base/Option.js +21 -22
  21. package/base/Result.d.ts +2 -2
  22. package/base/Tuple.d.ts +2 -2
  23. package/base/Tuple.js +10 -7
  24. package/base/UInt.d.ts +2 -2
  25. package/base/Vec.d.ts +2 -2
  26. package/base/Vec.js +12 -9
  27. package/base/VecAny.d.ts +2 -2
  28. package/base/VecFixed.d.ts +2 -2
  29. package/base/VecFixed.js +9 -6
  30. package/base/index.d.ts +12 -12
  31. package/bundle.d.ts +7 -7
  32. package/cjs/abstract/Array.js +2 -2
  33. package/cjs/abstract/index.js +6 -6
  34. package/cjs/base/Compact.js +2 -2
  35. package/cjs/base/Enum.js +8 -8
  36. package/cjs/base/Int.js +2 -2
  37. package/cjs/base/Option.js +4 -4
  38. package/cjs/base/Result.js +2 -2
  39. package/cjs/base/Tuple.js +8 -8
  40. package/cjs/base/UInt.js +2 -2
  41. package/cjs/base/Vec.js +6 -6
  42. package/cjs/base/VecAny.js +2 -2
  43. package/cjs/base/VecFixed.js +7 -7
  44. package/cjs/base/index.js +24 -24
  45. package/cjs/bundle.js +8 -8
  46. package/cjs/detectPackage.js +3 -3
  47. package/cjs/extended/BTreeMap.js +2 -2
  48. package/cjs/extended/BTreeSet.js +5 -5
  49. package/cjs/extended/BitVec.js +2 -2
  50. package/cjs/extended/Bytes.js +3 -3
  51. package/cjs/extended/HashMap.js +2 -2
  52. package/cjs/extended/Linkage.js +10 -10
  53. package/cjs/extended/Map.js +15 -15
  54. package/cjs/extended/OptionBool.js +5 -5
  55. package/cjs/extended/Range.js +2 -2
  56. package/cjs/extended/RangeInclusive.js +2 -2
  57. package/cjs/extended/Type.js +4 -4
  58. package/cjs/extended/U8aFixed.js +2 -2
  59. package/cjs/extended/WrapperKeepOpaque.js +6 -6
  60. package/cjs/extended/WrapperOpaque.js +2 -2
  61. package/cjs/extended/index.js +29 -29
  62. package/cjs/index.js +2 -2
  63. package/cjs/native/Json.js +2 -2
  64. package/cjs/native/Set.js +2 -2
  65. package/cjs/native/Struct.js +5 -5
  66. package/cjs/native/Text.js +2 -2
  67. package/cjs/native/index.js +19 -19
  68. package/cjs/packageInfo.js +1 -1
  69. package/cjs/primitive/F32.js +2 -2
  70. package/cjs/primitive/F64.js +2 -2
  71. package/cjs/primitive/I128.js +2 -2
  72. package/cjs/primitive/I16.js +2 -2
  73. package/cjs/primitive/I256.js +2 -2
  74. package/cjs/primitive/I32.js +2 -2
  75. package/cjs/primitive/I64.js +2 -2
  76. package/cjs/primitive/I8.js +2 -2
  77. package/cjs/primitive/U128.js +2 -2
  78. package/cjs/primitive/U16.js +2 -2
  79. package/cjs/primitive/U256.js +2 -2
  80. package/cjs/primitive/U32.js +2 -2
  81. package/cjs/primitive/U64.js +2 -2
  82. package/cjs/primitive/U8.js +2 -2
  83. package/cjs/primitive/USize.js +2 -2
  84. package/cjs/primitive/index.js +45 -45
  85. package/cjs/types/index.js +4 -4
  86. package/cjs/utils/compareArray.js +2 -2
  87. package/cjs/utils/compareMap.js +2 -2
  88. package/cjs/utils/index.js +22 -22
  89. package/cjs/utils/mapToTypeMap.js +2 -2
  90. package/extended/BTreeMap.d.ts +2 -2
  91. package/extended/BTreeSet.d.ts +1 -1
  92. package/extended/BTreeSet.js +7 -8
  93. package/extended/BitVec.d.ts +2 -2
  94. package/extended/BitVec.js +12 -9
  95. package/extended/Bytes.d.ts +2 -2
  96. package/extended/HashMap.d.ts +2 -2
  97. package/extended/Linkage.d.ts +4 -4
  98. package/extended/Map.d.ts +1 -1
  99. package/extended/Map.js +11 -12
  100. package/extended/OptionBool.d.ts +3 -3
  101. package/extended/Range.d.ts +2 -2
  102. package/extended/Range.js +7 -4
  103. package/extended/RangeInclusive.d.ts +2 -2
  104. package/extended/Type.d.ts +2 -2
  105. package/extended/U8aFixed.d.ts +2 -2
  106. package/extended/WrapperKeepOpaque.d.ts +2 -2
  107. package/extended/WrapperKeepOpaque.js +23 -20
  108. package/extended/WrapperOpaque.d.ts +2 -2
  109. package/extended/index.d.ts +14 -14
  110. package/index.d.ts +2 -2
  111. package/native/Bool.d.ts +1 -1
  112. package/native/Bool.js +1 -4
  113. package/native/Date.d.ts +1 -1
  114. package/native/Date.js +1 -4
  115. package/native/Float.d.ts +1 -1
  116. package/native/Float.js +8 -10
  117. package/native/Json.d.ts +1 -1
  118. package/native/Json.js +0 -4
  119. package/native/Raw.d.ts +1 -1
  120. package/native/Raw.js +0 -4
  121. package/native/Set.d.ts +1 -1
  122. package/native/Set.js +35 -34
  123. package/native/Struct.d.ts +1 -1
  124. package/native/Struct.js +22 -21
  125. package/native/Text.d.ts +1 -1
  126. package/native/Text.js +7 -8
  127. package/native/index.d.ts +8 -8
  128. package/package.json +3 -3
  129. package/packageInfo.js +1 -1
  130. package/primitive/F32.d.ts +2 -2
  131. package/primitive/F32.js +5 -2
  132. package/primitive/F64.d.ts +2 -2
  133. package/primitive/F64.js +5 -2
  134. package/primitive/I128.d.ts +2 -2
  135. package/primitive/I128.js +5 -2
  136. package/primitive/I16.d.ts +2 -2
  137. package/primitive/I16.js +5 -2
  138. package/primitive/I256.d.ts +2 -2
  139. package/primitive/I256.js +5 -2
  140. package/primitive/I32.d.ts +2 -2
  141. package/primitive/I32.js +5 -2
  142. package/primitive/I64.d.ts +2 -2
  143. package/primitive/I64.js +5 -2
  144. package/primitive/I8.d.ts +2 -2
  145. package/primitive/I8.js +5 -2
  146. package/primitive/U128.d.ts +2 -2
  147. package/primitive/U128.js +5 -2
  148. package/primitive/U16.d.ts +2 -2
  149. package/primitive/U16.js +5 -2
  150. package/primitive/U256.d.ts +2 -2
  151. package/primitive/U256.js +5 -2
  152. package/primitive/U32.d.ts +2 -2
  153. package/primitive/U32.js +5 -2
  154. package/primitive/U64.d.ts +2 -2
  155. package/primitive/U64.js +5 -2
  156. package/primitive/U8.d.ts +2 -2
  157. package/primitive/U8.js +5 -2
  158. package/primitive/USize.d.ts +2 -2
  159. package/primitive/index.d.ts +15 -15
  160. package/types/codec.d.ts +3 -3
  161. package/types/helpers.d.ts +1 -1
  162. package/types/index.d.ts +4 -4
  163. package/types/interfaces.d.ts +2 -2
  164. package/types/registry.d.ts +3 -3
  165. package/utils/decodeU8a.d.ts +1 -1
  166. package/utils/index.d.ts +9 -9
  167. package/utils/mapToTypeMap.d.ts +1 -1
  168. package/utils/sanitize.d.ts +1 -1
  169. package/utils/sortValues.d.ts +1 -1
  170. package/utils/typeToConstructor.d.ts +1 -1
  171. package/utils/typesToMap.d.ts +1 -1
package/base/Enum.js CHANGED
@@ -1,3 +1,5 @@
1
+ var _Enum_def, _Enum_entryIndex, _Enum_indexes, _Enum_isBasic, _Enum_isIndexed, _Enum_raw;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { isHex, isNumber, isObject, isString, isU8a, objectProperties, stringCamelCase, stringify, stringPascalCase, u8aConcatStrict, u8aToHex, u8aToU8a } from '@polkadot/util';
2
4
  import { mapToTypeMap, typesToMap } from '../utils/index.js';
3
5
  import { Null } from './Null.js';
@@ -126,39 +128,40 @@ function decodeEnum(registry, def, value, index) {
126
128
  * an extension to enum where the value type is determined by the actual index.
127
129
  */
128
130
  export class Enum {
129
- registry;
130
- createdAtHash;
131
- initialU8aLength;
132
- isStorageFallback;
133
- #def;
134
- #entryIndex;
135
- #indexes;
136
- #isBasic;
137
- #isIndexed;
138
- #raw;
139
131
  constructor(registry, Types, value, index, { definition, setDefinition = noopSetDefinition } = {}) {
132
+ _Enum_def.set(this, void 0);
133
+ _Enum_entryIndex.set(this, void 0);
134
+ _Enum_indexes.set(this, void 0);
135
+ _Enum_isBasic.set(this, void 0);
136
+ _Enum_isIndexed.set(this, void 0);
137
+ _Enum_raw.set(this, void 0);
140
138
  const { def, isBasic, isIndexed } = definition || setDefinition(extractDef(registry, Types));
141
139
  // shortcut isU8a as used in SCALE decoding
142
140
  const decoded = isU8a(value) && value.length && !isNumber(index)
143
141
  ? createFromU8a(registry, def, value[0], value.subarray(1))
144
142
  : decodeEnum(registry, def, value, index);
145
143
  this.registry = registry;
146
- this.#def = def;
147
- this.#isBasic = isBasic;
148
- this.#isIndexed = isIndexed;
149
- this.#indexes = Object.values(def).map(({ index }) => index);
150
- this.#entryIndex = this.#indexes.indexOf(decoded.index);
151
- this.#raw = decoded.value;
152
- if (this.#raw.initialU8aLength) {
153
- this.initialU8aLength = 1 + this.#raw.initialU8aLength;
144
+ __classPrivateFieldSet(this, _Enum_def, def, "f");
145
+ __classPrivateFieldSet(this, _Enum_isBasic, isBasic, "f");
146
+ __classPrivateFieldSet(this, _Enum_isIndexed, isIndexed, "f");
147
+ __classPrivateFieldSet(this, _Enum_indexes, Object.values(def).map(({ index }) => index), "f");
148
+ __classPrivateFieldSet(this, _Enum_entryIndex, __classPrivateFieldGet(this, _Enum_indexes, "f").indexOf(decoded.index), "f");
149
+ __classPrivateFieldSet(this, _Enum_raw, decoded.value, "f");
150
+ if (__classPrivateFieldGet(this, _Enum_raw, "f").initialU8aLength) {
151
+ this.initialU8aLength = 1 + __classPrivateFieldGet(this, _Enum_raw, "f").initialU8aLength;
154
152
  }
155
153
  }
156
154
  static with(Types) {
155
+ var _a;
157
156
  let definition;
158
157
  // eslint-disable-next-line no-return-assign
159
158
  const setDefinition = (d) => definition = d;
160
- return class extends Enum {
161
- static {
159
+ return _a = class extends Enum {
160
+ constructor(registry, value, index) {
161
+ super(registry, Types, value, index, { definition, setDefinition });
162
+ }
163
+ },
164
+ (() => {
162
165
  const keys = Array.isArray(Types)
163
166
  ? Types
164
167
  : Object.keys(Types);
@@ -169,24 +172,21 @@ export class Enum {
169
172
  asKeys[i] = `as${name}`;
170
173
  isKeys[i] = `is${name}`;
171
174
  }
172
- objectProperties(this.prototype, isKeys, (_, i, self) => self.type === keys[i]);
173
- objectProperties(this.prototype, asKeys, (k, i, self) => {
175
+ objectProperties(_a.prototype, isKeys, (_, i, self) => self.type === keys[i]);
176
+ objectProperties(_a.prototype, asKeys, (k, i, self) => {
174
177
  if (self.type !== keys[i]) {
175
178
  throw new Error(`Cannot convert '${self.type}' via ${k}`);
176
179
  }
177
180
  return self.value;
178
181
  });
179
- }
180
- constructor(registry, value, index) {
181
- super(registry, Types, value, index, { definition, setDefinition });
182
- }
183
- };
182
+ })(),
183
+ _a;
184
184
  }
185
185
  /**
186
186
  * @description The length of the value when encoded as a Uint8Array
187
187
  */
188
188
  get encodedLength() {
189
- return 1 + this.#raw.encodedLength;
189
+ return 1 + __classPrivateFieldGet(this, _Enum_raw, "f").encodedLength;
190
190
  }
191
191
  /**
192
192
  * @description returns a hash of the contents
@@ -198,55 +198,55 @@ export class Enum {
198
198
  * @description The index of the enum value
199
199
  */
200
200
  get index() {
201
- return this.#indexes[this.#entryIndex];
201
+ return __classPrivateFieldGet(this, _Enum_indexes, "f")[__classPrivateFieldGet(this, _Enum_entryIndex, "f")];
202
202
  }
203
203
  /**
204
204
  * @description The value of the enum
205
205
  */
206
206
  get inner() {
207
- return this.#raw;
207
+ return __classPrivateFieldGet(this, _Enum_raw, "f");
208
208
  }
209
209
  /**
210
210
  * @description true if this is a basic enum (no values)
211
211
  */
212
212
  get isBasic() {
213
- return this.#isBasic;
213
+ return __classPrivateFieldGet(this, _Enum_isBasic, "f");
214
214
  }
215
215
  /**
216
216
  * @description Checks if the value is an empty value
217
217
  */
218
218
  get isEmpty() {
219
- return this.#raw.isEmpty;
219
+ return __classPrivateFieldGet(this, _Enum_raw, "f").isEmpty;
220
220
  }
221
221
  /**
222
222
  * @description Checks if the Enum points to a [[Null]] type
223
223
  */
224
224
  get isNone() {
225
- return this.#raw instanceof Null;
225
+ return __classPrivateFieldGet(this, _Enum_raw, "f") instanceof Null;
226
226
  }
227
227
  /**
228
228
  * @description The available keys for this enum
229
229
  */
230
230
  get defIndexes() {
231
- return this.#indexes;
231
+ return __classPrivateFieldGet(this, _Enum_indexes, "f");
232
232
  }
233
233
  /**
234
234
  * @description The available keys for this enum
235
235
  */
236
236
  get defKeys() {
237
- return Object.keys(this.#def);
237
+ return Object.keys(__classPrivateFieldGet(this, _Enum_def, "f"));
238
238
  }
239
239
  /**
240
240
  * @description The name of the type this enum value represents
241
241
  */
242
242
  get type() {
243
- return this.defKeys[this.#entryIndex];
243
+ return this.defKeys[__classPrivateFieldGet(this, _Enum_entryIndex, "f")];
244
244
  }
245
245
  /**
246
246
  * @description The value of the enum
247
247
  */
248
248
  get value() {
249
- return this.#raw;
249
+ return __classPrivateFieldGet(this, _Enum_raw, "f");
250
250
  }
251
251
  /**
252
252
  * @description Compares the value of the input to see if there is a match
@@ -259,7 +259,7 @@ export class Enum {
259
259
  else if (isNumber(other)) {
260
260
  return this.toNumber() === other;
261
261
  }
262
- else if (this.#isBasic && isString(other)) {
262
+ else if (__classPrivateFieldGet(this, _Enum_isBasic, "f") && isString(other)) {
263
263
  return this.type === other;
264
264
  }
265
265
  else if (isHex(other)) {
@@ -278,10 +278,10 @@ export class Enum {
278
278
  * @description Returns a breakdown of the hex encoding for this Codec
279
279
  */
280
280
  inspect() {
281
- if (this.#isBasic) {
281
+ if (__classPrivateFieldGet(this, _Enum_isBasic, "f")) {
282
282
  return { outer: [new Uint8Array([this.index])] };
283
283
  }
284
- const { inner, outer = [] } = this.#raw.inspect();
284
+ const { inner, outer = [] } = __classPrivateFieldGet(this, _Enum_raw, "f").inspect();
285
285
  return {
286
286
  inner,
287
287
  outer: [new Uint8Array([this.index]), ...outer]
@@ -297,17 +297,17 @@ export class Enum {
297
297
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
298
298
  */
299
299
  toHuman(isExtended) {
300
- return this.#isBasic || this.isNone
300
+ return __classPrivateFieldGet(this, _Enum_isBasic, "f") || this.isNone
301
301
  ? this.type
302
- : { [this.type]: this.#raw.toHuman(isExtended) };
302
+ : { [this.type]: __classPrivateFieldGet(this, _Enum_raw, "f").toHuman(isExtended) };
303
303
  }
304
304
  /**
305
305
  * @description Converts the Object to JSON, typically used for RPC transfers
306
306
  */
307
307
  toJSON() {
308
- return this.#isBasic
308
+ return __classPrivateFieldGet(this, _Enum_isBasic, "f")
309
309
  ? this.type
310
- : { [stringCamelCase(this.type)]: this.#raw.toJSON() };
310
+ : { [stringCamelCase(this.type)]: __classPrivateFieldGet(this, _Enum_raw, "f").toJSON() };
311
311
  }
312
312
  /**
313
313
  * @description Returns the number representation for the value
@@ -319,23 +319,23 @@ export class Enum {
319
319
  * @description Converts the value in a best-fit primitive form
320
320
  */
321
321
  toPrimitive() {
322
- return this.#isBasic
322
+ return __classPrivateFieldGet(this, _Enum_isBasic, "f")
323
323
  ? this.type
324
- : { [stringCamelCase(this.type)]: this.#raw.toPrimitive() };
324
+ : { [stringCamelCase(this.type)]: __classPrivateFieldGet(this, _Enum_raw, "f").toPrimitive() };
325
325
  }
326
326
  /**
327
327
  * @description Returns a raw struct representation of the enum types
328
328
  */
329
329
  _toRawStruct() {
330
- if (this.#isBasic) {
331
- return this.#isIndexed
330
+ if (__classPrivateFieldGet(this, _Enum_isBasic, "f")) {
331
+ return __classPrivateFieldGet(this, _Enum_isIndexed, "f")
332
332
  ? this.defKeys.reduce((out, key, index) => {
333
- out[key] = this.#indexes[index];
333
+ out[key] = __classPrivateFieldGet(this, _Enum_indexes, "f")[index];
334
334
  return out;
335
335
  }, {})
336
336
  : this.defKeys;
337
337
  }
338
- const entries = Object.entries(this.#def);
338
+ const entries = Object.entries(__classPrivateFieldGet(this, _Enum_def, "f"));
339
339
  return typesToMap(this.registry, entries.reduce((out, [key, { Type }], i) => {
340
340
  out[0][i] = Type;
341
341
  out[1][i] = key;
@@ -362,10 +362,11 @@ export class Enum {
362
362
  */
363
363
  toU8a(isBare) {
364
364
  return isBare
365
- ? this.#raw.toU8a(isBare)
365
+ ? __classPrivateFieldGet(this, _Enum_raw, "f").toU8a(isBare)
366
366
  : u8aConcatStrict([
367
367
  new Uint8Array([this.index]),
368
- this.#raw.toU8a(isBare)
368
+ __classPrivateFieldGet(this, _Enum_raw, "f").toU8a(isBare)
369
369
  ]);
370
370
  }
371
- }
371
+ }
372
+ _Enum_def = new WeakMap(), _Enum_entryIndex = new WeakMap(), _Enum_indexes = new WeakMap(), _Enum_isBasic = new WeakMap(), _Enum_isIndexed = new WeakMap(), _Enum_raw = new WeakMap();
package/base/Int.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { AnyNumber, CodecClass, Registry, UIntBitLength } from '../types';
2
- import { AbstractInt } from '../abstract/Int';
1
+ import type { AnyNumber, CodecClass, Registry, UIntBitLength } from '../types/index.js';
2
+ import { AbstractInt } from '../abstract/Int.js';
3
3
  /**
4
4
  * @name Int
5
5
  * @description
package/base/Null.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
- import type { Codec, Inspect, IU8a, Registry } from '../types';
2
+ import type { Codec, Inspect, IU8a, Registry } from '../types/index.js';
3
3
  /**
4
4
  * @name Null
5
5
  * @description
package/base/Null.js CHANGED
@@ -5,13 +5,10 @@ import { isNull } from '@polkadot/util';
5
5
  * Implements a type that does not contain anything (apart from `null`)
6
6
  */
7
7
  export class Null {
8
- encodedLength = 0;
9
- isEmpty = true;
10
- registry;
11
- createdAtHash;
12
- initialU8aLength = 0;
13
- isStorageFallback;
14
8
  constructor(registry) {
9
+ this.encodedLength = 0;
10
+ this.isEmpty = true;
11
+ this.initialU8aLength = 0;
15
12
  this.registry = registry;
16
13
  }
17
14
  /**
package/base/Option.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
- import type { AnyJson, Codec, CodecClass, Inspect, IOption, IU8a, Registry } from '../types';
2
+ import type { AnyJson, Codec, CodecClass, Inspect, IOption, IU8a, Registry } from '../types/index.js';
3
3
  interface Options<T> {
4
4
  definition?: CodecClass<T>;
5
5
  setDefinition?: (d: CodecClass<T>) => CodecClass<T>;
package/base/Option.js CHANGED
@@ -1,3 +1,5 @@
1
+ var _Option_Type, _Option_raw;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { isCodec, isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
2
4
  import { typeToConstructor } from '../utils/index.js';
3
5
  import { Null } from './Null.js';
@@ -52,13 +54,9 @@ function decodeOption(registry, Type, value) {
52
54
  * with a value if/as required/found.
53
55
  */
54
56
  export class Option {
55
- registry;
56
- createdAtHash;
57
- initialU8aLength;
58
- isStorageFallback;
59
- #Type;
60
- #raw;
61
57
  constructor(registry, typeName, value, { definition, setDefinition = noopSetDefinition } = {}) {
58
+ _Option_Type.set(this, void 0);
59
+ _Option_raw.set(this, void 0);
62
60
  const Type = definition || setDefinition(typeToConstructor(registry, typeName));
63
61
  const decoded = isU8a(value) && value.length && !isCodec(value)
64
62
  ? value[0] === 0
@@ -66,8 +64,8 @@ export class Option {
66
64
  : new Type(registry, value.subarray(1))
67
65
  : decodeOption(registry, Type, value);
68
66
  this.registry = registry;
69
- this.#Type = Type;
70
- this.#raw = decoded;
67
+ __classPrivateFieldSet(this, _Option_Type, Type, "f");
68
+ __classPrivateFieldSet(this, _Option_raw, decoded, "f");
71
69
  if (decoded?.initialU8aLength) {
72
70
  this.initialU8aLength = 1 + decoded.initialU8aLength;
73
71
  }
@@ -89,7 +87,7 @@ export class Option {
89
87
  */
90
88
  get encodedLength() {
91
89
  // boolean byte (has value, doesn't have) along with wrapped length
92
- return 1 + this.#raw.encodedLength;
90
+ return 1 + __classPrivateFieldGet(this, _Option_raw, "f").encodedLength;
93
91
  }
94
92
  /**
95
93
  * @description returns a hash of the contents
@@ -107,7 +105,7 @@ export class Option {
107
105
  * @description Checks if the Option has no value
108
106
  */
109
107
  get isNone() {
110
- return this.#raw instanceof None;
108
+ return __classPrivateFieldGet(this, _Option_raw, "f") instanceof None;
111
109
  }
112
110
  /**
113
111
  * @description Checks if the Option has a value
@@ -119,7 +117,7 @@ export class Option {
119
117
  * @description The actual value for the Option
120
118
  */
121
119
  get value() {
122
- return this.#raw;
120
+ return __classPrivateFieldGet(this, _Option_raw, "f");
123
121
  }
124
122
  /**
125
123
  * @description Compares the value of the input to see if there is a match
@@ -137,7 +135,7 @@ export class Option {
137
135
  if (this.isNone) {
138
136
  return { outer: [new Uint8Array([0])] };
139
137
  }
140
- const { inner, outer = [] } = this.#raw.inspect();
138
+ const { inner, outer = [] } = __classPrivateFieldGet(this, _Option_raw, "f").inspect();
141
139
  return {
142
140
  inner,
143
141
  outer: [new Uint8Array([1]), ...outer]
@@ -157,7 +155,7 @@ export class Option {
157
155
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
158
156
  */
159
157
  toHuman(isExtended) {
160
- return this.#raw.toHuman(isExtended);
158
+ return __classPrivateFieldGet(this, _Option_raw, "f").toHuman(isExtended);
161
159
  }
162
160
  /**
163
161
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -165,7 +163,7 @@ export class Option {
165
163
  toJSON() {
166
164
  return this.isNone
167
165
  ? null
168
- : this.#raw.toJSON();
166
+ : __classPrivateFieldGet(this, _Option_raw, "f").toJSON();
169
167
  }
170
168
  /**
171
169
  * @description Converts the value in a best-fit primitive form
@@ -173,13 +171,13 @@ export class Option {
173
171
  toPrimitive() {
174
172
  return this.isNone
175
173
  ? null
176
- : this.#raw.toPrimitive();
174
+ : __classPrivateFieldGet(this, _Option_raw, "f").toPrimitive();
177
175
  }
178
176
  /**
179
177
  * @description Returns the base runtime type name for this instance
180
178
  */
181
179
  toRawType(isBare) {
182
- const wrapped = this.registry.getClassName(this.#Type) || new this.#Type(this.registry).toRawType();
180
+ const wrapped = this.registry.getClassName(__classPrivateFieldGet(this, _Option_Type, "f")) || new (__classPrivateFieldGet(this, _Option_Type, "f"))(this.registry).toRawType();
183
181
  return isBare
184
182
  ? wrapped
185
183
  : `Option<${wrapped}>`;
@@ -188,7 +186,7 @@ export class Option {
188
186
  * @description Returns the string representation of the value
189
187
  */
190
188
  toString() {
191
- return this.#raw.toString();
189
+ return __classPrivateFieldGet(this, _Option_raw, "f").toString();
192
190
  }
193
191
  /**
194
192
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
@@ -196,12 +194,12 @@ export class Option {
196
194
  */
197
195
  toU8a(isBare) {
198
196
  if (isBare) {
199
- return this.#raw.toU8a(true);
197
+ return __classPrivateFieldGet(this, _Option_raw, "f").toU8a(true);
200
198
  }
201
199
  const u8a = new Uint8Array(this.encodedLength);
202
200
  if (this.isSome) {
203
201
  u8a.set([1]);
204
- u8a.set(this.#raw.toU8a(), 1);
202
+ u8a.set(__classPrivateFieldGet(this, _Option_raw, "f").toU8a(), 1);
205
203
  }
206
204
  return u8a;
207
205
  }
@@ -212,7 +210,7 @@ export class Option {
212
210
  if (this.isNone) {
213
211
  throw new Error('Option: unwrapping a None value');
214
212
  }
215
- return this.#raw;
213
+ return __classPrivateFieldGet(this, _Option_raw, "f");
216
214
  }
217
215
  /**
218
216
  * @description Returns the value that the Option represents (if available) or defaultValue if none
@@ -230,6 +228,7 @@ export class Option {
230
228
  unwrapOrDefault() {
231
229
  return this.isSome
232
230
  ? this.unwrap()
233
- : new this.#Type(this.registry);
231
+ : new (__classPrivateFieldGet(this, _Option_Type, "f"))(this.registry);
234
232
  }
235
- }
233
+ }
234
+ _Option_Type = new WeakMap(), _Option_raw = new WeakMap();
package/base/Result.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Codec, CodecClass, IResult, Registry } from '../types';
2
- import { Enum } from './Enum';
1
+ import type { Codec, CodecClass, IResult, Registry } from '../types/index.js';
2
+ import { Enum } from './Enum.js';
3
3
  /**
4
4
  * @name Result
5
5
  * @description
package/base/Tuple.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { AnyTupleValue, Codec, CodecClass, Inspect, ITuple, Registry } from '../types';
2
- import { AbstractArray } from '../abstract/Array';
1
+ import type { AnyTupleValue, Codec, CodecClass, Inspect, ITuple, Registry } from '../types/index.js';
2
+ import { AbstractArray } from '../abstract/Array.js';
3
3
  type TupleType = (CodecClass | string);
4
4
  type TupleTypes = TupleType[] | {
5
5
  [index: string]: CodecClass | string;
package/base/Tuple.js CHANGED
@@ -1,3 +1,5 @@
1
+ var _Tuple_Types;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { isFunction, isHex, isString, isU8a, stringify, u8aConcatStrict, u8aToU8a } from '@polkadot/util';
2
4
  import { AbstractArray } from '../abstract/Array.js';
3
5
  import { decodeU8a, mapToTypeMap, typeToConstructor } from '../utils/index.js';
@@ -40,7 +42,6 @@ function decodeTuple(registry, result, value, Classes) {
40
42
  * own type. It extends the base JS `Array` object.
41
43
  */
42
44
  export class Tuple extends AbstractArray {
43
- #Types;
44
45
  constructor(registry, Types, value, { definition, setDefinition = noopSetDefinition } = {}) {
45
46
  const Classes = definition || setDefinition(Array.isArray(Types)
46
47
  ? [Types.map((t) => typeToConstructor(registry, t)), []]
@@ -48,10 +49,11 @@ export class Tuple extends AbstractArray {
48
49
  ? [[typeToConstructor(registry, Types)], []]
49
50
  : mapToTypeMap(registry, Types));
50
51
  super(registry, Classes[0].length);
52
+ _Tuple_Types.set(this, void 0);
51
53
  this.initialU8aLength = (isU8a(value)
52
54
  ? decodeU8a(registry, this, value, Classes)
53
55
  : decodeTuple(registry, this, value, Classes))[1];
54
- this.#Types = Classes;
56
+ __classPrivateFieldSet(this, _Tuple_Types, Classes, "f");
55
57
  }
56
58
  static with(Types) {
57
59
  let definition;
@@ -77,9 +79,9 @@ export class Tuple extends AbstractArray {
77
79
  * @description The types definition of the tuple
78
80
  */
79
81
  get Types() {
80
- return this.#Types[1].length
81
- ? this.#Types[1]
82
- : this.#Types[0].map((T) => new T(this.registry).toRawType());
82
+ return __classPrivateFieldGet(this, _Tuple_Types, "f")[1].length
83
+ ? __classPrivateFieldGet(this, _Tuple_Types, "f")[1]
84
+ : __classPrivateFieldGet(this, _Tuple_Types, "f")[0].map((T) => new T(this.registry).toRawType());
83
85
  }
84
86
  /**
85
87
  * @description Returns a breakdown of the hex encoding for this Codec
@@ -93,7 +95,7 @@ export class Tuple extends AbstractArray {
93
95
  * @description Returns the base runtime type name for this instance
94
96
  */
95
97
  toRawType() {
96
- const types = this.#Types[0].map((T) => this.registry.getClassName(T) || new T(this.registry).toRawType());
98
+ const types = __classPrivateFieldGet(this, _Tuple_Types, "f")[0].map((T) => this.registry.getClassName(T) || new T(this.registry).toRawType());
97
99
  return `(${types.join(',')})`;
98
100
  }
99
101
  /**
@@ -110,4 +112,5 @@ export class Tuple extends AbstractArray {
110
112
  toU8a(isBare) {
111
113
  return u8aConcatStrict(this.toU8aInner(isBare));
112
114
  }
113
- }
115
+ }
116
+ _Tuple_Types = new WeakMap();
package/base/UInt.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { CodecClass, UIntBitLength } from '../types';
2
- import { AbstractInt } from '../abstract/Int';
1
+ import type { CodecClass, UIntBitLength } from '../types/index.js';
2
+ import { AbstractInt } from '../abstract/Int.js';
3
3
  /**
4
4
  * @name UInt
5
5
  * @description
package/base/Vec.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
- import type { Codec, CodecClass, Registry } from '../types';
3
- import { AbstractArray } from '../abstract/Array';
2
+ import type { Codec, CodecClass, Registry } from '../types/index.js';
3
+ import { AbstractArray } from '../abstract/Array.js';
4
4
  interface Options<T> {
5
5
  definition?: CodecClass<T>;
6
6
  setDefinition?: (d: CodecClass<T>) => CodecClass<T>;
package/base/Vec.js CHANGED
@@ -1,3 +1,5 @@
1
+ var _Vec_Type;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { compactFromU8aLim, isHex, isU8a, logger, stringify, u8aToU8a } from '@polkadot/util';
2
4
  import { AbstractArray } from '../abstract/Array.js';
3
5
  import { decodeU8aVec, typeToConstructor } from '../utils/index.js';
@@ -56,14 +58,14 @@ export function decodeVec(registry, result, value, startAt, Type) {
56
58
  * specific encoding/decoding on top of the base type.
57
59
  */
58
60
  export class Vec extends AbstractArray {
59
- #Type;
60
61
  constructor(registry, Type, value = [], { definition, setDefinition = noopSetDefinition } = {}) {
61
62
  const [decodeFrom, length, startAt] = decodeVecLength(value);
62
63
  super(registry, length);
63
- this.#Type = definition || setDefinition(typeToConstructor(registry, Type));
64
+ _Vec_Type.set(this, void 0);
65
+ __classPrivateFieldSet(this, _Vec_Type, definition || setDefinition(typeToConstructor(registry, Type)), "f");
64
66
  this.initialU8aLength = (isU8a(decodeFrom)
65
- ? decodeU8aVec(registry, this, decodeFrom, startAt, this.#Type)
66
- : decodeVec(registry, this, decodeFrom, startAt, this.#Type))[0];
67
+ ? decodeU8aVec(registry, this, decodeFrom, startAt, __classPrivateFieldGet(this, _Vec_Type, "f"))
68
+ : decodeVec(registry, this, decodeFrom, startAt, __classPrivateFieldGet(this, _Vec_Type, "f")))[0];
67
69
  }
68
70
  static with(Type) {
69
71
  let definition;
@@ -79,16 +81,16 @@ export class Vec extends AbstractArray {
79
81
  * @description The type for the items
80
82
  */
81
83
  get Type() {
82
- return this.#Type.name;
84
+ return __classPrivateFieldGet(this, _Vec_Type, "f").name;
83
85
  }
84
86
  /**
85
87
  * @description Finds the index of the value in the array
86
88
  */
87
89
  indexOf(_other) {
88
90
  // convert type first, this removes overhead from the eq
89
- const other = _other instanceof this.#Type
91
+ const other = _other instanceof __classPrivateFieldGet(this, _Vec_Type, "f")
90
92
  ? _other
91
- : new this.#Type(this.registry, _other);
93
+ : new (__classPrivateFieldGet(this, _Vec_Type, "f"))(this.registry, _other);
92
94
  for (let i = 0; i < this.length; i++) {
93
95
  if (other.eq(this[i])) {
94
96
  return i;
@@ -100,6 +102,7 @@ export class Vec extends AbstractArray {
100
102
  * @description Returns the base runtime type name for this instance
101
103
  */
102
104
  toRawType() {
103
- return `Vec<${this.registry.getClassName(this.#Type) || new this.#Type(this.registry).toRawType()}>`;
105
+ return `Vec<${this.registry.getClassName(__classPrivateFieldGet(this, _Vec_Type, "f")) || new (__classPrivateFieldGet(this, _Vec_Type, "f"))(this.registry).toRawType()}>`;
104
106
  }
105
- }
107
+ }
108
+ _Vec_Type = new WeakMap();
package/base/VecAny.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Codec } from '../types';
2
- import { AbstractArray } from '../abstract/Array';
1
+ import type { Codec } from '../types/index.js';
2
+ import { AbstractArray } from '../abstract/Array.js';
3
3
  /**
4
4
  * @name VecAny
5
5
  * @description
@@ -1,6 +1,6 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
- import type { Codec, CodecClass, Inspect, Registry } from '../types';
3
- import { AbstractArray } from '../abstract/Array';
2
+ import type { Codec, CodecClass, Inspect, Registry } from '../types/index.js';
3
+ import { AbstractArray } from '../abstract/Array.js';
4
4
  interface Options<T> {
5
5
  definition?: CodecClass<T>;
6
6
  setDefinition?: (d: CodecClass<T>) => CodecClass<T>;
package/base/VecFixed.js CHANGED
@@ -1,3 +1,5 @@
1
+ var _VecFixed_Type;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
1
3
  import { isU8a, u8aConcatStrict } from '@polkadot/util';
2
4
  import { AbstractArray } from '../abstract/Array.js';
3
5
  import { decodeU8aVec, typeToConstructor } from '../utils/index.js';
@@ -11,13 +13,13 @@ function noopSetDefinition(d) {
11
13
  * This manages codec arrays of a fixed length
12
14
  */
13
15
  export class VecFixed extends AbstractArray {
14
- #Type;
15
16
  constructor(registry, Type, length, value = [], { definition, setDefinition = noopSetDefinition } = {}) {
16
17
  super(registry, length);
17
- this.#Type = definition || setDefinition(typeToConstructor(registry, Type));
18
+ _VecFixed_Type.set(this, void 0);
19
+ __classPrivateFieldSet(this, _VecFixed_Type, definition || setDefinition(typeToConstructor(registry, Type)), "f");
18
20
  this.initialU8aLength = (isU8a(value)
19
- ? decodeU8aVec(registry, this, value, 0, this.#Type)
20
- : decodeVec(registry, this, value, 0, this.#Type))[1];
21
+ ? decodeU8aVec(registry, this, value, 0, __classPrivateFieldGet(this, _VecFixed_Type, "f"))
22
+ : decodeVec(registry, this, value, 0, __classPrivateFieldGet(this, _VecFixed_Type, "f")))[1];
21
23
  }
22
24
  static with(Type, length) {
23
25
  let definition;
@@ -33,7 +35,7 @@ export class VecFixed extends AbstractArray {
33
35
  * @description The type for the items
34
36
  */
35
37
  get Type() {
36
- return new this.#Type(this.registry).toRawType();
38
+ return new (__classPrivateFieldGet(this, _VecFixed_Type, "f"))(this.registry).toRawType();
37
39
  }
38
40
  /**
39
41
  * @description The length of the value when encoded as a Uint8Array
@@ -67,4 +69,5 @@ export class VecFixed extends AbstractArray {
67
69
  toRawType() {
68
70
  return `[${this.Type};${this.length}]`;
69
71
  }
70
- }
72
+ }
73
+ _VecFixed_Type = new WeakMap();