@polkadot/types-codec 7.4.2-9 → 7.5.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.
Files changed (51) hide show
  1. package/abstract/AbstractArray.js +0 -4
  2. package/abstract/AbstractInt.js +10 -24
  3. package/base/Base.js +15 -29
  4. package/base/Compact.js +20 -34
  5. package/base/DoNotConstruct.js +14 -23
  6. package/base/Enum.js +36 -70
  7. package/base/Null.js +2 -3
  8. package/base/Option.js +19 -37
  9. package/base/Tuple.js +5 -11
  10. package/base/Vec.js +6 -12
  11. package/base/VecFixed.js +4 -10
  12. package/extended/BTreeSet.js +4 -13
  13. package/extended/BitVec.js +5 -11
  14. package/extended/Map.js +8 -27
  15. package/extended/Range.cjs +2 -20
  16. package/extended/Range.d.ts +0 -4
  17. package/extended/Range.js +4 -25
  18. package/extended/RangeInclusive.cjs +28 -0
  19. package/extended/RangeInclusive.d.ts +6 -0
  20. package/extended/RangeInclusive.js +18 -0
  21. package/extended/WrapperKeepOpaque.cjs +11 -3
  22. package/extended/WrapperKeepOpaque.d.ts +4 -2
  23. package/extended/WrapperKeepOpaque.js +15 -24
  24. package/extended/WrapperOpaque.cjs +7 -31
  25. package/extended/WrapperOpaque.d.ts +6 -10
  26. package/extended/WrapperOpaque.js +7 -30
  27. package/extended/index.cjs +3 -1
  28. package/extended/index.d.ts +2 -1
  29. package/extended/index.js +2 -1
  30. package/native/Bool.js +0 -2
  31. package/native/Date.js +0 -2
  32. package/native/Json.js +0 -2
  33. package/native/Raw.js +0 -3
  34. package/native/Set.js +18 -32
  35. package/native/Struct.js +12 -30
  36. package/native/Text.js +7 -20
  37. package/package.json +7 -2
  38. package/packageInfo.cjs +1 -1
  39. package/packageInfo.js +1 -1
  40. package/primitive/I128.js +2 -5
  41. package/primitive/I16.js +2 -5
  42. package/primitive/I256.js +2 -5
  43. package/primitive/I32.js +2 -5
  44. package/primitive/I64.js +2 -5
  45. package/primitive/I8.js +2 -5
  46. package/primitive/U128.js +2 -5
  47. package/primitive/U16.js +2 -5
  48. package/primitive/U256.js +2 -5
  49. package/primitive/U32.js +2 -5
  50. package/primitive/U64.js +2 -5
  51. package/primitive/U8.js +2 -5
package/extended/Map.js CHANGED
@@ -1,5 +1,3 @@
1
- import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
2
- import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
3
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
4
2
  // SPDX-License-Identifier: Apache-2.0
5
3
  import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
@@ -81,36 +79,19 @@ function decodeMap(registry, keyType, valType, value) {
81
79
  throw new Error('Map: cannot decode type');
82
80
  }
83
81
 
