@quantovainc/qcore 0.1.3
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/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +131 -0
- package/browser.mjs +9 -0
- package/index.d.ts +174 -0
- package/index.js +9 -0
- package/package.json +76 -0
- package/pkg/package.json +25 -0
- package/pkg/qcore_js.d.ts +56 -0
- package/pkg/qcore_js.js +9 -0
- package/pkg/qcore_js_bg.js +708 -0
- package/pkg/qcore_js_bg.wasm +0 -0
- package/pkg/qcore_js_bg.wasm.d.ts +36 -0
- package/pkg-node/package.json +19 -0
- package/pkg-node/qcore_js.d.ts +56 -0
- package/pkg-node/qcore_js.js +740 -0
- package/pkg-node/qcore_js_bg.wasm +0 -0
- package/shared.js +323 -0
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
/* @ts-self-types="./qcore_js.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} address
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
function account_body(address) {
|
|
8
|
+
let deferred2_0;
|
|
9
|
+
let deferred2_1;
|
|
10
|
+
try {
|
|
11
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.account_body(ptr0, len0);
|
|
14
|
+
deferred2_0 = ret[0];
|
|
15
|
+
deferred2_1 = ret[1];
|
|
16
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
17
|
+
} finally {
|
|
18
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.account_body = account_body;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} seed_hex
|
|
25
|
+
* @param {bigint} index
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
function address(seed_hex, index) {
|
|
29
|
+
let deferred3_0;
|
|
30
|
+
let deferred3_1;
|
|
31
|
+
try {
|
|
32
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
33
|
+
const len0 = WASM_VECTOR_LEN;
|
|
34
|
+
const ret = wasm.address(ptr0, len0, index);
|
|
35
|
+
var ptr2 = ret[0];
|
|
36
|
+
var len2 = ret[1];
|
|
37
|
+
if (ret[3]) {
|
|
38
|
+
ptr2 = 0; len2 = 0;
|
|
39
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
40
|
+
}
|
|
41
|
+
deferred3_0 = ptr2;
|
|
42
|
+
deferred3_1 = len2;
|
|
43
|
+
return getStringFromWasm0(ptr2, len2);
|
|
44
|
+
} finally {
|
|
45
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.address = address;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {bigint} height
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
function block_by_height_body(height) {
|
|
55
|
+
let deferred1_0;
|
|
56
|
+
let deferred1_1;
|
|
57
|
+
try {
|
|
58
|
+
const ret = wasm.block_by_height_body(height);
|
|
59
|
+
deferred1_0 = ret[0];
|
|
60
|
+
deferred1_1 = ret[1];
|
|
61
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
62
|
+
} finally {
|
|
63
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.block_by_height_body = block_by_height_body;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {string} contract
|
|
70
|
+
* @param {string} selector_hex
|
|
71
|
+
* @param {bigint} scheme_off
|
|
72
|
+
* @param {bigint} ptr_off
|
|
73
|
+
* @param {string} field_offs_csv
|
|
74
|
+
* @param {string} fields_csv
|
|
75
|
+
* @param {bigint} region_off
|
|
76
|
+
* @param {string} owner_seed_hex
|
|
77
|
+
* @param {bigint} owner_index
|
|
78
|
+
* @param {bigint} nonce
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
function buildSignedOrderCall(contract, selector_hex, scheme_off, ptr_off, field_offs_csv, fields_csv, region_off, owner_seed_hex, owner_index, nonce) {
|
|
82
|
+
let deferred7_0;
|
|
83
|
+
let deferred7_1;
|
|
84
|
+
try {
|
|
85
|
+
const ptr0 = passStringToWasm0(contract, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
86
|
+
const len0 = WASM_VECTOR_LEN;
|
|
87
|
+
const ptr1 = passStringToWasm0(selector_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
+
const len1 = WASM_VECTOR_LEN;
|
|
89
|
+
const ptr2 = passStringToWasm0(field_offs_csv, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
90
|
+
const len2 = WASM_VECTOR_LEN;
|
|
91
|
+
const ptr3 = passStringToWasm0(fields_csv, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
92
|
+
const len3 = WASM_VECTOR_LEN;
|
|
93
|
+
const ptr4 = passStringToWasm0(owner_seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
94
|
+
const len4 = WASM_VECTOR_LEN;
|
|
95
|
+
const ret = wasm.buildSignedOrderCall(ptr0, len0, ptr1, len1, scheme_off, ptr_off, ptr2, len2, ptr3, len3, region_off, ptr4, len4, owner_index, nonce);
|
|
96
|
+
var ptr6 = ret[0];
|
|
97
|
+
var len6 = ret[1];
|
|
98
|
+
if (ret[3]) {
|
|
99
|
+
ptr6 = 0; len6 = 0;
|
|
100
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
101
|
+
}
|
|
102
|
+
deferred7_0 = ptr6;
|
|
103
|
+
deferred7_1 = len6;
|
|
104
|
+
return getStringFromWasm0(ptr6, len6);
|
|
105
|
+
} finally {
|
|
106
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.buildSignedOrderCall = buildSignedOrderCall;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {string} name
|
|
113
|
+
* @returns {bigint}
|
|
114
|
+
*/
|
|
115
|
+
function chainIdFromName(name) {
|
|
116
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
117
|
+
const len0 = WASM_VECTOR_LEN;
|
|
118
|
+
const ret = wasm.chainIdFromName(ptr0, len0);
|
|
119
|
+
return BigInt.asUintN(64, ret);
|
|
120
|
+
}
|
|
121
|
+
exports.chainIdFromName = chainIdFromName;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} deployer
|
|
125
|
+
* @param {bigint} nonce
|
|
126
|
+
* @returns {string | undefined}
|
|
127
|
+
*/
|
|
128
|
+
function contractAddress(deployer, nonce) {
|
|
129
|
+
const ptr0 = passStringToWasm0(deployer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len0 = WASM_VECTOR_LEN;
|
|
131
|
+
const ret = wasm.contractAddress(ptr0, len0, nonce);
|
|
132
|
+
let v2;
|
|
133
|
+
if (ret[0] !== 0) {
|
|
134
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
135
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
136
|
+
}
|
|
137
|
+
return v2;
|
|
138
|
+
}
|
|
139
|
+
exports.contractAddress = contractAddress;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {bigint} height
|
|
143
|
+
* @returns {string}
|
|
144
|
+
*/
|
|
145
|
+
function eventsBody(height) {
|
|
146
|
+
let deferred1_0;
|
|
147
|
+
let deferred1_1;
|
|
148
|
+
try {
|
|
149
|
+
const ret = wasm.eventsBody(height);
|
|
150
|
+
deferred1_0 = ret[0];
|
|
151
|
+
deferred1_1 = ret[1];
|
|
152
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
153
|
+
} finally {
|
|
154
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.eventsBody = eventsBody;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @returns {bigint}
|
|
161
|
+
*/
|
|
162
|
+
function localChainId() {
|
|
163
|
+
const ret = wasm.localChainId();
|
|
164
|
+
return BigInt.asUintN(64, ret);
|
|
165
|
+
}
|
|
166
|
+
exports.localChainId = localChainId;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @returns {bigint}
|
|
170
|
+
*/
|
|
171
|
+
function mainnetChainId() {
|
|
172
|
+
const ret = wasm.mainnetChainId();
|
|
173
|
+
return BigInt.asUintN(64, ret);
|
|
174
|
+
}
|
|
175
|
+
exports.mainnetChainId = mainnetChainId;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {bigint} map_domain_tag
|
|
179
|
+
* @param {string} key_address_hex
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
function mapSlotKey(map_domain_tag, key_address_hex) {
|
|
183
|
+
let deferred3_0;
|
|
184
|
+
let deferred3_1;
|
|
185
|
+
try {
|
|
186
|
+
const ptr0 = passStringToWasm0(key_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
+
const len0 = WASM_VECTOR_LEN;
|
|
188
|
+
const ret = wasm.mapSlotKey(map_domain_tag, ptr0, len0);
|
|
189
|
+
var ptr2 = ret[0];
|
|
190
|
+
var len2 = ret[1];
|
|
191
|
+
if (ret[3]) {
|
|
192
|
+
ptr2 = 0; len2 = 0;
|
|
193
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
194
|
+
}
|
|
195
|
+
deferred3_0 = ptr2;
|
|
196
|
+
deferred3_1 = len2;
|
|
197
|
+
return getStringFromWasm0(ptr2, len2);
|
|
198
|
+
} finally {
|
|
199
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.mapSlotKey = mapSlotKey;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @param {string} seed_hex
|
|
206
|
+
* @returns {string}
|
|
207
|
+
*/
|
|
208
|
+
function mnemonicFromSeed(seed_hex) {
|
|
209
|
+
let deferred3_0;
|
|
210
|
+
let deferred3_1;
|
|
211
|
+
try {
|
|
212
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
213
|
+
const len0 = WASM_VECTOR_LEN;
|
|
214
|
+
const ret = wasm.mnemonicFromSeed(ptr0, len0);
|
|
215
|
+
var ptr2 = ret[0];
|
|
216
|
+
var len2 = ret[1];
|
|
217
|
+
if (ret[3]) {
|
|
218
|
+
ptr2 = 0; len2 = 0;
|
|
219
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
220
|
+
}
|
|
221
|
+
deferred3_0 = ptr2;
|
|
222
|
+
deferred3_1 = len2;
|
|
223
|
+
return getStringFromWasm0(ptr2, len2);
|
|
224
|
+
} finally {
|
|
225
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.mnemonicFromSeed = mnemonicFromSeed;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* @param {string} signer_hex
|
|
232
|
+
* @returns {string}
|
|
233
|
+
*/
|
|
234
|
+
function nonceSlotKey(signer_hex) {
|
|
235
|
+
let deferred3_0;
|
|
236
|
+
let deferred3_1;
|
|
237
|
+
try {
|
|
238
|
+
const ptr0 = passStringToWasm0(signer_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
const ret = wasm.nonceSlotKey(ptr0, len0);
|
|
241
|
+
var ptr2 = ret[0];
|
|
242
|
+
var len2 = ret[1];
|
|
243
|
+
if (ret[3]) {
|
|
244
|
+
ptr2 = 0; len2 = 0;
|
|
245
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
246
|
+
}
|
|
247
|
+
deferred3_0 = ptr2;
|
|
248
|
+
deferred3_1 = len2;
|
|
249
|
+
return getStringFromWasm0(ptr2, len2);
|
|
250
|
+
} finally {
|
|
251
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
exports.nonceSlotKey = nonceSlotKey;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @param {string} seed_hex
|
|
258
|
+
* @param {bigint} index
|
|
259
|
+
* @returns {string}
|
|
260
|
+
*/
|
|
261
|
+
function orderSigner(seed_hex, index) {
|
|
262
|
+
let deferred3_0;
|
|
263
|
+
let deferred3_1;
|
|
264
|
+
try {
|
|
265
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
266
|
+
const len0 = WASM_VECTOR_LEN;
|
|
267
|
+
const ret = wasm.orderSigner(ptr0, len0, index);
|
|
268
|
+
var ptr2 = ret[0];
|
|
269
|
+
var len2 = ret[1];
|
|
270
|
+
if (ret[3]) {
|
|
271
|
+
ptr2 = 0; len2 = 0;
|
|
272
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
273
|
+
}
|
|
274
|
+
deferred3_0 = ptr2;
|
|
275
|
+
deferred3_1 = len2;
|
|
276
|
+
return getStringFromWasm0(ptr2, len2);
|
|
277
|
+
} finally {
|
|
278
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.orderSigner = orderSigner;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @param {string} response
|
|
285
|
+
* @returns {string}
|
|
286
|
+
*/
|
|
287
|
+
function parseEvents(response) {
|
|
288
|
+
let deferred3_0;
|
|
289
|
+
let deferred3_1;
|
|
290
|
+
try {
|
|
291
|
+
const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
292
|
+
const len0 = WASM_VECTOR_LEN;
|
|
293
|
+
const ret = wasm.parseEvents(ptr0, len0);
|
|
294
|
+
var ptr2 = ret[0];
|
|
295
|
+
var len2 = ret[1];
|
|
296
|
+
if (ret[3]) {
|
|
297
|
+
ptr2 = 0; len2 = 0;
|
|
298
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
299
|
+
}
|
|
300
|
+
deferred3_0 = ptr2;
|
|
301
|
+
deferred3_1 = len2;
|
|
302
|
+
return getStringFromWasm0(ptr2, len2);
|
|
303
|
+
} finally {
|
|
304
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
exports.parseEvents = parseEvents;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @param {bigint} slot
|
|
311
|
+
* @returns {string}
|
|
312
|
+
*/
|
|
313
|
+
function scalarSlotKey(slot) {
|
|
314
|
+
let deferred1_0;
|
|
315
|
+
let deferred1_1;
|
|
316
|
+
try {
|
|
317
|
+
const ret = wasm.scalarSlotKey(slot);
|
|
318
|
+
deferred1_0 = ret[0];
|
|
319
|
+
deferred1_1 = ret[1];
|
|
320
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
321
|
+
} finally {
|
|
322
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.scalarSlotKey = scalarSlotKey;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* @param {string} phrase
|
|
329
|
+
* @returns {string}
|
|
330
|
+
*/
|
|
331
|
+
function seedFromMnemonic(phrase) {
|
|
332
|
+
let deferred3_0;
|
|
333
|
+
let deferred3_1;
|
|
334
|
+
try {
|
|
335
|
+
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
+
const len0 = WASM_VECTOR_LEN;
|
|
337
|
+
const ret = wasm.seedFromMnemonic(ptr0, len0);
|
|
338
|
+
var ptr2 = ret[0];
|
|
339
|
+
var len2 = ret[1];
|
|
340
|
+
if (ret[3]) {
|
|
341
|
+
ptr2 = 0; len2 = 0;
|
|
342
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
343
|
+
}
|
|
344
|
+
deferred3_0 = ptr2;
|
|
345
|
+
deferred3_1 = len2;
|
|
346
|
+
return getStringFromWasm0(ptr2, len2);
|
|
347
|
+
} finally {
|
|
348
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
exports.seedFromMnemonic = seedFromMnemonic;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @param {string} seed_hex
|
|
355
|
+
* @param {bigint} index
|
|
356
|
+
* @param {string} target
|
|
357
|
+
* @param {string} args_hex
|
|
358
|
+
* @param {bigint} nonce
|
|
359
|
+
* @param {bigint} meter_limit
|
|
360
|
+
* @param {string} fee
|
|
361
|
+
* @param {string} value
|
|
362
|
+
* @param {bigint} chain_id
|
|
363
|
+
* @returns {string}
|
|
364
|
+
*/
|
|
365
|
+
function signPayableCall(seed_hex, index, target, args_hex, nonce, meter_limit, fee, value, chain_id) {
|
|
366
|
+
let deferred7_0;
|
|
367
|
+
let deferred7_1;
|
|
368
|
+
try {
|
|
369
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
370
|
+
const len0 = WASM_VECTOR_LEN;
|
|
371
|
+
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
372
|
+
const len1 = WASM_VECTOR_LEN;
|
|
373
|
+
const ptr2 = passStringToWasm0(args_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
374
|
+
const len2 = WASM_VECTOR_LEN;
|
|
375
|
+
const ptr3 = passStringToWasm0(fee, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
376
|
+
const len3 = WASM_VECTOR_LEN;
|
|
377
|
+
const ptr4 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
378
|
+
const len4 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.signPayableCall(ptr0, len0, index, ptr1, len1, ptr2, len2, nonce, meter_limit, ptr3, len3, ptr4, len4, chain_id);
|
|
380
|
+
var ptr6 = ret[0];
|
|
381
|
+
var len6 = ret[1];
|
|
382
|
+
if (ret[3]) {
|
|
383
|
+
ptr6 = 0; len6 = 0;
|
|
384
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
385
|
+
}
|
|
386
|
+
deferred7_0 = ptr6;
|
|
387
|
+
deferred7_1 = len6;
|
|
388
|
+
return getStringFromWasm0(ptr6, len6);
|
|
389
|
+
} finally {
|
|
390
|
+
wasm.__wbindgen_free(deferred7_0, deferred7_1, 1);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
exports.signPayableCall = signPayableCall;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* @param {string} seed_hex
|
|
397
|
+
* @param {bigint} index
|
|
398
|
+
* @param {bigint} nonce
|
|
399
|
+
* @param {string} fee
|
|
400
|
+
* @param {bigint} chain_id
|
|
401
|
+
* @returns {string}
|
|
402
|
+
*/
|
|
403
|
+
function signRegister(seed_hex, index, nonce, fee, chain_id) {
|
|
404
|
+
let deferred4_0;
|
|
405
|
+
let deferred4_1;
|
|
406
|
+
try {
|
|
407
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
|
+
const len0 = WASM_VECTOR_LEN;
|
|
409
|
+
const ptr1 = passStringToWasm0(fee, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
410
|
+
const len1 = WASM_VECTOR_LEN;
|
|
411
|
+
const ret = wasm.signRegister(ptr0, len0, index, nonce, ptr1, len1, chain_id);
|
|
412
|
+
var ptr3 = ret[0];
|
|
413
|
+
var len3 = ret[1];
|
|
414
|
+
if (ret[3]) {
|
|
415
|
+
ptr3 = 0; len3 = 0;
|
|
416
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
417
|
+
}
|
|
418
|
+
deferred4_0 = ptr3;
|
|
419
|
+
deferred4_1 = len3;
|
|
420
|
+
return getStringFromWasm0(ptr3, len3);
|
|
421
|
+
} finally {
|
|
422
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
exports.signRegister = signRegister;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @param {string} seed_hex
|
|
429
|
+
* @param {bigint} index
|
|
430
|
+
* @param {string} target
|
|
431
|
+
* @param {string} args_hex
|
|
432
|
+
* @param {bigint} nonce
|
|
433
|
+
* @param {bigint} meter_limit
|
|
434
|
+
* @param {string} fee
|
|
435
|
+
* @param {bigint} chain_id
|
|
436
|
+
* @returns {string}
|
|
437
|
+
*/
|
|
438
|
+
function sign_call(seed_hex, index, target, args_hex, nonce, meter_limit, fee, chain_id) {
|
|
439
|
+
let deferred6_0;
|
|
440
|
+
let deferred6_1;
|
|
441
|
+
try {
|
|
442
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
443
|
+
const len0 = WASM_VECTOR_LEN;
|
|
444
|
+
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
445
|
+
const len1 = WASM_VECTOR_LEN;
|
|
446
|
+
const ptr2 = passStringToWasm0(args_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
447
|
+
const len2 = WASM_VECTOR_LEN;
|
|
448
|
+
const ptr3 = passStringToWasm0(fee, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
449
|
+
const len3 = WASM_VECTOR_LEN;
|
|
450
|
+
const ret = wasm.sign_call(ptr0, len0, index, ptr1, len1, ptr2, len2, nonce, meter_limit, ptr3, len3, chain_id);
|
|
451
|
+
var ptr5 = ret[0];
|
|
452
|
+
var len5 = ret[1];
|
|
453
|
+
if (ret[3]) {
|
|
454
|
+
ptr5 = 0; len5 = 0;
|
|
455
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
456
|
+
}
|
|
457
|
+
deferred6_0 = ptr5;
|
|
458
|
+
deferred6_1 = len5;
|
|
459
|
+
return getStringFromWasm0(ptr5, len5);
|
|
460
|
+
} finally {
|
|
461
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
exports.sign_call = sign_call;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* @param {string} seed_hex
|
|
468
|
+
* @param {bigint} index
|
|
469
|
+
* @param {string} to
|
|
470
|
+
* @param {string} amount
|
|
471
|
+
* @param {bigint} nonce
|
|
472
|
+
* @param {string} fee
|
|
473
|
+
* @param {bigint} chain_id
|
|
474
|
+
* @returns {string}
|
|
475
|
+
*/
|
|
476
|
+
function sign_transfer(seed_hex, index, to, amount, nonce, fee, chain_id) {
|
|
477
|
+
let deferred6_0;
|
|
478
|
+
let deferred6_1;
|
|
479
|
+
try {
|
|
480
|
+
const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
481
|
+
const len0 = WASM_VECTOR_LEN;
|
|
482
|
+
const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
483
|
+
const len1 = WASM_VECTOR_LEN;
|
|
484
|
+
const ptr2 = passStringToWasm0(amount, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
485
|
+
const len2 = WASM_VECTOR_LEN;
|
|
486
|
+
const ptr3 = passStringToWasm0(fee, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
487
|
+
const len3 = WASM_VECTOR_LEN;
|
|
488
|
+
const ret = wasm.sign_transfer(ptr0, len0, index, ptr1, len1, ptr2, len2, nonce, ptr3, len3, chain_id);
|
|
489
|
+
var ptr5 = ret[0];
|
|
490
|
+
var len5 = ret[1];
|
|
491
|
+
if (ret[3]) {
|
|
492
|
+
ptr5 = 0; len5 = 0;
|
|
493
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
494
|
+
}
|
|
495
|
+
deferred6_0 = ptr5;
|
|
496
|
+
deferred6_1 = len5;
|
|
497
|
+
return getStringFromWasm0(ptr5, len5);
|
|
498
|
+
} finally {
|
|
499
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
exports.sign_transfer = sign_transfer;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @param {string} contract
|
|
506
|
+
* @returns {string}
|
|
507
|
+
*/
|
|
508
|
+
function storageBody(contract) {
|
|
509
|
+
let deferred2_0;
|
|
510
|
+
let deferred2_1;
|
|
511
|
+
try {
|
|
512
|
+
const ptr0 = passStringToWasm0(contract, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
513
|
+
const len0 = WASM_VECTOR_LEN;
|
|
514
|
+
const ret = wasm.storageBody(ptr0, len0);
|
|
515
|
+
deferred2_0 = ret[0];
|
|
516
|
+
deferred2_1 = ret[1];
|
|
517
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
518
|
+
} finally {
|
|
519
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
exports.storageBody = storageBody;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* @param {string} response
|
|
526
|
+
* @param {string} slot_key_hex
|
|
527
|
+
* @returns {string}
|
|
528
|
+
*/
|
|
529
|
+
function storageValue(response, slot_key_hex) {
|
|
530
|
+
let deferred4_0;
|
|
531
|
+
let deferred4_1;
|
|
532
|
+
try {
|
|
533
|
+
const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
534
|
+
const len0 = WASM_VECTOR_LEN;
|
|
535
|
+
const ptr1 = passStringToWasm0(slot_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
536
|
+
const len1 = WASM_VECTOR_LEN;
|
|
537
|
+
const ret = wasm.storageValue(ptr0, len0, ptr1, len1);
|
|
538
|
+
var ptr3 = ret[0];
|
|
539
|
+
var len3 = ret[1];
|
|
540
|
+
if (ret[3]) {
|
|
541
|
+
ptr3 = 0; len3 = 0;
|
|
542
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
543
|
+
}
|
|
544
|
+
deferred4_0 = ptr3;
|
|
545
|
+
deferred4_1 = len3;
|
|
546
|
+
return getStringFromWasm0(ptr3, len3);
|
|
547
|
+
} finally {
|
|
548
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
exports.storageValue = storageValue;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* @param {string} tx_hex
|
|
555
|
+
* @returns {string}
|
|
556
|
+
*/
|
|
557
|
+
function submit_body(tx_hex) {
|
|
558
|
+
let deferred3_0;
|
|
559
|
+
let deferred3_1;
|
|
560
|
+
try {
|
|
561
|
+
const ptr0 = passStringToWasm0(tx_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
562
|
+
const len0 = WASM_VECTOR_LEN;
|
|
563
|
+
const ret = wasm.submit_body(ptr0, len0);
|
|
564
|
+
var ptr2 = ret[0];
|
|
565
|
+
var len2 = ret[1];
|
|
566
|
+
if (ret[3]) {
|
|
567
|
+
ptr2 = 0; len2 = 0;
|
|
568
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
569
|
+
}
|
|
570
|
+
deferred3_0 = ptr2;
|
|
571
|
+
deferred3_1 = len2;
|
|
572
|
+
return getStringFromWasm0(ptr2, len2);
|
|
573
|
+
} finally {
|
|
574
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
exports.submit_body = submit_body;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* @returns {bigint}
|
|
581
|
+
*/
|
|
582
|
+
function testnetChainId() {
|
|
583
|
+
const ret = wasm.testnetChainId();
|
|
584
|
+
return BigInt.asUintN(64, ret);
|
|
585
|
+
}
|
|
586
|
+
exports.testnetChainId = testnetChainId;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* @param {string} tx_id
|
|
590
|
+
* @returns {string}
|
|
591
|
+
*/
|
|
592
|
+
function transaction_body(tx_id) {
|
|
593
|
+
let deferred2_0;
|
|
594
|
+
let deferred2_1;
|
|
595
|
+
try {
|
|
596
|
+
const ptr0 = passStringToWasm0(tx_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
597
|
+
const len0 = WASM_VECTOR_LEN;
|
|
598
|
+
const ret = wasm.transaction_body(ptr0, len0);
|
|
599
|
+
deferred2_0 = ret[0];
|
|
600
|
+
deferred2_1 = ret[1];
|
|
601
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
602
|
+
} finally {
|
|
603
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
exports.transaction_body = transaction_body;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* @param {string} address
|
|
610
|
+
* @returns {boolean}
|
|
611
|
+
*/
|
|
612
|
+
function valid_address(address) {
|
|
613
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
614
|
+
const len0 = WASM_VECTOR_LEN;
|
|
615
|
+
const ret = wasm.valid_address(ptr0, len0);
|
|
616
|
+
return ret !== 0;
|
|
617
|
+
}
|
|
618
|
+
exports.valid_address = valid_address;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* @returns {string}
|
|
622
|
+
*/
|
|
623
|
+
function vmDeployAddress() {
|
|
624
|
+
let deferred1_0;
|
|
625
|
+
let deferred1_1;
|
|
626
|
+
try {
|
|
627
|
+
const ret = wasm.vmDeployAddress();
|
|
628
|
+
deferred1_0 = ret[0];
|
|
629
|
+
deferred1_1 = ret[1];
|
|
630
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
631
|
+
} finally {
|
|
632
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
exports.vmDeployAddress = vmDeployAddress;
|
|
636
|
+
function __wbg_get_imports() {
|
|
637
|
+
const import0 = {
|
|
638
|
+
__proto__: null,
|
|
639
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
640
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
641
|
+
return ret;
|
|
642
|
+
},
|
|
643
|
+
__wbindgen_init_externref_table: function() {
|
|
644
|
+
const table = wasm.__wbindgen_externrefs;
|
|
645
|
+
const offset = table.grow(4);
|
|
646
|
+
table.set(0, undefined);
|
|
647
|
+
table.set(offset + 0, undefined);
|
|
648
|
+
table.set(offset + 1, null);
|
|
649
|
+
table.set(offset + 2, true);
|
|
650
|
+
table.set(offset + 3, false);
|
|
651
|
+
},
|
|
652
|
+
};
|
|
653
|
+
return {
|
|
654
|
+
__proto__: null,
|
|
655
|
+
"./qcore_js_bg.js": import0,
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
function getStringFromWasm0(ptr, len) {
|
|
660
|
+
return decodeText(ptr >>> 0, len);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
let cachedUint8ArrayMemory0 = null;
|
|
664
|
+
function getUint8ArrayMemory0() {
|
|
665
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
666
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
667
|
+
}
|
|
668
|
+
return cachedUint8ArrayMemory0;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
672
|
+
if (realloc === undefined) {
|
|
673
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
674
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
675
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
676
|
+
WASM_VECTOR_LEN = buf.length;
|
|
677
|
+
return ptr;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
let len = arg.length;
|
|
681
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
682
|
+
|
|
683
|
+
const mem = getUint8ArrayMemory0();
|
|
684
|
+
|
|
685
|
+
let offset = 0;
|
|
686
|
+
|
|
687
|
+
for (; offset < len; offset++) {
|
|
688
|
+
const code = arg.charCodeAt(offset);
|
|
689
|
+
if (code > 0x7F) break;
|
|
690
|
+
mem[ptr + offset] = code;
|
|
691
|
+
}
|
|
692
|
+
if (offset !== len) {
|
|
693
|
+
if (offset !== 0) {
|
|
694
|
+
arg = arg.slice(offset);
|
|
695
|
+
}
|
|
696
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
697
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
698
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
699
|
+
|
|
700
|
+
offset += ret.written;
|
|
701
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
WASM_VECTOR_LEN = offset;
|
|
705
|
+
return ptr;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function takeFromExternrefTable0(idx) {
|
|
709
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
710
|
+
wasm.__externref_table_dealloc(idx);
|
|
711
|
+
return value;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
715
|
+
cachedTextDecoder.decode();
|
|
716
|
+
function decodeText(ptr, len) {
|
|
717
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const cachedTextEncoder = new TextEncoder();
|
|
721
|
+
|
|
722
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
723
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
724
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
725
|
+
view.set(buf);
|
|
726
|
+
return {
|
|
727
|
+
read: arg.length,
|
|
728
|
+
written: buf.length
|
|
729
|
+
};
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
let WASM_VECTOR_LEN = 0;
|
|
734
|
+
|
|
735
|
+
const wasmPath = `${__dirname}/qcore_js_bg.wasm`;
|
|
736
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
737
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
738
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
739
|
+
let wasm = wasmInstance.exports;
|
|
740
|
+
wasm.__wbindgen_start();
|