@polkadot/types-codec 6.12.2-2 → 6.12.2-6

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.
package/base/Base.cjs CHANGED
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.Base = void 0;
7
9
 
10
+ var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
11
+
12
+ var _classPrivateFieldLooseKey2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseKey"));
13
+
14
+ var _raw = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("raw");
15
+
8
16
  // Copyright 2017-2021 @polkadot/types-codec authors & contributors
9
17
  // SPDX-License-Identifier: Apache-2.0
10
18
 
@@ -17,9 +25,12 @@ class Base {
17
25
  this.registry = void 0;
18
26
  this.createdAtHash = void 0;
19
27
  this.initialU8aLength = void 0;
20
- this._raw = void 0;
28
+ Object.defineProperty(this, _raw, {
29
+ writable: true,
30
+ value: void 0
31
+ });
21
32
  this.registry = registry;
22
- this._raw = value;
33
+ (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw] = value;
23
34
  this.initialU8aLength = initialU8aLength;
24
35
  }
25
36
  /**
@@ -38,13 +49,17 @@ class Base {
38
49
  get hash() {
39
50
  return this.registry.hash(this.toU8a());
40
51
  }
52
+
53
+ get inner() {
54
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw];
55
+ }
41
56
  /**
42
57
  * @description Checks if the value is an empty value
43
58
  */
44
59
 
45
60
 
46
61
  get isEmpty() {
47
- return this._raw.isEmpty;
62
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].isEmpty;
48
63
  }
49
64
  /**
50
65
  * @description Compares the value of the input to see if there is a match
@@ -52,7 +67,7 @@ class Base {
52
67
 
53
68
 
54
69
  eq(other) {
55
- return this._raw.eq(other);
70
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].eq(other);
56
71
  }
57
72
  /**
58
73
  * @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
@@ -60,7 +75,7 @@ class Base {
60
75
 
61
76
 
62
77
  toHex(isLe) {
63
- return this._raw.toHex(isLe);
78
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].toHex(isLe);
64
79
  }
65
80
  /**
66
81
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
@@ -68,7 +83,7 @@ class Base {
68
83
 
69
84
 
70
85
  toHuman(isExtended) {
71
- return this._raw.toHuman(isExtended);
86
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].toHuman(isExtended);
72
87
  }
73
88
  /**
74
89
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -76,7 +91,7 @@ class Base {
76
91
 
77
92
 
78
93
  toJSON() {
79
- return this._raw.toJSON();
94
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].toJSON();
80
95
  }
81
96
  /**
82
97
  * @description Returns the string representation of the value
@@ -84,7 +99,7 @@ class Base {
84
99
 
85
100
 
86
101
  toString() {
87
- return this._raw.toString();
102
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].toString();
88
103
  }
89
104
  /**
90
105
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
@@ -93,7 +108,7 @@ class Base {
93
108
 
94
109
 
95
110
  toU8a(isBare) {
96
- return this._raw.toU8a(isBare);
111
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw].toU8a(isBare);
97
112
  }
98
113
  /**
99
114
  * @description Returns the base runtime type name for this instance
@@ -104,6 +119,10 @@ class Base {
104
119
  return 'Base';
105
120
  }
106
121
 
122
+ unwrap() {
123
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw];
124
+ }
125
+
107
126
  }
108
127
 
109
128
  exports.Base = Base;
package/base/Base.d.ts CHANGED
@@ -5,10 +5,10 @@ import type { AnyJson, BareOpts, Codec, CodecRegistry, IU8a } from '../types';
5
5
  * @description A type extends the Base class, when it holds a value
6
6
  */
7
7
  export declare abstract class Base<T extends Codec> implements Codec {
8
+ #private;
8
9
  readonly registry: CodecRegistry;
9
10
  createdAtHash?: IU8a;
10
11
  readonly initialU8aLength?: number;
11
- protected readonly _raw: T;
12
12
  protected constructor(registry: CodecRegistry, value: T, initialU8aLength?: number);
13
13
  /**
14
14
  * @description The length of the value when encoded as a Uint8Array
@@ -18,6 +18,7 @@ export declare abstract class Base<T extends Codec> implements Codec {
18
18
  * @description returns a hash of the contents
19
19
  */
20
20
  get hash(): IU8a;
21
+ get inner(): T;
21
22
  /**
22
23
  * @description Checks if the value is an empty value
23
24
  */
@@ -51,4 +52,5 @@ export declare abstract class Base<T extends Codec> implements Codec {
51
52
  * @description Returns the base runtime type name for this instance
52
53
  */
53
54
  toRawType(): string;
55
+ unwrap(): T;
54
56
  }
package/base/Base.js CHANGED
@@ -1,3 +1,8 @@
1
+ import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
2
+ import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
3
+
4
+ var _raw = /*#__PURE__*/_classPrivateFieldLooseKey("raw");
5
+
1
6
  // Copyright 2017-2021 @polkadot/types-codec authors & contributors
2
7
  // SPDX-License-Identifier: Apache-2.0
3
8
 
@@ -10,9 +15,12 @@ export class Base {
10
15
  this.registry = void 0;
11
16
  this.createdAtHash = void 0;
12
17
  this.initialU8aLength = void 0;
13
- this._raw = void 0;
18
+ Object.defineProperty(this, _raw, {
19
+ writable: true,
20
+ value: void 0
21
+ });
14
22
  this.registry = registry;
15
- this._raw = value;
23
+ _classPrivateFieldLooseBase(this, _raw)[_raw] = value;
16
24
  this.initialU8aLength = initialU8aLength;
17
25
  }
18
26
  /**
@@ -31,13 +39,17 @@ export class Base {
31
39
  get hash() {
32
40
  return this.registry.hash(this.toU8a());
33
41
  }
42
+
43
+ get inner() {
44
+ return _classPrivateFieldLooseBase(this, _raw)[_raw];
45
+ }
34
46
  /**
35
47
  * @description Checks if the value is an empty value
36
48
  */
37
49
 
38
50
 
39
51
  get isEmpty() {
40
- return this._raw.isEmpty;
52
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].isEmpty;
41
53
  }
