@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/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.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
2
  import type { AnyJson, Codec, CodecClass, DefinitionSetter, IEnum, Inspect, IU8a, Registry } from '../types/index.js';
3
- export interface EnumCodecClass<T = Codec> {
4
- new (registry: Registry, value?: any, index?: number): T;
5
- }
3
+ export type EnumCodecClass<T = Codec> = new (registry: Registry, value?: any, index?: number) => T;
6
4
  interface Definition {
7
5
  def: TypesDef;
8
6
  isBasic: boolean;
package/base/Enum.js CHANGED
@@ -47,7 +47,7 @@ function extractDef(registry, _def) {
47
47
  }
48
48
  function getEntryType(def, checkIdx) {
49
49
  const values = Object.values(def);
50
- for (let i = 0; i < values.length; i++) {
50
+ for (let i = 0, count = values.length; i < count; i++) {
51
51
  const { Type, index } = values[i];
52
52
  if (index === checkIdx) {
53
53
  return Type;
@@ -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.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { AnyTupleValue, Codec, CodecClass, DefinitionSetter, Inspect, ITuple, Registry } from '../types/index.js';
2
2
  import { AbstractArray } from '../abstract/Array.js';
3
3
  type TupleType = (CodecClass | string);
4
- type TupleTypes = TupleType[] | {
5
- [index: string]: CodecClass | string;
6
- };
4
+ type TupleTypes = TupleType[] | Record<string, CodecClass | string>;
7
5
  type Definition = [CodecClass[], string[]];
8
6
  /**
9
7
  * @name Tuple
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
@@ -50,7 +50,7 @@ function extractDef(registry, _def) {
50
50
  }
51
51
  function getEntryType(def, checkIdx) {
52
52
  const values = Object.values(def);
53
- for (let i = 0; i < values.length; i++) {
53
+ for (let i = 0, count = values.length; i < count; i++) {
54
54
  const { Type, index } = values[i];
55
55
  if (index === checkIdx) {
56
56
  return Type;
@@ -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));
@@ -5,7 +5,7 @@ const util_1 = require("@polkadot/util");
5
5
  const Raw_js_1 = require("../native/Raw.js");
6
6
  /** @internal */
7
7
  function decodeBitVecU8a(value) {
8
- if (!value || !value.length) {
8
+ if (!value?.length) {
9
9
  return [0, new Uint8Array()];
10
10
  }
11
11
  // handle all other Uint8Array inputs, these do have a length prefix which is the number of bits encoded
@@ -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);
@@ -28,7 +28,7 @@ class OptionBool extends Option_js_1.Option {
28
28
  * @description The length of the value when encoded as a Uint8Array
29
29
  */
30
30
  get encodedLength() {
31
- return 1;
31
+ return 1 | 0;
32
32
  }
33
33
  /**
34
34
  * @description Checks if the value is an empty value (always false)
@@ -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,20 +9,23 @@ 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
  /**
22
25
  * @description The length of the value when encoded as a Uint8Array
23
26
  */
24
27
  get encodedLength() {
25
- return 1;
28
+ return 1 | 0;
26
29
  }
27
30
  /**
28
31
  * @description returns a hash of the contents
@@ -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);
@@ -26,7 +30,7 @@ class Json extends Map {
26
30
  * @description Always 0, never encodes as a Uint8Array
27
31
  */
28
32
  get encodedLength() {
29
- return 0;
33
+ return 0 | 0;
30
34
  }
31
35
  /**
32
36
  * @description returns a hash of the contents
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)