@polkadot/types-codec 10.9.1 → 10.11.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 (86) hide show
  1. package/abstract/Array.js +4 -0
  2. package/abstract/Base.js +5 -0
  3. package/abstract/Int.js +7 -0
  4. package/abstract/Object.js +5 -0
  5. package/base/Compact.js +6 -0
  6. package/base/DoNotConstruct.js +4 -0
  7. package/base/Enum.d.ts +1 -3
  8. package/base/Enum.js +20 -12
  9. package/base/Null.js +6 -3
  10. package/base/Option.js +7 -1
  11. package/base/Tuple.d.ts +1 -3
  12. package/base/Tuple.js +1 -0
  13. package/base/Vec.js +1 -0
  14. package/base/VecFixed.js +1 -0
  15. package/cjs/abstract/Array.js +4 -0
  16. package/cjs/abstract/Base.js +5 -0
  17. package/cjs/abstract/Int.js +7 -0
  18. package/cjs/abstract/Object.js +5 -0
  19. package/cjs/base/Compact.js +6 -0
  20. package/cjs/base/DoNotConstruct.js +4 -0
  21. package/cjs/base/Enum.js +20 -12
  22. package/cjs/base/Null.js +6 -3
  23. package/cjs/base/Option.js +7 -1
  24. package/cjs/base/Tuple.js +1 -0
  25. package/cjs/base/Vec.js +1 -0
  26. package/cjs/base/VecFixed.js +1 -0
  27. package/cjs/extended/BTreeSet.js +5 -0
  28. package/cjs/extended/BitVec.js +3 -1
  29. package/cjs/extended/Map.js +7 -0
  30. package/cjs/extended/OptionBool.js +1 -1
  31. package/cjs/extended/Range.js +1 -0
  32. package/cjs/extended/WrapperKeepOpaque.js +3 -0
  33. package/cjs/native/Bool.js +5 -2
  34. package/cjs/native/Date.js +4 -1
  35. package/cjs/native/Float.js +6 -0
  36. package/cjs/native/Json.js +5 -1
  37. package/cjs/native/Raw.js +4 -0
  38. package/cjs/native/Set.js +27 -23
  39. package/cjs/native/Struct.js +14 -10
  40. package/cjs/native/Text.js +5 -1
  41. package/cjs/packageInfo.js +1 -1
  42. package/cjs/primitive/F32.js +2 -5
  43. package/cjs/primitive/F64.js +2 -5
  44. package/cjs/primitive/I128.js +2 -5
  45. package/cjs/primitive/I16.js +2 -5
  46. package/cjs/primitive/I256.js +2 -5
  47. package/cjs/primitive/I32.js +2 -5
  48. package/cjs/primitive/I64.js +2 -5
  49. package/cjs/primitive/I8.js +2 -5
  50. package/cjs/primitive/U128.js +2 -5
  51. package/cjs/primitive/U16.js +2 -5
  52. package/cjs/primitive/U256.js +2 -5
  53. package/cjs/primitive/U32.js +2 -5
  54. package/cjs/primitive/U64.js +2 -5
  55. package/cjs/primitive/U8.js +2 -5
  56. package/extended/BTreeSet.js +5 -0
  57. package/extended/BitVec.js +3 -1
  58. package/extended/Map.js +7 -0
  59. package/extended/OptionBool.js +1 -1
  60. package/extended/Range.js +1 -0
  61. package/extended/WrapperKeepOpaque.js +3 -0
  62. package/native/Bool.js +5 -2
  63. package/native/Date.js +4 -1
  64. package/native/Float.js +6 -0
  65. package/native/Json.js +5 -1
  66. package/native/Raw.js +4 -0
  67. package/native/Set.js +27 -23
  68. package/native/Struct.d.ts +1 -1
  69. package/native/Struct.js +14 -10
  70. package/native/Text.js +5 -1
  71. package/package.json +5 -5
  72. package/packageInfo.js +1 -1
  73. package/primitive/F32.js +2 -5
  74. package/primitive/F64.js +2 -5
  75. package/primitive/I128.js +2 -5
  76. package/primitive/I16.js +2 -5
  77. package/primitive/I256.js +2 -5
  78. package/primitive/I32.js +2 -5
  79. package/primitive/I64.js +2 -5
  80. package/primitive/I8.js +2 -5
  81. package/primitive/U128.js +2 -5
  82. package/primitive/U16.js +2 -5
  83. package/primitive/U256.js +2 -5
  84. package/primitive/U32.js +2 -5
  85. package/primitive/U64.js +2 -5
  86. package/primitive/U8.js +2 -5
package/cjs/native/Set.js CHANGED
@@ -69,42 +69,33 @@ function decodeSet(setValues, value = 0, bitLength) {
69
69
  * a bitwise representation of the values.
70
70
  */
71
71
  class CodecSet extends Set {
72
+ registry;
73
+ createdAtHash;
74
+ initialU8aLength;
75
+ isStorageFallback;
76
+ __internal__allowed;
77
+ __internal__byteLength;
72
78
  constructor(registry, setValues, value, bitLength = 8) {
73
79
  super(decodeSet(setValues, value, bitLength));
74
- /**
75
- * @description adds a value to the Set (extended to allow for validity checking)
76
- */
77
- this.add = (key) => {
78
- // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
79
- // we have the isUndefined(this._setValues) in here as well, add is used internally
80
- // in the Set constructor (so it is undefined at this point, and should allow)
81
- if (this.__internal__allowed && (0, util_1.isUndefined)(this.__internal__allowed[key])) {
82
- throw new Error(`Set: Invalid key '${key}' on add`);
83
- }
84
- super.add(key);
85
- return this;
86
- };
87
80
  this.registry = registry;
88
81
  this.__internal__allowed = setValues;
89
82
  this.__internal__byteLength = bitLength / 8;
90
83
  }
91
84
  static with(values, bitLength) {
92
- var _a;
93
- return _a = class extends CodecSet {
94
- constructor(registry, value) {
95
- super(registry, values, value, bitLength);
96
- }
97
- },
98
- (() => {
85
+ return class extends CodecSet {
86
+ static {
99
87
  const keys = Object.keys(values);
100
88
  const count = keys.length;
101
89
  const isKeys = new Array(count);
102
90
  for (let i = 0; i < count; i++) {
103
91
  isKeys[i] = `is${(0, util_1.stringPascalCase)(keys[i])}`;
104
92
  }
105
- (0, util_1.objectProperties)(_a.prototype, isKeys, (_, i, self) => self.strings.includes(keys[i]));
106
- })(),
107
- _a;
93
+ (0, util_1.objectProperties)(this.prototype, isKeys, (_, i, self) => self.strings.includes(keys[i]));
94
+ }
95
+ constructor(registry, value) {
96
+ super(registry, values, value, bitLength);
97
+ }
98
+ };
108
99
  }
109
100
  /**
110
101
  * @description The length of the value when encoded as a Uint8Array
@@ -136,6 +127,19 @@ class CodecSet extends Set {
136
127
  get valueEncoded() {
137
128
  return encodeSet(this.__internal__allowed, this.strings);
138
129
  }
130
+ /**
131
+ * @description adds a value to the Set (extended to allow for validity checking)
132
+ */
133
+ add = (key) => {
134
+ // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
135
+ // we have the isUndefined(this._setValues) in here as well, add is used internally
136
+ // in the Set constructor (so it is undefined at this point, and should allow)
137
+ if (this.__internal__allowed && (0, util_1.isUndefined)(this.__internal__allowed[key])) {
138
+ throw new Error(`Set: Invalid key '${key}' on add`);
139
+ }
140
+ super.add(key);
141
+ return this;
142
+ };
139
143
  /**
140
144
  * @description Compares the value of the input to see if there is a match
141
145
  */
@@ -75,6 +75,12 @@ function decodeStructFromObject(registry, [Types, keys], value, jsonMap) {
75
75
  * @noInheritDoc
76
76
  */
77
77
  class Struct extends Map {
78
+ registry;
79
+ createdAtHash;
80
+ initialU8aLength;
81
+ isStorageFallback;
82
+ __internal__jsonMap;
83
+ __internal__Types;
78
84
  constructor(registry, Types, value, jsonMap = new Map(), { definition, setDefinition = noopSetDefinition } = {}) {
79
85
  const typeMap = definition || setDefinition((0, index_js_1.mapToTypeMap)(registry, Types));
80
86
  const [decoded, decodedLength] = (0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
@@ -89,20 +95,18 @@ class Struct extends Map {
89
95
  this.__internal__Types = typeMap;
90
96
  }
91
97
  static with(Types, jsonMap) {
92
- var _a;
93
98
  let definition;
94
99
  // eslint-disable-next-line no-return-assign
95
100
  const setDefinition = (d) => definition = d;
96
- return _a = class extends Struct {
97
- constructor(registry, value) {
98
- super(registry, Types, value, jsonMap, { definition, setDefinition });
99
- }
100
- },
101
- (() => {
101
+ return class extends Struct {
102
+ static {
102
103
  const keys = Object.keys(Types);
103
- (0, util_1.objectProperties)(_a.prototype, keys, (k, _, self) => self.get(k));
104
- })(),
105
- _a;
104
+ (0, util_1.objectProperties)(this.prototype, keys, (k, _, self) => self.get(k));
105
+ }
106
+ constructor(registry, value) {
107
+ super(registry, Types, value, jsonMap, { definition, setDefinition });
108
+ }
109
+ };
106
110
  }
107
111
  /**
108
112
  * @description The available keys for this struct
@@ -39,10 +39,14 @@ function decodeText(value) {
39
39
  * @noInheritDoc
40
40
  */
41
41
  class Text extends String {
42
+ registry;
43
+ createdAtHash;
44
+ initialU8aLength;
45
+ isStorageFallback;
46
+ __internal__override = null;
42
47
  constructor(registry, value) {
43
48
  const [str, decodedLength] = decodeText(value);
44
49
  super(str);
45
- this.__internal__override = null;
46
50
  this.registry = registry;
47
51
  this.initialU8aLength = decodedLength;
48
52
  }
@@ -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.9.1' };
4
+ exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.11.1' };
@@ -8,10 +8,7 @@ const Float_js_1 = require("../native/Float.js");
8
8
  * A 32-bit float
9
9
  */
10
10
  class f32 extends Float_js_1.Float.with(32) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__FloatType = 'f32';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __FloatType = 'f32';
16
13
  }
17
14
  exports.f32 = f32;
@@ -8,10 +8,7 @@ const Float_js_1 = require("../native/Float.js");
8
8
  * A 64-bit float
9
9
  */
10
10
  class f64 extends Float_js_1.Float.with(64) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__FloatType = 'f64';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __FloatType = 'f64';
16
13
  }
17
14
  exports.f64 = f64;
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
8
8
  * A 128-bit signed integer
9
9
  */
10
10
  class i128 extends Int_js_1.Int.with(128) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__IntType = 'i128';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __IntType = 'i128';
16
13
  }
17
14
  exports.i128 = i128;
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
8
8
  * A 16-bit signed integer
9
9
  */
10
10
  class i16 extends Int_js_1.Int.with(16) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__IntType = 'i16';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __IntType = 'i16';
16
13
  }
17
14
  exports.i16 = i16;
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
8
8
  * A 256-bit signed integer
9
9
  */
10
10
  class i256 extends Int_js_1.Int.with(256) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__IntType = 'i256';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __IntType = 'i256';
16
13
  }
17
14
  exports.i256 = i256;
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
8
8
  * A 32-bit signed integer
9
9
  */
10
10
  class i32 extends Int_js_1.Int.with(32) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__IntType = 'i32';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __IntType = 'i32';
16
13
  }
17
14
  exports.i32 = i32;
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
8
8
  * A 64-bit signed integer
9
9
  */
10
10
  class i64 extends Int_js_1.Int.with(64) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__IntType = 'i64';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __IntType = 'i64';
16
13
  }
