@polkadot/types-codec 6.12.2-3 → 6.12.2-4
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 +28 -9
- package/base/Base.d.ts +3 -1
- package/base/Base.js +25 -9
- package/base/Enum.cjs +8 -0
- package/base/Enum.d.ts +4 -0
- package/base/Enum.js +8 -0
- package/extended/WrapperOpaque.cjs +1 -9
- package/extended/WrapperOpaque.d.ts +0 -4
- package/extended/WrapperOpaque.js +1 -9
- package/package.json +1 -1
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
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
|
|
28
|
+
Object.defineProperty(this, _raw, {
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
21
32
|
this.registry = registry;
|
|
22
|
-
this
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
18
|
+
Object.defineProperty(this, _raw, {
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
14
22
|
this.registry = registry;
|
|
15
|
-
this
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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/package.json
CHANGED
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED