@polkadot/types-codec 16.2.1 → 16.2.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.
@@ -24,15 +24,15 @@ 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
+ #Type;
28
+ #decoded;
29
+ #opaqueName;
30
30
  constructor(registry, typeName, value, { opaqueName = 'WrapperKeepOpaque' } = {}) {
31
31
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
32
32
  super(registry, u8a);
33
- this.__internal__Type = Type;
34
- this.__internal__decoded = decoded;
35
- this.__internal__opaqueName = opaqueName;
33
+ this.#Type = Type;
34
+ this.#decoded = decoded;
35
+ this.#opaqueName = opaqueName;
36
36
  }
37
37
  static with(Type) {
38
38
  return class extends WrapperKeepOpaque {
@@ -45,15 +45,15 @@ class WrapperKeepOpaque extends Bytes_js_1.Bytes {
45
45
  * @description Checks if the wrapper is decodable
46
46
  */
47
47
  get isDecoded() {
48
- return !!this.__internal__decoded;
48
+ return !!this.#decoded;
49
49
  }
50
50
  /**
51
51
  * @description Returns a breakdown of the hex encoding for this Codec
52
52
  */
53
53
  inspect() {
54
- return this.__internal__decoded
54
+ return this.#decoded
55
55
  ? {
56
- inner: [this.__internal__decoded.inspect()],
56
+ inner: [this.#decoded.inspect()],
57
57
  outer: [(0, util_1.compactToU8a)(this.length)]
58
58
  }
59
59
  : {
@@ -64,40 +64,40 @@ class WrapperKeepOpaque extends Bytes_js_1.Bytes {
64
64
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
65
65
  */
66
66
  toHuman(isExtended, disableAscii) {
67
- return this.__internal__decoded
68
- ? this.__internal__decoded.toHuman(isExtended, disableAscii)
67
+ return this.#decoded
68
+ ? this.#decoded.toHuman(isExtended, disableAscii)
69
69
  : super.toHuman(isExtended, disableAscii);
70
70
  }
71
71
  /**
72
72
  * @description Converts the value in a best-fit primitive form
73
73
  */
74
74
  toPrimitive(disableAscii) {
75
- return this.__internal__decoded
76
- ? this.__internal__decoded.toPrimitive(disableAscii)
75
+ return this.#decoded
76
+ ? this.#decoded.toPrimitive(disableAscii)
77
77
  : super.toPrimitive(disableAscii);
78
78
  }
79
79
  /**
80
80
  * @description Returns the base runtime type name for this instance
81
81
  */
82
82
  toRawType() {
83
- return `${this.__internal__opaqueName}<${this.registry.getClassName(this.__internal__Type) || (this.__internal__decoded ? this.__internal__decoded.toRawType() : new this.__internal__Type(this.registry).toRawType())}>`;
83
+ return `${this.#opaqueName}<${this.registry.getClassName(this.#Type) || (this.#decoded ? this.#decoded.toRawType() : new this.#Type(this.registry).toRawType())}>`;
84
84
  }
85
85
  /**
86
86
  * @description Converts the Object to to a string (either decoded or bytes)
87
87
  */
88
88
  toString() {
89
- return this.__internal__decoded
90
- ? this.__internal__decoded.toString()
89
+ return this.#decoded
90
+ ? this.#decoded.toString()
91
91
  : super.toString();
92
92
  }
93
93
  /**
94
94
  * @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
95
95
  */
96
96
  unwrap() {
97
- if (!this.__internal__decoded) {
98
- throw new Error(`${this.__internal__opaqueName}: unwrapping an undecodable value`);
97
+ if (!this.#decoded) {
98
+ throw new Error(`${this.#opaqueName}: unwrapping an undecodable value`);
99
99
  }
100
- return this.__internal__decoded;
100
+ return this.#decoded;
101
101
  }
102
102
  }
103
103
  exports.WrapperKeepOpaque = WrapperKeepOpaque;
@@ -16,14 +16,14 @@ class Float extends Number {
16
16
  createdAtHash;
17
17
  initialU8aLength;
18
18
  isStorageFallback;
19
- __internal__bitLength;
19
+ #bitLength;
20
20
  constructor(registry, value, { bitLength = 32 } = {}) {
21
21
  super((0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
22
22
  ? value.length === 0
23
23
  ? 0
24
24
  : (0, util_1.u8aToFloat)((0, util_1.u8aToU8a)(value), { bitLength })
25
25
  : (value || 0));
26
- this.__internal__bitLength = bitLength;
26
+ this.#bitLength = bitLength;
27
27
  this.encodedLength = bitLength / 8;
28
28
  this.initialU8aLength = this.encodedLength;
29
29
  this.registry = registry;
@@ -97,14 +97,14 @@ class Float extends Number {
97
97
  * @description Returns the base runtime type name for this instance
98
98
  */
99
99
  toRawType() {
100
- return `f${this.__internal__bitLength}`;
100
+ return `f${this.#bitLength}`;
101
101
  }
102
102
  /**
103
103
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
104
104
  */
105
105
  toU8a(_isBare) {
106
106
  return (0, util_1.floatToU8a)(this, {
107
- bitLength: this.__internal__bitLength
107
+ bitLength: this.#bitLength
108
108
  });
109
109
  }
110
110
  }
package/cjs/native/Set.js CHANGED
@@ -73,13 +73,13 @@ class CodecSet extends Set {
73
73
  createdAtHash;
74
74
  initialU8aLength;
75
75
  isStorageFallback;
76
- __internal__allowed;
77
- __internal__byteLength;
76
+ #allowed;
77
+ #byteLength;
78
78
  constructor(registry, setValues, value, bitLength = 8) {
79
79
  super(decodeSet(setValues, value, bitLength));
80
80
  this.registry = registry;
81
- this.__internal__allowed = setValues;
82
- this.__internal__byteLength = bitLength / 8;
81
+ this.#allowed = setValues;
82
+ this.#byteLength = bitLength / 8;
83
83
  }
84
84
  static with(values, bitLength) {
85
85
  return class extends CodecSet {
@@ -101,7 +101,7 @@ class CodecSet extends Set {
101
101
  * @description The length of the value when encoded as a Uint8Array
102
102
  */
103
103
  get encodedLength() {
104
- return this.__internal__byteLength;
104
+ return this.#byteLength;
105
105
  }
106
106
  /**
107
107
  * @description returns a hash of the contents
@@ -125,7 +125,7 @@ class CodecSet extends Set {
125
125
  * @description The encoded value for the set members
126
126
  */
127
127
  get valueEncoded() {
128
- return encodeSet(this.__internal__allowed, this.strings);
128
+ return encodeSet(this.#allowed, this.strings);
129
129
  }
130
130
  /**
131
131
  * @description adds a value to the Set (extended to allow for validity checking)
@@ -134,7 +134,7 @@ class CodecSet extends Set {
134
134
  // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
135
135
  // we have the isUndefined(this._setValues) in here as well, add is used internally
136
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])) {
137
+ if (this.#allowed && (0, util_1.isUndefined)(this.#allowed[key])) {
138
138
  throw new Error(`Set: Invalid key '${key}' on add`);
139
139
  }
140
140
  super.add(key);
@@ -198,7 +198,7 @@ class CodecSet extends Set {
198
198
  * @description Returns the base runtime type name for this instance
199
199
  */
200
200
  toRawType() {
201
- return (0, util_1.stringify)({ _set: this.__internal__allowed });
201
+ return (0, util_1.stringify)({ _set: this.#allowed });
202
202
  }
203
203
  /**
204
204
  * @description Returns the string representation of the value
@@ -211,7 +211,7 @@ class CodecSet extends Set {
211
211
  */
212
212
  toU8a(_isBare) {
213
213
  return (0, util_1.bnToU8a)(this.valueEncoded, {
214
- bitLength: this.__internal__byteLength * 8,
214
+ bitLength: this.#byteLength * 8,
215
215
  isLe: true
216
216
  });
217
217
  }
@@ -81,8 +81,8 @@ class Struct extends Map {
81
81
  createdAtHash;
82
82
  initialU8aLength;
83
83
  isStorageFallback;
84
- __internal__jsonMap;
85
- __internal__Types;
84
+ #jsonMap;
85
+ #Types;
86
86
  constructor(registry, Types, value, jsonMap = new Map(), { definition, setDefinition = noopSetDefinition } = {}) {
87
87
  const typeMap = definition || setDefinition((0, index_js_1.mapToTypeMap)(registry, Types));
88
88
  const [decoded, decodedLength] = (0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
@@ -93,8 +93,8 @@ class Struct extends Map {
93
93
  super(decoded);
94
94
  this.initialU8aLength = decodedLength;
95
95
  this.registry = registry;
96
- this.__internal__jsonMap = jsonMap;
97
- this.__internal__Types = typeMap;
96
+ this.#jsonMap = jsonMap;
97
+ this.#Types = typeMap;
98
98
  }
99
99
  static with(Types, jsonMap) {
100
100
  let definition;
@@ -114,7 +114,7 @@ class Struct extends Map {
114
114
  * @description The available keys for this struct
115
115
  */
116
116
  get defKeys() {
117
- return this.__internal__Types[1];
117
+ return this.#Types[1];
118
118
  }
119
119
  /**
120
120
  * @description Checks if the value is an empty value '{}'
@@ -143,7 +143,7 @@ class Struct extends Map {
143
143
  */
144
144
  get Type() {
145
145
  const result = {};
146
- const [Types, keys] = this.__internal__Types;
146
+ const [Types, keys] = this.#Types;
147
147
  for (let i = 0, count = keys.length; i < count; i++) {
148
148
  result[keys[i]] = new Types[i](this.registry).toRawType();
149
149
  }
@@ -221,7 +221,7 @@ class Struct extends Map {
221
221
  for (const [k, v] of this.entries()) {
222
222
  // Here we pull out the entry against the JSON mapping (if supplied)
223
223
  // since this representation goes over RPC and needs to be correct
224
- json[(this.__internal__jsonMap.get(k) || k)] = v.toJSON();
224
+ json[(this.#jsonMap.get(k) || k)] = v.toJSON();
225
225
  }
226
226
  return json;
227
227
  }
@@ -239,7 +239,7 @@ class Struct extends Map {
239
239
  * @description Returns the base runtime type name for this instance
240
240
  */
241
241
  toRawType() {
242
- return (0, util_1.stringify)((0, index_js_1.typesToMap)(this.registry, this.__internal__Types));
242
+ return (0, util_1.stringify)((0, index_js_1.typesToMap)(this.registry, this.#Types));
243
243
  }
244
244
  /**
245
245
  * @description Returns the string representation of the value
@@ -43,7 +43,7 @@ class Text extends String {
43
43
  createdAtHash;
44
44
  initialU8aLength;
45
45
  isStorageFallback;
46
- __internal__override = null;
46
+ #override = null;
47
47
  constructor(registry, value) {
48
48
  const [str, decodedLength] = decodeText(value);
49
49
  super(str);
@@ -98,7 +98,7 @@ class Text extends String {
98
98
  * @description Set an override value for this
99
99
  */
100
100
  setOverride(override) {
101
- this.__internal__override = override;
101
+ this.#override = override;
102
102
  }
103
103
  /**
104
104
  * @description Returns a hex string representation of the value
@@ -136,7 +136,7 @@ class Text extends String {
136
136
  * @description Returns the string representation of the value
137
137
  */
138
138
  toString() {
139
- return this.__internal__override || super.toString();
139
+ return this.#override || super.toString();
140
140
  }
141
141
  /**
142
142
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
@@ -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: '16.2.1' };
4
+ exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '16.2.2' };
@@ -4,6 +4,12 @@ exports.decodeU8a = decodeU8a;
4
4
  exports.decodeU8aStruct = decodeU8aStruct;
5
5
  exports.decodeU8aVec = decodeU8aVec;
6
6
  const util_1 = require("@polkadot/util");
7
+ const MAX_DEPTH = 1024;
8
+ /** @internal */
9
+ function isComplexType(Type) {
10
+ const typeName = Type.name?.toLowerCase() || '';
11
+ return ['enum', 'hashmap', 'linkage', 'null', 'option', 'range', 'rangeinclusive', 'result', 'struct', 'tuple', 'vec', 'vecfixed'].includes(typeName);
12
+ }
7
13
  /** @internal */
8
14
  function formatFailure(registry, fn, _result, { message }, u8a, i, count, Type, key) {
9
15
  let type = '';
@@ -55,6 +61,9 @@ function decodeU8aStruct(registry, result, u8a, [Types, keys]) {
55
61
  const count = result.length;
56
62
  let offset = 0;
57
63
  let i = 0;
64
+ if (count > MAX_DEPTH && isComplexType(Types[i])) {
65
+ throw new Error(`decodeU8aStruct: Maximum depth exceeded, received ${count} elements, limit ${MAX_DEPTH}`);
66
+ }
58
67
  try {
59
68
  while (i < count) {
60
69
  const value = new Types[i](registry, u8a.subarray(offset));
@@ -76,6 +85,9 @@ function decodeU8aStruct(registry, result, u8a, [Types, keys]) {
76
85
  */
77
86
  function decodeU8aVec(registry, result, u8a, startAt, Type) {
78
87
  const count = result.length;
88
+ if (count > MAX_DEPTH && isComplexType(Type)) {
89
+ throw new Error(`decodeU8aVec: Maximum depth exceeded, received ${count} elements, limit ${MAX_DEPTH}`);
90
+ }
79
91
  let offset = startAt;
80
92
  let i = 0;
81
93
  try {
@@ -58,13 +58,13 @@ export class BTreeSet extends Set {
58
58
  createdAtHash;
59
59
  initialU8aLength;
60
60
  isStorageFallback;
61
- __internal__ValClass;
61
+ #ValClass;
62
62
  constructor(registry, valType, rawValue) {
63
63
  const [ValClass, values, decodedLength] = decodeSet(registry, valType, rawValue);
64
64
  super(sortSet(values));
65
65
  this.registry = registry;
66
66
  this.initialU8aLength = decodedLength;
67
- this.__internal__ValClass = ValClass;
67
+ this.#ValClass = ValClass;
68
68
  }
69
69
  static with(valType) {
70
70
  return class extends BTreeSet {
@@ -150,7 +150,7 @@ export class BTreeSet extends Set {
150
150
  * @description Returns the base runtime type name for this instance
151
151
  */
152
152
  toRawType() {
153
- return `BTreeSet<${this.registry.getClassName(this.__internal__ValClass) || new this.__internal__ValClass(this.registry).toRawType()}>`;
153
+ return `BTreeSet<${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
154
154
  }
155
155
  /**
156
156
  * @description Converts the value in a best-fit primitive form
@@ -28,29 +28,29 @@ 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
+ #decodedLength;
32
+ #isMsb;
33
33
  // In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
34
34
  // we are dealing with Lsb, which is the default (as of writing) BitVec format used
35
35
  // in the Polkadot code (this only affects the toHuman displays)
36
36
  constructor(registry, value, isMsb = false) {
37
37
  const [decodedLength, u8a] = decodeBitVec(value);
38
38
  super(registry, u8a);
39
- this.__internal__decodedLength = decodedLength;
40
- this.__internal__isMsb = isMsb;
39
+ this.#decodedLength = decodedLength;
40
+ this.#isMsb = isMsb;
41
41
  }
42
42
  /**
43
43
  * @description The length of the value when encoded as a Uint8Array
44
44
  */
45
45
  get encodedLength() {
46
- return this.length + compactToU8a(this.__internal__decodedLength).length;
46
+ return this.length + compactToU8a(this.#decodedLength).length;
47
47
  }
48
48
  /**
49
49
  * @description Returns a breakdown of the hex encoding for this Codec
50
50
  */
51
51
  inspect() {
52
52
  return {
53
- outer: [compactToU8a(this.__internal__decodedLength), super.toU8a()]
53
+ outer: [compactToU8a(this.#decodedLength), super.toU8a()]
54
54
  };
55
55
  }
56
56
  /**
@@ -73,7 +73,7 @@ export class BitVec extends Raw {
73
73
  const off = i * 8;
74
74
  const v = map[i];
75
75
  for (let j = 0; j < 8; j++) {
76
- result[off + j] = this.__internal__isMsb
76
+ result[off + j] = this.#isMsb
77
77
  ? v[j]
78
78
  : v[7 - j];
79
79
  }
@@ -86,7 +86,7 @@ export class BitVec extends Raw {
86
86
  toHuman() {
87
87
  return `0b${[...this.toU8a(true)]
88
88
  .map((d) => `00000000${d.toString(2)}`.slice(-8))
89
- .map((s) => this.__internal__isMsb ? s : s.split('').reverse().join(''))
89
+ .map((s) => this.#isMsb ? s : s.split('').reverse().join(''))
90
90
  .join('_')}`;
91
91
  }
92
92
  /**
@@ -103,6 +103,6 @@ export class BitVec extends Raw {
103
103
  const bitVec = super.toU8a(isBare);
104
104
  return isBare
105
105
  ? bitVec
106
- : u8aConcatStrict([compactToU8a(this.__internal__decodedLength), bitVec]);
106
+ : u8aConcatStrict([compactToU8a(this.#decodedLength), bitVec]);
107
107
  }
108
108
  }
package/extended/Map.js CHANGED
@@ -77,17 +77,17 @@ export class CodecMap extends Map {
77
77
  createdAtHash;
78
78
  initialU8aLength;
79
79
  isStorageFallback;
80
- __internal__KeyClass;
81
- __internal__ValClass;
82
- __internal__type;
80
+ #KeyClass;
81
+ #ValClass;
82
+ #type;
83
83
  constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
84
84
  const [KeyClass, ValClass, decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
85
85
  super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
86
86
  this.registry = registry;
87
87
  this.initialU8aLength = decodedLength;
88
- this.__internal__KeyClass = KeyClass;
89
- this.__internal__ValClass = ValClass;
90
- this.__internal__type = type;
88
+ this.#KeyClass = KeyClass;
89
+ this.#ValClass = ValClass;
90
+ this.#type = type;
91
91
  }
92
92
  /**
93
93
  * @description The length of the value when encoded as a Uint8Array
@@ -175,7 +175,7 @@ export class CodecMap extends Map {
175
175
  * @description Returns the base runtime type name for this instance
176
176
  */
177
177
  toRawType() {
178
- 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()}>`;
178
+ return `${this.#type}<${this.registry.getClassName(this.#KeyClass) || new this.#KeyClass(this.registry).toRawType()},${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
179
179
  }
180
180
  /**
181
181
  * @description Returns the string representation of the value
package/extended/Range.js CHANGED
@@ -5,10 +5,10 @@ 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
+ #rangeName;
9
9
  constructor(registry, Type, value, { rangeName = 'Range' } = {}) {
10
10
  super(registry, [Type, Type], value);
11
- this.__internal__rangeName = rangeName;
11
+ this.#rangeName = rangeName;
12
12
  }
13
13
  static with(Type) {
14
14
  return class extends Range {
@@ -33,6 +33,6 @@ export class Range extends Tuple {
33
33
  * @description Returns the base runtime type name for this instance
34
34
  */
35
35
  toRawType() {
36
- return `${this.__internal__rangeName}<${this.start.toRawType()}>`;
36
+ return `${this.#rangeName}<${this.start.toRawType()}>`;
37
37
  }
38
38
  }
@@ -21,15 +21,15 @@ 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
+ #Type;
25
+ #decoded;
26
+ #opaqueName;
27
27
  constructor(registry, typeName, value, { opaqueName = 'WrapperKeepOpaque' } = {}) {
28
28
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
29
29
  super(registry, u8a);
30
- this.__internal__Type = Type;
31
- this.__internal__decoded = decoded;
32
- this.__internal__opaqueName = opaqueName;
30
+ this.#Type = Type;
31
+ this.#decoded = decoded;
32
+ this.#opaqueName = opaqueName;
33
33
  }
34
34
  static with(Type) {
35
35
  return class extends WrapperKeepOpaque {
@@ -42,15 +42,15 @@ export class WrapperKeepOpaque extends Bytes {
42
42
  * @description Checks if the wrapper is decodable
43
43
  */
44
44
  get isDecoded() {
45
- return !!this.__internal__decoded;
45
+ return !!this.#decoded;
46
46
  }
47
47
  /**
48
48
  * @description Returns a breakdown of the hex encoding for this Codec
49
49
  */
50
50
  inspect() {
51
- return this.__internal__decoded
51
+ return this.#decoded
52
52
  ? {
53
- inner: [this.__internal__decoded.inspect()],
53
+ inner: [this.#decoded.inspect()],
54
54
  outer: [compactToU8a(this.length)]
55
55
  }
56
56
  : {
@@ -61,39 +61,39 @@ export class WrapperKeepOpaque extends Bytes {
61
61
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
62
62
  */
63
63
  toHuman(isExtended, disableAscii) {
64
- return this.__internal__decoded
65
- ? this.__internal__decoded.toHuman(isExtended, disableAscii)
64
+ return this.#decoded
65
+ ? this.#decoded.toHuman(isExtended, disableAscii)
66
66
  : super.toHuman(isExtended, disableAscii);
67
67
  }
68
68
  /**
69
69
  * @description Converts the value in a best-fit primitive form
70
70
  */
71
71
  toPrimitive(disableAscii) {
72
- return this.__internal__decoded
73
- ? this.__internal__decoded.toPrimitive(disableAscii)
72
+ return this.#decoded
73
+ ? this.#decoded.toPrimitive(disableAscii)
74
74
  : super.toPrimitive(disableAscii);
75
75
  }
76
76
  /**
77
77
  * @description Returns the base runtime type name for this instance
78
78
  */
79
79
  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())}>`;
80
+ return `${this.#opaqueName}<${this.registry.getClassName(this.#Type) || (this.#decoded ? this.#decoded.toRawType() : new this.#Type(this.registry).toRawType())}>`;
81
81
  }
82
82
  /**
83
83
  * @description Converts the Object to to a string (either decoded or bytes)
84
84
  */
85
85
  toString() {
86
- return this.__internal__decoded
87
- ? this.__internal__decoded.toString()
86
+ return this.#decoded
87
+ ? this.#decoded.toString()
88
88
  : super.toString();
89
89
  }
90
90
  /**
91
91
  * @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
92
92
  */
93
93
  unwrap() {
94
- if (!this.__internal__decoded) {
95
- throw new Error(`${this.__internal__opaqueName}: unwrapping an undecodable value`);
94
+ if (!this.#decoded) {
95
+ throw new Error(`${this.#opaqueName}: unwrapping an undecodable value`);
96
96
  }
97
- return this.__internal__decoded;
97
+ return this.#decoded;
98
98
  }
99
99
  }
package/native/Float.js CHANGED
@@ -13,14 +13,14 @@ export class Float extends Number {
13
13
  createdAtHash;
14
14
  initialU8aLength;
15
15
  isStorageFallback;
16
- __internal__bitLength;
16
+ #bitLength;
17
17
  constructor(registry, value, { bitLength = 32 } = {}) {
18
18
  super(isU8a(value) || isHex(value)
19
19
  ? value.length === 0
20
20
  ? 0
21
21
  : u8aToFloat(u8aToU8a(value), { bitLength })
22
22
  : (value || 0));
23
- this.__internal__bitLength = bitLength;
23
+ this.#bitLength = bitLength;
24
24
  this.encodedLength = bitLength / 8;
25
25
  this.initialU8aLength = this.encodedLength;
26
26
  this.registry = registry;
@@ -94,14 +94,14 @@ export class Float extends Number {
94
94
  * @description Returns the base runtime type name for this instance
95
95
  */
96
96
  toRawType() {
97
- return `f${this.__internal__bitLength}`;
97
+ return `f${this.#bitLength}`;
98
98
  }
99
99
  /**
100
100
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
101
101
  */
102
102
  toU8a(_isBare) {
103
103
  return floatToU8a(this, {
104
- bitLength: this.__internal__bitLength
104
+ bitLength: this.#bitLength
105
105
  });
106
106
  }
107
107
  }
package/native/Set.js CHANGED
@@ -70,13 +70,13 @@ export class CodecSet extends Set {
70
70
  createdAtHash;
71
71
  initialU8aLength;
72
72
  isStorageFallback;
73
- __internal__allowed;
74
- __internal__byteLength;
73
+ #allowed;
74
+ #byteLength;
75
75
  constructor(registry, setValues, value, bitLength = 8) {
76
76
  super(decodeSet(setValues, value, bitLength));
77
77
  this.registry = registry;
78
- this.__internal__allowed = setValues;
79
- this.__internal__byteLength = bitLength / 8;
78
+ this.#allowed = setValues;
79
+ this.#byteLength = bitLength / 8;
80
80
  }
81
81
  static with(values, bitLength) {
82
82
  return class extends CodecSet {
@@ -98,7 +98,7 @@ export class CodecSet extends Set {
98
98
  * @description The length of the value when encoded as a Uint8Array
99
99
  */
100
100
  get encodedLength() {
101
- return this.__internal__byteLength;
101
+ return this.#byteLength;
102
102
  }
103
103
  /**
104
104
  * @description returns a hash of the contents
@@ -122,7 +122,7 @@ export class CodecSet extends Set {
122
122
  * @description The encoded value for the set members
123
123
  */
124
124
  get valueEncoded() {
125
- return encodeSet(this.__internal__allowed, this.strings);
125
+ return encodeSet(this.#allowed, this.strings);
126
126
  }
127
127
  /**
128
128
  * @description adds a value to the Set (extended to allow for validity checking)
@@ -131,7 +131,7 @@ export class CodecSet extends Set {
131
131
  // ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
132
132
  // we have the isUndefined(this._setValues) in here as well, add is used internally
133
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])) {
134
+ if (this.#allowed && isUndefined(this.#allowed[key])) {
135
135
  throw new Error(`Set: Invalid key '${key}' on add`);
136
136
  }
137
137
  super.add(key);
@@ -195,7 +195,7 @@ export class CodecSet extends Set {
195
195
  * @description Returns the base runtime type name for this instance
196
196
  */
197
197
  toRawType() {
198
- return stringify({ _set: this.__internal__allowed });
198
+ return stringify({ _set: this.#allowed });
199
199
  }
200
200
  /**
201
201
  * @description Returns the string representation of the value
@@ -208,7 +208,7 @@ export class CodecSet extends Set {
208
208
  */
209
209
  toU8a(_isBare) {
210
210
  return bnToU8a(this.valueEncoded, {
211
- bitLength: this.__internal__byteLength * 8,
211
+ bitLength: this.#byteLength * 8,
212
212
  isLe: true
213
213
  });
214
214
  }