17
14
  exports.i64 = i64;
@@ -8,10 +8,7 @@ const Int_js_1 = require("../base/Int.js");
8
8
  * An 8-bit signed integer
9
9
  */
10
10
  class i8 extends Int_js_1.Int.with(8) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__IntType = 'i8';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __IntType = 'i8';
16
13
  }
17
14
  exports.i8 = i8;
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
8
8
  * A 128-bit unsigned integer
9
9
  */
10
10
  class u128 extends UInt_js_1.UInt.with(128) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__UIntType = 'u128';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __UIntType = 'u128';
16
13
  }
17
14
  exports.u128 = u128;
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
8
8
  * A 16-bit unsigned integer
9
9
  */
10
10
  class u16 extends UInt_js_1.UInt.with(16) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__UIntType = 'u16';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __UIntType = 'u16';
16
13
  }
17
14
  exports.u16 = u16;
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
8
8
  * A 256-bit unsigned integer
9
9
  */
10
10
  class u256 extends UInt_js_1.UInt.with(256) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__UIntType = 'u256';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __UIntType = 'u256';
16
13
  }
17
14
  exports.u256 = u256;
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
8
8
  * A 32-bit unsigned integer
9
9
  */
10
10
  class u32 extends UInt_js_1.UInt.with(32) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__UIntType = 'u32';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __UIntType = 'u32';
