@polkadot-api/substrate-bindings 0.6.0 → 0.6.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.
- package/dist/esm/codecs/blockHeader.mjs +42 -0
- package/dist/esm/codecs/blockHeader.mjs.map +1 -0
- package/dist/esm/codecs/metadata/docs.mjs +6 -0
- package/dist/esm/codecs/metadata/docs.mjs.map +1 -0
- package/dist/esm/codecs/metadata/lookup.mjs +72 -0
- package/dist/esm/codecs/metadata/lookup.mjs.map +1 -0
- package/dist/esm/codecs/metadata/metadata.mjs +35 -0
- package/dist/esm/codecs/metadata/metadata.mjs.map +1 -0
- package/dist/esm/codecs/metadata/pallets.mjs +66 -0
- package/dist/esm/codecs/metadata/pallets.mjs.map +1 -0
- package/dist/esm/codecs/metadata/runtime-api.mjs +32 -0
- package/dist/esm/codecs/metadata/runtime-api.mjs.map +1 -0
- package/dist/esm/codecs/metadata/v14.mjs +39 -0
- package/dist/esm/codecs/metadata/v14.mjs.map +1 -0
- package/dist/esm/codecs/metadata/v15.mjs +44 -0
- package/dist/esm/codecs/metadata/v15.mjs.map +1 -0
- package/dist/esm/codecs/scale/AccountId.mjs +21 -0
- package/dist/esm/codecs/scale/AccountId.mjs.map +1 -0
- package/dist/esm/codecs/scale/Binary.mjs +62 -0
- package/dist/esm/codecs/scale/Binary.mjs.map +1 -0
- package/dist/esm/codecs/scale/Hex.mjs +17 -0
- package/dist/esm/codecs/scale/Hex.mjs.map +1 -0
- package/dist/esm/codecs/scale/Self.mjs +26 -0
- package/dist/esm/codecs/scale/Self.mjs.map +1 -0
- package/dist/esm/codecs/scale/Variant.mjs +30 -0
- package/dist/esm/codecs/scale/Variant.mjs.map +1 -0
- package/dist/esm/codecs/scale/bitSequence.mjs +24 -0
- package/dist/esm/codecs/scale/bitSequence.mjs.map +1 -0
- package/dist/esm/codecs/scale/char.mjs +10 -0
- package/dist/esm/codecs/scale/char.mjs.map +1 -0
- package/dist/esm/codecs/scale/compact.mjs +7 -0
- package/dist/esm/codecs/scale/compact.mjs.map +1 -0
- package/dist/esm/codecs/scale/ethAccount.mjs +32 -0
- package/dist/esm/codecs/scale/ethAccount.mjs.map +1 -0
- package/dist/esm/codecs/scale/fixed-str.mjs +12 -0
- package/dist/esm/codecs/scale/fixed-str.mjs.map +1 -0
- package/dist/esm/hashes/blake2.mjs +11 -0
- package/dist/esm/hashes/blake2.mjs.map +1 -0
- package/dist/esm/hashes/blake3.mjs +9 -0
- package/dist/esm/hashes/blake3.mjs.map +1 -0
- package/dist/esm/hashes/h64.mjs +134 -0
- package/dist/esm/hashes/h64.mjs.map +1 -0
- package/dist/esm/hashes/identity.mjs +4 -0
- package/dist/esm/hashes/identity.mjs.map +1 -0
- package/dist/esm/hashes/twoX.mjs +24 -0
- package/dist/esm/hashes/twoX.mjs.map +1 -0
- package/dist/esm/index.mjs +24 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/storage.mjs +53 -0
- package/dist/esm/storage.mjs.map +1 -0
- package/dist/esm/types/enum.mjs +29 -0
- package/dist/esm/types/enum.mjs.map +1 -0
- package/dist/esm/utils/ss58-util.mjs +55 -0
- package/dist/esm/utils/ss58-util.mjs.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +402 -406
- package/dist/index.js.map +1 -1
- package/package.json +14 -13
- package/dist/index.d.mts +0 -1094
- package/dist/index.mjs +0 -905
- package/dist/index.mjs.map +0 -1
- package/dist/min/index.d.ts +0 -1094
- package/dist/min/index.js +0 -2
- package/dist/min/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,117 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
25
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
26
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
27
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
28
|
-
|
|
29
|
-
// src/index.ts
|
|
30
|
-
var src_exports = {};
|
|
31
|
-
__export(src_exports, {
|
|
32
|
-
AccountId: () => AccountId,
|
|
33
|
-
Bin: () => Bin,
|
|
34
|
-
Binary: () => Binary,
|
|
35
|
-
Blake2128: () => Blake2128,
|
|
36
|
-
Blake2128Concat: () => Blake2128Concat,
|
|
37
|
-
Blake2256: () => Blake2256,
|
|
38
|
-
Blake3256: () => Blake3256,
|
|
39
|
-
Blake3256Concat: () => Blake3256Concat,
|
|
40
|
-
Bytes: () => import_scale_ts8.Bytes,
|
|
41
|
-
Enum: () => Enum2,
|
|
42
|
-
FixedSizeBinary: () => FixedSizeBinary,
|
|
43
|
-
Hex: () => Hex,
|
|
44
|
-
Identity: () => Identity,
|
|
45
|
-
Option: () => import_scale_ts8.Option,
|
|
46
|
-
Result: () => import_scale_ts8.Result,
|
|
47
|
-
ScaleEnum: () => import_scale_ts8.Enum,
|
|
48
|
-
Self: () => Self,
|
|
49
|
-
Storage: () => Storage,
|
|
50
|
-
Struct: () => import_scale_ts8.Struct,
|
|
51
|
-
Tuple: () => import_scale_ts8.Tuple,
|
|
52
|
-
Twox128: () => Twox128,
|
|
53
|
-
Twox256: () => Twox256,
|
|
54
|
-
Twox64Concat: () => Twox64Concat,
|
|
55
|
-
Variant: () => Variant,
|
|
56
|
-
Vector: () => import_scale_ts8.Vector,
|
|
57
|
-
_Enum: () => _Enum,
|
|
58
|
-
_void: () => import_scale_ts8._void,
|
|
59
|
-
bitSequence: () => bitSequence,
|
|
60
|
-
blockHeader: () => blockHeader,
|
|
61
|
-
bool: () => import_scale_ts8.bool,
|
|
62
|
-
char: () => char,
|
|
63
|
-
compact: () => import_scale_ts8.compact,
|
|
64
|
-
compactBn: () => compactBn,
|
|
65
|
-
compactNumber: () => compactNumber,
|
|
66
|
-
createCodec: () => import_scale_ts8.createCodec,
|
|
67
|
-
createDecoder: () => import_scale_ts8.createDecoder,
|
|
68
|
-
enhanceCodec: () => import_scale_ts8.enhanceCodec,
|
|
69
|
-
enhanceDecoder: () => import_scale_ts8.enhanceDecoder,
|
|
70
|
-
enhanceEncoder: () => import_scale_ts8.enhanceEncoder,
|
|
71
|
-
ethAccount: () => ethAccount,
|
|
72
|
-
fixedStr: () => fixedStr,
|
|
73
|
-
fromBufferToBase58: () => fromBufferToBase58,
|
|
74
|
-
getSs58AddressInfo: () => getSs58AddressInfo,
|
|
75
|
-
h64: () => h64,
|
|
76
|
-
i128: () => import_scale_ts8.i128,
|
|
77
|
-
i16: () => import_scale_ts8.i16,
|
|
78
|
-
i256: () => import_scale_ts8.i256,
|
|
79
|
-
i32: () => import_scale_ts8.i32,
|
|
80
|
-
i64: () => import_scale_ts8.i64,
|
|
81
|
-
i8: () => import_scale_ts8.i8,
|
|
82
|
-
metadata: () => metadata,
|
|
83
|
-
selfDecoder: () => selfDecoder,
|
|
84
|
-
selfEncoder: () => selfEncoder,
|
|
85
|
-
str: () => import_scale_ts8.str,
|
|
86
|
-
u128: () => import_scale_ts8.u128,
|
|
87
|
-
u16: () => import_scale_ts8.u16,
|
|
88
|
-
u256: () => import_scale_ts8.u256,
|
|
89
|
-
u32: () => import_scale_ts8.u32,
|
|
90
|
-
u64: () => import_scale_ts8.u64,
|
|
91
|
-
u8: () => import_scale_ts8.u8,
|
|
92
|
-
v14: () => v14,
|
|
93
|
-
v15: () => v15
|
|
94
|
-
});
|
|
95
|
-
module.exports = __toCommonJS(src_exports);
|
|
96
|
-
|
|
97
|
-
// src/codecs/scale/AccountId.ts
|
|
98
|
-
var import_scale_ts = require("scale-ts");
|
|
99
|
-
|
|
100
|
-
// src/utils/ss58-util.ts
|
|
101
|
-
var import_base = require("@scure/base");
|
|
102
|
-
var import_blake2b = require("@noble/hashes/blake2b");
|
|
103
|
-
var SS58_PREFIX = new TextEncoder().encode("SS58PRE");
|
|
104
|
-
var CHECKSUM_LENGTH = 2;
|
|
105
|
-
var getSs58AddressInfo = (address) => {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scaleTs = require('scale-ts');
|
|
4
|
+
var base = require('@scure/base');
|
|
5
|
+
var blake2b = require('@noble/hashes/blake2b');
|
|
6
|
+
var utils = require('@polkadot-api/utils');
|
|
7
|
+
var sha3 = require('@noble/hashes/sha3');
|
|
8
|
+
var blake3 = require('@noble/hashes/blake3');
|
|
9
|
+
|
|
10
|
+
const SS58_PREFIX = new TextEncoder().encode("SS58PRE");
|
|
11
|
+
const CHECKSUM_LENGTH = 2;
|
|
12
|
+
const getSs58AddressInfo = (address) => {
|
|
106
13
|
try {
|
|
107
|
-
const decoded =
|
|
14
|
+
const decoded = base.base58.decode(address);
|
|
108
15
|
const prefixBytes = decoded.subarray(0, decoded[0] & 64 ? 2 : 1);
|
|
109
16
|
const publicKey = decoded.subarray(
|
|
110
17
|
prefixBytes.length,
|
|
111
18
|
decoded.length - CHECKSUM_LENGTH
|
|
112
19
|
);
|
|
113
20
|
const checksum = decoded.subarray(prefixBytes.length + publicKey.length);
|
|
114
|
-
const expectedChecksum =
|
|
21
|
+
const expectedChecksum = blake2b.blake2b(
|
|
115
22
|
Uint8Array.of(...SS58_PREFIX, ...prefixBytes, ...publicKey),
|
|
116
23
|
{
|
|
117
24
|
dkLen: 64
|
|
@@ -128,29 +35,28 @@ var getSs58AddressInfo = (address) => {
|
|
|
128
35
|
return { isValid: false };
|
|
129
36
|
}
|
|
130
37
|
};
|
|
131
|
-
|
|
38
|
+
const prefixBytesToNumber = (bytes) => {
|
|
132
39
|
const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
133
40
|
return dv.byteLength === 1 ? dv.getUint8(0) : dv.getUint16(0);
|
|
134
41
|
};
|
|
135
|
-
|
|
42
|
+
const fromBufferToBase58 = (ss58Format) => {
|
|
136
43
|
const prefixBytes = ss58Format < 64 ? Uint8Array.of(ss58Format) : Uint8Array.of(
|
|
137
44
|
(ss58Format & 252) >> 2 | 64,
|
|
138
45
|
ss58Format >> 8 | (ss58Format & 3) << 6
|
|
139
46
|
);
|
|
140
47
|
return (publicKey) => {
|
|
141
|
-
const checksum =
|
|
48
|
+
const checksum = blake2b.blake2b(
|
|
142
49
|
Uint8Array.of(...SS58_PREFIX, ...prefixBytes, ...publicKey),
|
|
143
50
|
{
|
|
144
51
|
dkLen: 64
|
|
145
52
|
}
|
|
146
53
|
).subarray(0, CHECKSUM_LENGTH);
|
|
147
|
-
return
|
|
54
|
+
return base.base58.encode(
|
|
148
55
|
Uint8Array.of(...prefixBytes, ...publicKey, ...checksum)
|
|
149
56
|
);
|
|
150
57
|
};
|
|
151
58
|
};
|
|
152
59
|
|
|
153
|
-
// src/codecs/scale/AccountId.ts
|
|
154
60
|
function fromBase58ToBuffer(nBytes, _ss58Format) {
|
|
155
61
|
return (address) => {
|
|
156
62
|
const info = getSs58AddressInfo(address);
|
|
@@ -161,78 +67,79 @@ function fromBase58ToBuffer(nBytes, _ss58Format) {
|
|
|
161
67
|
return publicKey;
|
|
162
68
|
};
|
|
163
69
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
fromBase58ToBuffer(nBytes
|
|
70
|
+
const AccountId = (ss58Format = 42, nBytes = 32) => scaleTs.enhanceCodec(
|
|
71
|
+
scaleTs.Bytes(nBytes),
|
|
72
|
+
fromBase58ToBuffer(nBytes),
|
|
167
73
|
fromBufferToBase58(ss58Format)
|
|
168
74
|
);
|
|
169
75
|
|
|
170
|
-
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var
|
|
76
|
+
var __defProp = Object.defineProperty;
|
|
77
|
+
var __typeError = (msg) => {
|
|
78
|
+
throw TypeError(msg);
|
|
79
|
+
};
|
|
80
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
81
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
82
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
83
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
84
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
85
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
175
86
|
var _bytes, _hex, _str;
|
|
176
|
-
|
|
87
|
+
const textEncoder$3 = new TextEncoder();
|
|
88
|
+
const textDecoder$2 = new TextDecoder();
|
|
89
|
+
class Binary {
|
|
177
90
|
constructor(data) {
|
|
178
91
|
__privateAdd(this, _bytes);
|
|
179
92
|
__privateAdd(this, _hex, null);
|
|
180
93
|
__privateAdd(this, _str, null);
|
|
181
|
-
__publicField(this, "asText", () => __privateGet(this, _str) === null ? __privateSet(this, _str, textDecoder.decode(__privateGet(this, _bytes))) : __privateGet(this, _str));
|
|
182
|
-
__publicField(this, "asHex", () => __privateGet(this, _hex) === null ? __privateSet(this, _hex,
|
|
94
|
+
__publicField(this, "asText", () => __privateGet(this, _str) === null ? __privateSet(this, _str, textDecoder$2.decode(__privateGet(this, _bytes))) : __privateGet(this, _str));
|
|
95
|
+
__publicField(this, "asHex", () => __privateGet(this, _hex) === null ? __privateSet(this, _hex, utils.toHex(__privateGet(this, _bytes))) : __privateGet(this, _hex));
|
|
183
96
|
__publicField(this, "asBytes", () => __privateGet(this, _bytes));
|
|
184
97
|
__privateSet(this, _bytes, data);
|
|
185
98
|
}
|
|
186
99
|
static fromText(input) {
|
|
187
|
-
return new
|
|
100
|
+
return new this(textEncoder$3.encode(input));
|
|
188
101
|
}
|
|
189
102
|
static fromHex(input) {
|
|
190
|
-
return new
|
|
103
|
+
return new this(utils.fromHex(input));
|
|
191
104
|
}
|
|
192
105
|
static fromBytes(input) {
|
|
193
|
-
return new
|
|
106
|
+
return new this(input);
|
|
194
107
|
}
|
|
195
|
-
}
|
|
108
|
+
}
|
|
196
109
|
_bytes = new WeakMap();
|
|
197
110
|
_hex = new WeakMap();
|
|
198
111
|
_str = new WeakMap();
|
|
199
|
-
|
|
200
|
-
var FixedSizeBinary = class _FixedSizeBinary extends Binary {
|
|
112
|
+
class FixedSizeBinary extends Binary {
|
|
201
113
|
constructor(data) {
|
|
202
114
|
super(data);
|
|
203
115
|
}
|
|
204
116
|
static fromArray(input) {
|
|
205
|
-
return new
|
|
117
|
+
return new this(new Uint8Array(input));
|
|
206
118
|
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const _enc =
|
|
119
|
+
}
|
|
120
|
+
const enc$1 = (nBytes) => {
|
|
121
|
+
const _enc = scaleTs.Bytes.enc(nBytes);
|
|
210
122
|
return (value) => _enc(value.asBytes());
|
|
211
123
|
};
|
|
212
|
-
|
|
213
|
-
const _dec =
|
|
214
|
-
|
|
124
|
+
const dec$1 = (nBytes) => {
|
|
125
|
+
const _dec = scaleTs.Bytes.dec(nBytes);
|
|
126
|
+
const Bin2 = nBytes == null ? Binary : FixedSizeBinary;
|
|
127
|
+
return (value) => Bin2.fromBytes(_dec(value));
|
|
215
128
|
};
|
|
216
|
-
|
|
217
|
-
Bin.enc = enc;
|
|
218
|
-
Bin.dec = dec;
|
|
129
|
+
const Bin = (nBytes) => scaleTs.createCodec(enc$1(nBytes), dec$1(nBytes));
|
|
130
|
+
Bin.enc = enc$1;
|
|
131
|
+
Bin.dec = dec$1;
|
|
219
132
|
|
|
220
|
-
|
|
221
|
-
|
|
133
|
+
const compactNumber = scaleTs.compact;
|
|
134
|
+
const compactBn = scaleTs.compact;
|
|
222
135
|
|
|
223
|
-
|
|
224
|
-
var import_scale_ts3 = require("scale-ts");
|
|
225
|
-
var compactNumber = import_scale_ts3.compact;
|
|
226
|
-
var compactBn = import_scale_ts3.compact;
|
|
227
|
-
|
|
228
|
-
// src/codecs/scale/bitSequence.ts
|
|
229
|
-
var bitSequenceDecoder = (0, import_scale_ts4.createDecoder)((data) => {
|
|
136
|
+
const bitSequenceDecoder = scaleTs.createDecoder((data) => {
|
|
230
137
|
const bitsLen = compactNumber.dec(data);
|
|
231
138
|
const bytesLen = Math.ceil(bitsLen / 8);
|
|
232
|
-
const bytes =
|
|
139
|
+
const bytes = scaleTs.Bytes(bytesLen).dec(data);
|
|
233
140
|
return { bytes, bitsLen };
|
|
234
141
|
});
|
|
235
|
-
|
|
142
|
+
const bitSequenceEncoder = (input) => {
|
|
236
143
|
if (input.bitsLen > input.bytes.length * 8)
|
|
237
144
|
throw new Error(
|
|
238
145
|
`Not enough bytes. (bitsLen:${input.bitsLen}, bytesLen:${input.bytes.length})`
|
|
@@ -243,47 +150,35 @@ var bitSequenceEncoder = (input) => {
|
|
|
243
150
|
result.set(input.bytes, lenEncoded.length);
|
|
244
151
|
return result;
|
|
245
152
|
};
|
|
246
|
-
|
|
153
|
+
const bitSequence$1 = scaleTs.createCodec(bitSequenceEncoder, bitSequenceDecoder);
|
|
247
154
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
import_scale_ts5.u8,
|
|
252
|
-
(str8) => str8.charCodeAt(0),
|
|
155
|
+
const char = scaleTs.enhanceCodec(
|
|
156
|
+
scaleTs.u8,
|
|
157
|
+
(str) => str.charCodeAt(0),
|
|
253
158
|
String.fromCharCode
|
|
254
159
|
);
|
|
255
160
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
var enc2 = (nBytes) => {
|
|
260
|
-
const _enc = import_scale_ts6.Bytes.enc(nBytes);
|
|
261
|
-
return (value) => _enc((0, import_utils2.fromHex)(value));
|
|
161
|
+
const enc = (nBytes) => {
|
|
162
|
+
const _enc = scaleTs.Bytes.enc(nBytes);
|
|
163
|
+
return (value) => _enc(utils.fromHex(value));
|
|
262
164
|
};
|
|
263
|
-
|
|
264
|
-
const _dec =
|
|
265
|
-
return (value) =>
|
|
165
|
+
const dec = (nBytes) => {
|
|
166
|
+
const _dec = scaleTs.Bytes.dec(nBytes);
|
|
167
|
+
return (value) => utils.toHex(_dec(value));
|
|
266
168
|
};
|
|
267
|
-
|
|
268
|
-
Hex.enc =
|
|
269
|
-
Hex.dec =
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
(
|
|
277
|
-
(str8) => textEncoder2.encode(str8),
|
|
278
|
-
(bytes) => textDecoder2.decode(bytes)
|
|
169
|
+
const Hex = (nBytes) => scaleTs.createCodec(enc(nBytes), dec(nBytes));
|
|
170
|
+
Hex.enc = enc;
|
|
171
|
+
Hex.dec = dec;
|
|
172
|
+
|
|
173
|
+
const textEncoder$2 = new TextEncoder();
|
|
174
|
+
const textDecoder$1 = new TextDecoder();
|
|
175
|
+
const fixedStr = (nBytes) => scaleTs.enhanceCodec(
|
|
176
|
+
scaleTs.Bytes(nBytes),
|
|
177
|
+
(str) => textEncoder$2.encode(str),
|
|
178
|
+
(bytes) => textDecoder$1.decode(bytes)
|
|
279
179
|
);
|
|
280
180
|
|
|
281
|
-
|
|
282
|
-
var import_scale_ts8 = require("scale-ts");
|
|
283
|
-
|
|
284
|
-
// src/codecs/scale/Self.ts
|
|
285
|
-
var import_scale_ts9 = require("scale-ts");
|
|
286
|
-
var selfEncoder = (value) => {
|
|
181
|
+
const selfEncoder = (value) => {
|
|
287
182
|
let cache = (x) => {
|
|
288
183
|
const encoder = value();
|
|
289
184
|
cache = encoder;
|
|
@@ -291,7 +186,7 @@ var selfEncoder = (value) => {
|
|
|
291
186
|
};
|
|
292
187
|
return (x) => cache(x);
|
|
293
188
|
};
|
|
294
|
-
|
|
189
|
+
const selfDecoder = (value) => {
|
|
295
190
|
let cache = (x) => {
|
|
296
191
|
const decoder = value();
|
|
297
192
|
const result = decoder;
|
|
@@ -300,17 +195,12 @@ var selfDecoder = (value) => {
|
|
|
300
195
|
};
|
|
301
196
|
return (x) => cache(x);
|
|
302
197
|
};
|
|
303
|
-
|
|
198
|
+
const Self = (value) => scaleTs.createCodec(
|
|
304
199
|
selfEncoder(() => value().enc),
|
|
305
200
|
selfDecoder(() => value().dec)
|
|
306
201
|
);
|
|
307
202
|
|
|
308
|
-
|
|
309
|
-
var import_scale_ts10 = require("scale-ts");
|
|
310
|
-
var import_utils3 = require("@polkadot-api/utils");
|
|
311
|
-
|
|
312
|
-
// src/types/enum.ts
|
|
313
|
-
var discriminant = {
|
|
203
|
+
const discriminant = {
|
|
314
204
|
is(value, type) {
|
|
315
205
|
return value.type === type;
|
|
316
206
|
},
|
|
@@ -322,250 +212,228 @@ var discriminant = {
|
|
|
322
212
|
return value;
|
|
323
213
|
}
|
|
324
214
|
};
|
|
325
|
-
|
|
215
|
+
const Enum = Object.assign((type, value) => {
|
|
326
216
|
return {
|
|
327
217
|
type,
|
|
328
218
|
value
|
|
329
219
|
};
|
|
330
220
|
}, discriminant);
|
|
331
|
-
|
|
221
|
+
const _Enum = new Proxy(
|
|
332
222
|
{},
|
|
333
223
|
{
|
|
334
224
|
get(_, prop) {
|
|
335
|
-
return (value) =>
|
|
225
|
+
return (value) => Enum(prop, value);
|
|
336
226
|
}
|
|
337
227
|
}
|
|
338
228
|
);
|
|
339
229
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
return (v) => enc3({ tag: v.type, value: v.value });
|
|
230
|
+
const VariantEnc = (...args) => {
|
|
231
|
+
const enc = scaleTs.Enum.enc(...args);
|
|
232
|
+
return (v) => enc({ tag: v.type, value: v.value });
|
|
344
233
|
};
|
|
345
|
-
|
|
346
|
-
const
|
|
234
|
+
const VariantDec = (...args) => {
|
|
235
|
+
const dec = scaleTs.Enum.dec(...args);
|
|
347
236
|
return (v) => {
|
|
348
|
-
const { tag, value } =
|
|
349
|
-
return
|
|
237
|
+
const { tag, value } = dec(v);
|
|
238
|
+
return Enum(tag, value);
|
|
350
239
|
};
|
|
351
240
|
};
|
|
352
|
-
|
|
241
|
+
const Variant = (inner, ...args) => scaleTs.createCodec(
|
|
353
242
|
VariantEnc(
|
|
354
|
-
|
|
243
|
+
utils.mapObject(inner, ([encoder]) => encoder),
|
|
355
244
|
...args
|
|
356
245
|
),
|
|
357
246
|
VariantDec(
|
|
358
|
-
|
|
247
|
+
utils.mapObject(inner, ([, decoder]) => decoder),
|
|
359
248
|
...args
|
|
360
249
|
)
|
|
361
250
|
);
|
|
362
251
|
Variant.enc = VariantEnc;
|
|
363
252
|
Variant.dec = VariantDec;
|
|
364
253
|
|
|
365
|
-
|
|
366
|
-
var import_utils4 = require("@polkadot-api/utils");
|
|
367
|
-
var import_scale_ts11 = require("scale-ts");
|
|
368
|
-
var import_sha3 = require("@noble/hashes/sha3");
|
|
369
|
-
var getFormattedAddress = (hexAddress) => {
|
|
254
|
+
const getFormattedAddress = (hexAddress) => {
|
|
370
255
|
const nonChecksum = hexAddress.slice(2);
|
|
371
|
-
const hashedAddress =
|
|
256
|
+
const hashedAddress = utils.toHex(sha3.keccak_256(nonChecksum)).slice(2);
|
|
372
257
|
const result = new Array(40);
|
|
373
258
|
for (let i = 0; i < 40; i++) {
|
|
374
259
|
const checksumVal = parseInt(hashedAddress[i], 16);
|
|
375
|
-
const
|
|
376
|
-
result[i] = checksumVal > 7 ?
|
|
260
|
+
const char = nonChecksum[i];
|
|
261
|
+
result[i] = checksumVal > 7 ? char.toUpperCase() : char;
|
|
377
262
|
}
|
|
378
263
|
return `0x${result.join("")}`;
|
|
379
264
|
};
|
|
380
|
-
|
|
381
|
-
|
|
265
|
+
const bytes20Dec = scaleTs.Bytes(20)[1];
|
|
266
|
+
const ethAccount = scaleTs.createCodec(
|
|
382
267
|
(input) => {
|
|
383
|
-
const bytes =
|
|
268
|
+
const bytes = utils.fromHex(input);
|
|
384
269
|
if (bytes.length !== 20)
|
|
385
270
|
throw new Error(`Invalid length found on EthAddress(${input})`);
|
|
386
|
-
const hexAddress =
|
|
271
|
+
const hexAddress = utils.toHex(bytes);
|
|
387
272
|
if (input === hexAddress || input === hexAddress.toUpperCase()) return bytes;
|
|
388
273
|
if (getFormattedAddress(hexAddress) !== input)
|
|
389
274
|
throw new Error(`Invalid checksum found on EthAddress(${input})`);
|
|
390
275
|
return bytes;
|
|
391
276
|
},
|
|
392
|
-
|
|
277
|
+
scaleTs.createDecoder((bytes) => getFormattedAddress(utils.toHex(bytes20Dec(bytes))))
|
|
393
278
|
);
|
|
394
279
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
textDecoder3.decode.bind(textDecoder3)
|
|
280
|
+
const textEncoder$1 = new TextEncoder();
|
|
281
|
+
const textDecoder = new TextDecoder();
|
|
282
|
+
const fourChars = scaleTs.enhanceCodec(
|
|
283
|
+
scaleTs.Bytes(4),
|
|
284
|
+
textEncoder$1.encode.bind(textEncoder$1),
|
|
285
|
+
textDecoder.decode.bind(textDecoder)
|
|
402
286
|
);
|
|
403
|
-
|
|
287
|
+
const diggestVal = scaleTs.Struct({
|
|
404
288
|
engine: fourChars,
|
|
405
289
|
payload: Hex()
|
|
406
290
|
});
|
|
407
|
-
|
|
291
|
+
const diggest = Variant(
|
|
408
292
|
{
|
|
409
293
|
consensus: diggestVal,
|
|
410
294
|
seal: diggestVal,
|
|
411
295
|
preRuntime: diggestVal,
|
|
412
|
-
runtimeUpdated:
|
|
296
|
+
runtimeUpdated: scaleTs._void
|
|
413
297
|
},
|
|
414
298
|
[4, 5, 6, 8]
|
|
415
299
|
);
|
|
416
|
-
|
|
417
|
-
|
|
300
|
+
const hex32 = Hex(32);
|
|
301
|
+
const blockHeader = scaleTs.Struct({
|
|
418
302
|
parentHash: hex32,
|
|
419
303
|
number: compactNumber,
|
|
420
304
|
stateRoot: hex32,
|
|
421
305
|
extrinsicRoot: hex32,
|
|
422
|
-
digests:
|
|
306
|
+
digests: scaleTs.Vector(diggest)
|
|
423
307
|
});
|
|
424
308
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
u64: import_scale_ts13._void,
|
|
448
|
-
u128: import_scale_ts13._void,
|
|
449
|
-
u256: import_scale_ts13._void,
|
|
450
|
-
i8: import_scale_ts13._void,
|
|
451
|
-
i16: import_scale_ts13._void,
|
|
452
|
-
i32: import_scale_ts13._void,
|
|
453
|
-
i64: import_scale_ts13._void,
|
|
454
|
-
i128: import_scale_ts13._void,
|
|
455
|
-
i256: import_scale_ts13._void
|
|
456
|
-
});
|
|
457
|
-
var fields = (0, import_scale_ts13.Vector)(
|
|
458
|
-
(0, import_scale_ts13.Struct)({
|
|
309
|
+
const docs = scaleTs.Vector(scaleTs.str);
|
|
310
|
+
|
|
311
|
+
const oStr = scaleTs.Option(scaleTs.str);
|
|
312
|
+
const primitive = scaleTs.Enum({
|
|
313
|
+
bool: scaleTs._void,
|
|
314
|
+
char: scaleTs._void,
|
|
315
|
+
str: scaleTs._void,
|
|
316
|
+
u8: scaleTs._void,
|
|
317
|
+
u16: scaleTs._void,
|
|
318
|
+
u32: scaleTs._void,
|
|
319
|
+
u64: scaleTs._void,
|
|
320
|
+
u128: scaleTs._void,
|
|
321
|
+
u256: scaleTs._void,
|
|
322
|
+
i8: scaleTs._void,
|
|
323
|
+
i16: scaleTs._void,
|
|
324
|
+
i32: scaleTs._void,
|
|
325
|
+
i64: scaleTs._void,
|
|
326
|
+
i128: scaleTs._void,
|
|
327
|
+
i256: scaleTs._void
|
|
328
|
+
});
|
|
329
|
+
const fields = scaleTs.Vector(
|
|
330
|
+
scaleTs.Struct({
|
|
459
331
|
name: oStr,
|
|
460
332
|
type: compactNumber,
|
|
461
333
|
typeName: oStr,
|
|
462
334
|
docs
|
|
463
335
|
})
|
|
464
336
|
);
|
|
465
|
-
|
|
466
|
-
len:
|
|
337
|
+
const arr = scaleTs.Struct({
|
|
338
|
+
len: scaleTs.u32,
|
|
467
339
|
type: compactNumber
|
|
468
340
|
});
|
|
469
|
-
|
|
341
|
+
const bitSequence = scaleTs.Struct({
|
|
470
342
|
bitStoreType: compactNumber,
|
|
471
343
|
bitOrderType: compactNumber
|
|
472
344
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
name:
|
|
345
|
+
const variant = scaleTs.Vector(
|
|
346
|
+
scaleTs.Struct({
|
|
347
|
+
name: scaleTs.str,
|
|
476
348
|
fields,
|
|
477
|
-
index:
|
|
349
|
+
index: scaleTs.u8,
|
|
478
350
|
docs
|
|
479
351
|
})
|
|
480
352
|
);
|
|
481
|
-
|
|
353
|
+
const def = scaleTs.Enum({
|
|
482
354
|
composite: fields,
|
|
483
355
|
variant,
|
|
484
356
|
sequence: compactNumber,
|
|
485
357
|
array: arr,
|
|
486
|
-
tuple:
|
|
358
|
+
tuple: scaleTs.Vector(compactNumber),
|
|
487
359
|
primitive,
|
|
488
360
|
compact: compactNumber,
|
|
489
|
-
bitSequence
|
|
361
|
+
bitSequence
|
|
490
362
|
});
|
|
491
|
-
|
|
492
|
-
name:
|
|
493
|
-
type:
|
|
363
|
+
const param = scaleTs.Struct({
|
|
364
|
+
name: scaleTs.str,
|
|
365
|
+
type: scaleTs.Option(compactNumber)
|
|
494
366
|
});
|
|
495
|
-
|
|
496
|
-
|
|
367
|
+
const params = scaleTs.Vector(param);
|
|
368
|
+
const entry = scaleTs.Struct({
|
|
497
369
|
id: compactNumber,
|
|
498
370
|
path: docs,
|
|
499
371
|
params,
|
|
500
372
|
def,
|
|
501
373
|
docs
|
|
502
374
|
});
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
var hashers = (0, import_scale_ts14.Vector)(hashType);
|
|
517
|
-
var storageMap = (0, import_scale_ts14.Struct)({
|
|
375
|
+
const lookup = scaleTs.Vector(entry);
|
|
376
|
+
|
|
377
|
+
const hashType = scaleTs.Enum({
|
|
378
|
+
Blake2128: scaleTs._void,
|
|
379
|
+
Blake2256: scaleTs._void,
|
|
380
|
+
Blake2128Concat: scaleTs._void,
|
|
381
|
+
Twox128: scaleTs._void,
|
|
382
|
+
Twox256: scaleTs._void,
|
|
383
|
+
Twox64Concat: scaleTs._void,
|
|
384
|
+
Identity: scaleTs._void
|
|
385
|
+
});
|
|
386
|
+
const hashers = scaleTs.Vector(hashType);
|
|
387
|
+
const storageMap = scaleTs.Struct({
|
|
518
388
|
hashers,
|
|
519
389
|
key: compactNumber,
|
|
520
390
|
value: compactNumber
|
|
521
391
|
});
|
|
522
|
-
|
|
523
|
-
name:
|
|
524
|
-
modifier:
|
|
525
|
-
type:
|
|
392
|
+
const storageItem = scaleTs.Struct({
|
|
393
|
+
name: scaleTs.str,
|
|
394
|
+
modifier: scaleTs.u8,
|
|
395
|
+
type: scaleTs.Enum({
|
|
526
396
|
plain: compactNumber,
|
|
527
397
|
map: storageMap
|
|
528
398
|
}),
|
|
529
399
|
fallback: Hex(),
|
|
530
400
|
docs
|
|
531
401
|
});
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
prefix:
|
|
535
|
-
items:
|
|
402
|
+
const storage = scaleTs.Option(
|
|
403
|
+
scaleTs.Struct({
|
|
404
|
+
prefix: scaleTs.str,
|
|
405
|
+
items: scaleTs.Vector(storageItem)
|
|
536
406
|
})
|
|
537
407
|
);
|
|
538
|
-
|
|
539
|
-
name:
|
|
408
|
+
const v14Pallet = {
|
|
409
|
+
name: scaleTs.str,
|
|
540
410
|
storage,
|
|
541
|
-
calls:
|
|
542
|
-
events:
|
|
543
|
-
constants:
|
|
544
|
-
|
|
545
|
-
name:
|
|
411
|
+
calls: scaleTs.Option(compactNumber),
|
|
412
|
+
events: scaleTs.Option(compactNumber),
|
|
413
|
+
constants: scaleTs.Vector(
|
|
414
|
+
scaleTs.Struct({
|
|
415
|
+
name: scaleTs.str,
|
|
546
416
|
type: compactNumber,
|
|
547
417
|
value: Hex(),
|
|
548
418
|
docs
|
|
549
419
|
})
|
|
550
420
|
),
|
|
551
|
-
errors:
|
|
552
|
-
index:
|
|
421
|
+
errors: scaleTs.Option(compactNumber),
|
|
422
|
+
index: scaleTs.u8
|
|
553
423
|
};
|
|
554
|
-
|
|
424
|
+
const v15Pallet = {
|
|
555
425
|
...v14Pallet,
|
|
556
426
|
docs
|
|
557
427
|
};
|
|
558
428
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
(0, import_scale_ts15.Struct)({
|
|
568
|
-
name: import_scale_ts15.str,
|
|
429
|
+
const runtimeApi = scaleTs.Struct({
|
|
430
|
+
name: scaleTs.str,
|
|
431
|
+
methods: scaleTs.Vector(
|
|
432
|
+
scaleTs.Struct({
|
|
433
|
+
name: scaleTs.str,
|
|
434
|
+
inputs: scaleTs.Vector(
|
|
435
|
+
scaleTs.Struct({
|
|
436
|
+
name: scaleTs.str,
|
|
569
437
|
type: compactNumber
|
|
570
438
|
})
|
|
571
439
|
),
|
|
@@ -576,72 +444,68 @@ var runtimeApi = (0, import_scale_ts15.Struct)({
|
|
|
576
444
|
docs
|
|
577
445
|
});
|
|
578
446
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
version: import_scale_ts16.u8,
|
|
447
|
+
const extrinsic$1 = scaleTs.Struct({
|
|
448
|
+
version: scaleTs.u8,
|
|
582
449
|
address: compactNumber,
|
|
583
450
|
call: compactNumber,
|
|
584
451
|
signature: compactNumber,
|
|
585
452
|
extra: compactNumber,
|
|
586
|
-
signedExtensions:
|
|
587
|
-
|
|
588
|
-
identifier:
|
|
453
|
+
signedExtensions: scaleTs.Vector(
|
|
454
|
+
scaleTs.Struct({
|
|
455
|
+
identifier: scaleTs.str,
|
|
589
456
|
type: compactNumber,
|
|
590
457
|
additionalSigned: compactNumber
|
|
591
458
|
})
|
|
592
459
|
)
|
|
593
460
|
});
|
|
594
|
-
|
|
461
|
+
const v15 = scaleTs.Struct({
|
|
595
462
|
lookup,
|
|
596
|
-
pallets:
|
|
597
|
-
extrinsic,
|
|
463
|
+
pallets: scaleTs.Vector(scaleTs.Struct(v15Pallet)),
|
|
464
|
+
extrinsic: extrinsic$1,
|
|
598
465
|
type: compactNumber,
|
|
599
|
-
apis:
|
|
600
|
-
outerEnums:
|
|
466
|
+
apis: scaleTs.Vector(runtimeApi),
|
|
467
|
+
outerEnums: scaleTs.Struct({
|
|
601
468
|
call: compactNumber,
|
|
602
469
|
event: compactNumber,
|
|
603
470
|
error: compactNumber
|
|
604
471
|
}),
|
|
605
|
-
custom:
|
|
472
|
+
custom: scaleTs.Vector(scaleTs.Tuple(scaleTs.str, scaleTs.Struct({ type: compactNumber, value: Hex() })))
|
|
606
473
|
});
|
|
607
474
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
var empty = new Uint8Array();
|
|
611
|
-
var Always = (value) => (0, import_scale_ts17.createCodec)(
|
|
475
|
+
const empty = new Uint8Array();
|
|
476
|
+
const Always = (value) => scaleTs.createCodec(
|
|
612
477
|
() => empty,
|
|
613
478
|
() => value
|
|
614
479
|
);
|
|
615
|
-
|
|
480
|
+
const extrinsic = scaleTs.Struct({
|
|
616
481
|
type: compactNumber,
|
|
617
|
-
version:
|
|
618
|
-
signedExtensions:
|
|
619
|
-
|
|
620
|
-
identifier:
|
|
482
|
+
version: scaleTs.u8,
|
|
483
|
+
signedExtensions: scaleTs.Vector(
|
|
484
|
+
scaleTs.Struct({
|
|
485
|
+
identifier: scaleTs.str,
|
|
621
486
|
type: compactNumber,
|
|
622
487
|
additionalSigned: compactNumber
|
|
623
488
|
})
|
|
624
489
|
)
|
|
625
490
|
});
|
|
626
|
-
|
|
491
|
+
const v14 = scaleTs.Struct({
|
|
627
492
|
lookup,
|
|
628
|
-
pallets:
|
|
629
|
-
extrinsic
|
|
493
|
+
pallets: scaleTs.Vector(scaleTs.Struct({ ...v14Pallet, docs: Always([]) })),
|
|
494
|
+
extrinsic,
|
|
630
495
|
type: compactNumber,
|
|
631
496
|
apis: Always([])
|
|
632
497
|
});
|
|
633
498
|
|
|
634
|
-
|
|
635
|
-
var unsupportedFn = () => {
|
|
499
|
+
const unsupportedFn = () => {
|
|
636
500
|
throw new Error("Unsupported metadata version!");
|
|
637
501
|
};
|
|
638
|
-
|
|
502
|
+
const unsupported = scaleTs.createCodec(
|
|
639
503
|
unsupportedFn,
|
|
640
504
|
unsupportedFn
|
|
641
505
|
);
|
|
642
|
-
|
|
643
|
-
magicNumber:
|
|
644
|
-
metadata:
|
|
506
|
+
const metadata = scaleTs.Struct({
|
|
507
|
+
magicNumber: scaleTs.u32,
|
|
508
|
+
metadata: scaleTs.Enum({
|
|
645
509
|
v0: unsupported,
|
|
646
510
|
v1: unsupported,
|
|
647
511
|
v2: unsupported,
|
|
@@ -661,40 +525,28 @@ var metadata = (0, import_scale_ts18.Struct)({
|
|
|
661
525
|
})
|
|
662
526
|
});
|
|
663
527
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
// src/hashes/h64.ts
|
|
688
|
-
var bigintFromU16 = (v0, v1, v2, v3) => new DataView(new Uint16Array([v0, v1, v2, v3]).buffer).getBigUint64(0, true);
|
|
689
|
-
var MASK_64 = 2n ** 64n - 1n;
|
|
690
|
-
var rotl = (input, nBits) => input << nBits & MASK_64 | input >> 64n - nBits;
|
|
691
|
-
var multiply = (a, b) => a * b & MASK_64;
|
|
692
|
-
var add = (a, b) => a + b & MASK_64;
|
|
693
|
-
var PRIME64_1 = 11400714785074694791n;
|
|
694
|
-
var PRIME64_2 = 14029467366897019727n;
|
|
695
|
-
var PRIME64_3 = 1609587929392839161n;
|
|
696
|
-
var PRIME64_4 = 9650029242287828579n;
|
|
697
|
-
var PRIME64_5 = 2870177450012600261n;
|
|
528
|
+
const len32$1 = { dkLen: 32 };
|
|
529
|
+
const Blake2256 = (encoded) => blake2b.blake2b(encoded, len32$1);
|
|
530
|
+
const len16 = { dkLen: 16 };
|
|
531
|
+
const Blake2128 = (encoded) => blake2b.blake2b(encoded, len16);
|
|
532
|
+
const Blake2128Concat = (encoded) => utils.mergeUint8(Blake2128(encoded), encoded);
|
|
533
|
+
|
|
534
|
+
const len32 = { dkLen: 32 };
|
|
535
|
+
const Blake3256 = (encoded) => blake3.blake3(encoded, len32);
|
|
536
|
+
const Blake3256Concat = (encoded) => utils.mergeUint8(Blake3256(encoded), encoded);
|
|
537
|
+
|
|
538
|
+
const Identity = (encoded) => encoded;
|
|
539
|
+
|
|
540
|
+
const bigintFromU16 = (v0, v1, v2, v3) => new DataView(new Uint16Array([v0, v1, v2, v3]).buffer).getBigUint64(0, true);
|
|
541
|
+
const MASK_64 = 2n ** 64n - 1n;
|
|
542
|
+
const rotl = (input, nBits) => input << nBits & MASK_64 | input >> 64n - nBits;
|
|
543
|
+
const multiply = (a, b) => a * b & MASK_64;
|
|
544
|
+
const add = (a, b) => a + b & MASK_64;
|
|
545
|
+
const PRIME64_1 = 11400714785074694791n;
|
|
546
|
+
const PRIME64_2 = 14029467366897019727n;
|
|
547
|
+
const PRIME64_3 = 1609587929392839161n;
|
|
548
|
+
const PRIME64_4 = 9650029242287828579n;
|
|
549
|
+
const PRIME64_5 = 2870177450012600261n;
|
|
698
550
|
function h64(input, seed = 0n) {
|
|
699
551
|
let v1 = add(add(seed, PRIME64_1), PRIME64_2);
|
|
700
552
|
let v2 = add(seed, PRIME64_2);
|
|
@@ -817,15 +669,14 @@ function h64(input, seed = 0n) {
|
|
|
817
669
|
return result;
|
|
818
670
|
}
|
|
819
671
|
|
|
820
|
-
|
|
821
|
-
var Twox128 = (input) => {
|
|
672
|
+
const Twox128 = (input) => {
|
|
822
673
|
const result = new Uint8Array(16);
|
|
823
674
|
const dv = new DataView(result.buffer);
|
|
824
675
|
dv.setBigUint64(0, h64(input), true);
|
|
825
676
|
dv.setBigUint64(8, h64(input, 1n), true);
|
|
826
677
|
return result;
|
|
827
678
|
};
|
|
828
|
-
|
|
679
|
+
const Twox256 = (input) => {
|
|
829
680
|
const result = new Uint8Array(32);
|
|
830
681
|
const dv = new DataView(result.buffer);
|
|
831
682
|
dv.setBigUint64(0, h64(input), true);
|
|
@@ -834,19 +685,17 @@ var Twox256 = (input) => {
|
|
|
834
685
|
dv.setBigUint64(24, h64(input, 3n), true);
|
|
835
686
|
return result;
|
|
836
687
|
};
|
|
837
|
-
|
|
688
|
+
const Twox64Concat = (encoded) => utils.mergeUint8(scaleTs.u64.enc(h64(encoded)), encoded);
|
|
838
689
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
return (name, dec3, ...encoders) => {
|
|
845
|
-
const palletItemEncoded = (0, import_utils8.mergeUint8)(
|
|
690
|
+
const textEncoder = new TextEncoder();
|
|
691
|
+
const Storage = (pallet) => {
|
|
692
|
+
const palledEncoded = Twox128(textEncoder.encode(pallet));
|
|
693
|
+
return (name, dec, ...encoders) => {
|
|
694
|
+
const palletItemEncoded = utils.mergeUint8(
|
|
846
695
|
palledEncoded,
|
|
847
|
-
Twox128(
|
|
696
|
+
Twox128(textEncoder.encode(name))
|
|
848
697
|
);
|
|
849
|
-
const palletItemEncodedHex =
|
|
698
|
+
const palletItemEncodedHex = utils.toHex(palletItemEncoded);
|
|
850
699
|
const bytesToSkip = encoders.map((e) => e[1]).map((x) => {
|
|
851
700
|
if (x === Identity) return 0;
|
|
852
701
|
if (x === Twox64Concat) return 8;
|
|
@@ -870,16 +719,163 @@ var Storage = (pallet) => {
|
|
|
870
719
|
return result;
|
|
871
720
|
};
|
|
872
721
|
const fns = encoders.map(
|
|
873
|
-
([{ enc:
|
|
722
|
+
([{ enc: enc2 }, hash]) => (val) => hash(enc2(val))
|
|
874
723
|
);
|
|
875
|
-
const
|
|
876
|
-
|
|
724
|
+
const enc = (...args) => utils.toHex(
|
|
725
|
+
utils.mergeUint8(palletItemEncoded, ...args.map((val, idx) => fns[idx](val)))
|
|
877
726
|
);
|
|
878
727
|
return {
|
|
879
|
-
enc
|
|
880
|
-
dec
|
|
728
|
+
enc,
|
|
729
|
+
dec,
|
|
881
730
|
keyDecoder
|
|
882
731
|
};
|
|
883
732
|
};
|
|
884
733
|
};
|
|
885
|
-
|
|
734
|
+
|
|
735
|
+
Object.defineProperty(exports, "Bytes", {
|
|
736
|
+
enumerable: true,
|
|
737
|
+
get: function () { return scaleTs.Bytes; }
|
|
738
|
+
});
|
|
739
|
+
Object.defineProperty(exports, "Option", {
|
|
740
|
+
enumerable: true,
|
|
741
|
+
get: function () { return scaleTs.Option; }
|
|
742
|
+
});
|
|
743
|
+
Object.defineProperty(exports, "Result", {
|
|
744
|
+
enumerable: true,
|
|
745
|
+
get: function () { return scaleTs.Result; }
|
|
746
|
+
});
|
|
747
|
+
Object.defineProperty(exports, "ScaleEnum", {
|
|
748
|
+
enumerable: true,
|
|
749
|
+
get: function () { return scaleTs.Enum; }
|
|
750
|
+
});
|
|
751
|
+
Object.defineProperty(exports, "Struct", {
|
|
752
|
+
enumerable: true,
|
|
753
|
+
get: function () { return scaleTs.Struct; }
|
|
754
|
+
});
|
|
755
|
+
Object.defineProperty(exports, "Tuple", {
|
|
756
|
+
enumerable: true,
|
|
757
|
+
get: function () { return scaleTs.Tuple; }
|
|
758
|
+
});
|
|
759
|
+
Object.defineProperty(exports, "Vector", {
|
|
760
|
+
enumerable: true,
|
|
761
|
+
get: function () { return scaleTs.Vector; }
|
|
762
|
+
});
|
|
763
|
+
Object.defineProperty(exports, "_void", {
|
|
764
|
+
enumerable: true,
|
|
765
|
+
get: function () { return scaleTs._void; }
|
|
766
|
+
});
|
|
767
|
+
Object.defineProperty(exports, "bool", {
|
|
768
|
+
enumerable: true,
|
|
769
|
+
get: function () { return scaleTs.bool; }
|
|
770
|
+
});
|
|
771
|
+
Object.defineProperty(exports, "compact", {
|
|
772
|
+
enumerable: true,
|
|
773
|
+
get: function () { return scaleTs.compact; }
|
|
774
|
+
});
|
|
775
|
+
Object.defineProperty(exports, "createCodec", {
|
|
776
|
+
enumerable: true,
|
|
777
|
+
get: function () { return scaleTs.createCodec; }
|
|
778
|
+
});
|
|
779
|
+
Object.defineProperty(exports, "createDecoder", {
|
|
780
|
+
enumerable: true,
|
|
781
|
+
get: function () { return scaleTs.createDecoder; }
|
|
782
|
+
});
|
|
783
|
+
Object.defineProperty(exports, "enhanceCodec", {
|
|
784
|
+
enumerable: true,
|
|
785
|
+
get: function () { return scaleTs.enhanceCodec; }
|
|
786
|
+
});
|
|
787
|
+
Object.defineProperty(exports, "enhanceDecoder", {
|
|
788
|
+
enumerable: true,
|
|
789
|
+
get: function () { return scaleTs.enhanceDecoder; }
|
|
790
|
+
});
|
|
791
|
+
Object.defineProperty(exports, "enhanceEncoder", {
|
|
792
|
+
enumerable: true,
|
|
793
|
+
get: function () { return scaleTs.enhanceEncoder; }
|
|
794
|
+
});
|
|
795
|
+
Object.defineProperty(exports, "i128", {
|
|
796
|
+
enumerable: true,
|
|
797
|
+
get: function () { return scaleTs.i128; }
|
|
798
|
+
});
|
|
799
|
+
Object.defineProperty(exports, "i16", {
|
|
800
|
+
enumerable: true,
|
|
801
|
+
get: function () { return scaleTs.i16; }
|
|
802
|
+
});
|
|
803
|
+
Object.defineProperty(exports, "i256", {
|
|
804
|
+
enumerable: true,
|
|
805
|
+
get: function () { return scaleTs.i256; }
|
|
806
|
+
});
|
|
807
|
+
Object.defineProperty(exports, "i32", {
|
|
808
|
+
enumerable: true,
|
|
809
|
+
get: function () { return scaleTs.i32; }
|
|
810
|
+
});
|
|
811
|
+
Object.defineProperty(exports, "i64", {
|
|
812
|
+
enumerable: true,
|
|
813
|
+
get: function () { return scaleTs.i64; }
|
|
814
|
+
});
|
|
815
|
+
Object.defineProperty(exports, "i8", {
|
|
816
|
+
enumerable: true,
|
|
817
|
+
get: function () { return scaleTs.i8; }
|
|
818
|
+
});
|
|
819
|
+
Object.defineProperty(exports, "str", {
|
|
820
|
+
enumerable: true,
|
|
821
|
+
get: function () { return scaleTs.str; }
|
|
822
|
+
});
|
|
823
|
+
Object.defineProperty(exports, "u128", {
|
|
824
|
+
enumerable: true,
|
|
825
|
+
get: function () { return scaleTs.u128; }
|
|
826
|
+
});
|
|
827
|
+
Object.defineProperty(exports, "u16", {
|
|
828
|
+
enumerable: true,
|
|
829
|
+
get: function () { return scaleTs.u16; }
|
|
830
|
+
});
|
|
831
|
+
Object.defineProperty(exports, "u256", {
|
|
832
|
+
enumerable: true,
|
|
833
|
+
get: function () { return scaleTs.u256; }
|
|
834
|
+
});
|
|
835
|
+
Object.defineProperty(exports, "u32", {
|
|
836
|
+
enumerable: true,
|
|
837
|
+
get: function () { return scaleTs.u32; }
|
|
838
|
+
});
|
|
839
|
+
Object.defineProperty(exports, "u64", {
|
|
840
|
+
enumerable: true,
|
|
841
|
+
get: function () { return scaleTs.u64; }
|
|
842
|
+
});
|
|
843
|
+
Object.defineProperty(exports, "u8", {
|
|
844
|
+
enumerable: true,
|
|
845
|
+
get: function () { return scaleTs.u8; }
|
|
846
|
+
});
|
|
847
|
+
exports.AccountId = AccountId;
|
|
848
|
+
exports.Bin = Bin;
|
|
849
|
+
exports.Binary = Binary;
|
|
850
|
+
exports.Blake2128 = Blake2128;
|
|
851
|
+
exports.Blake2128Concat = Blake2128Concat;
|
|
852
|
+
exports.Blake2256 = Blake2256;
|
|
853
|
+
exports.Blake3256 = Blake3256;
|
|
854
|
+
exports.Blake3256Concat = Blake3256Concat;
|
|
855
|
+
exports.Enum = Enum;
|
|
856
|
+
exports.FixedSizeBinary = FixedSizeBinary;
|
|
857
|
+
exports.Hex = Hex;
|
|
858
|
+
exports.Identity = Identity;
|
|
859
|
+
exports.Self = Self;
|
|
860
|
+
exports.Storage = Storage;
|
|
861
|
+
exports.Twox128 = Twox128;
|
|
862
|
+
exports.Twox256 = Twox256;
|
|
863
|
+
exports.Twox64Concat = Twox64Concat;
|
|
864
|
+
exports.Variant = Variant;
|
|
865
|
+
exports._Enum = _Enum;
|
|
866
|
+
exports.bitSequence = bitSequence$1;
|
|
867
|
+
exports.blockHeader = blockHeader;
|
|
868
|
+
exports.char = char;
|
|
869
|
+
exports.compactBn = compactBn;
|
|
870
|
+
exports.compactNumber = compactNumber;
|
|
871
|
+
exports.ethAccount = ethAccount;
|
|
872
|
+
exports.fixedStr = fixedStr;
|
|
873
|
+
exports.fromBufferToBase58 = fromBufferToBase58;
|
|
874
|
+
exports.getSs58AddressInfo = getSs58AddressInfo;
|
|
875
|
+
exports.h64 = h64;
|
|
876
|
+
exports.metadata = metadata;
|
|
877
|
+
exports.selfDecoder = selfDecoder;
|
|
878
|
+
exports.selfEncoder = selfEncoder;
|
|
879
|
+
exports.v14 = v14;
|
|
880
|
+
exports.v15 = v15;
|
|
881
|
+
//# sourceMappingURL=index.js.map
|