84
- var _KeyClass = /*#__PURE__*/_classPrivateFieldLooseKey("KeyClass");
85
-
86
- var _ValClass = /*#__PURE__*/_classPrivateFieldLooseKey("ValClass");
87
-
88
- var _type = /*#__PURE__*/_classPrivateFieldLooseKey("type");
89
-
90
82
  export class CodecMap extends Map {
83
+ #KeyClass;
84
+ #ValClass;
85
+ #type;
86
+
91
87
  constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
92
88
  const [decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
93
89
  super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
94
- this.registry = void 0;
95
- this.createdAtHash = void 0;
96
- Object.defineProperty(this, _KeyClass, {
97
- writable: true,
98
- value: void 0
99
- });
100
- Object.defineProperty(this, _ValClass, {
101
- writable: true,
102
- value: void 0
103
- });
104
- this.initialU8aLength = void 0;
105
- Object.defineProperty(this, _type, {
106
- writable: true,
107
- value: void 0
108
- });
109
90
  this.registry = registry;
110
91
  this.initialU8aLength = decodedLength;
111
- _classPrivateFieldLooseBase(this, _KeyClass)[_KeyClass] = typeToConstructor(registry, keyType);
112
- _classPrivateFieldLooseBase(this, _ValClass)[_ValClass] = typeToConstructor(registry, valType);
113
- _classPrivateFieldLooseBase(this, _type)[_type] = type;
92
+ this.#KeyClass = typeToConstructor(registry, keyType);
93
+ this.#ValClass = typeToConstructor(registry, valType);
94
+ this.#type = type;
114
95
  }
115
96
  /**
116
97
  * @description The length of the value when encoded as a Uint8Array
@@ -192,7 +173,7 @@ export class CodecMap extends Map {
192
173
 
193
174
 
194
175
  toRawType() {
195
- return `${_classPrivateFieldLooseBase(this, _type)[_type]}<${this.registry.getClassName(_classPrivateFieldLooseBase(this, _KeyClass)[_KeyClass]) || new (_classPrivateFieldLooseBase(this, _KeyClass)[_KeyClass])(this.registry).toRawType()},${this.registry.getClassName(_classPrivateFieldLooseBase(this, _ValClass)[_ValClass]) || new (_classPrivateFieldLooseBase(this, _ValClass)[_ValClass])(this.registry).toRawType()}>`;
176
+ 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()}>`;
196
177
  }
197
178
  /**
198
179
  * @description Returns the string representation of the value
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.RangeInclusive = exports.Range = void 0;
8
+ exports.Range = void 0;
9
9
 
10
10
  var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
11
11
 
@@ -71,22 +71,4 @@ class Range extends _Tuple.Tuple {
71
71
 
72
72
  }
73
73
 
74
- exports.Range = Range;
75
-
76
- class RangeInclusive extends Range {
77
- constructor(registry, Type, value) {
78
- super(registry, Type, value, 'RangeInclusive');
79
- }
80
-
81
- static with(Type) {
82
- return class extends RangeInclusive {
83
- constructor(registry, value) {
84
- super(registry, Type, value);
85
- }
86
-
87
- };
88
- }
89
-
90
- }
91
-
92
- exports.RangeInclusive = RangeInclusive;
74
+ exports.Range = Range;
@@ -23,8 +23,4 @@ export declare class Range<T extends INumber> extends Tuple {
23
23
  */
24
24
  toRawType(): string;
25
25
  }
26
- export declare class RangeInclusive<T extends INumber = INumber> extends Range<T> {
27
- constructor(registry: Registry, Type: CodecClass<T> | string, value?: AnyTuple);
28
- static with<T extends INumber>(Type: CodecClass<T> | string): CodecClass<RangeInclusive<T>>;
29
- }
30
26
  export {};
package/extended/Range.js CHANGED
@@ -1,27 +1,21 @@
1
- import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
2
- import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
3
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
4
2
  // SPDX-License-Identifier: Apache-2.0
5
3
  import { Tuple } from "../base/Tuple.js";
6
4
 
7
- var _rangeName = /*#__PURE__*/_classPrivateFieldLooseKey("rangeName");
8
-
9
5
  /**
10
6
  * @name Range
11
7
  * @description
12
8
  * Rust `Range<T>` representation
13
9
  */
