@quantovainc/qcore 0.3.2 → 0.4.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantovainc/qcore",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Quantova's post quantum client core for JavaScript. Signs with ML-DSA-65 and builds Q1 addresses.",
5
5
  "scripts": {
6
6
  "build": "bash scripts/build.sh",
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.3.2",
5
+ "version": "0.4.0",
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(seed_hex: string, index: bigint): string;
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, owner_seed_hex: string, owner_index: bigint, nonce: bigint): string;
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, owner_seed_hex: string, owner_index: bigint, nonce: bigint): 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(seed_hex: string): any;
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(seed_hex: string, index: bigint): string;
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): any;
52
+ export function seedFromMnemonic(phrase: string): Uint8Array;
53
53
 
54
- export function signAssetCall(seed_hex: string, 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;
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(seed_hex: string, 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;
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(seed_hex: string, index: bigint, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
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(seed_hex: string, 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;
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(seed_hex: string, index: bigint, to: string, amount: string, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
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
 
@@ -18,15 +18,15 @@ export function account_body(address) {
18
18
  }
19
19
 
20
20
  /**
21
- * @param {string} seed_hex
21
+ * @param {Uint8Array} seed_bytes
22
22
  * @param {bigint} index
23
23
  * @returns {string}
24
24
  */
25
- export function address(seed_hex, index) {
25
+ export function address(seed_bytes, index) {
26
26
  let deferred3_0;
27
27
  let deferred3_1;
28
28
  try {
29
- const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} owner_seed_hex
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, owner_seed_hex, owner_index, nonce) {
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 = passStringToWasm0(owner_seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} owner_seed_hex
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, owner_seed_hex, owner_index, nonce) {
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 = passStringToWasm0(owner_seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
332
+ * @param {Uint8Array} seed_bytes
333
333
  * @returns {any}
334
334
  */
335
- export function mnemonicFromSeed(seed_hex) {
336
- const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
390
+ * @param {Uint8Array} seed_bytes
391
391
  * @param {bigint} index
392
392
  * @returns {string}
393
393
  */
394
- export function orderSigner(seed_hex, index) {
394
+ export function orderSigner(seed_bytes, index) {
395
395
  let deferred3_0;
396
396
  let deferred3_1;
397
397
  try {
398
- const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {any}
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[2]) {
491
- throw takeFromExternrefTable0(ret[1]);
490
+ if (ret[3]) {
491
+ throw takeFromExternrefTable0(ret[2]);
492
492
  }
493
- return takeFromExternrefTable0(ret[0]);
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 {string} seed_hex
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(seed_hex, index, target, args_hex, asset_issuer, amount, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, target, args_hex, nonce, meter_limit, fee, value, chain_id, valid_until, transfer_fee) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, nonce, fee, chain_id, valid_until) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, target, args_hex, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, to, amount, nonce, fee, chain_id, valid_until) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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++) {
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];
@@ -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.3.2",
4
+ "version": "0.4.0",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -3,7 +3,7 @@
3
3
 
4
4
  export function account_body(address: string): string;
5
5
 
6
- export function address(seed_hex: string, index: bigint): string;
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, owner_seed_hex: string, owner_index: bigint, nonce: bigint): string;
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, owner_seed_hex: string, owner_index: bigint, nonce: bigint): 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(seed_hex: string): any;
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(seed_hex: string, index: bigint): string;
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): any;
52
+ export function seedFromMnemonic(phrase: string): Uint8Array;
53
53
 
54
- export function signAssetCall(seed_hex: string, 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;
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(seed_hex: string, 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;
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(seed_hex: string, index: bigint, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
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(seed_hex: string, 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;
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(seed_hex: string, index: bigint, to: string, amount: string, nonce: bigint, fee: string, chain_id: bigint, valid_until: bigint): string;
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
 
@@ -21,15 +21,15 @@ function account_body(address) {
21
21
  exports.account_body = account_body;
22
22
 
23
23
  /**
24
- * @param {string} seed_hex
24
+ * @param {Uint8Array} seed_bytes
25
25
  * @param {bigint} index
26
26
  * @returns {string}
27
27
  */
28
- function address(seed_hex, index) {
28
+ function address(seed_bytes, index) {
29
29
  let deferred3_0;
30
30
  let deferred3_1;
31
31
  try {
32
- const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} owner_seed_hex
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, owner_seed_hex, owner_index, nonce) {
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 = passStringToWasm0(owner_seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} owner_seed_hex
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, owner_seed_hex, owner_index, nonce) {
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 = passStringToWasm0(owner_seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
350
+ * @param {Uint8Array} seed_bytes
351
351
  * @returns {any}
352
352
  */
353
- function mnemonicFromSeed(seed_hex) {
354
- const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
411
+ * @param {Uint8Array} seed_bytes
412
412
  * @param {bigint} index
413
413
  * @returns {string}
414
414
  */
415
- function orderSigner(seed_hex, index) {
415
+ function orderSigner(seed_bytes, index) {
416
416
  let deferred3_0;
417
417
  let deferred3_1;
418
418
  try {
419
- const ptr0 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {any}
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[2]) {
517
- throw takeFromExternrefTable0(ret[1]);
516
+ if (ret[3]) {
517
+ throw takeFromExternrefTable0(ret[2]);
518
518
  }
519
- return takeFromExternrefTable0(ret[0]);
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 {string} seed_hex
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(seed_hex, index, target, args_hex, asset_issuer, amount, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, target, args_hex, nonce, meter_limit, fee, value, chain_id, valid_until, transfer_fee) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, nonce, fee, chain_id, valid_until) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, target, args_hex, nonce, meter_limit, fee, chain_id, valid_until, transfer_fee) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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 {string} seed_hex
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(seed_hex, index, to, amount, nonce, fee, chain_id, valid_until) {
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 = passStringToWasm0(seed_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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
@@ -61,6 +61,11 @@ function coreArg(kind, label, value) {
61
61
  if (typeof value !== 'string') throw new Error(`the ${label} must be a string`);
62
62
  return value;
63
63
  }
64
+ if (kind === 'seed') {
65
+ 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`);
66
+ if (value.length !== 32) throw new Error(`the ${label} must be 32 bytes`);
67
+ return value;
68
+ }
64
69
  if (kind === 'u64') return wholeNumber(value, label, U64_MAX);
65
70
  if (kind === 'u64s') return wholeNumber(value, label, U64_MAX).toString();
66
71
  if (kind === 'u128s') return wholeNumber(value, label, U128_MAX).toString();
@@ -68,17 +73,17 @@ function coreArg(kind, label, value) {
68
73
  }
69
74
 
70
75
  const CORE_ARGS = {
71
- address: [['text', 'seed'], ['u64', 'account index']],
72
- mnemonicFromSeed: [['text', 'seed']],
76
+ address: [['seed', 'seed'], ['u64', 'account index']],
77
+ mnemonicFromSeed: [['seed', 'seed']],
73
78
  seedFromMnemonic: [['text', 'recovery phrase']],
74
- orderSigner: [['text', 'seed'], ['u64', 'account index']],
75
- sign_transfer: [['text', 'seed'], ['u64', 'account index'], ['text', 'recipient'], ['u64s', 'amount'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
76
- signRegister: [['text', 'seed'], ['u64', 'account index'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
77
- sign_call: [['text', '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']],
78
- signPayableCall: [['text', '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']],
79
- signAssetCall: [['text', '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']],
80
- buildSignedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['text', 'field offsets'], ['text', 'fields'], ['u64', 'region offset'], ['text', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
81
- buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'region offset'], ['text', 'fields'], ['text', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
79
+ orderSigner: [['seed', 'seed'], ['u64', 'account index']],
80
+ sign_transfer: [['seed', 'seed'], ['u64', 'account index'], ['text', 'recipient'], ['u64s', 'amount'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
81
+ signRegister: [['seed', 'seed'], ['u64', 'account index'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
82
+ 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']],
83
+ 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']],
84
+ 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']],
85
+ 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']],
86
+ 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
87
  contractAddress: [['text', 'deployer'], ['u64', 'nonce']],
83
88
  scalarSlotKey: [['u64', 'slot']],
84
89
  mapSlotKey: [['u64', 'map domain tag'], ['text', 'key address']],
@@ -246,9 +251,7 @@ function generateSeed() {
246
251
  }
247
252
  const bytes = new Uint8Array(32);
248
253
  source.getRandomValues(bytes);
249
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
250
- bytes.fill(0);
251
- return hex;
254
+ return bytes;
252
255
  }
253
256
 
254
257
  function makeClient(core) {
package/shared.mjs CHANGED
@@ -61,6 +61,11 @@ function coreArg(kind, label, value) {
61
61
  if (typeof value !== 'string') throw new Error(`the ${label} must be a string`);
62
62
  return value;
63
63
  }
64
+ if (kind === 'seed') {
65
+ 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`);
66
+ if (value.length !== 32) throw new Error(`the ${label} must be 32 bytes`);
67
+ return value;
68
+ }
64
69
  if (kind === 'u64') return wholeNumber(value, label, U64_MAX);
65
70
  if (kind === 'u64s') return wholeNumber(value, label, U64_MAX).toString();
66
71
  if (kind === 'u128s') return wholeNumber(value, label, U128_MAX).toString();
@@ -68,17 +73,17 @@ function coreArg(kind, label, value) {
68
73
  }
69
74
 
70
75
  const CORE_ARGS = {
71
- address: [['text', 'seed'], ['u64', 'account index']],
72
- mnemonicFromSeed: [['text', 'seed']],
76
+ address: [['seed', 'seed'], ['u64', 'account index']],
77
+ mnemonicFromSeed: [['seed', 'seed']],
73
78
  seedFromMnemonic: [['text', 'recovery phrase']],
74
- orderSigner: [['text', 'seed'], ['u64', 'account index']],
75
- sign_transfer: [['text', 'seed'], ['u64', 'account index'], ['text', 'recipient'], ['u64s', 'amount'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
76
- signRegister: [['text', 'seed'], ['u64', 'account index'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
77
- sign_call: [['text', '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']],
78
- signPayableCall: [['text', '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']],
79
- signAssetCall: [['text', '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']],
80
- buildSignedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['text', 'field offsets'], ['text', 'fields'], ['u64', 'region offset'], ['text', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
81
- buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'region offset'], ['text', 'fields'], ['text', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce']],
79
+ orderSigner: [['seed', 'seed'], ['u64', 'account index']],
80
+ sign_transfer: [['seed', 'seed'], ['u64', 'account index'], ['text', 'recipient'], ['u64s', 'amount'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
81
+ signRegister: [['seed', 'seed'], ['u64', 'account index'], ['u64', 'nonce'], ['u128s', 'fee'], ['u64', 'chain id'], ['u64', 'validity deadline']],
82
+ 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']],
83
+ 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']],
84
+ 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']],
85
+ 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']],
86
+ 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
87
  contractAddress: [['text', 'deployer'], ['u64', 'nonce']],
83
88
  scalarSlotKey: [['u64', 'slot']],
84
89
  mapSlotKey: [['u64', 'map domain tag'], ['text', 'key address']],
@@ -246,9 +251,7 @@ function generateSeed() {
246
251
  }
247
252
  const bytes = new Uint8Array(32);
248
253
  source.getRandomValues(bytes);
249
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
250
- bytes.fill(0);
251
- return hex;
254
+ return bytes;
252
255
  }
253
256
 
254
257
  function makeClient(core) {