16
13
  }
17
14
  exports.u32 = u32;
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
8
8
  * A 64-bit unsigned integer
9
9
  */
10
10
  class u64 extends UInt_js_1.UInt.with(64) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__UIntType = 'u64';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __UIntType = 'u64';
16
13
  }
17
14
  exports.u64 = u64;
@@ -8,10 +8,7 @@ const UInt_js_1 = require("../base/UInt.js");
8
8
  * An 8-bit unsigned integer
9
9
  */
10
10
  class u8 extends UInt_js_1.UInt.with(8) {
11
- constructor() {
12
- super(...arguments);
13
- // NOTE without this, we cannot properly determine extensions
14
- this.__UIntType = 'u8';
15
- }
11
+ // NOTE without this, we cannot properly determine extensions
12
+ __UIntType = 'u8';
16
13
  }
17
14
  exports.u8 = u8;
@@ -54,6 +54,11 @@ function decodeSet(registry, valType, value) {
54
54
  throw new Error('BTreeSet: cannot decode type');
55
55
  }
56
56
  export class BTreeSet extends Set {
57
+ registry;
58
+ createdAtHash;
59
+ initialU8aLength;
60
+ isStorageFallback;
61
+ __internal__ValClass;
57
62
  constructor(registry, valType, rawValue) {
58
63
  const [ValClass, values, decodedLength] = decodeSet(registry, valType, rawValue);
59
64
  super(sortSet(values));
@@ -2,7 +2,7 @@ import { compactFromU8aLim, compactToU8a, isString, u8aConcatStrict, u8aToU8a }
2
2
  import { Raw } from '../native/Raw.js';
3
3
  /** @internal */
4
4
  function decodeBitVecU8a(value) {
5
- if (!value || !value.length) {
5
+ if (!value?.length) {
6
6
  return [0, new Uint8Array()];
7
7
  }
8
8
  // handle all other Uint8Array inputs, these do have a length prefix which is the number of bits encoded
@@ -28,6 +28,8 @@ function decodeBitVec(value) {
28
28
  * and a normal Bytes would be that the length prefix indicates the number of bits encoded, not the bytes
29
29
  */
30
30
  export class BitVec extends Raw {
31
+ __internal__decodedLength;
32
+ __internal__isMsb;
31
33
  // In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
32
34
  // we are dealing with Lsb, which is the default (as of writing) BitVec format used
33
35
  // in the Polkadot code (this only affects the toHuman displays)
package/extended/Map.js CHANGED
@@ -73,6 +73,13 @@ function decodeMap(registry, keyType, valType, value) {
73
73
  throw new Error('Map: cannot decode type');
74
74
  }
75
75
  export class CodecMap extends Map {
76
+ registry;
77
+ createdAtHash;
78
+ initialU8aLength;
79
+ isStorageFallback;
80
+ __internal__KeyClass;
81
+ __internal__ValClass;
82
+ __internal__type;
76
83
  constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
77
84
  const [KeyClass, ValClass, decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
78
85
  super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
@@ -25,7 +25,7 @@ export class OptionBool extends Option {
25
25
  * @description The length of the value when encoded as a Uint8Array
26
26
  */
27
27
  get encodedLength() {
28
- return 1;
28
+ return 1 | 0;
29
29
  }
30
30
  /**
31
31
  * @description Checks if the value is an empty value (always false)
package/extended/Range.js CHANGED
@@ -5,6 +5,7 @@ import { Tuple } from '../base/Tuple.js';
5
5
  * Rust `Range<T>` representation
6
6
  */
7
7
  export class Range extends Tuple {
8
+ __internal__rangeName;
8
9
  constructor(registry, Type, value, { rangeName = 'Range' } = {}) {
9
10
  super(registry, [Type, Type], value);
10
11
  this.__internal__rangeName = rangeName;
@@ -21,6 +21,9 @@ function decodeRaw(registry, typeName, value) {
21
21
  return [Type, instance, compactAddLength(instance.toU8a())];
22
22
  }
23
23
  export class WrapperKeepOpaque extends Bytes {
24
+ __internal__Type;
25
+ __internal__decoded;
26
+ __internal__opaqueName;
24
27
  constructor(registry, typeName, value, { opaqueName = 'WrapperKeepOpaque' } = {}) {
25
28
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
26
29
  super(registry, u8a);
package/native/Bool.js CHANGED
@@ -6,20 +6,23 @@ import { isU8a, u8aToHex } from '@polkadot/util';
6
6
  * @noInheritDoc
7
7
  */
8
8
  export class bool extends Boolean {
9
+ registry;
10
+ createdAtHash;
11
+ initialU8aLength = 1;
12
+ isStorageFallback;
9
13
  constructor(registry, value = false) {
10
14
  super(isU8a(value)
11
15
  ? value[0] === 1
12
16
  : value instanceof Boolean
13
17
  ? value.valueOf()
14
18
  : !!value);
15
- this.initialU8aLength = 1;
16
19
  this.registry = registry;
17
20
  }
18
21
  /**
19
22
  * @description The length of the value when encoded as a Uint8Array
20
23
  */
21
24
  get encodedLength() {
22
- return 1;
25
+ return 1 | 0;
23
26
  }
24
27
  /**
25
28
  * @description returns a hash of the contents
package/native/Date.js CHANGED
@@ -24,9 +24,12 @@ function decodeDate(value) {
24
24
  * @noInheritDoc
25
25
  */
26
26
  export class CodecDate extends Date {
27
+ registry;
28
+ createdAtHash;
29
+ initialU8aLength = BITLENGTH / 8;
30
+ isStorageFallback;
27
31
  constructor(registry, value = 0) {
28
32
  super(decodeDate(value));
29
- this.initialU8aLength = BITLENGTH / 8;
30
33
  this.registry = registry;
31
34
  }
32
35
  /**
package/native/Float.js CHANGED
@@ -8,6 +8,12 @@ import { floatToU8a, isHex, isU8a, u8aToFloat, u8aToHex, u8aToU8a } from '@polka
8
8
  * in some eth_* RPCs
9
9
  */
10
10
  export class Float extends Number {
11
+ encodedLength;
12
+ registry;
13
+ createdAtHash;
14
+ initialU8aLength;
15
+ isStorageFallback;
16
+ __internal__bitLength;
11
17
  constructor(registry, value, { bitLength = 32 } = {}) {
12
18
  super(isU8a(value) || isHex(value)
13
19
  ? value.length === 0
package/native/Json.js CHANGED
@@ -13,6 +13,10 @@ function decodeJson(value) {
13
13
  * @noInheritDoc
14
14
  */
15
15
  export class Json extends Map {
16
+ registry;
17
+ createdAtHash;
18
+ initialU8aLength;
19
+ isStorageFallback;
16
20
  constructor(registry, value) {
17
21
  const decoded = decodeJson(value);
18
22
  super(decoded);
@@ -23,7 +27,7 @@ export class Json extends Map {
23
27
  * @description Always 0, never encodes as a Uint8Array
24
28
  */
25
29
  get encodedLength() {
26
- return 0;
30
+ return 0 | 0;
27
31
  }
28
32
  /**
29
33
  * @description returns a hash of the contents
package/native/Raw.js CHANGED
@@ -9,6 +9,10 @@ import { isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@
9
9
  * @noInheritDoc
10
10
  */
11
11
  export class Raw extends Uint8Array {
12
+ registry;
13
+ createdAtHash;
14
+ initialU8aLength;
15
+ isStorageFallback;
12
16
  /**
13
17
  * @description This ensures that operators such as clice, filter, map, etc. return
14
18
  * new Array instances (without this we need to apply overrides)
package/native/Set.js CHANGED
@@ -66,42 +66,33 @@ function decodeSet(setValues, value = 0, bitLength) {
66
66
  * a bitwise representation of the values.
67
67
  */
68
68
  export class CodecSet extends Set {
69
+ registry;
70
+ createdAtHash;
71
+ initialU8aLength;
72
+ isStorageFallback;
73
+ __internal__allowed;
74
+ __internal__byteLength;
69
75
  constructor(registry, setValues, value, bitLength = 8) {
70
76
  super(decodeSet(setValues, value, bitLength));
71
- /**
72
- * @description adds a value to the Set (extended to allow for validity checking)
73
- */
74
- this.add = (key) => {
75
- // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
76
- // we have the isUndefined(this._setValues) in here as well, add is used internally
77
- // in the Set constructor (so it is undefined at this point, and should allow)
78
- if (this.__internal__allowed && isUndefined(this.__internal__allowed[key])) {
79
- throw new Error(`Set: Invalid key '${key}' on add`);
80
- }
81
- super.add(key);
82
- return this;
83
- };
84
77
  this.registry = registry;
85
78
  this.__internal__allowed = setValues;
86
79
  this.__internal__byteLength = bitLength / 8;
87
80
  }
88
81
  static with(values, bitLength) {
89
- var _a;
90
- return _a = class extends CodecSet {
91
- constructor(registry, value) {
92
- super(registry, values, value, bitLength);
93
- }
94
- },
95
- (() => {
82
+ return class extends CodecSet {
83
+ static {
96
84
  const keys = Object.keys(values);
97
85
  const count = keys.length;
98
86
  const isKeys = new Array(count);
99
87
  for (let i = 0; i < count; i++) {
100
88
  isKeys[i] = `is${stringPascalCase(keys[i])}`;
101
89
  }
102
- objectProperties(_a.prototype, isKeys, (_, i, self) => self.strings.includes(keys[i]));
103
- })(),
104
- _a;
90
+ objectProperties(this.prototype, isKeys, (_, i, self) => self.strings.includes(keys[i]));
91
+ }
92
+ constructor(registry, value) {
93
+ super(registry, values, value, bitLength);
94
+ }
95
+ };
105
96
  }
106
97
  /**
107
98
  * @description The length of the value when encoded as a Uint8Array
@@ -133,6 +124,19 @@ export class CodecSet extends Set {
133
124
  get valueEncoded() {
134
125
  return encodeSet(this.__internal__allowed, this.strings);
135
126
  }
127
+ /**
128
+ * @description adds a value to the Set (extended to allow for validity checking)
129
+ */
130
+ add = (key) => {
131
+ // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
132
+ // we have the isUndefined(this._setValues) in here as well, add is used internally
133
+ // in the Set constructor (so it is undefined at this point, and should allow)
134
+ if (this.__internal__allowed && isUndefined(this.__internal__allowed[key])) {
135
+ throw new Error(`Set: Invalid key '${key}' on add`);
136
+ }
137
+ super.add(key);
138
+ return this;
139
+ };
136
140
  /**
137
141
  * @description Compares the value of the input to see if there is a match
138
142
  */
@@ -64,7 +64,7 @@ export declare class Struct<S extends TypesDef = TypesDef, V extends {
64
64
  /**
65
65
  * @description Returns the a types value by name
66
66
  */
67
- getT<T>(key: string): T;
67
+ getT<T = Codec>(key: string): T;
68
68
  /**
69
69
  * @description Returns a breakdown of the hex encoding for this Codec
70
70
  */
package/native/Struct.js CHANGED
@@ -72,6 +72,12 @@ function decodeStructFromObject(registry, [Types, keys], value, jsonMap) {
72
72
  * @noInheritDoc
73
73
  */
74
74
  export class Struct extends Map {
75
+ registry;
76
+ createdAtHash;
77
+ initialU8aLength;
78
+ isStorageFallback;
79
+ __internal__jsonMap;
80
+ __internal__Types;
75
81
  constructor(registry, Types, value, jsonMap = new Map(), { definition, setDefinition = noopSetDefinition } = {}) {
76
82
  const typeMap = definition || setDefinition(mapToTypeMap(registry, Types));
77
83
  const [decoded, decodedLength] = isU8a(value) || isHex(value)
@@ -86,20 +92,18 @@ export class Struct extends Map {
86
92
  this.__internal__Types = typeMap;
87
93
  }
88
94
  static with(Types, jsonMap) {
89
- var _a;
90
95
  let definition;
91
96
  // eslint-disable-next-line no-return-assign
92
97
  const setDefinition = (d) => definition = d;
93
- return _a = class extends Struct {
94
- constructor(registry, value) {
95
- super(registry, Types, value, jsonMap, { definition, setDefinition });
96
- }
97
- },
98
- (() => {
98
+ return class extends Struct {
99
+ static {
99
100
  const keys = Object.keys(Types);
100
- objectProperties(_a.prototype, keys, (k, _, self) => self.get(k));
101
- })(),
102
- _a;
101
+ objectProperties(this.prototype, keys, (k, _, self) => self.get(k));
102
+ }
103
+ constructor(registry, value) {
104
+ super(registry, Types, value, jsonMap, { definition, setDefinition });
105
+ }
106
+ };
103
107
  }
104
108
  /**
105
109
  * @description The available keys for this struct
package/native/Text.js CHANGED
@@ -36,10 +36,14 @@ function decodeText(value) {
36
36
  * @noInheritDoc
37
37
  */
38
38
  export class Text extends String {
39
+ registry;
40
+ createdAtHash;
41
+ initialU8aLength;
42
+ isStorageFallback;
43
+ __internal__override = null;
39
44
  constructor(registry, value) {
40
45
  const [str, decodedLength] = decodeText(value);
41
46
  super(str);
42
- this.__internal__override = null;
43
47
  this.registry = registry;
44
48
  this.initialU8aLength = decodedLength;
45
49
  }