14
10
  export class Range extends Tuple {
11
+ #rangeName;
12
+
15
13
  constructor(registry, Type, value, rangeName = 'Range') {
16
14
  super(registry, {
17
15
  end: Type,
18
16
  start: Type
19
17
  }, value);
20
- Object.defineProperty(this, _rangeName, {
21
- writable: true,
22
- value: void 0
23
- });
24
- _classPrivateFieldLooseBase(this, _rangeName)[_rangeName] = rangeName;
18
+ this.#rangeName = rangeName;
25
19
  }
26
20
 
27
21
  static with(Types) {
@@ -54,22 +48,7 @@ export class Range extends Tuple {
54
48
 
55
49
 
56
50
  toRawType() {
57
- return `${_classPrivateFieldLooseBase(this, _rangeName)[_rangeName]}<${this.start.toRawType()}>`;
58
- }
59
-
60
- }
61
- export class RangeInclusive extends Range {
62
- constructor(registry, Type, value) {
63
- super(registry, Type, value, 'RangeInclusive');
64
- }
65
-
66
- static with(Type) {
67
- return class extends RangeInclusive {
68
- constructor(registry, value) {
69
- super(registry, Type, value);
70
- }
71
-
72
- };
51
+ return `${this.#rangeName}<${this.start.toRawType()}>`;
73
52
  }
74
53
 
75
54
  }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RangeInclusive = void 0;
7
+
8
+ var _Range = require("./Range.cjs");
9
+
10
+ // Copyright 2017-2022 @polkadot/types-codec authors & contributors
11
+ // SPDX-License-Identifier: Apache-2.0
12
+ class RangeInclusive extends _Range.Range {
13
+ constructor(registry, Type, value) {
14
+ super(registry, Type, value, 'RangeInclusive');
15
+ }
16
+
17
+ static with(Type) {
18
+ return class extends RangeInclusive {
19
+ constructor(registry, value) {
20
+ super(registry, Type, value);
21
+ }
22
+
23
+ };
24
+ }
25
+
26
+ }
27
+
28
+ exports.RangeInclusive = RangeInclusive;
@@ -0,0 +1,6 @@
1
+ import type { AnyTuple, CodecClass, INumber, Registry } from '../types';
2
+ import { Range } from './Range';
3
+ export declare class RangeInclusive<T extends INumber = INumber> extends Range<T> {
4
+ constructor(registry: Registry, Type: CodecClass<T> | string, value?: AnyTuple);
5
+ static with<T extends INumber>(Type: CodecClass<T> | string): CodecClass<RangeInclusive<T>>;
6
+ }
@@ -0,0 +1,18 @@
1
+ // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Range } from "./Range.js";
4
+ export class RangeInclusive extends Range {
5
+ constructor(registry, Type, value) {
6
+ super(registry, Type, value, 'RangeInclusive');
7
+ }
8
+
9
+ static with(Type) {
10
+ return class extends RangeInclusive {
11
+ constructor(registry, value) {
12
+ super(registry, Type, value);
13
+ }
14
+
15
+ };
16
+ }
17
+
18
+ }
@@ -34,15 +34,18 @@ function decodeRaw(registry, typeName, value) {
34
34
  }
35
35
 
36
36
  const instance = new Type(registry, value);
37
- return [Type, instance, instance.toHex()];
37
+ return [Type, instance, (0, _util.compactAddLength)(instance.toU8a())];
38
38
  }
39
39
 
40
40
  var _Type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Type");
41
41
 
42
42
  var _decoded = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("decoded");
43
43
 
44
+ var _opaqueName = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("opaqueName");
45
+
44
46
  class WrapperKeepOpaque extends _Bytes.Bytes {
45
47
  constructor(registry, typeName, value) {
48
+ let opaqueName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'WrapperKeepOpaque';
46
49
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
47
50
  super(registry, u8a);
48
51
  Object.defineProperty(this, _Type, {
@@ -53,8 +56,13 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
53
56
  writable: true,
54
57
  value: void 0
55
58
  });
59
+ Object.defineProperty(this, _opaqueName, {
60
+ writable: true,
61
+ value: void 0
62
+ });
56
63
  (0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type] = Type;
57
64
  (0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded] = decoded;
65
+ (0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName] = opaqueName;
58
66
  }
59
67
 
60
68
  static with(Type) {
@@ -87,7 +95,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
87
95
 
88
96
 
89
97
  toRawType() {
90
- return `WrapperKeepOpaque<${this.registry.getClassName((0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type]) || ((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded] ? (0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded].toRawType() : new ((0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type])(this.registry).toRawType())}>`;
98
+ return `${(0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName]}<${this.registry.getClassName((0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type]) || ((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded] ? (0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded].toRawType() : new ((0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type])(this.registry).toRawType())}>`;
91
99
  }
92
100
  /**
93
101
  * @description Converts the Object to to a string (either decoded or bytes)
@@ -103,7 +111,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
103
111
 
104
112
 
105
113
  unwrap() {
106
- return (0, _util.assertReturn)((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded], 'WrapperKeepOpaque: unwrapping an undecodable value');
114
+ return (0, _util.assertReturn)((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded], () => `${(0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName]}: unwrapping an undecodable value`);
107
115
  }
108
116
 
109
117
  }
@@ -1,8 +1,9 @@
1
- import type { AnyJson, AnyU8a, Codec, CodecClass, Registry } from '../types';
1
+ import type { AnyJson, Codec, CodecClass, Registry } from '../types';
2
2
  import { Bytes } from './Bytes';
3
+ declare type OpaqueName = 'WrapperKeepOpaque' | 'WrapperOpaque';
3
4
  export declare class WrapperKeepOpaque<T extends Codec> extends Bytes {
4
5
  #private;
5
- constructor(registry: Registry, typeName: CodecClass<T> | string, value?: AnyU8a | Codec);
6
+ constructor(registry: Registry, typeName: CodecClass<T> | string, value?: unknown, opaqueName?: OpaqueName);
6
7
  static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<WrapperKeepOpaque<T>>;
7
8
  /**
8
9
  * @description Checks if the wrapper is decodable
@@ -25,3 +26,4 @@ export declare class WrapperKeepOpaque<T extends Codec> extends Bytes {
25
26
  */
26
27
  unwrap(): T;
27
28
  }
29
+ export {};
@@ -1,8 +1,6 @@
1
- import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
2
- import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
3
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
4
2
  // SPDX-License-Identifier: Apache-2.0
5
- import { assertReturn, compactStripLength, isHex, isU8a } from '@polkadot/util';
3
+ import { assertReturn, compactAddLength, compactStripLength, isHex, isU8a } from '@polkadot/util';
6
4
  import { Raw } from "../native/Raw.js";
7
5
  import { typeToConstructor } from "../utils/index.js";
8
6
  import { Bytes } from "./Bytes.js";
@@ -20,27 +18,20 @@ function decodeRaw(registry, typeName, value) {
20
18
  }
21
19
 
22
20
  const instance = new Type(registry, value);
23
- return [Type, instance, instance.toHex()];
21
+ return [Type, instance, compactAddLength(instance.toU8a())];
24
22
  }
25
23
 
26
- var _Type = /*#__PURE__*/_classPrivateFieldLooseKey("Type");
27
-
28
- var _decoded = /*#__PURE__*/_classPrivateFieldLooseKey("decoded");
29
-
30
24
  export class WrapperKeepOpaque extends Bytes {
31
- constructor(registry, typeName, value) {
25
+ #Type;
26
+ #decoded;
27
+ #opaqueName;
28
+
29
+ constructor(registry, typeName, value, opaqueName = 'WrapperKeepOpaque') {
32
30
  const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
33
31
  super(registry, u8a);
34
- Object.defineProperty(this, _Type, {
35
- writable: true,
36
- value: void 0
37
- });
38
- Object.defineProperty(this, _decoded, {
39
- writable: true,
40
- value: void 0
41
- });
42
- _classPrivateFieldLooseBase(this, _Type)[_Type] = Type;
43
- _classPrivateFieldLooseBase(this, _decoded)[_decoded] = decoded;
32
+ this.#Type = Type;
33
+ this.#decoded = decoded;
34
+ this.#opaqueName = opaqueName;
44
35
  }
45
36
 
46
37
  static with(Type) {
@@ -57,7 +48,7 @@ export class WrapperKeepOpaque extends Bytes {
57
48
 
58
49
 
59
50
  get isDecoded() {
60
- return !!_classPrivateFieldLooseBase(this, _decoded)[_decoded];
51
+ return !!this.#decoded;
61
52
  }
62
53
  /**
63
54
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
@@ -65,7 +56,7 @@ export class WrapperKeepOpaque extends Bytes {
65
56
 
66
57
 
67
58
  toHuman(isExtended) {
68
- return _classPrivateFieldLooseBase(this, _decoded)[_decoded] ? _classPrivateFieldLooseBase(this, _decoded)[_decoded].toHuman(isExtended) : super.toHuman();
59
+ return this.#decoded ? this.#decoded.toHuman(isExtended) : super.toHuman();
69
60
  }
70
61
  /**
71
62
  * @description Returns the base runtime type name for this instance
@@ -73,7 +64,7 @@ export class WrapperKeepOpaque extends Bytes {
73
64
 
74
65
 
75
66
  toRawType() {
76
- return `WrapperKeepOpaque<${this.registry.getClassName(_classPrivateFieldLooseBase(this, _Type)[_Type]) || (_classPrivateFieldLooseBase(this, _decoded)[_decoded] ? _classPrivateFieldLooseBase(this, _decoded)[_decoded].toRawType() : new (_classPrivateFieldLooseBase(this, _Type)[_Type])(this.registry).toRawType())}>`;
67
+ return `${this.#opaqueName}<${this.registry.getClassName(this.#Type) || (this.#decoded ? this.#decoded.toRawType() : new this.#Type(this.registry).toRawType())}>`;
77
68
  }
78
69
  /**
79
70
  * @description Converts the Object to to a string (either decoded or bytes)
@@ -81,7 +72,7 @@ export class WrapperKeepOpaque extends Bytes {
81
72
 
82
73
 
83
74
  toString() {
84
- return _classPrivateFieldLooseBase(this, _decoded)[_decoded] ? _classPrivateFieldLooseBase(this, _decoded)[_decoded].toString() : super.toString();
75
+ return this.#decoded ? this.#decoded.toString() : super.toString();
85
76
  }
86
77
  /**
87
78
  * @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
@@ -89,7 +80,7 @@ export class WrapperKeepOpaque extends Bytes {
89
80
 
90
81
 
91
82
  unwrap() {
92
- return assertReturn(_classPrivateFieldLooseBase(this, _decoded)[_decoded], 'WrapperKeepOpaque: unwrapping an undecodable value');
83
+ return assertReturn(this.#decoded, () => `${this.#opaqueName}: unwrapping an undecodable value`);
93
84
  }
94
85
 
95
86
  }
@@ -5,28 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.WrapperOpaque = void 0;
7
7
 
8
- var _util = require("@polkadot/util");
9
-
10
- var _Base = require("../base/Base.cjs");
11
-
12
- var _index = require("../utils/index.cjs");
8
+ var _WrapperKeepOpaque = require("./WrapperKeepOpaque.cjs");
13
9
 
14
10
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
15
11
  // SPDX-License-Identifier: Apache-2.0
16
- function decodeRaw(registry, Type, value) {
17
- const Clazz = (0, _index.typeToConstructor)(registry, Type);
18
-
19
- if ((0, _util.isU8a)(value)) {
20
- const [, u8a] = (0, _util.compactStripLength)(value);
21
- return new Clazz(registry, u8a);
22
- }
23
-
24
- return new Clazz(registry, value);
25
- }
26
-
27
- class WrapperOpaque extends _Base.Base {
28
- constructor(registry, Type, value) {
29
- super(registry, decodeRaw(registry, Type, value));
12
+ class WrapperOpaque extends _WrapperKeepOpaque.WrapperKeepOpaque {
13
+ constructor(registry, typeName, value) {
14
+ super(registry, typeName, value, 'WrapperOpaque');
30
15
  }
31
16
 
32
17
  static with(Type) {
@@ -38,21 +23,12 @@ class WrapperOpaque extends _Base.Base {
38
23
  };
39
24
  }
40
25
  /**
41
- * @description Returns the base runtime type name for this instance
42
- */
43
-
44
-
45
- toRawType() {
46
- return `WrapperOpaque<${this.inner.toRawType()}>`;
47
- }
48
- /**
49
- * @description The length of the value when encoded as a Uint8Array
26
+ * @description The inner value for this wrapper, in all cases it _should_ be decodable (unlike KeepOpaque)
50
27
  */
51
28
 
52
29
 
53
- toU8a(isBare) {
54
- const u8a = super.toU8a(isBare);
55
- return isBare ? u8a : (0, _util.compactAddLength)(u8a);
30
+ get inner() {
31
+ return this.unwrap();
56
32
  }
57
33
 
58
34
  }
@@ -1,14 +1,10 @@
1
1
  import type { Codec, CodecClass, Registry } from '../types';
2
- import { Base } from '../base/Base';
3
- export declare class WrapperOpaque<T extends Codec> extends Base<T> {
4
- constructor(registry: Registry, Type: CodecClass<T> | string, value?: unknown);
5
- static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<WrapperOpaque<T>>;
2
+ import { WrapperKeepOpaque } from './WrapperKeepOpaque';
3
+ export declare class WrapperOpaque<T extends Codec> extends WrapperKeepOpaque<T> {
4
+ constructor(registry: Registry, typeName: CodecClass<T> | string, value?: unknown);
5
+ static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<WrapperKeepOpaque<T>>;
6
6
  /**
7
- * @description Returns the base runtime type name for this instance
7
+ * @description The inner value for this wrapper, in all cases it _should_ be decodable (unlike KeepOpaque)
8
8
  */
9
- toRawType(): string;
10
- /**
11
- * @description The length of the value when encoded as a Uint8Array
12
- */
13
- toU8a(isBare?: boolean): Uint8Array;
9
+ get inner(): T;
14
10
  }
@@ -1,23 +1,9 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { compactAddLength, compactStripLength, isU8a } from '@polkadot/util';
4
- import { Base } from "../base/Base.js";
5
- import { typeToConstructor } from "../utils/index.js";
6
-
7
- function decodeRaw(registry, Type, value) {
8
- const Clazz = typeToConstructor(registry, Type);
9
-
10
- if (isU8a(value)) {
11
- const [, u8a] = compactStripLength(value);
12
- return new Clazz(registry, u8a);
13
- }
14
-
15
- return new Clazz(registry, value);
16
- }
17
-
18
- export class WrapperOpaque extends Base {
19
- constructor(registry, Type, value) {
20
- super(registry, decodeRaw(registry, Type, value));
3
+ import { WrapperKeepOpaque } from "./WrapperKeepOpaque.js";
4
+ export class WrapperOpaque extends WrapperKeepOpaque {
5
+ constructor(registry, typeName, value) {
6
+ super(registry, typeName, value, 'WrapperOpaque');
21
7
  }
22
8
 
23
9
  static with(Type) {
@@ -29,21 +15,12 @@ export class WrapperOpaque extends Base {
29
15
  };
30
16
  }
31
17
  /**
32
- * @description Returns the base runtime type name for this instance
33
- */
34
-
35
-
36
- toRawType() {
37
- return `WrapperOpaque<${this.inner.toRawType()}>`;
38
- }
39
- /**
40
- * @description The length of the value when encoded as a Uint8Array
18
+ * @description The inner value for this wrapper, in all cases it _should_ be decodable (unlike KeepOpaque)
41
19
  */
42
20
 
43
21
 
44
- toU8a(isBare) {
45
- const u8a = super.toU8a(isBare);
46
- return isBare ? u8a : compactAddLength(u8a);
22
+ get inner() {
23
+ return this.unwrap();
47
24
  }
48
25
 
49
26
  }
@@ -60,7 +60,7 @@ Object.defineProperty(exports, "Range", {
60
60
  Object.defineProperty(exports, "RangeInclusive", {
61
61
  enumerable: true,
62
62
  get: function () {
63
- return _Range.RangeInclusive;
63
+ return _RangeInclusive.RangeInclusive;
64
64
  }
65
65
  });
66
66
  Object.defineProperty(exports, "Type", {
@@ -104,6 +104,8 @@ var _Map = require("./Map.cjs");
104
104
 
105
105
  var _Range = require("./Range.cjs");
106
106
 
107
+ var _RangeInclusive = require("./RangeInclusive.cjs");
108
+
107
109
  var _Type = require("./Type.cjs");
108
110
 
109
111
  var _U8aFixed = require("./U8aFixed.cjs");
@@ -5,7 +5,8 @@ export { Bytes } from './Bytes';
5
5
  export { HashMap } from './HashMap';
6
6
  export { Linkage } from './Linkage';
7
7
  export { CodecMap, CodecMap as Map } from './Map';
8
- export { Range, RangeInclusive } from './Range';
8
+ export { Range } from './Range';
9
+ export { RangeInclusive } from './RangeInclusive';
9
10
  export { Type } from './Type';
10
11
  export { U8aFixed } from './U8aFixed';
11
12
  export { WrapperKeepOpaque } from './WrapperKeepOpaque';
package/extended/index.js CHANGED
@@ -7,7 +7,8 @@ export { Bytes } from "./Bytes.js";
7
7
  export { HashMap } from "./HashMap.js";
8
8
  export { Linkage } from "./Linkage.js";
9
9
  export { CodecMap, CodecMap as Map } from "./Map.js";
10
- export { Range, RangeInclusive } from "./Range.js";
10
+ export { Range } from "./Range.js";
11
+ export { RangeInclusive } from "./RangeInclusive.js";
11
12
  export { Type } from "./Type.js";
12
13
  export { U8aFixed } from "./U8aFixed.js";
13
14
  export { WrapperKeepOpaque } from "./WrapperKeepOpaque.js";
package/native/Bool.js CHANGED
@@ -24,8 +24,6 @@ export class bool extends Boolean {
24
24
  // eslint-disable-next-line @typescript-eslint/ban-types
25
25
  constructor(registry, value = false) {
26
26
  super(decodeBool(value));
27
- this.registry = void 0;
28
- this.createdAtHash = void 0;
29
27
  this.registry = registry;
30
28
  }
31
29
  /**
package/native/Date.js CHANGED
@@ -29,8 +29,6 @@ function decodeDate(value) {
29
29
  export class CodecDate extends Date {
30
30
  constructor(registry, value = 0) {
31
31
  super(decodeDate(value));
32
- this.registry = void 0;
33
- this.createdAtHash = void 0;
34
32
  this.registry = registry;
35
33
  }
36
34
  /**
package/native/Json.js CHANGED
@@ -21,8 +21,6 @@ export class Json extends Map {
21
21
  constructor(registry, value) {
22
22
  const decoded = decodeJson(value);
23
23
  super(decoded);
24
- this.registry = void 0;
25
- this.createdAtHash = void 0;
26
24
  this.registry = registry;
27
25
  objectProperties(this, decoded.map(([k]) => k), k => this.get(k));
28
26
  }
package/native/Raw.js CHANGED
@@ -14,9 +14,6 @@ import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a }
14
14
  export class Raw extends Uint8Array {
15
15
  constructor(registry, value, initialU8aLength) {
16
16
  super(u8aToU8a(value));
17
- this.registry = void 0;
18
- this.createdAtHash = void 0;
19
- this.initialU8aLength = void 0;
20
17
  this.registry = registry;
21
18
  this.initialU8aLength = initialU8aLength;
22
19
  }