42
54
  /**
43
55
  * @description Compares the value of the input to see if there is a match
@@ -45,7 +57,7 @@ export class Base {
45
57
 
46
58
 
47
59
  eq(other) {
48
- return this._raw.eq(other);
60
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].eq(other);
49
61
  }
50
62
  /**
51
63
  * @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
@@ -53,7 +65,7 @@ export class Base {
53
65
 
54
66
 
55
67
  toHex(isLe) {
56
- return this._raw.toHex(isLe);
68
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].toHex(isLe);
57
69
  }
58
70
  /**
59
71
  * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
@@ -61,7 +73,7 @@ export class Base {
61
73
 
62
74
 
63
75
  toHuman(isExtended) {
64
- return this._raw.toHuman(isExtended);
76
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].toHuman(isExtended);
65
77
  }
66
78
  /**
67
79
  * @description Converts the Object to JSON, typically used for RPC transfers
@@ -69,7 +81,7 @@ export class Base {
69
81
 
70
82
 
71
83
  toJSON() {
72
- return this._raw.toJSON();
84
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].toJSON();
73
85
  }
74
86
  /**
75
87
  * @description Returns the string representation of the value
@@ -77,7 +89,7 @@ export class Base {
77
89
 
78
90
 
79
91
  toString() {
80
- return this._raw.toString();
92
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].toString();
81
93
  }
82
94
  /**
83
95
  * @description Encodes the value as a Uint8Array as per the SCALE specifications
@@ -86,7 +98,7 @@ export class Base {
86
98
 
87
99
 
88
100
  toU8a(isBare) {
89
- return this._raw.toU8a(isBare);
101
+ return _classPrivateFieldLooseBase(this, _raw)[_raw].toU8a(isBare);
90
102
  }
91
103
  /**
92
104
  * @description Returns the base runtime type name for this instance
@@ -97,4 +109,8 @@ export class Base {
97
109
  return 'Base';
98
110
  }
99
111
 
112
+ unwrap() {
113
+ return _classPrivateFieldLooseBase(this, _raw)[_raw];
114
+ }
115
+
100
116
  }
package/base/Enum.cjs CHANGED
@@ -257,6 +257,14 @@ class Enum {
257
257
  get index() {
258
258
  return (0, _classPrivateFieldLooseBase2.default)(this, _indexes)[_indexes][(0, _classPrivateFieldLooseBase2.default)(this, _entryIndex)[_entryIndex]];
259
259
  }
260
+ /**
261
+ * @description The value of the enum
262
+ */
263
+
264
+
265
+ get inner() {
266
+ return (0, _classPrivateFieldLooseBase2.default)(this, _raw)[_raw];
267
+ }
260
268
  /**
261
269
  * @description true if this is a basic enum (no values)
262
270
  */
