@quantovainc/qcore 0.3.2 → 0.4.1
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/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/qcore_js.d.ts +11 -11
- package/pkg/qcore_js_bg.js +48 -34
- package/pkg/qcore_js_bg.wasm +0 -0
- package/pkg/qcore_js_bg.wasm.d.ts +1 -1
- package/pkg-node/package.json +1 -1
- package/pkg-node/qcore_js.d.ts +11 -11
- package/pkg-node/qcore_js.js +48 -34
- package/pkg-node/qcore_js_bg.wasm +0 -0
- package/shared.js +18 -13
- package/shared.mjs +18 -13
package/package.json
CHANGED
package/pkg/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "qcore-js",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.4.1",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/pkg/qcore_js.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
export function account_body(address: string): string;
|
|
5
5
|
|
|
6
|
-
export function address(
|
|
6
|
+
export function address(seed_bytes: Uint8Array, index: bigint): string;
|
|
7
7
|
|
|
8
8
|
export function assetBalanceBody(issuer: string, holder: string): string;
|
|
9
9
|
|
|
@@ -11,9 +11,9 @@ export function assetSupplyBody(issuer: string): string;
|
|
|
11
11
|
|
|
12
12
|
export function block_by_height_body(height: bigint): string;
|
|
13
13
|
|
|
14
|
-
export function buildSignedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, field_offs_csv: string, fields_csv: string, region_off: bigint,
|
|
14
|
+
export function buildSignedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, field_offs_csv: string, fields_csv: string, region_off: bigint, owner_seed_bytes: Uint8Array, owner_index: bigint, nonce: bigint): string;
|
|
15
15
|
|
|
16
|
-
export function buildTypedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, region_off: bigint, fields_json: string,
|
|
16
|
+
export function buildTypedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, region_off: bigint, fields_json: string, owner_seed_bytes: Uint8Array, owner_index: bigint, nonce: bigint): string;
|
|
17
17
|
|
|
18
18
|
export function chainIdFromName(name: string): bigint;
|
|
19
19
|
|
|
@@ -33,13 +33,13 @@ export function mapAddrWordKey(map_domain_tag: bigint, key32_hex: string, word:
|
|
|
33
33
|
|
|
34
34
|
export function mapSlotKey(map_domain_tag: bigint, key_address_hex: string): string;
|
|
35
35
|
|
|
36
|
-
export function mnemonicFromSeed(
|
|
36
|
+
export function mnemonicFromSeed(seed_bytes: Uint8Array): any;
|
|
37
37
|
|
|
38
38
|
export function nameKey(label: string): string;
|
|
39
39
|
|
|
40
40
|
export function nonceSlotKey(signer_hex: string): string;
|
|
41
41
|
|
|
42
|
-
export function orderSigner(
|
|
42
|
+
export function orderSigner(seed_bytes: Uint8Array, index: bigint): string;
|
|
43
43
|
|
|
44
44
|
export function packSymbol(symbol: string): bigint;
|
|
45
45
|
|
|
@@ -49,17 +49,17 @@ export function sameAddress(a: string, b: string): boolean;
|
|
|
49
49
|
|
|
50
50
|
export function scalarSlotKey(slot: bigint): string;
|
|
51
51
|
|
|
52
|
-
export function seedFromMnemonic(phrase: string):
|
|
52
|
+
export function seedFromMnemonic(phrase: string): Uint8Array;
|
|
53
53
|
|
|
54
|
-
export function signAssetCall(
|
|
54
|
+
export function signAssetCall(seed_bytes: Uint8Array, index: bigint, target: string, args_hex: string, asset_issuer: string, amount: string, nonce: bigint, meter_limit: bigint, fee: string, chain_id: bigint, valid_until: bigint, transfer_fee?: string | null): string;
|
|
55
55
|
|
|
56
|
-
export function signPayableCall(
|
|
56
|
+
export function signPayableCall(seed_bytes: Uint8Array, index: bigint, target: string, args_hex: string, nonce: bigint, meter_limit: bigint, fee: string, value: string, chain_id: bigint, valid_until: bigint, transfer_fee?: string | null): string;
|
|
57
57
|
|
|
58
|
-
export function signRegister(
|
|
58
|
+
export function signRegister(seed_bytes: Uint8Array, index: bigint, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
|
|
59
59
|
|
|
60
|
-
export function sign_call(
|
|
60
|
+
export function sign_call(seed_bytes: Uint8Array, index: bigint, target: string, args_hex: string, nonce: bigint, meter_limit: bigint, fee: string, chain_id: bigint, valid_until: bigint, transfer_fee?: string | null): string;
|
|
61
61
|
|
|
62
|
-
export function sign_transfer(
|
|
62
|
+
export function sign_transfer(seed_bytes: Uint8Array, index: bigint, to: string, amount: string, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
|
|
63
63
|
|
|
64
64
|
export function storageBody(contract: string): string;
|
|
65
65
|
|
package/pkg/qcore_js_bg.js
CHANGED
|
@@ -18,15 +18,15 @@ export function account_body(address) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {Uint8Array} seed_bytes
|
|
22
22
|
* @param {bigint} index
|
|
23
23
|
* @returns {string}
|
|
24
24
|
*/
|
|
25
|
-
export function address(
|
|
25
|
+
export function address(seed_bytes, index) {
|
|
26
26
|
let deferred3_0;
|
|
27
27
|
let deferred3_1;
|
|
28
28
|
try {
|
|
29
|
-
const ptr0 =
|
|
29
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
30
30
|
const len0 = WASM_VECTOR_LEN;
|
|
31
31
|
const ret = wasm.address(ptr0, len0, index);
|
|
32
32
|
var ptr2 = ret[0];
|
|
@@ -110,12 +110,12 @@ export function block_by_height_body(height) {
|
|
|
110
110
|
* @param {string} field_offs_csv
|
|
111
111
|
* @param {string} fields_csv
|
|
112
112
|
* @param {bigint} region_off
|
|
113
|
-
* @param {
|
|
113
|
+
* @param {Uint8Array} owner_seed_bytes
|
|
114
114
|
* @param {bigint} owner_index
|
|
115
115
|
* @param {bigint} nonce
|
|
116
116
|
* @returns {string}
|
|
117
117
|
*/
|
|
118
|
-
export function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, field_offs_csv, fields_csv, region_off,
|
|
118
|
+
export function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, field_offs_csv, fields_csv, region_off, owner_seed_bytes, owner_index, nonce) {
|
|
119
119
|
let deferred7_0;
|
|
120
120
|
let deferred7_1;
|
|
121
121
|
try {
|
|
@@ -127,7 +127,7 @@ export function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_of
|
|
|
127
127
|
const len2 = WASM_VECTOR_LEN;
|
|
128
128
|
const ptr3 = passStringToWasm0(fields_csv, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
129
|
const len3 = WASM_VECTOR_LEN;
|
|
130
|
-
const ptr4 =
|
|
130
|
+
const ptr4 = passArray8ToWasm0(owner_seed_bytes, wasm.__wbindgen_malloc);
|
|
131
131
|
const len4 = WASM_VECTOR_LEN;
|
|
132
132
|
const ret = wasm.buildSignedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, ptr2, len2, ptr3, len3, region_off, ptr4, len4, owner_index, nonce);
|
|
133
133
|
var ptr6 = ret[0];
|
|
@@ -152,12 +152,12 @@ export function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_of
|
|
|
152
152
|
* @param {bigint} ptr_off
|
|
153
153
|
* @param {bigint} region_off
|
|
154
154
|
* @param {string} fields_json
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {Uint8Array} owner_seed_bytes
|
|
156
156
|
* @param {bigint} owner_index
|
|
157
157
|
* @param {bigint} nonce
|
|
158
158
|
* @returns {string}
|
|
159
159
|
*/
|
|
160
|
-
export function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, region_off, fields_json,
|
|
160
|
+
export function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, region_off, fields_json, owner_seed_bytes, owner_index, nonce) {
|
|
161
161
|
let deferred6_0;
|
|
162
162
|
let deferred6_1;
|
|
163
163
|
try {
|
|
@@ -167,7 +167,7 @@ export function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off
|
|
|
167
167
|
const len1 = WASM_VECTOR_LEN;
|
|
168
168
|
const ptr2 = passStringToWasm0(fields_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
169
169
|
const len2 = WASM_VECTOR_LEN;
|
|
170
|
-
const ptr3 =
|
|
170
|
+
const ptr3 = passArray8ToWasm0(owner_seed_bytes, wasm.__wbindgen_malloc);
|
|
171
171
|
const len3 = WASM_VECTOR_LEN;
|
|
172
172
|
const ret = wasm.buildTypedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, region_off, ptr2, len2, ptr3, len3, owner_index, nonce);
|
|
173
173
|
var ptr5 = ret[0];
|
|
@@ -329,11 +329,11 @@ export function mapSlotKey(map_domain_tag, key_address_hex) {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
|
-
* @param {
|
|
332
|
+
* @param {Uint8Array} seed_bytes
|
|
333
333
|
* @returns {any}
|
|
334
334
|
*/
|
|
335
|
-
export function mnemonicFromSeed(
|
|
336
|
-
const ptr0 =
|
|
335
|
+
export function mnemonicFromSeed(seed_bytes) {
|
|
336
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
337
337
|
const len0 = WASM_VECTOR_LEN;
|
|
338
338
|
const ret = wasm.mnemonicFromSeed(ptr0, len0);
|
|
339
339
|
if (ret[2]) {
|
|
@@ -387,15 +387,15 @@ export function nonceSlotKey(signer_hex) {
|
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
/**
|
|
390
|
-
* @param {
|
|
390
|
+
* @param {Uint8Array} seed_bytes
|
|
391
391
|
* @param {bigint} index
|
|
392
392
|
* @returns {string}
|
|
393
393
|
*/
|
|
394
|
-
export function orderSigner(
|
|
394
|
+
export function orderSigner(seed_bytes, index) {
|
|
395
395
|
let deferred3_0;
|
|
396
396
|
let deferred3_1;
|
|
397
397
|
try {
|
|
398
|
-
const ptr0 =
|
|
398
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
399
399
|
const len0 = WASM_VECTOR_LEN;
|
|
400
400
|
const ret = wasm.orderSigner(ptr0, len0, index);
|
|
401
401
|
var ptr2 = ret[0];
|
|
@@ -481,20 +481,22 @@ export function scalarSlotKey(slot) {
|
|
|
481
481
|
|
|
482
482
|
/**
|
|
483
483
|
* @param {string} phrase
|
|
484
|
-
* @returns {
|
|
484
|
+
* @returns {Uint8Array}
|
|
485
485
|
*/
|
|
486
486
|
export function seedFromMnemonic(phrase) {
|
|
487
487
|
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
488
488
|
const len0 = WASM_VECTOR_LEN;
|
|
489
489
|
const ret = wasm.seedFromMnemonic(ptr0, len0);
|
|
490
|
-
if (ret[
|
|
491
|
-
throw takeFromExternrefTable0(ret[
|
|
490
|
+
if (ret[3]) {
|
|
491
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
492
492
|
}
|
|
493
|
-
|
|
493
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
494
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
495
|
+
return v2;
|
|
494
496
|
}
|
|
495
497
|
|
|
496
498
|
/**
|
|
497
|
-
* @param {
|
|
499
|
+
* @param {Uint8Array} seed_bytes
|
|
498
500
|
* @param {bigint} index
|
|
499
501
|
* @param {string} target
|
|
500
502
|
* @param {string} args_hex
|
|
@@ -508,11 +510,11 @@ export function seedFromMnemonic(phrase) {
|
|
|
508
510
|
* @param {string | null} [transfer_fee]
|
|
509
511
|
* @returns {string}
|
|
510
512
|
*/
|
|
511
|
-
export function signAssetCall(
|
|
513
|
+
export function signAssetCall(seed_bytes, index, target, args_hex, asset_issuer, amount, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
|
|
512
514
|
let deferred9_0;
|
|
513
515
|
let deferred9_1;
|
|
514
516
|
try {
|
|
515
|
-
const ptr0 =
|
|
517
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
516
518
|
const len0 = WASM_VECTOR_LEN;
|
|
517
519
|
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
518
520
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -542,7 +544,7 @@ export function signAssetCall(seed_hex, index, target, args_hex, asset_issuer, a
|
|
|
542
544
|
}
|
|
543
545
|
|
|
544
546
|
/**
|
|
545
|
-
* @param {
|
|
547
|
+
* @param {Uint8Array} seed_bytes
|
|
546
548
|
* @param {bigint} index
|
|
547
549
|
* @param {string} target
|
|
548
550
|
* @param {string} args_hex
|
|
@@ -555,11 +557,11 @@ export function signAssetCall(seed_hex, index, target, args_hex, asset_issuer, a
|
|
|
555
557
|
* @param {string | null} [transfer_fee]
|
|
556
558
|
* @returns {string}
|
|
557
559
|
*/
|
|
558
|
-
export function signPayableCall(
|
|
560
|
+
export function signPayableCall(seed_bytes, index, target, args_hex, nonce, meter_limit, fee, value, chain_id, valid_until, transfer_fee) {
|
|
559
561
|
let deferred8_0;
|
|
560
562
|
let deferred8_1;
|
|
561
563
|
try {
|
|
562
|
-
const ptr0 =
|
|
564
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
563
565
|
const len0 = WASM_VECTOR_LEN;
|
|
564
566
|
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
565
567
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -587,7 +589,7 @@ export function signPayableCall(seed_hex, index, target, args_hex, nonce, meter_
|
|
|
587
589
|
}
|
|
588
590
|
|
|
589
591
|
/**
|
|
590
|
-
* @param {
|
|
592
|
+
* @param {Uint8Array} seed_bytes
|
|
591
593
|
* @param {bigint} index
|
|
592
594
|
* @param {bigint} nonce
|
|
593
595
|
* @param {string} fee
|
|
@@ -595,11 +597,11 @@ export function signPayableCall(seed_hex, index, target, args_hex, nonce, meter_
|
|
|
595
597
|
* @param {bigint} valid_until
|
|
596
598
|
* @returns {string}
|
|
597
599
|
*/
|
|
598
|
-
export function signRegister(
|
|
600
|
+
export function signRegister(seed_bytes, index, nonce, fee, chain_id, valid_until) {
|
|
599
601
|
let deferred4_0;
|
|
600
602
|
let deferred4_1;
|
|
601
603
|
try {
|
|
602
|
-
const ptr0 =
|
|
604
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
603
605
|
const len0 = WASM_VECTOR_LEN;
|
|
604
606
|
const ptr1 = passStringToWasm0(fee, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
605
607
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -619,7 +621,7 @@ export function signRegister(seed_hex, index, nonce, fee, chain_id, valid_until)
|
|
|
619
621
|
}
|
|
620
622
|
|
|
621
623
|
/**
|
|
622
|
-
* @param {
|
|
624
|
+
* @param {Uint8Array} seed_bytes
|
|
623
625
|
* @param {bigint} index
|
|
624
626
|
* @param {string} target
|
|
625
627
|
* @param {string} args_hex
|
|
@@ -631,11 +633,11 @@ export function signRegister(seed_hex, index, nonce, fee, chain_id, valid_until)
|
|
|
631
633
|
* @param {string | null} [transfer_fee]
|
|
632
634
|
* @returns {string}
|
|
633
635
|
*/
|
|
634
|
-
export function sign_call(
|
|
636
|
+
export function sign_call(seed_bytes, index, target, args_hex, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
|
|
635
637
|
let deferred7_0;
|
|
636
638
|
let deferred7_1;
|
|
637
639
|
try {
|
|
638
|
-
const ptr0 =
|
|
640
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
639
641
|
const len0 = WASM_VECTOR_LEN;
|
|
640
642
|
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
641
643
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -661,7 +663,7 @@ export function sign_call(seed_hex, index, target, args_hex, nonce, meter_limit,
|
|
|
661
663
|
}
|
|
662
664
|
|
|
663
665
|
/**
|
|
664
|
-
* @param {
|
|
666
|
+
* @param {Uint8Array} seed_bytes
|
|
665
667
|
* @param {bigint} index
|
|
666
668
|
* @param {string} to
|
|
667
669
|
* @param {string} amount
|
|
@@ -671,11 +673,11 @@ export function sign_call(seed_hex, index, target, args_hex, nonce, meter_limit,
|
|
|
671
673
|
* @param {bigint} valid_until
|
|
672
674
|
* @returns {string}
|
|
673
675
|
*/
|
|
674
|
-
export function sign_transfer(
|
|
676
|
+
export function sign_transfer(seed_bytes, index, to, amount, nonce, fee, chain_id, valid_until) {
|
|
675
677
|
let deferred6_0;
|
|
676
678
|
let deferred6_1;
|
|
677
679
|
try {
|
|
678
|
-
const ptr0 =
|
|
680
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
679
681
|
const len0 = WASM_VECTOR_LEN;
|
|
680
682
|
const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
681
683
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -917,6 +919,11 @@ function addToExternrefTable0(obj) {
|
|
|
917
919
|
return idx;
|
|
918
920
|
}
|
|
919
921
|
|
|
922
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
923
|
+
ptr = ptr >>> 0;
|
|
924
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
925
|
+
}
|
|
926
|
+
|
|
920
927
|
let cachedDataViewMemory0 = null;
|
|
921
928
|
function getDataViewMemory0() {
|
|
922
929
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -941,6 +948,13 @@ function isLikeNone(x) {
|
|
|
941
948
|
return x === undefined || x === null;
|
|
942
949
|
}
|
|
943
950
|
|
|
951
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
952
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
953
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
954
|
+
WASM_VECTOR_LEN = arg.length;
|
|
955
|
+
return ptr;
|
|
956
|
+
}
|
|
957
|
+
|
|
944
958
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
945
959
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
946
960
|
for (let i = 0; i < array.length; i++) {
|
package/pkg/qcore_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -25,7 +25,7 @@ export const packSymbol: (a: number, b: number) => bigint;
|
|
|
25
25
|
export const parseEvents: (a: number, b: number) => [number, number, number, number];
|
|
26
26
|
export const sameAddress: (a: number, b: number, c: number, d: number) => number;
|
|
27
27
|
export const scalarSlotKey: (a: bigint) => [number, number];
|
|
28
|
-
export const seedFromMnemonic: (a: number, b: number) => [number, number, number];
|
|
28
|
+
export const seedFromMnemonic: (a: number, b: number) => [number, number, number, number];
|
|
29
29
|
export const signAssetCall: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: bigint, m: bigint, n: number, o: number, p: bigint, q: bigint, r: number, s: number) => [number, number, number, number];
|
|
30
30
|
export const signPayableCall: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: number, k: number, l: number, m: number, n: bigint, o: bigint, p: number, q: number) => [number, number, number, number];
|
|
31
31
|
export const signRegister: (a: number, b: number, c: bigint, d: bigint, e: number, f: number, g: bigint, h: bigint) => [number, number, number, number];
|
package/pkg-node/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qcore-js",
|
|
3
3
|
"description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/pkg-node/qcore_js.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
export function account_body(address: string): string;
|
|
5
5
|
|
|
6
|
-
export function address(
|
|
6
|
+
export function address(seed_bytes: Uint8Array, index: bigint): string;
|
|
7
7
|
|
|
8
8
|
export function assetBalanceBody(issuer: string, holder: string): string;
|
|
9
9
|
|
|
@@ -11,9 +11,9 @@ export function assetSupplyBody(issuer: string): string;
|
|
|
11
11
|
|
|
12
12
|
export function block_by_height_body(height: bigint): string;
|
|
13
13
|
|
|
14
|
-
export function buildSignedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, field_offs_csv: string, fields_csv: string, region_off: bigint,
|
|
14
|
+
export function buildSignedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, field_offs_csv: string, fields_csv: string, region_off: bigint, owner_seed_bytes: Uint8Array, owner_index: bigint, nonce: bigint): string;
|
|
15
15
|
|
|
16
|
-
export function buildTypedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, region_off: bigint, fields_json: string,
|
|
16
|
+
export function buildTypedOrderCall(chain_id: bigint, contract: string, selector_hex: string, scheme_off: bigint, ptr_off: bigint, region_off: bigint, fields_json: string, owner_seed_bytes: Uint8Array, owner_index: bigint, nonce: bigint): string;
|
|
17
17
|
|
|
18
18
|
export function chainIdFromName(name: string): bigint;
|
|
19
19
|
|
|
@@ -33,13 +33,13 @@ export function mapAddrWordKey(map_domain_tag: bigint, key32_hex: string, word:
|
|
|
33
33
|
|
|
34
34
|
export function mapSlotKey(map_domain_tag: bigint, key_address_hex: string): string;
|
|
35
35
|
|
|
36
|
-
export function mnemonicFromSeed(
|
|
36
|
+
export function mnemonicFromSeed(seed_bytes: Uint8Array): any;
|
|
37
37
|
|
|
38
38
|
export function nameKey(label: string): string;
|
|
39
39
|
|
|
40
40
|
export function nonceSlotKey(signer_hex: string): string;
|
|
41
41
|
|
|
42
|
-
export function orderSigner(
|
|
42
|
+
export function orderSigner(seed_bytes: Uint8Array, index: bigint): string;
|
|
43
43
|
|
|
44
44
|
export function packSymbol(symbol: string): bigint;
|
|
45
45
|
|
|
@@ -49,17 +49,17 @@ export function sameAddress(a: string, b: string): boolean;
|
|
|
49
49
|
|
|
50
50
|
export function scalarSlotKey(slot: bigint): string;
|
|
51
51
|
|
|
52
|
-
export function seedFromMnemonic(phrase: string):
|
|
52
|
+
export function seedFromMnemonic(phrase: string): Uint8Array;
|
|
53
53
|
|
|
54
|
-
export function signAssetCall(
|
|
54
|
+
export function signAssetCall(seed_bytes: Uint8Array, index: bigint, target: string, args_hex: string, asset_issuer: string, amount: string, nonce: bigint, meter_limit: bigint, fee: string, chain_id: bigint, valid_until: bigint, transfer_fee?: string | null): string;
|
|
55
55
|
|
|
56
|
-
export function signPayableCall(
|
|
56
|
+
export function signPayableCall(seed_bytes: Uint8Array, index: bigint, target: string, args_hex: string, nonce: bigint, meter_limit: bigint, fee: string, value: string, chain_id: bigint, valid_until: bigint, transfer_fee?: string | null): string;
|
|
57
57
|
|
|
58
|
-
export function signRegister(
|
|
58
|
+
export function signRegister(seed_bytes: Uint8Array, index: bigint, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
|
|
59
59
|
|
|
60
|
-
export function sign_call(
|
|
60
|
+
export function sign_call(seed_bytes: Uint8Array, index: bigint, target: string, args_hex: string, nonce: bigint, meter_limit: bigint, fee: string, chain_id: bigint, valid_until: bigint, transfer_fee?: string | null): string;
|
|
61
61
|
|
|
62
|
-
export function sign_transfer(
|
|
62
|
+
export function sign_transfer(seed_bytes: Uint8Array, index: bigint, to: string, amount: string, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
|
|
63
63
|
|
|
64
64
|
export function storageBody(contract: string): string;
|
|
65
65
|
|
package/pkg-node/qcore_js.js
CHANGED
|
@@ -21,15 +21,15 @@ function account_body(address) {
|
|
|
21
21
|
exports.account_body = account_body;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @param {
|
|
24
|
+
* @param {Uint8Array} seed_bytes
|
|
25
25
|
* @param {bigint} index
|
|
26
26
|
* @returns {string}
|
|
27
27
|
*/
|
|
28
|
-
function address(
|
|
28
|
+
function address(seed_bytes, index) {
|
|
29
29
|
let deferred3_0;
|
|
30
30
|
let deferred3_1;
|
|
31
31
|
try {
|
|
32
|
-
const ptr0 =
|
|
32
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
33
33
|
const len0 = WASM_VECTOR_LEN;
|
|
34
34
|
const ret = wasm.address(ptr0, len0, index);
|
|
35
35
|
var ptr2 = ret[0];
|
|
@@ -117,12 +117,12 @@ exports.block_by_height_body = block_by_height_body;
|
|
|
117
117
|
* @param {string} field_offs_csv
|
|
118
118
|
* @param {string} fields_csv
|
|
119
119
|
* @param {bigint} region_off
|
|
120
|
-
* @param {
|
|
120
|
+
* @param {Uint8Array} owner_seed_bytes
|
|
121
121
|
* @param {bigint} owner_index
|
|
122
122
|
* @param {bigint} nonce
|
|
123
123
|
* @returns {string}
|
|
124
124
|
*/
|
|
125
|
-
function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, field_offs_csv, fields_csv, region_off,
|
|
125
|
+
function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, field_offs_csv, fields_csv, region_off, owner_seed_bytes, owner_index, nonce) {
|
|
126
126
|
let deferred7_0;
|
|
127
127
|
let deferred7_1;
|
|
128
128
|
try {
|
|
@@ -134,7 +134,7 @@ function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_
|
|
|
134
134
|
const len2 = WASM_VECTOR_LEN;
|
|
135
135
|
const ptr3 = passStringToWasm0(fields_csv, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
136
136
|
const len3 = WASM_VECTOR_LEN;
|
|
137
|
-
const ptr4 =
|
|
137
|
+
const ptr4 = passArray8ToWasm0(owner_seed_bytes, wasm.__wbindgen_malloc);
|
|
138
138
|
const len4 = WASM_VECTOR_LEN;
|
|
139
139
|
const ret = wasm.buildSignedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, ptr2, len2, ptr3, len3, region_off, ptr4, len4, owner_index, nonce);
|
|
140
140
|
var ptr6 = ret[0];
|
|
@@ -160,12 +160,12 @@ exports.buildSignedOrderCall = buildSignedOrderCall;
|
|
|
160
160
|
* @param {bigint} ptr_off
|
|
161
161
|
* @param {bigint} region_off
|
|
162
162
|
* @param {string} fields_json
|
|
163
|
-
* @param {
|
|
163
|
+
* @param {Uint8Array} owner_seed_bytes
|
|
164
164
|
* @param {bigint} owner_index
|
|
165
165
|
* @param {bigint} nonce
|
|
166
166
|
* @returns {string}
|
|
167
167
|
*/
|
|
168
|
-
function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, region_off, fields_json,
|
|
168
|
+
function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, region_off, fields_json, owner_seed_bytes, owner_index, nonce) {
|
|
169
169
|
let deferred6_0;
|
|
170
170
|
let deferred6_1;
|
|
171
171
|
try {
|
|
@@ -175,7 +175,7 @@ function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_o
|
|
|
175
175
|
const len1 = WASM_VECTOR_LEN;
|
|
176
176
|
const ptr2 = passStringToWasm0(fields_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
177
177
|
const len2 = WASM_VECTOR_LEN;
|
|
178
|
-
const ptr3 =
|
|
178
|
+
const ptr3 = passArray8ToWasm0(owner_seed_bytes, wasm.__wbindgen_malloc);
|
|
179
179
|
const len3 = WASM_VECTOR_LEN;
|
|
180
180
|
const ret = wasm.buildTypedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, region_off, ptr2, len2, ptr3, len3, owner_index, nonce);
|
|
181
181
|
var ptr5 = ret[0];
|
|
@@ -347,11 +347,11 @@ function mapSlotKey(map_domain_tag, key_address_hex) {
|
|
|
347
347
|
exports.mapSlotKey = mapSlotKey;
|
|
348
348
|
|
|
349
349
|
/**
|
|
350
|
-
* @param {
|
|
350
|
+
* @param {Uint8Array} seed_bytes
|
|
351
351
|
* @returns {any}
|
|
352
352
|
*/
|
|
353
|
-
function mnemonicFromSeed(
|
|
354
|
-
const ptr0 =
|
|
353
|
+
function mnemonicFromSeed(seed_bytes) {
|
|
354
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
355
355
|
const len0 = WASM_VECTOR_LEN;
|
|
356
356
|
const ret = wasm.mnemonicFromSeed(ptr0, len0);
|
|
357
357
|
if (ret[2]) {
|
|
@@ -408,15 +408,15 @@ function nonceSlotKey(signer_hex) {
|
|
|
408
408
|
exports.nonceSlotKey = nonceSlotKey;
|
|
409
409
|
|
|
410
410
|
/**
|
|
411
|
-
* @param {
|
|
411
|
+
* @param {Uint8Array} seed_bytes
|
|
412
412
|
* @param {bigint} index
|
|
413
413
|
* @returns {string}
|
|
414
414
|
*/
|
|
415
|
-
function orderSigner(
|
|
415
|
+
function orderSigner(seed_bytes, index) {
|
|
416
416
|
let deferred3_0;
|
|
417
417
|
let deferred3_1;
|
|
418
418
|
try {
|
|
419
|
-
const ptr0 =
|
|
419
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
420
420
|
const len0 = WASM_VECTOR_LEN;
|
|
421
421
|
const ret = wasm.orderSigner(ptr0, len0, index);
|
|
422
422
|
var ptr2 = ret[0];
|
|
@@ -507,21 +507,23 @@ exports.scalarSlotKey = scalarSlotKey;
|
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
509
|
* @param {string} phrase
|
|
510
|
-
* @returns {
|
|
510
|
+
* @returns {Uint8Array}
|
|
511
511
|
*/
|
|
512
512
|
function seedFromMnemonic(phrase) {
|
|
513
513
|
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
514
514
|
const len0 = WASM_VECTOR_LEN;
|
|
515
515
|
const ret = wasm.seedFromMnemonic(ptr0, len0);
|
|
516
|
-
if (ret[
|
|
517
|
-
throw takeFromExternrefTable0(ret[
|
|
516
|
+
if (ret[3]) {
|
|
517
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
518
518
|
}
|
|
519
|
-
|
|
519
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
520
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
521
|
+
return v2;
|
|
520
522
|
}
|
|
521
523
|
exports.seedFromMnemonic = seedFromMnemonic;
|
|
522
524
|
|
|
523
525
|
/**
|
|
524
|
-
* @param {
|
|
526
|
+
* @param {Uint8Array} seed_bytes
|
|
525
527
|
* @param {bigint} index
|
|
526
528
|
* @param {string} target
|
|
527
529
|
* @param {string} args_hex
|
|
@@ -535,11 +537,11 @@ exports.seedFromMnemonic = seedFromMnemonic;
|
|
|
535
537
|
* @param {string | null} [transfer_fee]
|
|
536
538
|
* @returns {string}
|
|
537
539
|
*/
|
|
538
|
-
function signAssetCall(
|
|
540
|
+
function signAssetCall(seed_bytes, index, target, args_hex, asset_issuer, amount, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
|
|
539
541
|
let deferred9_0;
|
|
540
542
|
let deferred9_1;
|
|
541
543
|
try {
|
|
542
|
-
const ptr0 =
|
|
544
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
543
545
|
const len0 = WASM_VECTOR_LEN;
|
|
544
546
|
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
545
547
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -570,7 +572,7 @@ function signAssetCall(seed_hex, index, target, args_hex, asset_issuer, amount,
|
|
|
570
572
|
exports.signAssetCall = signAssetCall;
|
|
571
573
|
|
|
572
574
|
/**
|
|
573
|
-
* @param {
|
|
575
|
+
* @param {Uint8Array} seed_bytes
|
|
574
576
|
* @param {bigint} index
|
|
575
577
|
* @param {string} target
|
|
576
578
|
* @param {string} args_hex
|
|
@@ -583,11 +585,11 @@ exports.signAssetCall = signAssetCall;
|
|
|
583
585
|
* @param {string | null} [transfer_fee]
|
|
584
586
|
* @returns {string}
|
|
585
587
|
*/
|
|
586
|
-
function signPayableCall(
|
|
588
|
+
function signPayableCall(seed_bytes, index, target, args_hex, nonce, meter_limit, fee, value, chain_id, valid_until, transfer_fee) {
|
|
587
589
|
let deferred8_0;
|
|
588
590
|
let deferred8_1;
|
|
589
591
|
try {
|
|
590
|
-
const ptr0 =
|
|
592
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
591
593
|
const len0 = WASM_VECTOR_LEN;
|
|
592
594
|
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
593
595
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -616,7 +618,7 @@ function signPayableCall(seed_hex, index, target, args_hex, nonce, meter_limit,
|
|
|
616
618
|
exports.signPayableCall = signPayableCall;
|
|
617
619
|
|
|
618
620
|
/**
|
|
619
|
-
* @param {
|
|
621
|
+
* @param {Uint8Array} seed_bytes
|
|
620
622
|
* @param {bigint} index
|
|
621
623
|
* @param {bigint} nonce
|
|
622
624
|
* @param {string} fee
|
|
@@ -624,11 +626,11 @@ exports.signPayableCall = signPayableCall;
|
|
|
624
626
|
* @param {bigint} valid_until
|
|
625
627
|
* @returns {string}
|
|
626
628
|
*/
|
|
627
|
-
function signRegister(
|
|
629
|
+
function signRegister(seed_bytes, index, nonce, fee, chain_id, valid_until) {
|
|
628
630
|
let deferred4_0;
|
|
629
631
|
let deferred4_1;
|
|
630
632
|
try {
|
|
631
|
-
const ptr0 =
|
|
633
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
632
634
|
const len0 = WASM_VECTOR_LEN;
|
|
633
635
|
const ptr1 = passStringToWasm0(fee, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
634
636
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -649,7 +651,7 @@ function signRegister(seed_hex, index, nonce, fee, chain_id, valid_until) {
|
|
|
649
651
|
exports.signRegister = signRegister;
|
|
650
652
|
|
|
651
653
|
/**
|
|
652
|
-
* @param {
|
|
654
|
+
* @param {Uint8Array} seed_bytes
|
|
653
655
|
* @param {bigint} index
|
|
654
656
|
* @param {string} target
|
|
655
657
|
* @param {string} args_hex
|
|
@@ -661,11 +663,11 @@ exports.signRegister = signRegister;
|
|
|
661
663
|
* @param {string | null} [transfer_fee]
|
|
662
664
|
* @returns {string}
|
|
663
665
|
*/
|
|
664
|
-
function sign_call(
|
|
666
|
+
function sign_call(seed_bytes, index, target, args_hex, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
|
|
665
667
|
let deferred7_0;
|
|
666
668
|
let deferred7_1;
|
|
667
669
|
try {
|
|
668
|
-
const ptr0 =
|
|
670
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
669
671
|
const len0 = WASM_VECTOR_LEN;
|
|
670
672
|
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
671
673
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -692,7 +694,7 @@ function sign_call(seed_hex, index, target, args_hex, nonce, meter_limit, fee, c
|
|
|
692
694
|
exports.sign_call = sign_call;
|
|
693
695
|
|
|
694
696
|
/**
|
|
695
|
-
* @param {
|
|
697
|
+
* @param {Uint8Array} seed_bytes
|
|
696
698
|
* @param {bigint} index
|
|
697
699
|
* @param {string} to
|
|
698
700
|
* @param {string} amount
|
|
@@ -702,11 +704,11 @@ exports.sign_call = sign_call;
|
|
|
702
704
|
* @param {bigint} valid_until
|
|
703
705
|
* @returns {string}
|
|
704
706
|
*/
|
|
705
|
-
function sign_transfer(
|
|
707
|
+
function sign_transfer(seed_bytes, index, to, amount, nonce, fee, chain_id, valid_until) {
|
|
706
708
|
let deferred6_0;
|
|
707
709
|
let deferred6_1;
|
|
708
710
|
try {
|
|
709
|
-
const ptr0 =
|
|
711
|
+
const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
|
|
710
712
|
const len0 = WASM_VECTOR_LEN;
|
|
711
713
|
const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
712
714
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -970,6 +972,11 @@ function addToExternrefTable0(obj) {
|
|
|
970
972
|
return idx;
|
|
971
973
|
}
|
|
972
974
|
|
|
975
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
976
|
+
ptr = ptr >>> 0;
|
|
977
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
978
|
+
}
|
|
979
|
+
|
|
973
980
|
let cachedDataViewMemory0 = null;
|
|
974
981
|
function getDataViewMemory0() {
|
|
975
982
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -994,6 +1001,13 @@ function isLikeNone(x) {
|
|
|
994
1001
|
return x === undefined || x === null;
|
|
995
1002
|
}
|
|
996
1003
|
|
|
1004
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1005
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1006
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1007
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1008
|
+
return ptr;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
997
1011
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
998
1012
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
999
1013
|
for (let i = 0; i < array.length; i++) {
|
|
Binary file
|
package/shared.js
CHANGED
|
@@ -29,6 +29,7 @@ function accountNonce(nonce) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const VALIDITY_BLOCKS = 300n;
|
|
32
|
+
const ORDER_HOLD_UNTIL = 1n << 62n;
|
|
32
33
|
const MAX_PLAUSIBLE_HEAD = 1n << 40n;
|
|
33
34
|
const HEAD_BLOCKS_PER_SEC = 4n;
|
|
34
35
|
const HEAD_SLACK_SECS = 60n;
|
|
@@ -61,6 +62,11 @@ function coreArg(kind, label, value) {
|
|
|
61
62
|
if (typeof value !== 'string') throw new Error(`the ${label} must be a string`);
|
|
62
63
|
return value;
|
|
63
64
|
}
|
|
65
|
+
if (kind === 'seed') {
|
|
66
|
+
if (!(value instanceof Uint8Array)) throw new Error(`the ${label} must be a Uint8Array of 32 bytes; pass a handle you can wipe after use, not a hex string`);
|
|
67
|
+
if (value.length !== 32) throw new Error(`the ${label} must be 32 bytes`);
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
64
70
|
if (kind === 'u64') return wholeNumber(value, label, U64_MAX);
|
|
65
71
|
if (kind === 'u64s') return wholeNumber(value, label, U64_MAX).toString();
|
|
66
72
|
if (kind === 'u128s') return wholeNumber(value, label, U128_MAX).toString();
|
|
@@ -68,17 +74,17 @@ function coreArg(kind, label, value) {
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
const CORE_ARGS = {
|
|
71
|
-
address: [['
|
|
72
|
-
mnemonicFromSeed: [['
|
|
77
|
+
address: [['seed', 'seed'], ['u64', 'account index']],
|
|
78
|
+
mnemonicFromSeed: [['seed', 'seed']],
|
|
73
79
|
seedFromMnemonic: [['text', 'recovery phrase']],
|
|
74
|
-
orderSigner: [['
|
|
75
|
-
sign_transfer: [['
|
|
76
|
-
signRegister: [['
|
|
77
|
-
sign_call: [['
|
|
78
|
-
signPayableCall: [['
|
|
79
|
-
signAssetCall: [['
|
|
80
|
-
buildSignedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['text', 'field offsets'], ['text', 'fields'], ['u64', 'region offset'], ['
|
|
81
|
-
buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'region offset'], ['text', 'fields'], ['
|
|
80
|
+
orderSigner: [['seed', 'seed'], ['u64', 'account index']],
|
|
81
|
+
sign_transfer: [['seed', 'seed'], ['u64', 'account index'], ['text', 'recipient'], ['u64s', 'amount'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
|
|
82
|
+
signRegister: [['seed', 'seed'], ['u64', 'account index'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
|
|
83
|
+
sign_call: [['seed', 'seed'], ['u64', 'account index'], ['text', 'target'], ['text', 'call arguments'], ['u64', 'nonce'], ['u64', 'meter limit'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline'], ['u128s', 'transfer fee']],
|
|
84
|
+
signPayableCall: [['seed', 'seed'], ['u64', 'account index'], ['text', 'target'], ['text', 'call arguments'], ['u64', 'nonce'], ['u64', 'meter limit'], ['u128s', 'fee'], ['u64s', 'value'], ['u64', 'chain id'], ['u64', 'validity deadline'], ['u128s', 'transfer fee']],
|
|
85
|
+
signAssetCall: [['seed', 'seed'], ['u64', 'account index'], ['text', 'target'], ['text', 'call arguments'], ['text', 'asset issuer'], ['u64s', 'amount'], ['u64', 'nonce'], ['u64', 'meter limit'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline'], ['u128s', 'transfer fee']],
|
|
86
|
+
buildSignedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['text', 'field offsets'], ['text', 'fields'], ['u64', 'region offset'], ['seed', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
|
|
87
|
+
buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'region offset'], ['text', 'fields'], ['seed', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
|
|
82
88
|
contractAddress: [['text', 'deployer'], ['u64', 'nonce']],
|
|
83
89
|
scalarSlotKey: [['u64', 'slot']],
|
|
84
90
|
mapSlotKey: [['u64', 'map domain tag'], ['text', 'key address']],
|
|
@@ -246,9 +252,7 @@ function generateSeed() {
|
|
|
246
252
|
}
|
|
247
253
|
const bytes = new Uint8Array(32);
|
|
248
254
|
source.getRandomValues(bytes);
|
|
249
|
-
|
|
250
|
-
bytes.fill(0);
|
|
251
|
-
return hex;
|
|
255
|
+
return bytes;
|
|
252
256
|
}
|
|
253
257
|
|
|
254
258
|
function makeClient(core) {
|
|
@@ -610,6 +614,7 @@ function makeClient(core) {
|
|
|
610
614
|
const signed = JSON.parse(
|
|
611
615
|
core.sign_call(callerSeedHex, accountIndex(callerIndex), contract, order.call_args, accountNonceUsed, meterLimitOf(meterLimit), String(fee), chainId, until, String(transferFee))
|
|
612
616
|
);
|
|
617
|
+
this._guardSigned(orderKey, nonce, order.call_args, ORDER_HOLD_UNTIL, expectedOrderNonce != null);
|
|
613
618
|
this._guardSigned(from, accountNonceUsed, signed.tx_hex, until, expectedNonce != null);
|
|
614
619
|
const outcome = await this.submit(signed.tx_hex);
|
|
615
620
|
this._remember(from, accountNonceUsed, outcome);
|
package/shared.mjs
CHANGED
|
@@ -29,6 +29,7 @@ function accountNonce(nonce) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const VALIDITY_BLOCKS = 300n;
|
|
32
|
+
const ORDER_HOLD_UNTIL = 1n << 62n;
|
|
32
33
|
const MAX_PLAUSIBLE_HEAD = 1n << 40n;
|
|
33
34
|
const HEAD_BLOCKS_PER_SEC = 4n;
|
|
34
35
|
const HEAD_SLACK_SECS = 60n;
|
|
@@ -61,6 +62,11 @@ function coreArg(kind, label, value) {
|
|
|
61
62
|
if (typeof value !== 'string') throw new Error(`the ${label} must be a string`);
|
|
62
63
|
return value;
|
|
63
64
|
}
|
|
65
|
+
if (kind === 'seed') {
|
|
66
|
+
if (!(value instanceof Uint8Array)) throw new Error(`the ${label} must be a Uint8Array of 32 bytes; pass a handle you can wipe after use, not a hex string`);
|
|
67
|
+
if (value.length !== 32) throw new Error(`the ${label} must be 32 bytes`);
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
64
70
|
if (kind === 'u64') return wholeNumber(value, label, U64_MAX);
|
|
65
71
|
if (kind === 'u64s') return wholeNumber(value, label, U64_MAX).toString();
|
|
66
72
|
if (kind === 'u128s') return wholeNumber(value, label, U128_MAX).toString();
|
|
@@ -68,17 +74,17 @@ function coreArg(kind, label, value) {
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
const CORE_ARGS = {
|
|
71
|
-
address: [['
|
|
72
|
-
mnemonicFromSeed: [['
|
|
77
|
+
address: [['seed', 'seed'], ['u64', 'account index']],
|
|
78
|
+
mnemonicFromSeed: [['seed', 'seed']],
|
|
73
79
|
seedFromMnemonic: [['text', 'recovery phrase']],
|
|
74
|
-
orderSigner: [['
|
|
75
|
-
sign_transfer: [['
|
|
76
|
-
signRegister: [['
|
|
77
|
-
sign_call: [['
|
|
78
|
-
signPayableCall: [['
|
|
79
|
-
signAssetCall: [['
|
|
80
|
-
buildSignedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['text', 'field offsets'], ['text', 'fields'], ['u64', 'region offset'], ['
|
|
81
|
-
buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'region offset'], ['text', 'fields'], ['
|
|
80
|
+
orderSigner: [['seed', 'seed'], ['u64', 'account index']],
|
|
81
|
+
sign_transfer: [['seed', 'seed'], ['u64', 'account index'], ['text', 'recipient'], ['u64s', 'amount'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
|
|
82
|
+
signRegister: [['seed', 'seed'], ['u64', 'account index'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
|
|
83
|
+
sign_call: [['seed', 'seed'], ['u64', 'account index'], ['text', 'target'], ['text', 'call arguments'], ['u64', 'nonce'], ['u64', 'meter limit'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline'], ['u128s', 'transfer fee']],
|
|
84
|
+
signPayableCall: [['seed', 'seed'], ['u64', 'account index'], ['text', 'target'], ['text', 'call arguments'], ['u64', 'nonce'], ['u64', 'meter limit'], ['u128s', 'fee'], ['u64s', 'value'], ['u64', 'chain id'], ['u64', 'validity deadline'], ['u128s', 'transfer fee']],
|
|
85
|
+
signAssetCall: [['seed', 'seed'], ['u64', 'account index'], ['text', 'target'], ['text', 'call arguments'], ['text', 'asset issuer'], ['u64s', 'amount'], ['u64', 'nonce'], ['u64', 'meter limit'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline'], ['u128s', 'transfer fee']],
|
|
86
|
+
buildSignedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['text', 'field offsets'], ['text', 'fields'], ['u64', 'region offset'], ['seed', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
|
|
87
|
+
buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'region offset'], ['text', 'fields'], ['seed', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
|
|
82
88
|
contractAddress: [['text', 'deployer'], ['u64', 'nonce']],
|
|
83
89
|
scalarSlotKey: [['u64', 'slot']],
|
|
84
90
|
mapSlotKey: [['u64', 'map domain tag'], ['text', 'key address']],
|
|
@@ -246,9 +252,7 @@ function generateSeed() {
|
|
|
246
252
|
}
|
|
247
253
|
const bytes = new Uint8Array(32);
|
|
248
254
|
source.getRandomValues(bytes);
|
|
249
|
-
|
|
250
|
-
bytes.fill(0);
|
|
251
|
-
return hex;
|
|
255
|
+
return bytes;
|
|
252
256
|
}
|
|
253
257
|
|
|
254
258
|
function makeClient(core) {
|
|
@@ -610,6 +614,7 @@ function makeClient(core) {
|
|
|
610
614
|
const signed = JSON.parse(
|
|
611
615
|
core.sign_call(callerSeedHex, accountIndex(callerIndex), contract, order.call_args, accountNonceUsed, meterLimitOf(meterLimit), String(fee), chainId, until, String(transferFee))
|
|
612
616
|
);
|
|
617
|
+
this._guardSigned(orderKey, nonce, order.call_args, ORDER_HOLD_UNTIL, expectedOrderNonce != null);
|
|
613
618
|
this._guardSigned(from, accountNonceUsed, signed.tx_hex, until, expectedNonce != null);
|
|
614
619
|
const outcome = await this.submit(signed.tx_hex);
|
|
615
620
|
this._remember(from, accountNonceUsed, outcome);
|