@polkadot/types-codec 10.10.1 → 10.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) 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.js +19 -11
  8. package/base/Null.js +6 -3
  9. package/base/Option.js +7 -1
  10. package/base/Tuple.js +1 -0
  11. package/base/Vec.js +1 -0
  12. package/base/VecFixed.js +1 -0
  13. package/cjs/abstract/Array.js +4 -0
  14. package/cjs/abstract/Base.js +5 -0
  15. package/cjs/abstract/Int.js +7 -0
  16. package/cjs/abstract/Object.js +5 -0
  17. package/cjs/base/Compact.js +6 -0
  18. package/cjs/base/DoNotConstruct.js +4 -0
  19. package/cjs/base/Enum.js +19 -11
  20. package/cjs/base/Null.js +6 -3
  21. package/cjs/base/Option.js +7 -1
  22. package/cjs/base/Tuple.js +1 -0
  23. package/cjs/base/Vec.js +1 -0
  24. package/cjs/base/VecFixed.js +1 -0
  25. package/cjs/extended/BTreeSet.js +5 -0
  26. package/cjs/extended/BitVec.js +2 -0
  27. package/cjs/extended/Map.js +7 -0
  28. package/cjs/extended/Range.js +1 -0
  29. package/cjs/extended/WrapperKeepOpaque.js +3 -0
  30. package/cjs/native/Bool.js +4 -1
  31. package/cjs/native/Date.js +4 -1
  32. package/cjs/native/Float.js +6 -0
  33. package/cjs/native/Json.js +4 -0
  34. package/cjs/native/Raw.js +4 -0
  35. package/cjs/native/Set.js +27 -23
  36. package/cjs/native/Struct.js +14 -10
  37. package/cjs/native/Text.js +5 -1
  38. package/cjs/packageInfo.js +1 -1
  39. package/cjs/primitive/F32.js +2 -5
  40. package/cjs/primitive/F64.js +2 -5
  41. package/cjs/primitive/I128.js +2 -5
  42. package/cjs/primitive/I16.js +2 -5
  43. package/cjs/primitive/I256.js +2 -5
  44. package/cjs/primitive/I32.js +2 -5
  45. package/cjs/primitive/I64.js +2 -5
  46. package/cjs/primitive/I8.js +2 -5
  47. package/cjs/primitive/U128.js +2 -5
  48. package/cjs/primitive/U16.js +2 -5
  49. package/cjs/primitive/U256.js +2 -5
  50. package/cjs/primitive/U32.js +2 -5
  51. package/cjs/primitive/U64.js +2 -5
  52. package/cjs/primitive/U8.js +2 -5
  53. package/extended/BTreeSet.js +5 -0
  54. package/extended/BitVec.js +2 -0
  55. package/extended/Map.js +7 -0
  56. package/extended/Range.js +1 -0
  57. package/extended/WrapperKeepOpaque.js +3 -0
  58. package/native/Bool.js +4 -1
  59. package/native/Date.js +4 -1
  60. package/native/Float.js +6 -0
  61. package/native/Json.js +4 -0
  62. package/native/Raw.js +4 -0
  63. package/native/Set.js +27 -23
  64. package/native/Struct.js +14 -10
  65. package/native/Text.js +5 -1
  66. package/package.json +4 -4
  67. package/packageInfo.js +1 -1
  68. package/primitive/F32.js +2 -5
  69. package/primitive/F64.js +2 -5
  70. package/primitive/I128.js +2 -5
  71. package/primitive/I16.js +2 -5
  72. package/primitive/I256.js +2 -5
  73. package/primitive/I32.js +2 -5
  74. package/primitive/I64.js +2 -5
  75. package/primitive/I8.js +2 -5
  76. package/primitive/U128.js +2 -5
  77. package/primitive/U16.js +2 -5
  78. package/primitive/U256.js +2 -5
  79. package/primitive/U32.js +2 -5
  80. package/primitive/U64.js +2 -5
  81. package/primitive/U8.js +2 -5
  82. package/types/registry.d.ts +1 -0
package/abstract/Array.js CHANGED
@@ -8,6 +8,10 @@ import { compareArray } from '../utils/compareArray.js';
8
8
  * @noInheritDoc
9
9
  */
10
10
  export class AbstractArray extends Array {
11
+ registry;
12
+ createdAtHash;
13
+ initialU8aLength;
14
+ isStorageFallback;
11
15
  /**
12
16
  * @description This ensures that operators such as clice, filter, map, etc. return
13
17
  * new Array instances (without this we need to apply overrides)
package/abstract/Base.js CHANGED
@@ -3,6 +3,11 @@
3
3
  * @description A type extends the Base class, when it holds a value
4
4
  */
5
5
  export class AbstractBase {
6
+ registry;
7
+ createdAtHash;
8
+ initialU8aLength;
9
+ isStorageFallback;
10
+ __internal__raw;
6
11
  constructor(registry, value, initialU8aLength) {
7
12
  this.initialU8aLength = initialU8aLength;
8
13
  this.__internal__raw = value;
package/abstract/Int.js CHANGED
@@ -58,6 +58,13 @@ function decodeAbstractInt(value, isNegative) {
58
58
  * @noInheritDoc
59
59
  */
60
60
  export class AbstractInt extends BN {
61
+ registry;
62
+ encodedLength;
63
+ isUnsigned;
64
+ createdAtHash;
65
+ initialU8aLength;
66
+ isStorageFallback;
67
+ __internal__bitLength;
61
68
  constructor(registry, value = 0, bitLength = DEFAULT_UINT_BITS, isSigned = false) {
62
69
  // Construct via a string/number, which will be passed in the BN constructor.
63
70
  // It would be ideal to actually return a BN, but there is an issue:
@@ -3,6 +3,11 @@
3
3
  * @description A type extends the Base class, when it holds a value
4
4
  */
5
5
  export class AbstractObject {
6
+ registry;
7
+ createdAtHash;
8
+ initialU8aLength;
9
+ isStorageFallback;
10
+ $;
6
11
  constructor(registry, value, initialU8aLength) {
7
12
  this.$ = value;
8
13
  this.initialU8aLength = initialU8aLength;
package/base/Compact.js CHANGED
@@ -27,6 +27,12 @@ function decodeCompact(registry, Type, value) {
27
27
  * a number and making the compact representation thereof
28
28
  */
29
29
  export class Compact {
30
+ registry;
31
+ createdAtHash;
32
+ initialU8aLength;
33
+ isStorageFallback;
34
+ __internal__Type;
35
+ __internal__raw;
30
36
  constructor(registry, Type, value = 0, { definition, setDefinition = identity } = {}) {
31
37
  this.registry = registry;
32
38
  this.__internal__Type = definition || setDefinition(typeToConstructor(registry, Type));
@@ -4,6 +4,10 @@
4
4
  * An unknown type that fails on construction with the type info
5
5
  */
6
6
  export class DoNotConstruct {
7
+ registry;
8
+ createdAtHash;
9
+ isStorageFallback;
10
+ __internal__neverError;
7
11
  constructor(registry, typeName = 'DoNotConstruct') {
8
12
  this.registry = registry;
9
13
  this.__internal__neverError = new Error(`DoNotConstruct: Cannot construct unknown type ${typeName}`);
package/base/Enum.js CHANGED
@@ -123,6 +123,16 @@ function decodeEnum(registry, def, value, index) {
123
123
  * an extension to enum where the value type is determined by the actual index.
124
124
  */
125
125
  export class Enum {
126
+ registry;
127
+ createdAtHash;
128
+ initialU8aLength;
129
+ isStorageFallback;
130
+ __internal__def;
131
+ __internal__entryIndex;
132
+ __internal__indexes;
133
+ __internal__isBasic;
134
+ __internal__isIndexed;
135
+ __internal__raw;
126
136
  constructor(registry, Types, value, index, { definition, setDefinition = identity } = {}) {
127
137
  const { def, isBasic, isIndexed } = definition || setDefinition(extractDef(registry, Types));
128
138
  // shortcut isU8a as used in SCALE decoding
@@ -141,16 +151,11 @@ export class Enum {
141
151
  }
142
152
  }
143
153
  static with(Types) {
144
- var _a;
145
154
  let definition;
146
155
  // eslint-disable-next-line no-return-assign
147
156
  const setDefinition = (d) => definition = d;
148
- return _a = class extends Enum {
149
- constructor(registry, value, index) {
150
- super(registry, Types, value, index, { definition, setDefinition });
151
- }
152
- },
153
- (() => {
157
+ return class extends Enum {
158
+ static {
154
159
  const keys = Array.isArray(Types)
155
160
  ? Types
156
161
  : Object.keys(Types);
@@ -162,15 +167,18 @@ export class Enum {
162
167
  asKeys[i] = `as${name}`;
163
168
  isKeys[i] = `is${name}`;
164
169
  }
165
- objectProperties(_a.prototype, isKeys, (_, i, self) => self.type === keys[i]);
166
- objectProperties(_a.prototype, asKeys, (k, i, self) => {
170
+ objectProperties(this.prototype, isKeys, (_, i, self) => self.type === keys[i]);
171
+ objectProperties(this.prototype, asKeys, (k, i, self) => {
167
172
  if (self.type !== keys[i]) {
168
173
  throw new Error(`Cannot convert '${self.type}' via ${k}`);
169
174
  }
170
175
  return self.value;
171
176
  });
172
- })(),
173
- _a;
177
+ }
178
+ constructor(registry, value, index) {
179
+ super(registry, Types, value, index, { definition, setDefinition });
180
+ }
181
+ };
174
182
  }
175
183
  /**
176
184
  * @description The length of the value when encoded as a Uint8Array
package/base/Null.js CHANGED
@@ -5,10 +5,13 @@ 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;
8
14
  constructor(registry) {
9
- this.encodedLength = 0;
10
- this.isEmpty = true;
11
- this.initialU8aLength = 0;
12
15
  this.registry = registry;
13
16
  }
14
17
  /**
package/base/Option.js CHANGED
@@ -28,7 +28,7 @@ function decodeOption(registry, Type, value) {
28
28
  return new Type(registry, value.value);
29
29
  }
30
30
  else if (isNull(value) || isUndefined(value) || value === '0x' || value instanceof None) {
31
- // anyhting empty we pass as-is
31
+ // anything empty we pass as-is
32
32
  return new None(registry);
33
33
  }
34
34
  else if (isU8a(value)) {
@@ -49,6 +49,12 @@ function decodeOption(registry, Type, value) {
49
49
  * with a value if/as required/found.
50
50
  */
51
51
  export class Option {
52
+ registry;
53
+ createdAtHash;
54
+ initialU8aLength;
55
+ isStorageFallback;
56
+ __internal__Type;
57
+ __internal__raw;
52
58
  constructor(registry, typeName, value, { definition, setDefinition = identity } = {}) {
53
59
  const Type = definition || setDefinition(typeToConstructor(registry, typeName));
54
60
  const decoded = isU8a(value) && value.length && !isCodec(value)
package/base/Tuple.js CHANGED
@@ -37,6 +37,7 @@ function decodeTuple(registry, result, value, Classes) {
37
37
  * own type. It extends the base JS `Array` object.
38
38
  */
39
39
  export class Tuple extends AbstractArray {
40
+ __internal__Types;
40
41
  constructor(registry, Types, value, { definition, setDefinition = identity } = {}) {
41
42
  const Classes = definition || setDefinition(Array.isArray(Types)
42
43
  ? [typesToConstructors(registry, Types), []]
package/base/Vec.js CHANGED
@@ -53,6 +53,7 @@ export function decodeVec(registry, result, value, startAt, Type) {
53
53
  * specific encoding/decoding on top of the base type.
54
54
  */
55
55
  export class Vec extends AbstractArray {
56
+ __internal__Type;
56
57
  constructor(registry, Type, value = [], { definition, setDefinition = identity } = {}) {
57
58
  const [decodeFrom, length, startAt] = decodeVecLength(value);
58
59
  super(registry, length);
package/base/VecFixed.js CHANGED
@@ -8,6 +8,7 @@ import { decodeVec } from './Vec.js';
8
8
  * This manages codec arrays of a fixed length
9
9
  */
10
10
  export class VecFixed extends AbstractArray {
11
+ __internal__Type;
11
12
  constructor(registry, Type, length, value = [], { definition, setDefinition = identity } = {}) {
12
13
  super(registry, length);
13
14
  this.__internal__Type = definition || setDefinition(typeToConstructor(registry, Type));
@@ -11,6 +11,10 @@ const compareArray_js_1 = require("../utils/compareArray.js");
11
11
  * @noInheritDoc
12
12
  */
13
13
  class AbstractArray extends Array {
14
+ registry;
15
+ createdAtHash;
16
+ initialU8aLength;
17
+ isStorageFallback;
14
18
  /**
15
19
  * @description This ensures that operators such as clice, filter, map, etc. return
16
20
  * new Array instances (without this we need to apply overrides)
@@ -6,6 +6,11 @@ exports.AbstractBase = void 0;
6
6
  * @description A type extends the Base class, when it holds a value
7
7
  */
8
8
  class AbstractBase {
9
+ registry;
10
+ createdAtHash;
11
+ initialU8aLength;
12
+ isStorageFallback;
13
+ __internal__raw;
9
14
  constructor(registry, value, initialU8aLength) {
10
15
  this.initialU8aLength = initialU8aLength;
11
16
  this.__internal__raw = value;
@@ -61,6 +61,13 @@ function decodeAbstractInt(value, isNegative) {
61
61
  * @noInheritDoc
62
62
  */
63
63
  class AbstractInt extends util_1.BN {
64
+ registry;
65
+ encodedLength;
66
+ isUnsigned;
67
+ createdAtHash;
68
+ initialU8aLength;
69
+ isStorageFallback;
70
+ __internal__bitLength;
64
71
  constructor(registry, value = 0, bitLength = exports.DEFAULT_UINT_BITS, isSigned = false) {
65
72
  // Construct via a string/number, which will be passed in the BN constructor.
66
73
  // It would be ideal to actually return a BN, but there is an issue:
@@ -6,6 +6,11 @@ exports.AbstractObject = void 0;
6
6
  * @description A type extends the Base class, when it holds a value
7
7
  */
8
8
  class AbstractObject {
9
+ registry;
10
+ createdAtHash;
11
+ initialU8aLength;
12
+ isStorageFallback;
13
+ $;
9
14
  constructor(registry, value, initialU8aLength) {
10
15
  this.$ = value;
11
16
  this.initialU8aLength = initialU8aLength;
@@ -30,6 +30,12 @@ function decodeCompact(registry, Type, value) {
30
30
  * a number and making the compact representation thereof
31
31
  */
32
32
  class Compact {
33
+ registry;
34
+ createdAtHash;
35
+ initialU8aLength;
36
+ isStorageFallback;
37
+ __internal__Type;
38
+ __internal__raw;
33
39
  constructor(registry, Type, value = 0, { definition, setDefinition = util_1.identity } = {}) {
34
40
  this.registry = registry;
35
41
  this.__internal__Type = definition || setDefinition((0, index_js_1.typeToConstructor)(registry, Type));
@@ -7,6 +7,10 @@ exports.DoNotConstruct = void 0;
7
7
  * An unknown type that fails on construction with the type info
8
8
  */
9
9
  class DoNotConstruct {
10
+ registry;
11
+ createdAtHash;
12
+ isStorageFallback;
13
+ __internal__neverError;
10
14
  constructor(registry, typeName = 'DoNotConstruct') {
11
15
  this.registry = registry;
12
16
  this.__internal__neverError = new Error(`DoNotConstruct: Cannot construct unknown type ${typeName}`);
package/cjs/base/Enum.js CHANGED
@@ -126,6 +126,16 @@ function decodeEnum(registry, def, value, index) {
126
126
  * an extension to enum where the value type is determined by the actual index.
127
127
  */
128
128
  class Enum {
129
+ registry;
130
+ createdAtHash;
131
+ initialU8aLength;
132
+ isStorageFallback;
133
+ __internal__def;
134
+ __internal__entryIndex;
135
+ __internal__indexes;
136
+ __internal__isBasic;
137
+ __internal__isIndexed;
138
+ __internal__raw;
129
139
  constructor(registry, Types, value, index, { definition, setDefinition = util_1.identity } = {}) {
130
140
  const { def, isBasic, isIndexed } = definition || setDefinition(extractDef(registry, Types));
131
141
  // shortcut isU8a as used in SCALE decoding
@@ -144,16 +154,11 @@ class Enum {
144
154
  }
145
155
  }
146
156
  static with(Types) {
147
- var _a;
148
157
  let definition;
149
158
  // eslint-disable-next-line no-return-assign
150
159
  const setDefinition = (d) => definition = d;
151
- return _a = class extends Enum {
152
- constructor(registry, value, index) {
153
- super(registry, Types, value, index, { definition, setDefinition });
154
- }
155
- },
156
- (() => {
160
+ return class extends Enum {
161
+ static {
157
162
  const keys = Array.isArray(Types)
158
163
  ? Types
159
164
  : Object.keys(Types);
@@ -165,15 +170,18 @@ class Enum {
165
170
  asKeys[i] = `as${name}`;
166
171
  isKeys[i] = `is${name}`;
167
172
  }
168
- (0, util_1.objectProperties)(_a.prototype, isKeys, (_, i, self) => self.type === keys[i]);
169
- (0, util_1.objectProperties)(_a.prototype, asKeys, (k, i, self) => {
173
+ (0, util_1.objectProperties)(this.prototype, isKeys, (_, i, self) => self.type === keys[i]);
174
+ (0, util_1.objectProperties)(this.prototype, asKeys, (k, i, self) => {
170
175
  if (self.type !== keys[i]) {
171
176
  throw new Error(`Cannot convert '${self.type}' via ${k}`);
172
177
  }
173
178
  return self.value;
174
179
  });
175
- })(),
176
- _a;
180
+ }
181
+ constructor(registry, value, index) {
182
+ super(registry, Types, value, index, { definition, setDefinition });
183
+ }
184
+ };
177
185
  }
178
186
  /**
179
187
  * @description The length of the value when encoded as a Uint8Array
package/cjs/base/Null.js CHANGED
@@ -8,10 +8,13 @@ const util_1 = require("@polkadot/util");
8
8
  * Implements a type that does not contain anything (apart from `null`)
9
9
  */
10
10
  class Null {
11
+ encodedLength = 0;
12
+ isEmpty = true;
13
+ registry;
14
+ createdAtHash;
15
+ initialU8aLength = 0;
16
+ isStorageFallback;
11
17
  constructor(registry) {
12
- this.encodedLength = 0;
13
- this.isEmpty = true;
14
- this.initialU8aLength = 0;
15
18
  this.registry = registry;
16
19
  }
17
20
  /**
@@ -31,7 +31,7 @@ function decodeOption(registry, Type, value) {
31
31
  return new Type(registry, value.value);
32
32
  }
33
33
  else if ((0, util_1.isNull)(value) || (0, util_1.isUndefined)(value) || value === '0x' || value instanceof None) {
34
- // anyhting empty we pass as-is
34
+ // anything empty we pass as-is
35
35
  return new None(registry);
36
36
  }
37
37
  else if ((0, util_1.isU8a)(value)) {
@@ -52,6 +52,12 @@ function decodeOption(registry, Type, value) {
52
52
  * with a value if/as required/found.
53
53
  */
54
54
  class Option {
55
+ registry;
56
+ createdAtHash;
57
+ initialU8aLength;
58
+ isStorageFallback;
59
+ __internal__Type;
60
+ __internal__raw;
55
61
  constructor(registry, typeName, value, { definition, setDefinition = util_1.identity } = {}) {
56
62
  const Type = definition || setDefinition((0, index_js_1.typeToConstructor)(registry, typeName));
57
63
  const decoded = (0, util_1.isU8a)(value) && value.length && !(0, util_1.isCodec)(value)
package/cjs/base/Tuple.js CHANGED
@@ -40,6 +40,7 @@ function decodeTuple(registry, result, value, Classes) {
40
40
  * own type. It extends the base JS `Array` object.
41
41
  */
42
42
  class Tuple extends Array_js_1.AbstractArray {
43
+ __internal__Types;
43
44
  constructor(registry, Types, value, { definition, setDefinition = util_1.identity } = {}) {
44
45
  const Classes = definition || setDefinition(Array.isArray(Types)
45
46
  ? [(0, index_js_1.typesToConstructors)(registry, Types), []]
package/cjs/base/Vec.js CHANGED
@@ -57,6 +57,7 @@ exports.decodeVec = decodeVec;
57
57
  * specific encoding/decoding on top of the base type.
58
58
  */
59
59
  class Vec extends Array_js_1.AbstractArray {
60
+ __internal__Type;
60
61
  constructor(registry, Type, value = [], { definition, setDefinition = util_1.identity } = {}) {
61
62
  const [decodeFrom, length, startAt] = decodeVecLength(value);
62
63
  super(registry, length);
@@ -11,6 +11,7 @@ const Vec_js_1 = require("./Vec.js");
11
11
  * This manages codec arrays of a fixed length
12
12
  */
13
13
  class VecFixed extends Array_js_1.AbstractArray {
14
+ __internal__Type;
14
15
  constructor(registry, Type, length, value = [], { definition, setDefinition = util_1.identity } = {}) {
15
16
  super(registry, length);
16
17
  this.__internal__Type = definition || setDefinition((0, index_js_1.typeToConstructor)(registry, Type));
@@ -57,6 +57,11 @@ function decodeSet(registry, valType, value) {
57
57
  throw new Error('BTreeSet: cannot decode type');
58
58
  }
59
59
  class BTreeSet extends Set {
60
+ registry;
61
+ createdAtHash;
62
+ initialU8aLength;
63
+ isStorageFallback;
64
+ __internal__ValClass;
60
65
  constructor(registry, valType, rawValue) {
61
66
  const [ValClass, values, decodedLength] = decodeSet(registry, valType, rawValue);
62
67
  super((0, index_js_1.sortSet)(values));
@@ -31,6 +31,8 @@ function decodeBitVec(value) {
31
31
  * and a normal Bytes would be that the length prefix indicates the number of bits encoded, not the bytes
32
32
  */
33
33
  class BitVec extends Raw_js_1.Raw {
34
+ __internal__decodedLength;
35
+ __internal__isMsb;
34
36
  // In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
35
37
  // we are dealing with Lsb, which is the default (as of writing) BitVec format used
36
38
  // in the Polkadot code (this only affects the toHuman displays)
@@ -76,6 +76,13 @@ function decodeMap(registry, keyType, valType, value) {
76
76
  throw new Error('Map: cannot decode type');
77
77
  }
78
78
  class CodecMap extends Map {
79
+ registry;
80
+ createdAtHash;
81
+ initialU8aLength;
82
+ isStorageFallback;
83
+ __internal__KeyClass;
84
+ __internal__ValClass;
85
+ __internal__type;
79
86
  constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
80
87
  const [KeyClass, ValClass, decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
81
88
  super(type === 'BTreeMap' ? (0, index_js_1.sortMap)(decoded) : decoded);
@@ -8,6 +8,7 @@ const Tuple_js_1 = require("../base/Tuple.js");
8
8
  * Rust `Range<T>` representation
9
9
  */
10
10
  class Range extends Tuple_js_1.Tuple {
11
+ __internal__rangeName;
11
12
  constructor(registry, Type, value, { rangeName = 'Range' } = {}) {
12
13
  super(registry, [Type, Type], value);
13
14
  this.__internal__rangeName = rangeName;
@@ -24,6 +24,9 @@ function decodeRaw(registry, typeName, value) {
24
24
  return [Type, instance, (0, util_1.compactAddLength)(instance.toU8a())];
25
25
  }
26
26
  class WrapperKeepOpaque extends Bytes_js_1.Bytes {
27
+ __internal__Type;
28
+ __internal__decoded;
29
+ __internal__opaqueName;
27
30
  constructor(registry, typeName, value, { opaqueName = 'WrapperKeepOpaque' } = {}) {
28
31
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
29
32
  super(registry, u8a);
@@ -9,13 +9,16 @@ const util_1 = require("@polkadot/util");
9
9
  * @noInheritDoc
10
10
  */
11
11
  class bool extends Boolean {
12
+ registry;
13
+ createdAtHash;
14
+ initialU8aLength = 1;
15
+ isStorageFallback;
12
16
  constructor(registry, value = false) {
13
17
  super((0, util_1.isU8a)(value)
14
18
  ? value[0] === 1
15
19
  : value instanceof Boolean
16
20
  ? value.valueOf()
17
21
  : !!value);
18
- this.initialU8aLength = 1;
19
22
  this.registry = registry;
20
23
  }
21
24
  /**
@@ -27,9 +27,12 @@ function decodeDate(value) {
27
27
  * @noInheritDoc
28
28
  */
29
29
  class CodecDate extends Date {
30
+ registry;
31
+ createdAtHash;
32
+ initialU8aLength = BITLENGTH / 8;
33
+ isStorageFallback;
30
34
  constructor(registry, value = 0) {
31
35
  super(decodeDate(value));
32
- this.initialU8aLength = BITLENGTH / 8;
33
36
  this.registry = registry;
34
37
  }
35
38
  /**
@@ -11,6 +11,12 @@ const util_1 = require("@polkadot/util");
11
11
  * in some eth_* RPCs
12
12
  */
13
13
  class Float extends Number {
14
+ encodedLength;
15
+ registry;
16
+ createdAtHash;
17
+ initialU8aLength;
18
+ isStorageFallback;
19
+ __internal__bitLength;
14
20
  constructor(registry, value, { bitLength = 32 } = {}) {
15
21
  super((0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
16
22
  ? value.length === 0
@@ -16,6 +16,10 @@ function decodeJson(value) {
16
16
  * @noInheritDoc
17
17
  */
18
18
  class Json extends Map {
19
+ registry;
20
+ createdAtHash;
21
+ initialU8aLength;
22
+ isStorageFallback;
19
23
  constructor(registry, value) {
20
24
  const decoded = decodeJson(value);
21
25
  super(decoded);
package/cjs/native/Raw.js CHANGED
@@ -12,6 +12,10 @@ const util_1 = require("@polkadot/util");
12
12
  * @noInheritDoc
13
13
  */
14
14
  class Raw extends Uint8Array {
15
+ registry;
16
+ createdAtHash;
17
+ initialU8aLength;
18
+ isStorageFallback;
15
19
  /**
16
20
  * @description This ensures that operators such as clice, filter, map, etc. return
17
21
  * new Array instances (without this we need to apply overrides)
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