package/base/Enum.d.ts CHANGED
@@ -28,6 +28,10 @@ export declare class Enum implements IEnum {
28
28
  * @description The index of the enum value
29
29
  */
30
30
  get index(): number;
31
+ /**
32
+ * @description The value of the enum
33
+ */
34
+ get inner(): Codec;
31
35
  /**
32
36
  * @description true if this is a basic enum (no values)
33
37
  */
package/base/Enum.js CHANGED
@@ -236,6 +236,14 @@ export class Enum {
236
236
  get index() {
237
237
  return _classPrivateFieldLooseBase(this, _indexes)[_indexes][_classPrivateFieldLooseBase(this, _entryIndex)[_entryIndex]];
238
238
  }
239
+ /**
240
+ * @description The value of the enum
241
+ */
242
+
243
+
244
+ get inner() {
245
+ return _classPrivateFieldLooseBase(this, _raw)[_raw];
246
+ }
239
247
  /**
240
248
  * @description true if this is a basic enum (no values)
241
249
  */
@@ -43,7 +43,7 @@ class WrapperOpaque extends _Base.Base {
43
43
 
44
44
 
45
45
  toRawType() {
46
- return `WrapperOpaque<${this._raw.toRawType()}>`;
46
+ return `WrapperOpaque<${this.inner.toRawType()}>`;
47
47
  }
48
48
  /**
49
49
  * @description The length of the value when encoded as a Uint8Array
@@ -54,14 +54,6 @@ class WrapperOpaque extends _Base.Base {
54
54
  const u8a = super.toU8a(isBare);
55
55
  return isBare ? u8a : (0, _util.compactAddLength)(u8a);
56
56
  }
57
- /**
58
- * @description Return the inner value for the wrapped type
59
- */
60
-
61
-
62
- unwrap() {
63
- return this._raw;
64
- }
65
57
 
66
58
  }
67
59
 
@@ -11,8 +11,4 @@ export declare class WrapperOpaque<T extends Codec> extends Base<T> {
11
11
  * @description The length of the value when encoded as a Uint8Array
12
12
  */
13
13
  toU8a(isBare?: boolean): Uint8Array;
14
- /**
15
- * @description Return the inner value for the wrapped type
16
- */
17
- unwrap(): T;
18
14
  }
@@ -34,7 +34,7 @@ export class WrapperOpaque extends Base {
34
34
 
35
35
 
36
36
  toRawType() {
37
- return `WrapperOpaque<${this._raw.toRawType()}>`;
37
+ return `WrapperOpaque<${this.inner.toRawType()}>`;
38
38
  }
39
39
  /**
40
40
  * @description The length of the value when encoded as a Uint8Array
@@ -45,13 +45,5 @@ export class WrapperOpaque extends Base {
45
45
  const u8a = super.toU8a(isBare);
46
46
  return isBare ? u8a : compactAddLength(u8a);
47
47
  }
48
- /**
49
- * @description Return the inner value for the wrapped type
50
- */
51
-
52
-
53
- unwrap() {
54
- return this._raw;
55
- }
56
48
 
57
49
  }
package/native/Json.cjs CHANGED
@@ -70,6 +70,10 @@ class Json extends Map {
70
70
  eq(other) {
71
71
  return (0, _index.compareMap)(this, other);
72
72
  }
73
+
74
+ getT(key) {
75
+ return this.get(key);
76
+ }
73
77
  /**
74
78
  * @description Unimplemented, will throw
75
79
  */
package/native/Json.d.ts CHANGED
@@ -28,6 +28,7 @@ export declare class Json extends Map<string, any> implements Codec {
28
28
  * @description Compares the value of the input to see if there is a match
29
29
  */
30
30
  eq(other?: unknown): boolean;
31
+ getT<T>(key: string): T;
31
32
  /**
32
33
  * @description Unimplemented, will throw
33
34
  */
package/native/Json.js CHANGED
@@ -58,6 +58,10 @@ export class Json extends Map {
58
58
  eq(other) {
59
59
  return compareMap(this, other);
60
60
  }
61
+
62
+ getT(key) {
63
+ return this.get(key);
64
+ }
61
65
  /**
62
66
  * @description Unimplemented, will throw
63
67
  */
package/native/Struct.cjs CHANGED
@@ -128,6 +128,10 @@ class Struct extends Map {
128
128
  get defKeys() {
129
129
  return Object.keys((0, _classPrivateFieldLooseBase2.default)(this, _Types)[_Types]);
130
130
  }
131
+
132
+ getT(key) {
133
+ return this.get(key);
134
+ }
131
135
  /**
132
136
  * @description Checks if the value is an empty value
133
137
  */
@@ -30,6 +30,7 @@ export declare class Struct<S extends TypesDef = TypesDef, V extends {
30
30
  * @description The available keys for this struct
31
31
  */
32
32
  get defKeys(): string[];
33
+ getT<T>(key: string): T;
33
34
  /**
34
35
  * @description Checks if the value is an empty value
35
36
  */
package/native/Struct.js CHANGED
@@ -114,6 +114,10 @@ export class Struct extends Map {
114
114
  get defKeys() {
115
115
  return Object.keys(_classPrivateFieldLooseBase(this, _Types)[_Types]);
116
116
  }
117
+
118
+ getT(key) {
119
+ return this.get(key);
120
+ }
117
121
  /**
118
122
  * @description Checks if the value is an empty value
119
123
  */
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "6.12.2-2",
23
+ "version": "6.12.2-6",
24
24
  "main": "index.js",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.16.3",
package/packageInfo.cjs CHANGED
@@ -9,6 +9,6 @@ exports.packageInfo = void 0;
9
9
  // Auto-generated by @polkadot/dev, do not edit
10
10
  const packageInfo = {
11
11
  name: '@polkadot/types-codec',
12
- version: '6.12.2-2'
12
+ version: '6.12.2-6'
13
13
  };
14
14
  exports.packageInfo = packageInfo;
package/packageInfo.js CHANGED
@@ -3,5 +3,5 @@
3
3
  // Auto-generated by @polkadot/dev, do not edit
4
4
  export const packageInfo = {
5
5
  name: '@polkadot/types-codec',
6
- version: '6.12.2-2'
6
+ version: '6.12.2-6'
7
7
  };