@polkadot/types-codec 6.12.2-10
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/abstract/AbstractArray.cjs +208 -0
- package/abstract/AbstractArray.d.ts +84 -0
- package/abstract/AbstractArray.js +197 -0
- package/abstract/AbstractInt.cjs +254 -0
- package/abstract/AbstractInt.d.ts +75 -0
- package/abstract/AbstractInt.js +231 -0
- package/abstract/index.cjs +21 -0
- package/abstract/index.d.ts +2 -0
- package/abstract/index.js +4 -0
- package/base/Base.cjs +137 -0
- package/base/Base.d.ts +56 -0
- package/base/Base.js +125 -0
- package/base/Compact.cjs +201 -0
- package/base/Compact.d.ts +83 -0
- package/base/Compact.js +186 -0
- package/base/DoNotConstruct.cjs +101 -0
- package/base/DoNotConstruct.d.ts +33 -0
- package/base/DoNotConstruct.js +88 -0
- package/base/Enum.cjs +445 -0
- package/base/Enum.d.ts +105 -0
- package/base/Enum.js +421 -0
- package/base/Int.cjs +45 -0
- package/base/Int.d.ts +16 -0
- package/base/Int.js +33 -0
- package/base/Null.cjs +111 -0
- package/base/Null.d.ts +54 -0
- package/base/Null.js +101 -0
- package/base/Option.cjs +256 -0
- package/base/Option.d.ts +88 -0
- package/base/Option.js +240 -0
- package/base/Result.cjs +109 -0
- package/base/Result.d.ts +46 -0
- package/base/Result.js +98 -0
- package/base/Tuple.cjs +132 -0
- package/base/Tuple.d.ts +39 -0
- package/base/Tuple.js +116 -0
- package/base/UInt.cjs +39 -0
- package/base/UInt.d.ts +15 -0
- package/base/UInt.js +29 -0
- package/base/Vec.cjs +126 -0
- package/base/Vec.d.ts +28 -0
- package/base/Vec.js +104 -0
- package/base/VecAny.cjs +31 -0
- package/base/VecAny.d.ts +15 -0
- package/base/VecAny.js +21 -0
- package/base/VecFixed.cjs +111 -0
- package/base/VecFixed.d.ts +26 -0
- package/base/VecFixed.js +93 -0
- package/base/index.cjs +109 -0
- package/base/index.d.ts +13 -0
- package/base/index.js +15 -0
- package/bundle.cjs +100 -0
- package/bundle.d.ts +7 -0
- package/bundle.js +9 -0
- package/detectPackage.cjs +9 -0
- package/detectPackage.d.ts +1 -0
- package/detectPackage.js +5 -0
- package/extended/BTreeMap.cjs +24 -0
- package/extended/BTreeMap.d.ts +5 -0
- package/extended/BTreeMap.js +14 -0
- package/extended/BTreeSet.cjs +227 -0
- package/extended/BTreeSet.d.ts +55 -0
- package/extended/BTreeSet.js +212 -0
- package/extended/BitVec.cjs +97 -0
- package/extended/BitVec.d.ts +26 -0
- package/extended/BitVec.js +82 -0
- package/extended/Bytes.cjs +86 -0
- package/extended/Bytes.d.ts +25 -0
- package/extended/Bytes.js +75 -0
- package/extended/HashMap.cjs +24 -0
- package/extended/HashMap.d.ts +5 -0
- package/extended/HashMap.js +14 -0
- package/extended/Linkage.cjs +89 -0
- package/extended/Linkage.d.ts +31 -0
- package/extended/Linkage.js +71 -0
- package/extended/Map.cjs +244 -0
- package/extended/Map.d.ts +50 -0
- package/extended/Map.js +225 -0
- package/extended/Range.cjs +92 -0
- package/extended/Range.d.ts +30 -0
- package/extended/Range.js +75 -0
- package/extended/Type.cjs +39 -0
- package/extended/Type.d.ts +16 -0
- package/extended/Type.js +27 -0
- package/extended/U8aFixed.cjs +66 -0
- package/extended/U8aFixed.d.ts +16 -0
- package/extended/U8aFixed.js +53 -0
- package/extended/WrapperOpaque.cjs +60 -0
- package/extended/WrapperOpaque.d.ts +14 -0
- package/extended/WrapperOpaque.js +49 -0
- package/extended/index.cjs +105 -0
- package/extended/index.d.ts +11 -0
- package/extended/index.js +13 -0
- package/index.cjs +20 -0
- package/index.d.ts +2 -0
- package/index.js +4 -0
- package/native/Bool.cjs +141 -0
- package/native/Bool.d.ts +62 -0
- package/native/Bool.js +130 -0
- package/native/Date.cjs +170 -0
- package/native/Date.d.ts +76 -0
- package/native/Date.js +158 -0
- package/native/Json.cjs +137 -0
- package/native/Json.d.ts +56 -0
- package/native/Json.js +121 -0
- package/native/Raw.cjs +192 -0
- package/native/Raw.d.ts +90 -0
- package/native/Raw.js +182 -0
- package/native/Set.cjs +268 -0
- package/native/Set.d.ts +76 -0
- package/native/Set.js +251 -0
- package/native/Struct.cjs +302 -0
- package/native/Struct.d.ts +93 -0
- package/native/Struct.js +286 -0
- package/native/Text.cjs +193 -0
- package/native/Text.d.ts +71 -0
- package/native/Text.js +178 -0
- package/native/index.cjs +79 -0
- package/native/index.d.ts +7 -0
- package/native/index.js +9 -0
- package/package.json +387 -0
- package/packageInfo.cjs +14 -0
- package/packageInfo.d.ts +4 -0
- package/packageInfo.js +7 -0
- package/primitive/I128.cjs +26 -0
- package/primitive/I128.d.ts +11 -0
- package/primitive/I128.js +16 -0
- package/primitive/I16.cjs +26 -0
- package/primitive/I16.d.ts +11 -0
- package/primitive/I16.js +16 -0
- package/primitive/I256.cjs +26 -0
- package/primitive/I256.d.ts +11 -0
- package/primitive/I256.js +16 -0
- package/primitive/I32.cjs +26 -0
- package/primitive/I32.d.ts +11 -0
- package/primitive/I32.js +16 -0
- package/primitive/I64.cjs +26 -0
- package/primitive/I64.d.ts +11 -0
- package/primitive/I64.js +16 -0
- package/primitive/I8.cjs +26 -0
- package/primitive/I8.d.ts +11 -0
- package/primitive/I8.js +16 -0
- package/primitive/U128.cjs +26 -0
- package/primitive/U128.d.ts +11 -0
- package/primitive/U128.js +16 -0
- package/primitive/U16.cjs +26 -0
- package/primitive/U16.d.ts +11 -0
- package/primitive/U16.js +16 -0
- package/primitive/U256.cjs +26 -0
- package/primitive/U256.d.ts +11 -0
- package/primitive/U256.js +16 -0
- package/primitive/U32.cjs +26 -0
- package/primitive/U32.d.ts +11 -0
- package/primitive/U32.js +16 -0
- package/primitive/U64.cjs +26 -0
- package/primitive/U64.d.ts +11 -0
- package/primitive/U64.js +16 -0
- package/primitive/U8.cjs +26 -0
- package/primitive/U8.d.ts +11 -0
- package/primitive/U8.js +16 -0
- package/primitive/USize.cjs +28 -0
- package/primitive/USize.d.ts +12 -0
- package/primitive/USize.js +18 -0
- package/primitive/index.cjs +187 -0
- package/primitive/index.d.ts +13 -0
- package/primitive/index.js +15 -0
- package/types/codec.cjs +1 -0
- package/types/codec.d.ts +77 -0
- package/types/codec.js +1 -0
- package/types/helpers.cjs +1 -0
- package/types/helpers.d.ts +14 -0
- package/types/helpers.js +1 -0
- package/types/index.cjs +57 -0
- package/types/index.d.ts +4 -0
- package/types/index.js +6 -0
- package/types/interfaces.cjs +1 -0
- package/types/interfaces.d.ts +69 -0
- package/types/interfaces.js +1 -0
- package/types/registry.cjs +1 -0
- package/types/registry.d.ts +61 -0
- package/types/registry.js +1 -0
- package/utils/compareArray.cjs +22 -0
- package/utils/compareArray.d.ts +1 -0
- package/utils/compareArray.js +13 -0
- package/utils/compareMap.cjs +39 -0
- package/utils/compareMap.d.ts +1 -0
- package/utils/compareMap.js +31 -0
- package/utils/compareSet.cjs +29 -0
- package/utils/compareSet.d.ts +1 -0
- package/utils/compareSet.js +22 -0
- package/utils/decodeU8a.cjs +69 -0
- package/utils/decodeU8a.d.ts +13 -0
- package/utils/decodeU8a.js +60 -0
- package/utils/index.cjs +95 -0
- package/utils/index.d.ts +9 -0
- package/utils/index.js +11 -0
- package/utils/mapToTypeMap.cjs +25 -0
- package/utils/mapToTypeMap.d.ts +5 -0
- package/utils/mapToTypeMap.js +17 -0
- package/utils/sanitize.cjs +242 -0
- package/utils/sanitize.d.ts +16 -0
- package/utils/sanitize.js +215 -0
- package/utils/sortValues.cjs +89 -0
- package/utils/sortValues.d.ts +13 -0
- package/utils/sortValues.js +73 -0
- package/utils/typeToConstructor.cjs +14 -0
- package/utils/typeToConstructor.d.ts +2 -0
- package/utils/typeToConstructor.js +6 -0
- package/utils/typesToMap.cjs +20 -0
- package/utils/typesToMap.d.ts +2 -0
- package/utils/typesToMap.js +13 -0
- package/utils/util.cjs +15 -0
- package/utils/util.d.ts +3 -0
- package/utils/util.js +7 -0
package/primitive/U8.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2017-2021 @polkadot/types authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { UInt } from "../base/UInt.js";
|
|
4
|
+
/**
|
|
5
|
+
* @name u8
|
|
6
|
+
* @description
|
|
7
|
+
* An 8-bit unsigned integer
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class u8 extends UInt.with(8) {
|
|
11
|
+
constructor(...args) {
|
|
12
|
+
super(...args);
|
|
13
|
+
this.__UIntType = 'u8';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usize = void 0;
|
|
7
|
+
|
|
8
|
+
var _U = require("./U32.cjs");
|
|
9
|
+
|
|
10
|
+
// Copyright 2017-2021 @polkadot/types authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @name USize
|
|
15
|
+
* @description
|
|
16
|
+
* A System default unsigned number, typically used in RPC to report non-consensus
|
|
17
|
+
* data. It is a wrapper for [[U32]] as a WASM default (as generated by Rust bindings).
|
|
18
|
+
* It is not to be used, since it created consensus mismatches.
|
|
19
|
+
*/
|
|
20
|
+
class usize extends _U.u32 {
|
|
21
|
+
constructor(registry, value) {
|
|
22
|
+
super(registry, value);
|
|
23
|
+
throw new Error('The `usize` type should not be used. Since it is platform-specific, it creates incompatibilities between native (generally u64) and WASM (always u32) code. Use one of the `u32` or `u64` types explicitly.');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.usize = usize;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CodecRegistry } from '../types';
|
|
2
|
+
import { u32 } from './U32';
|
|
3
|
+
/**
|
|
4
|
+
* @name USize
|
|
5
|
+
* @description
|
|
6
|
+
* A System default unsigned number, typically used in RPC to report non-consensus
|
|
7
|
+
* data. It is a wrapper for [[U32]] as a WASM default (as generated by Rust bindings).
|
|
8
|
+
* It is not to be used, since it created consensus mismatches.
|
|
9
|
+
*/
|
|
10
|
+
export declare class usize extends u32 {
|
|
11
|
+
constructor(registry: CodecRegistry, value?: unknown);
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright 2017-2021 @polkadot/types authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { u32 } from "./U32.js";
|
|
4
|
+
/**
|
|
5
|
+
* @name USize
|
|
6
|
+
* @description
|
|
7
|
+
* A System default unsigned number, typically used in RPC to report non-consensus
|
|
8
|
+
* data. It is a wrapper for [[U32]] as a WASM default (as generated by Rust bindings).
|
|
9
|
+
* It is not to be used, since it created consensus mismatches.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export class usize extends u32 {
|
|
13
|
+
constructor(registry, value) {
|
|
14
|
+
super(registry, value);
|
|
15
|
+
throw new Error('The `usize` type should not be used. Since it is platform-specific, it creates incompatibilities between native (generally u64) and WASM (always u32) code. Use one of the `u32` or `u64` types explicitly.');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "I128", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _I5.i128;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "I16", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _I2.i16;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "I256", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _I6.i256;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "I32", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _I3.i32;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "I64", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _I4.i64;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "I8", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _I.i8;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "U128", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _U5.u128;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "U16", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _U2.u16;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "U256", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _U6.u256;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "U32", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _U3.u32;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "U64", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _U4.u64;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "U8", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _U.u8;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "USize", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _USize.usize;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "i128", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _I5.i128;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "i16", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _I2.i16;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "i256", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _I6.i256;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "i32", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _I3.i32;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "i64", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _I4.i64;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(exports, "i8", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _I.i8;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "u128", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _U5.u128;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, "u16", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function () {
|
|
129
|
+
return _U2.u16;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "u256", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () {
|
|
135
|
+
return _U6.u256;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "u32", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _U3.u32;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "u64", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _U4.u64;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, "u8", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return _U.u8;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "usize", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return _USize.usize;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
var _I = require("./I8.cjs");
|
|
164
|
+
|
|
165
|
+
var _I2 = require("./I16.cjs");
|
|
166
|
+
|
|
167
|
+
var _I3 = require("./I32.cjs");
|
|
168
|
+
|
|
169
|
+
var _I4 = require("./I64.cjs");
|
|
170
|
+
|
|
171
|
+
var _I5 = require("./I128.cjs");
|
|
172
|
+
|
|
173
|
+
var _I6 = require("./I256.cjs");
|
|
174
|
+
|
|
175
|
+
var _U = require("./U8.cjs");
|
|
176
|
+
|
|
177
|
+
var _U2 = require("./U16.cjs");
|
|
178
|
+
|
|
179
|
+
var _U3 = require("./U32.cjs");
|
|
180
|
+
|
|
181
|
+
var _U4 = require("./U64.cjs");
|
|
182
|
+
|
|
183
|
+
var _U5 = require("./U128.cjs");
|
|
184
|
+
|
|
185
|
+
var _U6 = require("./U256.cjs");
|
|
186
|
+
|
|
187
|
+
var _USize = require("./USize.cjs");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { i8, i8 as I8 } from './I8';
|
|
2
|
+
export { i16, i16 as I16 } from './I16';
|
|
3
|
+
export { i32, i32 as I32 } from './I32';
|
|
4
|
+
export { i64, i64 as I64 } from './I64';
|
|
5
|
+
export { i128, i128 as I128 } from './I128';
|
|
6
|
+
export { i256, i256 as I256 } from './I256';
|
|
7
|
+
export { u8, u8 as U8 } from './U8';
|
|
8
|
+
export { u16, u16 as U16 } from './U16';
|
|
9
|
+
export { u32, u32 as U32 } from './U32';
|
|
10
|
+
export { u64, u64 as U64 } from './U64';
|
|
11
|
+
export { u128, u128 as U128 } from './U128';
|
|
12
|
+
export { u256, u256 as U256 } from './U256';
|
|
13
|
+
export { usize, usize as USize } from './USize';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2017-2021 @polkadot/types-codec authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export { i8, i8 as I8 } from "./I8.js";
|
|
4
|
+
export { i16, i16 as I16 } from "./I16.js";
|
|
5
|
+
export { i32, i32 as I32 } from "./I32.js";
|
|
6
|
+
export { i64, i64 as I64 } from "./I64.js";
|
|
7
|
+
export { i128, i128 as I128 } from "./I128.js";
|
|
8
|
+
export { i256, i256 as I256 } from "./I256.js";
|
|
9
|
+
export { u8, u8 as U8 } from "./U8.js";
|
|
10
|
+
export { u16, u16 as U16 } from "./U16.js";
|
|
11
|
+
export { u32, u32 as U32 } from "./U32.js";
|
|
12
|
+
export { u64, u64 as U64 } from "./U64.js";
|
|
13
|
+
export { u128, u128 as U128 } from "./U128.js";
|
|
14
|
+
export { u256, u256 as U256 } from "./U256.js";
|
|
15
|
+
export { usize, usize as USize } from "./USize.js";
|
package/types/codec.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/types/codec.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { AnyJson } from './helpers';
|
|
3
|
+
import type { IU8a } from './interfaces';
|
|
4
|
+
import type { CodecRegistry } from './registry';
|
|
5
|
+
export declare type BareOpts = boolean | Record<string, boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* @name Codec
|
|
8
|
+
* @description
|
|
9
|
+
* The base Codec interface. All types implement the interface provided here. Additionally
|
|
10
|
+
* implementors can add their own specific interfaces and helpers with getters and functions.
|
|
11
|
+
* The Codec Base is however required for operating as an encoding/decoding layer
|
|
12
|
+
*/
|
|
13
|
+
export interface Codec {
|
|
14
|
+
/**
|
|
15
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
16
|
+
*/
|
|
17
|
+
readonly encodedLength: number;
|
|
18
|
+
/**
|
|
19
|
+
* @description Returns a hash of the value
|
|
20
|
+
*/
|
|
21
|
+
readonly hash: IU8a;
|
|
22
|
+
/**
|
|
23
|
+
* @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
|
|
24
|
+
*/
|
|
25
|
+
readonly initialU8aLength?: number;
|
|
26
|
+
/**
|
|
27
|
+
* @description Checks if the value is an empty value
|
|
28
|
+
*/
|
|
29
|
+
readonly isEmpty: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @description The registry associated with this object
|
|
32
|
+
*/
|
|
33
|
+
readonly registry: CodecRegistry;
|
|
34
|
+
/**
|
|
35
|
+
* @description The block at which this value was retrieved/created (set to non-empty when retrieved from storage)
|
|
36
|
+
*/
|
|
37
|
+
createdAtHash?: IU8a;
|
|
38
|
+
/**
|
|
39
|
+
* @description Compares the value of the input to see if there is a match
|
|
40
|
+
*/
|
|
41
|
+
eq(other?: unknown): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
|
|
44
|
+
*/
|
|
45
|
+
toHex(isLe?: boolean): HexString;
|
|
46
|
+
/**
|
|
47
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
48
|
+
*/
|
|
49
|
+
toHuman(isExtended?: boolean): AnyJson;
|
|
50
|
+
/**
|
|
51
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
52
|
+
*/
|
|
53
|
+
toJSON(): AnyJson;
|
|
54
|
+
/**
|
|
55
|
+
* @description Returns the base runtime type name for this instance
|
|
56
|
+
*/
|
|
57
|
+
toRawType(): string;
|
|
58
|
+
/**
|
|
59
|
+
* @description Returns the string representation of the value
|
|
60
|
+
*/
|
|
61
|
+
toString(): string;
|
|
62
|
+
/**
|
|
63
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
64
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
65
|
+
*/
|
|
66
|
+
toU8a(isBare?: BareOpts): Uint8Array;
|
|
67
|
+
}
|
|
68
|
+
export interface CodecClass<T = Codec> {
|
|
69
|
+
/**
|
|
70
|
+
* @description An internal fallback type (previous generation) if encoding fails
|
|
71
|
+
*/
|
|
72
|
+
readonly __fallbackType?: string;
|
|
73
|
+
new (registry: CodecRegistry, ...args: any[]): T;
|
|
74
|
+
}
|
|
75
|
+
export declare type CodecClassDef<T = Codec> = Record<string, CodecClass<T>>;
|
|
76
|
+
export declare type CodecTo = 'toHex' | 'toJSON' | 'toString' | 'toU8a';
|
|
77
|
+
export declare type ArgsDef = Record<string, CodecClass | string>;
|
package/types/codec.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import type { BN } from '@polkadot/util';
|
|
3
|
+
import type { Codec } from './codec';
|
|
4
|
+
export declare type AnyJson = string | number | boolean | null | undefined | AnyJson[] | {
|
|
5
|
+
[index: string]: AnyJson;
|
|
6
|
+
};
|
|
7
|
+
export declare type AnyFunction = (...args: any[]) => any;
|
|
8
|
+
export declare type AnyNumber = BN | bigint | Uint8Array | number | string;
|
|
9
|
+
export declare type AnyString = string | string;
|
|
10
|
+
export declare type AnyTuple = Codec[];
|
|
11
|
+
export declare type AnyU8a = Uint8Array | number[] | string;
|
|
12
|
+
export declare type UIntBitLength = 8 | 16 | 32 | 64 | 128 | 256;
|
|
13
|
+
export declare type U8aBitLength = 8 | 16 | 32 | 64 | 128 | 160 | 256 | 264 | 512 | 520 | 1024 | 2048;
|
|
14
|
+
export declare type AnyTupleValue = AnyU8a | (Codec | AnyU8a | AnyNumber | AnyString | undefined | null)[];
|
package/types/helpers.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/index.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _codec = require("./codec.cjs");
|
|
8
|
+
|
|
9
|
+
Object.keys(_codec).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _codec[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _codec[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _helpers = require("./helpers.cjs");
|
|
21
|
+
|
|
22
|
+
Object.keys(_helpers).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _helpers[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _helpers[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _interfaces = require("./interfaces.cjs");
|
|
34
|
+
|
|
35
|
+
Object.keys(_interfaces).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _interfaces[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _interfaces[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _registry = require("./registry.cjs");
|
|
47
|
+
|
|
48
|
+
Object.keys(_registry).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _registry[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _registry[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
package/types/index.d.ts
ADDED
package/types/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import type { BN } from '@polkadot/util';
|
|
3
|
+
import type { ArgsDef, Codec } from './codec';
|
|
4
|
+
import type { AnyTuple } from './helpers';
|
|
5
|
+
export interface ICompact<T extends INumber = INumber> extends Codec {
|
|
6
|
+
toBigInt(): bigint;
|
|
7
|
+
toBn(): BN;
|
|
8
|
+
toNumber(): number;
|
|
9
|
+
unwrap(): T;
|
|
10
|
+
}
|
|
11
|
+
export interface IEnum extends Codec {
|
|
12
|
+
readonly defIndexes: number[];
|
|
13
|
+
readonly defKeys: string[];
|
|
14
|
+
readonly index: number;
|
|
15
|
+
readonly isBasic: boolean;
|
|
16
|
+
readonly type: string;
|
|
17
|
+
readonly value: Codec;
|
|
18
|
+
toNumber(): number;
|
|
19
|
+
}
|
|
20
|
+
export interface IMap<K extends Codec = Codec, V extends Codec = Codec> extends Map<K, V>, Codec {
|
|
21
|
+
}
|
|
22
|
+
export interface INumber extends Codec {
|
|
23
|
+
bitLength(): number;
|
|
24
|
+
toBigInt(): bigint;
|
|
25
|
+
toBn(): BN;
|
|
26
|
+
toNumber(): number;
|
|
27
|
+
}
|
|
28
|
+
export interface IOption<T extends Codec = Codec> extends Codec {
|
|
29
|
+
readonly isNone: boolean;
|
|
30
|
+
readonly isSome: boolean;
|
|
31
|
+
readonly value: Codec;
|
|
32
|
+
unwrap(): T;
|
|
33
|
+
unwrapOr<O>(other: O): T | O;
|
|
34
|
+
unwrapOrDefault(): T;
|
|
35
|
+
}
|
|
36
|
+
export interface IResult<O extends Codec = Codec, E extends Codec = Codec> extends IEnum {
|
|
37
|
+
readonly asErr: E;
|
|
38
|
+
readonly asOk: O;
|
|
39
|
+
readonly isErr: boolean;
|
|
40
|
+
readonly isOk: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface ISet<K = string> extends Set<K>, Codec {
|
|
43
|
+
readonly strings: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface IStruct<K = string, V extends Codec = Codec> extends Map<K, V>, Codec {
|
|
46
|
+
readonly defKeys: string[];
|
|
47
|
+
getAtIndex(index: number): Codec;
|
|
48
|
+
toArray(): Codec[];
|
|
49
|
+
}
|
|
50
|
+
export declare type ITuple<T extends AnyTuple = Codec[]> = T & Codec;
|
|
51
|
+
export interface IU8a extends Uint8Array, Codec {
|
|
52
|
+
readonly isAscii: boolean;
|
|
53
|
+
readonly isUtf8: boolean;
|
|
54
|
+
bitLength(): number;
|
|
55
|
+
toHuman(isExtended?: boolean): any;
|
|
56
|
+
toJSON(): any;
|
|
57
|
+
toUtf8(): string;
|
|
58
|
+
}
|
|
59
|
+
export interface IVec<T extends Codec = Codec> extends Array<T>, Codec {
|
|
60
|
+
toArray(): T[];
|
|
61
|
+
}
|
|
62
|
+
export interface IMethod<A extends AnyTuple = AnyTuple, M = any> extends Codec {
|
|
63
|
+
readonly args: A;
|
|
64
|
+
readonly argsDef: ArgsDef;
|
|
65
|
+
readonly callIndex: Uint8Array;
|
|
66
|
+
readonly data: Uint8Array;
|
|
67
|
+
readonly meta: M;
|
|
68
|
+
is: (tx: IMethod<AnyTuple>) => tx is IMethod<A>;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import type { BN } from '@polkadot/util';
|
|
3
|
+
import type { Codec, CodecClass } from './codec';
|
|
4
|
+
import type { AnyTuple } from './helpers';
|
|
5
|
+
import type { ICompact, IEnum, IMap, IMethod, INumber, IOption, IResult, ISet, IStruct, ITuple, IU8a, IVec } from './interfaces';
|
|
6
|
+
export declare type OnlyCodec<K, T, Types> = K extends keyof Types ? Types[K] : T extends ICompact | IEnum | IMap | IMethod | INumber | IOption | IResult | ISet | IStruct | ITuple | IU8a | IVec ? T : T extends Codec ? T : never;
|
|
7
|
+
export interface RegistryError {
|
|
8
|
+
args: string[];
|
|
9
|
+
docs: string[];
|
|
10
|
+
index: number;
|
|
11
|
+
method: string;
|
|
12
|
+
name: string;
|
|
13
|
+
section: string;
|
|
14
|
+
}
|
|
15
|
+
export declare type RegistryTypes = Record<string, CodecClass | string | Record<string, string> | {
|
|
16
|
+
_enum: string[] | Record<string, number> | Record<string, string | null>;
|
|
17
|
+
} | {
|
|
18
|
+
_set: Record<string, number>;
|
|
19
|
+
}>;
|
|
20
|
+
export interface CodecCreateOptions {
|
|
21
|
+
blockHash?: Uint8Array | string | null;
|
|
22
|
+
isOptional?: boolean;
|
|
23
|
+
isPedantic?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface CallBase<A extends AnyTuple, M = any> extends IMethod<A, M> {
|
|
26
|
+
readonly method: string;
|
|
27
|
+
readonly section: string;
|
|
28
|
+
toJSON: () => any;
|
|
29
|
+
}
|
|
30
|
+
export interface CallFunction<A extends AnyTuple = AnyTuple, M = any> extends CallBase<A, M> {
|
|
31
|
+
(...args: any[]): IMethod<A, M>;
|
|
32
|
+
}
|
|
33
|
+
export interface CodecRegistry {
|
|
34
|
+
readonly chainDecimals: number[];
|
|
35
|
+
readonly chainSS58: number | undefined;
|
|
36
|
+
readonly chainTokens: string[];
|
|
37
|
+
createdAtHash?: IU8a;
|
|
38
|
+
findMetaCall(callIndex: Uint8Array): CallFunction;
|
|
39
|
+
findMetaError(errorIndex: Uint8Array | {
|
|
40
|
+
error: BN;
|
|
41
|
+
index: BN;
|
|
42
|
+
}): RegistryError;
|
|
43
|
+
findMetaEvent(eventIndex: Uint8Array): CodecClass<any>;
|
|
44
|
+
isLookupType(value: string): boolean;
|
|
45
|
+
createLookupType(lookupId: ICompact<INumber> | number): string;
|
|
46
|
+
createClassUnsafe<T extends Codec = Codec, K extends string = string>(type: K): CodecClass<T>;
|
|
47
|
+
createTypeUnsafe<T extends Codec = Codec, K extends string = string>(type: K, params: unknown[], options?: CodecCreateOptions): T;
|
|
48
|
+
getClassName(clazz: CodecClass): string | undefined;
|
|
49
|
+
getOrThrow<T extends Codec = Codec, K extends string = string>(name: K, msg?: string): CodecClass<T>;
|
|
50
|
+
getOrUnknown<T extends Codec = Codec, K extends string = string>(name: K): CodecClass<T>;
|
|
51
|
+
getSignedExtensionExtra(): Record<string, string>;
|
|
52
|
+
getSignedExtensionTypes(): Record<string, string>;
|
|
53
|
+
hasClass(name: string): boolean;
|
|
54
|
+
hasDef(name: string): boolean;
|
|
55
|
+
hasType(name: string): boolean;
|
|
56
|
+
hash(data: Uint8Array): IU8a;
|
|
57
|
+
register(type: CodecClass | RegistryTypes): void;
|
|
58
|
+
register(name: string, type: CodecClass): void;
|
|
59
|
+
register(arg1: string | CodecClass | RegistryTypes, arg2?: CodecClass): void;
|
|
60
|
+
setMetadata(metadata: unknown, signedExtensions?: string[], userExtensions?: unknown): void;
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compareArray = compareArray;
|
|
7
|
+
|
|
8
|
+
var _util = require("@polkadot/util");
|
|
9
|
+
|
|
10
|
+
var _util2 = require("./util.cjs");
|
|
11
|
+
|
|
12
|
+
// Copyright 2017-2021 @polkadot/types-codec authors & contributors
|
|
13
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
+
// NOTE These are used internally and when comparing objects, expects that
|
|
15
|
+
// when the second is an Codec[] that the first has to be as well
|
|
16
|
+
function compareArray(a, b) {
|
|
17
|
+
if (Array.isArray(b)) {
|
|
18
|
+
return a.length === b.length && (0, _util.isUndefined)(a.find((v, index) => (0, _util2.hasEq)(v) ? !v.eq(b[index]) : v !== b[index]));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compareArray(a: unknown[], b?: unknown): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2017-2021 @polkadot/types-codec authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { isUndefined } from '@polkadot/util';
|
|
4
|
+
import { hasEq } from "./util.js"; // NOTE These are used internally and when comparing objects, expects that
|
|
5
|
+
// when the second is an Codec[] that the first has to be as well
|
|
6
|
+
|
|
7
|
+
export function compareArray(a, b) {
|
|
8
|
+
if (Array.isArray(b)) {
|
|
9
|
+
return a.length === b.length && isUndefined(a.find((v, index) => hasEq(v) ? !v.eq(b[index]) : v !== b[index]));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return false;
|
|
13
|
+
}
|