@polkadot/types-codec 10.3.4 → 10.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.
Files changed (66) hide show
  1. package/abstract/Array.js +21 -14
  2. package/abstract/Base.js +13 -17
  3. package/abstract/Int.js +8 -12
  4. package/base/Compact.js +20 -28
  5. package/base/DoNotConstruct.js +14 -18
  6. package/base/Enum.js +42 -53
  7. package/base/Option.js +17 -25
  8. package/base/Tuple.js +12 -19
  9. package/base/Vec.js +10 -17
  10. package/base/VecFixed.js +7 -14
  11. package/cjs/abstract/Array.js +21 -14
  12. package/cjs/abstract/Base.js +13 -17
  13. package/cjs/abstract/Int.js +8 -12
  14. package/cjs/base/Compact.js +19 -27
  15. package/cjs/base/DoNotConstruct.js +14 -18
  16. package/cjs/base/Enum.js +41 -52
  17. package/cjs/base/Option.js +16 -24
  18. package/cjs/base/Tuple.js +10 -17
  19. package/cjs/base/Vec.js +9 -16
  20. package/cjs/base/VecFixed.js +6 -13
  21. package/cjs/extended/BTreeSet.js +2 -6
  22. package/cjs/extended/BitVec.js +10 -14
  23. package/cjs/extended/Map.js +5 -11
  24. package/cjs/extended/Range.js +2 -6
  25. package/cjs/extended/WrapperKeepOpaque.js +16 -22
  26. package/cjs/native/Float.js +3 -7
  27. package/cjs/native/Set.js +15 -18
  28. package/cjs/native/Struct.js +12 -16
  29. package/cjs/native/Text.js +3 -6
  30. package/cjs/native/index.js +2 -2
  31. package/cjs/packageInfo.js +1 -1
  32. package/cjs/primitive/index.js +17 -17
  33. package/cjs/utils/index.js +6 -6
  34. package/cjs/utils/sanitize.js +16 -16
  35. package/cjs/utils/sortValues.js +2 -6
  36. package/cjs/utils/toConstructors.js +41 -0
  37. package/cjs/utils/typesToMap.js +1 -1
  38. package/extended/BTreeSet.js +2 -6
  39. package/extended/BitVec.js +10 -14
  40. package/extended/Map.js +5 -11
  41. package/extended/Range.js +2 -6
  42. package/extended/WrapperKeepOpaque.js +16 -22
  43. package/native/Float.js +3 -7
  44. package/native/Set.js +15 -18
  45. package/native/Struct.js +12 -16
  46. package/native/Text.js +3 -6
  47. package/native/index.d.ts +1 -1
  48. package/native/index.js +1 -1
  49. package/package.json +9 -14
  50. package/packageInfo.js +1 -1
  51. package/primitive/index.d.ts +16 -16
  52. package/primitive/index.js +16 -16
  53. package/types/registry.d.ts +2 -1
  54. package/utils/index.d.ts +2 -3
  55. package/utils/index.js +2 -3
  56. package/utils/sanitize.js +16 -16
  57. package/utils/sortValues.js +1 -5
  58. package/utils/toConstructors.d.ts +16 -0
  59. package/utils/toConstructors.js +35 -0
  60. package/utils/typesToMap.js +1 -1
  61. package/cjs/utils/mapToTypeMap.js +0 -18
  62. package/cjs/utils/typeToConstructor.js +0 -10
  63. package/utils/mapToTypeMap.d.ts +0 -5
  64. package/utils/mapToTypeMap.js +0 -14
  65. package/utils/typeToConstructor.d.ts +0 -2
  66. package/utils/typeToConstructor.js +0 -6
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _BitVec_decodedLength, _BitVec_isMsb;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.BitVec = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  const Raw_js_1 = require("../native/Raw.js");
8
6
  /** @internal */
@@ -39,23 +37,21 @@ class BitVec extends Raw_js_1.Raw {
39
37
  constructor(registry, value, isMsb = false) {
40
38
  const [decodedLength, u8a] = decodeBitVec(value);
41
39
  super(registry, u8a);
42
- _BitVec_decodedLength.set(this, void 0);
43
- _BitVec_isMsb.set(this, void 0);
44
- tslib_1.__classPrivateFieldSet(this, _BitVec_decodedLength, decodedLength, "f");
45
- tslib_1.__classPrivateFieldSet(this, _BitVec_isMsb, isMsb, "f");
40
+ this.__internal__decodedLength = decodedLength;
41
+ this.__internal__isMsb = isMsb;
46
42
  }
47
43
  /**
48
44
  * @description The length of the value when encoded as a Uint8Array
49
45
  */
50
46
  get encodedLength() {
51
- return this.length + (0, util_1.compactToU8a)(tslib_1.__classPrivateFieldGet(this, _BitVec_decodedLength, "f")).length;
47
+ return this.length + (0, util_1.compactToU8a)(this.__internal__decodedLength).length;
52
48
  }
53
49
  /**
54
50
  * @description Returns a breakdown of the hex encoding for this Codec
55
51
  */
56
52
  inspect() {
57
53
  return {
58
- outer: [(0, util_1.compactToU8a)(tslib_1.__classPrivateFieldGet(this, _BitVec_decodedLength, "f")), super.toU8a()]
54
+ outer: [(0, util_1.compactToU8a)(this.__internal__decodedLength), super.toU8a()]
59
55
  };
60
56
  }
61
57
  /**
@@ -72,12 +68,13 @@ class BitVec extends Raw_js_1.Raw {
72
68
  !!(v & 2),
73
69
  !!(v & 1)
74
70
  ]);
75
- const result = new Array(8 * map.length);
76
- for (let i = 0; i < map.length; i++) {
71
+ const count = map.length;
72
+ const result = new Array(8 * count);
73
+ for (let i = 0; i < count; i++) {
77
74
  const off = i * 8;
78
75
  const v = map[i];
79
76
  for (let j = 0; j < 8; j++) {
80
- result[off + j] = tslib_1.__classPrivateFieldGet(this, _BitVec_isMsb, "f")
77
+ result[off + j] = this.__internal__isMsb
81
78
  ? v[j]
82
79
  : v[7 - j];
83
80
  }
@@ -90,7 +87,7 @@ class BitVec extends Raw_js_1.Raw {
90
87
  toHuman() {
91
88
  return `0b${[...this.toU8a(true)]
92
89
  .map((d) => `00000000${d.toString(2)}`.slice(-8))
93
- .map((s) => tslib_1.__classPrivateFieldGet(this, _BitVec_isMsb, "f") ? s : s.split('').reverse().join(''))
90
+ .map((s) => this.__internal__isMsb ? s : s.split('').reverse().join(''))
94
91
  .join('_')}`;
95
92
  }
96
93
  /**
@@ -107,8 +104,7 @@ class BitVec extends Raw_js_1.Raw {
107
104
  const bitVec = super.toU8a(isBare);
108
105
  return isBare
109
106
  ? bitVec
110
- : (0, util_1.u8aConcatStrict)([(0, util_1.compactToU8a)(tslib_1.__classPrivateFieldGet(this, _BitVec_decodedLength, "f")), bitVec]);
107
+ : (0, util_1.u8aConcatStrict)([(0, util_1.compactToU8a)(this.__internal__decodedLength), bitVec]);
111
108
  }
112
109
  }
113
110
  exports.BitVec = BitVec;
114
- _BitVec_decodedLength = new WeakMap(), _BitVec_isMsb = new WeakMap();
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _CodecMap_KeyClass, _CodecMap_ValClass, _CodecMap_type;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.CodecMap = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  const Array_js_1 = require("../abstract/Array.js");
8
6
  const Enum_js_1 = require("../base/Enum.js");
@@ -19,7 +17,7 @@ function decodeMapFromU8a(registry, KeyClass, ValClass, u8a) {
19
17
  types.push(KeyClass, ValClass);
20
18
  }
21
19
  const [values, decodedLength] = (0, index_js_1.decodeU8a)(registry, new Array(types.length), u8a.subarray(offset), [types, []]);
22
- for (let i = 0; i < values.length; i += 2) {
20
+ for (let i = 0, count = values.length; i < count; i += 2) {
23
21
  output.set(values[i], values[i + 1]);
24
22
  }
25
23
  return [KeyClass, ValClass, output, offset + decodedLength];
@@ -81,14 +79,11 @@ class CodecMap extends Map {
81
79
  constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
82
80
  const [KeyClass, ValClass, decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
83
81
  super(type === 'BTreeMap' ? (0, index_js_1.sortMap)(decoded) : decoded);
84
- _CodecMap_KeyClass.set(this, void 0);
85
- _CodecMap_ValClass.set(this, void 0);
86
- _CodecMap_type.set(this, void 0);
87
82
  this.registry = registry;
88
83
  this.initialU8aLength = decodedLength;
89
- tslib_1.__classPrivateFieldSet(this, _CodecMap_KeyClass, KeyClass, "f");
90
- tslib_1.__classPrivateFieldSet(this, _CodecMap_ValClass, ValClass, "f");
91
- tslib_1.__classPrivateFieldSet(this, _CodecMap_type, type, "f");
84
+ this.__internal__KeyClass = KeyClass;
85
+ this.__internal__ValClass = ValClass;
86
+ this.__internal__type = type;
92
87
  }
93
88
  /**
94
89
  * @description The length of the value when encoded as a Uint8Array
@@ -176,7 +171,7 @@ class CodecMap extends Map {
176
171
  * @description Returns the base runtime type name for this instance
177
172
  */
178
173
  toRawType() {
179
- return `${tslib_1.__classPrivateFieldGet(this, _CodecMap_type, "f")}<${this.registry.getClassName(tslib_1.__classPrivateFieldGet(this, _CodecMap_KeyClass, "f")) || new (tslib_1.__classPrivateFieldGet(this, _CodecMap_KeyClass, "f"))(this.registry).toRawType()},${this.registry.getClassName(tslib_1.__classPrivateFieldGet(this, _CodecMap_ValClass, "f")) || new (tslib_1.__classPrivateFieldGet(this, _CodecMap_ValClass, "f"))(this.registry).toRawType()}>`;
174
+ return `${this.__internal__type}<${this.registry.getClassName(this.__internal__KeyClass) || new this.__internal__KeyClass(this.registry).toRawType()},${this.registry.getClassName(this.__internal__ValClass) || new this.__internal__ValClass(this.registry).toRawType()}>`;
180
175
  }
181
176
  /**
182
177
  * @description Returns the string representation of the value
@@ -200,4 +195,3 @@ class CodecMap extends Map {
200
195
  }
201
196
  }
202
197
  exports.CodecMap = CodecMap;
203
- _CodecMap_KeyClass = new WeakMap(), _CodecMap_ValClass = new WeakMap(), _CodecMap_type = new WeakMap();
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _Range_rangeName;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.Range = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const Tuple_js_1 = require("../base/Tuple.js");
7
5
  /**
8
6
  * @name Range
@@ -12,8 +10,7 @@ const Tuple_js_1 = require("../base/Tuple.js");
12
10
  class Range extends Tuple_js_1.Tuple {
13
11
  constructor(registry, Type, value, { rangeName = 'Range' } = {}) {
14
12
  super(registry, [Type, Type], value);
15
- _Range_rangeName.set(this, void 0);
16
- tslib_1.__classPrivateFieldSet(this, _Range_rangeName, rangeName, "f");
13
+ this.__internal__rangeName = rangeName;
17
14
  }
18
15
  static with(Type) {
19
16
  return class extends Range {
@@ -38,8 +35,7 @@ class Range extends Tuple_js_1.Tuple {
38
35
  * @description Returns the base runtime type name for this instance
39
36
  */
40
37
  toRawType() {
41
- return `${tslib_1.__classPrivateFieldGet(this, _Range_rangeName, "f")}<${this.start.toRawType()}>`;
38
+ return `${this.__internal__rangeName}<${this.start.toRawType()}>`;
42
39
  }
43
40
  }
44
41
  exports.Range = Range;
45
- _Range_rangeName = new WeakMap();
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _WrapperKeepOpaque_Type, _WrapperKeepOpaque_decoded, _WrapperKeepOpaque_opaqueName;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.WrapperKeepOpaque = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  const Raw_js_1 = require("../native/Raw.js");
8
6
  const index_js_1 = require("../utils/index.js");
@@ -29,12 +27,9 @@ class WrapperKeepOpaque extends Bytes_js_1.Bytes {
29
27
  constructor(registry, typeName, value, { opaqueName = 'WrapperKeepOpaque' } = {}) {
30
28
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
31
29
  super(registry, u8a);
32
- _WrapperKeepOpaque_Type.set(this, void 0);
33
- _WrapperKeepOpaque_decoded.set(this, void 0);
34
- _WrapperKeepOpaque_opaqueName.set(this, void 0);
35
- tslib_1.__classPrivateFieldSet(this, _WrapperKeepOpaque_Type, Type, "f");
36
- tslib_1.__classPrivateFieldSet(this, _WrapperKeepOpaque_decoded, decoded, "f");
37
- tslib_1.__classPrivateFieldSet(this, _WrapperKeepOpaque_opaqueName, opaqueName, "f");
30
+ this.__internal__Type = Type;
31
+ this.__internal__decoded = decoded;
32
+ this.__internal__opaqueName = opaqueName;
38
33
  }
39
34
  static with(Type) {
40
35
  return class extends WrapperKeepOpaque {
@@ -47,15 +42,15 @@ class WrapperKeepOpaque extends Bytes_js_1.Bytes {
47
42
  * @description Checks if the wrapper is decodable
48
43
  */
49
44
  get isDecoded() {
50
- return !!tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f");
45
+ return !!this.__internal__decoded;
51
46
  }
52
47
  /**
53
48
  * @description Returns a breakdown of the hex encoding for this Codec
54
49
  */
55
50
  inspect() {
56
- return tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f")
51
+ return this.__internal__decoded
57
52
  ? {
58
- inner: [tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f").inspect()],
53
+ inner: [this.__internal__decoded.inspect()],
59
54
  outer: [(0, util_1.compactToU8a)(this.length)]
60
55
  }
61
56
  : {
@@ -66,41 +61,40 @@ class WrapperKeepOpaque extends Bytes_js_1.Bytes {
66
61
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
67
62
  */
68
63
  toHuman(isExtended) {
69
- return tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f")
70
- ? tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f").toHuman(isExtended)
64
+ return this.__internal__decoded
65
+ ? this.__internal__decoded.toHuman(isExtended)
71
66
  : super.toHuman();
72
67
  }
73
68
  /**
74
69
  * @description Converts the value in a best-fit primitive form
75
70
  */
76
71
  toPrimitive() {
77
- return tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f")
78
- ? tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f").toPrimitive()
72
+ return this.__internal__decoded
73
+ ? this.__internal__decoded.toPrimitive()
79
74
  : super.toPrimitive();
80
75
  }
81
76
  /**
82
77
  * @description Returns the base runtime type name for this instance
83
78
  */
84
79
  toRawType() {
85
- return `${tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_opaqueName, "f")}<${this.registry.getClassName(tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_Type, "f")) || (tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f") ? tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f").toRawType() : new (tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_Type, "f"))(this.registry).toRawType())}>`;
80
+ return `${this.__internal__opaqueName}<${this.registry.getClassName(this.__internal__Type) || (this.__internal__decoded ? this.__internal__decoded.toRawType() : new this.__internal__Type(this.registry).toRawType())}>`;
86
81
  }
87
82
  /**
88
83
  * @description Converts the Object to to a string (either decoded or bytes)
89
84
  */
90
85
  toString() {
91
- return tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f")
92
- ? tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f").toString()
86
+ return this.__internal__decoded
87
+ ? this.__internal__decoded.toString()
93
88
  : super.toString();
94
89
  }
95
90
  /**
96
91
  * @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
97
92
  */
98
93
  unwrap() {
99
- if (!tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f")) {
100
- throw new Error(`${tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_opaqueName, "f")}: unwrapping an undecodable value`);
94
+ if (!this.__internal__decoded) {
95
+ throw new Error(`${this.__internal__opaqueName}: unwrapping an undecodable value`);
101
96
  }
102
- return tslib_1.__classPrivateFieldGet(this, _WrapperKeepOpaque_decoded, "f");
97
+ return this.__internal__decoded;
103
98
  }
104
99
  }
105
100
  exports.WrapperKeepOpaque = WrapperKeepOpaque;
106
- _WrapperKeepOpaque_Type = new WeakMap(), _WrapperKeepOpaque_decoded = new WeakMap(), _WrapperKeepOpaque_opaqueName = new WeakMap();
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _Float_bitLength;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.Float = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  /**
8
6
  * @name Float
@@ -19,8 +17,7 @@ class Float extends Number {
19
17
  ? 0
20
18
  : (0, util_1.u8aToFloat)((0, util_1.u8aToU8a)(value), { bitLength })
21
19
  : (value || 0));
22
- _Float_bitLength.set(this, void 0);
23
- tslib_1.__classPrivateFieldSet(this, _Float_bitLength, bitLength, "f");
20
+ this.__internal__bitLength = bitLength;
24
21
  this.encodedLength = bitLength / 8;
25
22
  this.initialU8aLength = this.encodedLength;
26
23
  this.registry = registry;
@@ -94,16 +91,15 @@ class Float extends Number {
94
91
  * @description Returns the base runtime type name for this instance
95
92
  */
96
93
  toRawType() {
97
- return `f${tslib_1.__classPrivateFieldGet(this, _Float_bitLength, "f")}`;
94
+ return `f${this.__internal__bitLength}`;
98
95
  }
99
96
  /**
100
97
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
101
98
  */
102
99
  toU8a(_isBare) {
103
100
  return (0, util_1.floatToU8a)(this, {
104
- bitLength: tslib_1.__classPrivateFieldGet(this, _Float_bitLength, "f")
101
+ bitLength: this.__internal__bitLength
105
102
  });
106
103
  }
107
104
  }
108
105
  exports.Float = Float;
109
- _Float_bitLength = new WeakMap();
package/cjs/native/Set.js CHANGED
@@ -1,21 +1,20 @@
1
1
  "use strict";
2
- var _CodecSet_allowed, _CodecSet_byteLength;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.CodecSet = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  const index_js_1 = require("../utils/index.js");
8
6
  function encodeSet(setValues, values) {
9
7
  const encoded = new util_1.BN(0);
10
- for (let i = 0; i < values.length; i++) {
8
+ for (let i = 0, count = values.length; i < count; i++) {
11
9
  encoded.ior((0, util_1.bnToBn)(setValues[values[i]] || 0));
12
10
  }
13
11
  return encoded;
14
12
  }
15
13
  /** @internal */
16
14
  function decodeSetArray(setValues, values) {
17
- const result = new Array(values.length);
18
- for (let i = 0; i < values.length; i++) {
15
+ const count = values.length;
16
+ const result = new Array(count);
17
+ for (let i = 0; i < count; i++) {
19
18
  const key = values[i];
20
19
  if ((0, util_1.isUndefined)(setValues[key])) {
21
20
  throw new Error(`Set: Invalid key '${key}' passed to Set, allowed ${Object.keys(setValues).join(', ')}`);
@@ -29,7 +28,7 @@ function decodeSetNumber(setValues, _value) {
29
28
  const bn = (0, util_1.bnToBn)(_value);
30
29
  const keys = Object.keys(setValues);
31
30
  const result = [];
32
- for (let i = 0; i < keys.length; i++) {
31
+ for (let i = 0, count = keys.length; i < count; i++) {
33
32
  const key = keys[i];
34
33
  if (bn.and((0, util_1.bnToBn)(setValues[key])).eq((0, util_1.bnToBn)(setValues[key]))) {
35
34
  result.push(key);
@@ -72,8 +71,6 @@ function decodeSet(setValues, value = 0, bitLength) {
72
71
  class CodecSet extends Set {
73
72
  constructor(registry, setValues, value, bitLength = 8) {
74
73
  super(decodeSet(setValues, value, bitLength));
75
- _CodecSet_allowed.set(this, void 0);
76
- _CodecSet_byteLength.set(this, void 0);
77
74
  /**
78
75
  * @description adds a value to the Set (extended to allow for validity checking)
79
76
  */
@@ -81,15 +78,15 @@ class CodecSet extends Set {
81
78
  // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
82
79
  // we have the isUndefined(this._setValues) in here as well, add is used internally
83
80
  // in the Set constructor (so it is undefined at this point, and should allow)
84
- if (tslib_1.__classPrivateFieldGet(this, _CodecSet_allowed, "f") && (0, util_1.isUndefined)(tslib_1.__classPrivateFieldGet(this, _CodecSet_allowed, "f")[key])) {
81
+ if (this.__internal__allowed && (0, util_1.isUndefined)(this.__internal__allowed[key])) {
85
82
  throw new Error(`Set: Invalid key '${key}' on add`);
86
83
  }
87
84
  super.add(key);
88
85
  return this;
89
86
  };
90
87
  this.registry = registry;
91
- tslib_1.__classPrivateFieldSet(this, _CodecSet_allowed, setValues, "f");
92
- tslib_1.__classPrivateFieldSet(this, _CodecSet_byteLength, bitLength / 8, "f");
88
+ this.__internal__allowed = setValues;
89
+ this.__internal__byteLength = bitLength / 8;
93
90
  }
94
91
  static with(values, bitLength) {
95
92
  var _a;
@@ -100,8 +97,9 @@ class CodecSet extends Set {
100
97
  },
101
98
  (() => {
102
99
  const keys = Object.keys(values);
103
- const isKeys = new Array(keys.length);
104
- for (let i = 0; i < keys.length; i++) {
100
+ const count = keys.length;
101
+ const isKeys = new Array(count);
102
+ for (let i = 0; i < count; i++) {
105
103
  isKeys[i] = `is${(0, util_1.stringPascalCase)(keys[i])}`;
106
104
  }
107
105
  (0, util_1.objectProperties)(_a.prototype, isKeys, (_, i, self) => self.strings.includes(keys[i]));
@@ -112,7 +110,7 @@ class CodecSet extends Set {
112
110
  * @description The length of the value when encoded as a Uint8Array
113
111
  */
114
112
  get encodedLength() {
115
- return tslib_1.__classPrivateFieldGet(this, _CodecSet_byteLength, "f");
113
+ return this.__internal__byteLength;
116
114
  }
117
115
  /**
118
116
  * @description returns a hash of the contents
@@ -136,7 +134,7 @@ class CodecSet extends Set {
136
134
  * @description The encoded value for the set members
137
135
  */
138
136
  get valueEncoded() {
139
- return encodeSet(tslib_1.__classPrivateFieldGet(this, _CodecSet_allowed, "f"), this.strings);
137
+ return encodeSet(this.__internal__allowed, this.strings);
140
138
  }
141
139
  /**
142
140
  * @description Compares the value of the input to see if there is a match
@@ -196,7 +194,7 @@ class CodecSet extends Set {
196
194
  * @description Returns the base runtime type name for this instance
197
195
  */
198
196
  toRawType() {
199
- return (0, util_1.stringify)({ _set: tslib_1.__classPrivateFieldGet(this, _CodecSet_allowed, "f") });
197
+ return (0, util_1.stringify)({ _set: this.__internal__allowed });
200
198
  }
201
199
  /**
202
200
  * @description Returns the string representation of the value
@@ -209,10 +207,9 @@ class CodecSet extends Set {
209
207
  */
210
208
  toU8a(_isBare) {
211
209
  return (0, util_1.bnToU8a)(this.valueEncoded, {
212
- bitLength: tslib_1.__classPrivateFieldGet(this, _CodecSet_byteLength, "f") * 8,
210
+ bitLength: this.__internal__byteLength * 8,
213
211
  isLe: true
214
212
  });
215
213
  }
216
214
  }
217
215
  exports.CodecSet = CodecSet;
218
- _CodecSet_allowed = new WeakMap(), _CodecSet_byteLength = new WeakMap();
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _Struct_jsonMap, _Struct_Types;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.Struct = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  const index_js_1 = require("../utils/index.js");
8
6
  function noopSetDefinition(d) {
@@ -13,14 +11,15 @@ function decodeStructFromObject(registry, [Types, keys], value, jsonMap) {
13
11
  let jsonObj;
14
12
  const typeofArray = Array.isArray(value);
15
13
  const typeofMap = value instanceof Map;
14
+ const count = keys.length;
16
15
  if (!typeofArray && !typeofMap && !(0, util_1.isObject)(value)) {
17
16
  throw new Error(`Struct: Cannot decode value ${(0, util_1.stringify)(value)} (typeof ${typeof value}), expected an input object, map or array`);
18
17
  }
19
- else if (typeofArray && value.length !== keys.length) {
18
+ else if (typeofArray && value.length !== count) {
20
19
  throw new Error(`Struct: Unable to map ${(0, util_1.stringify)(value)} array to object with known keys ${keys.join(', ')}`);
21
20
  }
22
- const raw = new Array(keys.length);
23
- for (let i = 0; i < keys.length; i++) {
21
+ const raw = new Array(count);
22
+ for (let i = 0; i < count; i++) {
24
23
  const key = keys[i];
25
24
  const jsonKey = jsonMap.get(key) || key;
26
25
  const Type = Types[i];
@@ -38,7 +37,7 @@ function decodeStructFromObject(registry, [Types, keys], value, jsonMap) {
38
37
  if ((0, util_1.isUndefined)(jsonObj)) {
39
38
  const entries = Object.entries(value);
40
39
  jsonObj = {};
41
- for (let e = 0; e < entries.length; e++) {
40
+ for (let e = 0, ecount = entries.length; e < ecount; e++) {
42
41
  jsonObj[(0, util_1.stringCamelCase)(entries[e][0])] = entries[e][1];
43
42
  }
44
43
  }
@@ -84,12 +83,10 @@ class Struct extends Map {
84
83
  ? [value, 0]
85
84
  : decodeStructFromObject(registry, typeMap, value || {}, jsonMap);
86
85
  super(decoded);
87
- _Struct_jsonMap.set(this, void 0);
88
- _Struct_Types.set(this, void 0);
89
86
  this.initialU8aLength = decodedLength;
90
87
  this.registry = registry;
91
- tslib_1.__classPrivateFieldSet(this, _Struct_jsonMap, jsonMap, "f");
92
- tslib_1.__classPrivateFieldSet(this, _Struct_Types, typeMap, "f");
88
+ this.__internal__jsonMap = jsonMap;
89
+ this.__internal__Types = typeMap;
93
90
  }
94
91
  static with(Types, jsonMap) {
95
92
  var _a;
@@ -111,7 +108,7 @@ class Struct extends Map {
111
108
  * @description The available keys for this struct
112
109
  */
113
110
  get defKeys() {
114
- return tslib_1.__classPrivateFieldGet(this, _Struct_Types, "f")[1];
111
+ return this.__internal__Types[1];
115
112
  }
116
113
  /**
117
114
  * @description Checks if the value is an empty value
@@ -145,8 +142,8 @@ class Struct extends Map {
145
142
  */
146
143
  get Type() {
147
144
  const result = {};
148
- const [Types, keys] = tslib_1.__classPrivateFieldGet(this, _Struct_Types, "f");
149
- for (let i = 0; i < keys.length; i++) {
145
+ const [Types, keys] = this.__internal__Types;
146
+ for (let i = 0, count = keys.length; i < count; i++) {
150
147
  result[keys[i]] = new Types[i](this.registry).toRawType();
151
148
  }
152
149
  return result;
@@ -223,7 +220,7 @@ class Struct extends Map {
223
220
  for (const [k, v] of this.entries()) {
224
221
  // Here we pull out the entry against the JSON mapping (if supplied)
225
222
  // since this representation goes over RPC and needs to be correct
226
- json[(tslib_1.__classPrivateFieldGet(this, _Struct_jsonMap, "f").get(k) || k)] = v.toJSON();
223
+ json[(this.__internal__jsonMap.get(k) || k)] = v.toJSON();
227
224
  }
228
225
  return json;
229
226
  }
@@ -241,7 +238,7 @@ class Struct extends Map {
241
238
  * @description Returns the base runtime type name for this instance
242
239
  */
243
240
  toRawType() {
244
- return (0, util_1.stringify)((0, index_js_1.typesToMap)(this.registry, tslib_1.__classPrivateFieldGet(this, _Struct_Types, "f")));
241
+ return (0, util_1.stringify)((0, index_js_1.typesToMap)(this.registry, this.__internal__Types));
245
242
  }
246
243
  /**
247
244
  * @description Returns the string representation of the value
@@ -264,4 +261,3 @@ class Struct extends Map {
264
261
  }
265
262
  }
266
263
  exports.Struct = Struct;
267
- _Struct_jsonMap = new WeakMap(), _Struct_Types = new WeakMap();
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
- var _Text_override;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.Text = void 0;
5
- const tslib_1 = require("tslib");
6
4
  const util_1 = require("@polkadot/util");
7
5
  const Raw_js_1 = require("./Raw.js");
8
6
  const MAX_LENGTH = 128 * 1024;
@@ -44,7 +42,7 @@ class Text extends String {
44
42
  constructor(registry, value) {
45
43
  const [str, decodedLength] = decodeText(value);
46
44
  super(str);
47
- _Text_override.set(this, null);
45
+ this.__internal__override = null;
48
46
  this.registry = registry;
49
47
  this.initialU8aLength = decodedLength;
50
48
  }
@@ -96,7 +94,7 @@ class Text extends String {
96
94
  * @description Set an override value for this
97
95
  */
98
96
  setOverride(override) {
99
- tslib_1.__classPrivateFieldSet(this, _Text_override, override, "f");
97
+ this.__internal__override = override;
100
98
  }
101
99
  /**
102
100
  * @description Returns a hex string representation of the value
@@ -134,7 +132,7 @@ class Text extends String {
134
132
  * @description Returns the string representation of the value
135
133
  */
136
134
  toString() {
137
- return tslib_1.__classPrivateFieldGet(this, _Text_override, "f") || super.toString();
135
+ return this.__internal__override || super.toString();
138
136
  }
139
137
  /**
140
138
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
@@ -150,4 +148,3 @@ class Text extends String {
150
148
  }
151
149
  }
152
150
  exports.Text = Text;
153
- _Text_override = new WeakMap();
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Text = exports.Struct = exports.Set = exports.CodecSet = exports.Raw = exports.Json = exports.Float = exports.Date = exports.CodecDate = exports.Bool = exports.bool = void 0;
3
+ exports.Text = exports.Struct = exports.Set = exports.CodecSet = exports.Raw = exports.Json = exports.Float = exports.Date = exports.CodecDate = exports.bool = exports.Bool = void 0;
4
4
  var Bool_js_1 = require("./Bool.js");
5
- Object.defineProperty(exports, "bool", { enumerable: true, get: function () { return Bool_js_1.bool; } });
6
5
  Object.defineProperty(exports, "Bool", { enumerable: true, get: function () { return Bool_js_1.bool; } });
6
+ Object.defineProperty(exports, "bool", { enumerable: true, get: function () { return Bool_js_1.bool; } });
7
7
  var Date_js_1 = require("./Date.js");
8
8
  Object.defineProperty(exports, "CodecDate", { enumerable: true, get: function () { return Date_js_1.CodecDate; } });
9
9
  Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return Date_js_1.CodecDate; } });
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.3.4' };
4
+ exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.5.1' };
@@ -1,51 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USize = exports.usize = exports.U256 = exports.u256 = exports.U128 = exports.u128 = exports.U64 = exports.u64 = exports.U32 = exports.u32 = exports.U16 = exports.u16 = exports.U8 = exports.u8 = exports.ISize = exports.isize = exports.I256 = exports.i256 = exports.I128 = exports.i128 = exports.I64 = exports.i64 = exports.I32 = exports.i32 = exports.I16 = exports.i16 = exports.I8 = exports.i8 = exports.F64 = exports.f64 = exports.F32 = exports.f32 = void 0;
3
+ exports.usize = exports.USize = exports.u256 = exports.U256 = exports.u128 = exports.U128 = exports.u64 = exports.U64 = exports.u32 = exports.U32 = exports.u16 = exports.U16 = exports.u8 = exports.U8 = exports.isize = exports.ISize = exports.i256 = exports.I256 = exports.i128 = exports.I128 = exports.i64 = exports.I64 = exports.i32 = exports.I32 = exports.i16 = exports.I16 = exports.i8 = exports.I8 = exports.f64 = exports.F64 = exports.f32 = exports.F32 = void 0;
4
4
  var F32_js_1 = require("./F32.js");
5
- Object.defineProperty(exports, "f32", { enumerable: true, get: function () { return F32_js_1.f32; } });
6
5
  Object.defineProperty(exports, "F32", { enumerable: true, get: function () { return F32_js_1.f32; } });
6
+ Object.defineProperty(exports, "f32", { enumerable: true, get: function () { return F32_js_1.f32; } });
7
7
  var F64_js_1 = require("./F64.js");
8
- Object.defineProperty(exports, "f64", { enumerable: true, get: function () { return F64_js_1.f64; } });
9
8
  Object.defineProperty(exports, "F64", { enumerable: true, get: function () { return F64_js_1.f64; } });
9
+ Object.defineProperty(exports, "f64", { enumerable: true, get: function () { return F64_js_1.f64; } });
10
10
  var I8_js_1 = require("./I8.js");
11
- Object.defineProperty(exports, "i8", { enumerable: true, get: function () { return I8_js_1.i8; } });
12
11
  Object.defineProperty(exports, "I8", { enumerable: true, get: function () { return I8_js_1.i8; } });
12
+ Object.defineProperty(exports, "i8", { enumerable: true, get: function () { return I8_js_1.i8; } });
13
13
  var I16_js_1 = require("./I16.js");
14
- Object.defineProperty(exports, "i16", { enumerable: true, get: function () { return I16_js_1.i16; } });
15
14
  Object.defineProperty(exports, "I16", { enumerable: true, get: function () { return I16_js_1.i16; } });
15
+ Object.defineProperty(exports, "i16", { enumerable: true, get: function () { return I16_js_1.i16; } });
16
16
  var I32_js_1 = require("./I32.js");
17
- Object.defineProperty(exports, "i32", { enumerable: true, get: function () { return I32_js_1.i32; } });
18
17
  Object.defineProperty(exports, "I32", { enumerable: true, get: function () { return I32_js_1.i32; } });
18
+ Object.defineProperty(exports, "i32", { enumerable: true, get: function () { return I32_js_1.i32; } });
19
19
  var I64_js_1 = require("./I64.js");
20
- Object.defineProperty(exports, "i64", { enumerable: true, get: function () { return I64_js_1.i64; } });
21
20
  Object.defineProperty(exports, "I64", { enumerable: true, get: function () { return I64_js_1.i64; } });
21
+ Object.defineProperty(exports, "i64", { enumerable: true, get: function () { return I64_js_1.i64; } });
22
22
  var I128_js_1 = require("./I128.js");
23
- Object.defineProperty(exports, "i128", { enumerable: true, get: function () { return I128_js_1.i128; } });
24
23
  Object.defineProperty(exports, "I128", { enumerable: true, get: function () { return I128_js_1.i128; } });
24
+ Object.defineProperty(exports, "i128", { enumerable: true, get: function () { return I128_js_1.i128; } });
25
25
  var I256_js_1 = require("./I256.js");
26
- Object.defineProperty(exports, "i256", { enumerable: true, get: function () { return I256_js_1.i256; } });
27
26
  Object.defineProperty(exports, "I256", { enumerable: true, get: function () { return I256_js_1.i256; } });
27
+ Object.defineProperty(exports, "i256", { enumerable: true, get: function () { return I256_js_1.i256; } });
28
28
  var ISize_js_1 = require("./ISize.js");
29
- Object.defineProperty(exports, "isize", { enumerable: true, get: function () { return ISize_js_1.isize; } });
30
29
  Object.defineProperty(exports, "ISize", { enumerable: true, get: function () { return ISize_js_1.isize; } });
30
+ Object.defineProperty(exports, "isize", { enumerable: true, get: function () { return ISize_js_1.isize; } });
31
31
  var U8_js_1 = require("./U8.js");
32
- Object.defineProperty(exports, "u8", { enumerable: true, get: function () { return U8_js_1.u8; } });
33
32
  Object.defineProperty(exports, "U8", { enumerable: true, get: function () { return U8_js_1.u8; } });
33
+ Object.defineProperty(exports, "u8", { enumerable: true, get: function () { return U8_js_1.u8; } });
34
34
  var U16_js_1 = require("./U16.js");
35
- Object.defineProperty(exports, "u16", { enumerable: true, get: function () { return U16_js_1.u16; } });
36
35
  Object.defineProperty(exports, "U16", { enumerable: true, get: function () { return U16_js_1.u16; } });
36
+ Object.defineProperty(exports, "u16", { enumerable: true, get: function () { return U16_js_1.u16; } });
37
37
  var U32_js_1 = require("./U32.js");
38
- Object.defineProperty(exports, "u32", { enumerable: true, get: function () { return U32_js_1.u32; } });
39
38
  Object.defineProperty(exports, "U32", { enumerable: true, get: function () { return U32_js_1.u32; } });
39
+ Object.defineProperty(exports, "u32", { enumerable: true, get: function () { return U32_js_1.u32; } });
40
40
  var U64_js_1 = require("./U64.js");
41
- Object.defineProperty(exports, "u64", { enumerable: true, get: function () { return U64_js_1.u64; } });
42
41
  Object.defineProperty(exports, "U64", { enumerable: true, get: function () { return U64_js_1.u64; } });
42
+ Object.defineProperty(exports, "u64", { enumerable: true, get: function () { return U64_js_1.u64; } });
43
43
  var U128_js_1 = require("./U128.js");
44
- Object.defineProperty(exports, "u128", { enumerable: true, get: function () { return U128_js_1.u128; } });
45
44
  Object.defineProperty(exports, "U128", { enumerable: true, get: function () { return U128_js_1.u128; } });
45
+ Object.defineProperty(exports, "u128", { enumerable: true, get: function () { return U128_js_1.u128; } });
46
46
  var U256_js_1 = require("./U256.js");
47
- Object.defineProperty(exports, "u256", { enumerable: true, get: function () { return U256_js_1.u256; } });
48
47
  Object.defineProperty(exports, "U256", { enumerable: true, get: function () { return U256_js_1.u256; } });
48
+ Object.defineProperty(exports, "u256", { enumerable: true, get: function () { return U256_js_1.u256; } });
49
49
  var USize_js_1 = require("./USize.js");
50
- Object.defineProperty(exports, "usize", { enumerable: true, get: function () { return USize_js_1.usize; } });
51
50
  Object.defineProperty(exports, "USize", { enumerable: true, get: function () { return USize_js_1.usize; } });
51
+ Object.defineProperty(exports, "usize", { enumerable: true, get: function () { return USize_js_1.usize; } });