@zerc20/wallet-sdk 0.1.0 → 0.3.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/dist/burnWorker.js +6 -6
- package/dist/burnWorker.js.map +1 -1
- package/dist/chain.d.ts +19 -5
- package/dist/chain.js +17 -11
- package/dist/chain.js.map +1 -1
- package/dist/context.d.ts +23 -4
- package/dist/context.js +35 -6
- package/dist/context.js.map +1 -1
- package/dist/core.d.ts +32 -17
- package/dist/core.js +253 -70
- package/dist/core.js.map +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/pos.js +2 -2
- package/dist/pos.js.map +1 -1
- package/dist/rageExit.js +3 -5
- package/dist/rageExit.js.map +1 -1
- package/dist/seed.d.ts +4 -0
- package/dist/seed.js +12 -1
- package/dist/seed.js.map +1 -1
- package/dist/services.d.ts +5 -5
- package/dist/services.js +10 -7
- package/dist/services.js.map +1 -1
- package/dist/spend.d.ts +1 -1
- package/dist/spend.js +5 -4
- package/dist/spend.js.map +1 -1
- package/dist/state.d.ts +14 -4
- package/dist/state.js +10 -7
- package/dist/state.js.map +1 -1
- package/dist/sync.d.ts +16 -3
- package/dist/sync.js +90 -25
- package/dist/sync.js.map +1 -1
- package/dist/wallet.d.ts +27 -13
- package/dist/wallet.js +125 -62
- package/dist/wallet.js.map +1 -1
- package/package.json +4 -3
- package/src/burnWorker.ts +9 -10
- package/src/chain.ts +35 -12
- package/src/context.ts +48 -8
- package/src/core.ts +279 -87
- package/src/errors.ts +2 -0
- package/src/index.ts +2 -2
- package/src/pos.ts +2 -2
- package/src/rageExit.ts +3 -4
- package/src/seed.ts +13 -1
- package/src/services.ts +18 -7
- package/src/spend.ts +5 -5
- package/src/state.ts +17 -7
- package/src/sync.ts +95 -24
- package/src/wallet.ts +159 -64
- package/wasm/zerc20_wallet_core.d.ts +16 -13
- package/wasm/zerc20_wallet_core.js +49 -42
- package/wasm/zerc20_wallet_core_bg.wasm +0 -0
- package/wasm/zerc20_wallet_core_bg.wasm.d.ts +3 -3
|
@@ -20,24 +20,6 @@ export function aspLeaves(bitmap, first, count) {
|
|
|
20
20
|
return v2;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* A seed's `index`-th burn address for one chain and token, with its salt: `{salt, address}`. About 2^16 hashes.
|
|
25
|
-
* @param {Uint8Array} seed
|
|
26
|
-
* @param {bigint} chain_id
|
|
27
|
-
* @param {number} token_id
|
|
28
|
-
* @param {number} index
|
|
29
|
-
* @returns {any}
|
|
30
|
-
*/
|
|
31
|
-
export function burnAddress(seed, chain_id, token_id, index) {
|
|
32
|
-
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
33
|
-
const len0 = WASM_VECTOR_LEN;
|
|
34
|
-
const ret = wasm.burnAddress(ptr0, len0, chain_id, token_id, index);
|
|
35
|
-
if (ret[2]) {
|
|
36
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
37
|
-
}
|
|
38
|
-
return takeFromExternrefTable0(ret[0]);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
23
|
/**
|
|
42
24
|
* @param {bigint} chain_id
|
|
43
25
|
* @param {string} public_key
|
|
@@ -61,6 +43,53 @@ export function burnAddressOf(chain_id, public_key, salt) {
|
|
|
61
43
|
return v3;
|
|
62
44
|
}
|
|
63
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The `index`-th burn address of `public_key` on one chain and token from `burn_key`, and its salt, if the salt's
|
|
48
|
+
* counter is in `from..=to`: `{salt, address}` or `undefined`. Searched in blocks of counters from 0, the result is
|
|
49
|
+
* the first block's hit.
|
|
50
|
+
* @param {Uint8Array} burn_key
|
|
51
|
+
* @param {bigint} chain_id
|
|
52
|
+
* @param {number} token_id
|
|
53
|
+
* @param {number} index
|
|
54
|
+
* @param {string} public_key
|
|
55
|
+
* @param {number} from
|
|
56
|
+
* @param {number} to
|
|
57
|
+
* @returns {any}
|
|
58
|
+
*/
|
|
59
|
+
export function burnBlock(burn_key, chain_id, token_id, index, public_key, from, to) {
|
|
60
|
+
const ptr0 = passArray8ToWasm0(burn_key, wasm.__wbindgen_malloc);
|
|
61
|
+
const len0 = WASM_VECTOR_LEN;
|
|
62
|
+
const ptr1 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len1 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.burnBlock(ptr0, len0, chain_id, token_id, index, ptr1, len1, from, to);
|
|
65
|
+
if (ret[2]) {
|
|
66
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
67
|
+
}
|
|
68
|
+
return takeFromExternrefTable0(ret[0]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A burn address of someone else's `public_key` on a chain, with its salt: the first of the `count` salts from
|
|
73
|
+
* `start` that has the proof of work, `{salt, address}`, or `undefined`. A random `start` makes the salt
|
|
74
|
+
* unguessable.
|
|
75
|
+
* @param {bigint} chain_id
|
|
76
|
+
* @param {string} public_key
|
|
77
|
+
* @param {string} start
|
|
78
|
+
* @param {number} count
|
|
79
|
+
* @returns {any}
|
|
80
|
+
*/
|
|
81
|
+
export function burnBlockFor(chain_id, public_key, start, count) {
|
|
82
|
+
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
83
|
+
const len0 = WASM_VECTOR_LEN;
|
|
84
|
+
const ptr1 = passStringToWasm0(start, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
85
|
+
const len1 = WASM_VECTOR_LEN;
|
|
86
|
+
const ret = wasm.burnBlockFor(chain_id, ptr0, len0, ptr1, len1, count);
|
|
87
|
+
if (ret[2]) {
|
|
88
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
89
|
+
}
|
|
90
|
+
return takeFromExternrefTable0(ret[0]);
|
|
91
|
+
}
|
|
92
|
+
|
|
64
93
|
/**
|
|
65
94
|
* The key that owns the notes paid to a seed's `index`-th receive code for one chain and token, shaped like
|
|
66
95
|
* `spendKey`.
|
|
@@ -70,10 +99,10 @@ export function burnAddressOf(chain_id, public_key, salt) {
|
|
|
70
99
|
* @param {number} index
|
|
71
100
|
* @returns {any}
|
|
72
101
|
*/
|
|
73
|
-
export function
|
|
102
|
+
export function codeSpendKey(seed, chain_id, token_id, index) {
|
|
74
103
|
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
75
104
|
const len0 = WASM_VECTOR_LEN;
|
|
76
|
-
const ret = wasm.
|
|
105
|
+
const ret = wasm.codeSpendKey(ptr0, len0, chain_id, token_id, index);
|
|
77
106
|
if (ret[2]) {
|
|
78
107
|
throw takeFromExternrefTable0(ret[1]);
|
|
79
108
|
}
|
|
@@ -295,28 +324,6 @@ export function pathRoot(leaf, i, siblings) {
|
|
|
295
324
|
}
|
|
296
325
|
}
|
|
297
326
|
|
|
298
|
-
/**
|
|
299
|
-
* The `k`-th burn address a point of sale holding `lane_key` makes for `public_key` on one chain and token, with its
|
|
300
|
-
* salt: `{salt, address}`. About 2^16 hashes.
|
|
301
|
-
* @param {Uint8Array} lane_key
|
|
302
|
-
* @param {bigint} chain_id
|
|
303
|
-
* @param {number} token_id
|
|
304
|
-
* @param {number} k
|
|
305
|
-
* @param {string} public_key
|
|
306
|
-
* @returns {any}
|
|
307
|
-
*/
|
|
308
|
-
export function posBurnAddress(lane_key, chain_id, token_id, k, public_key) {
|
|
309
|
-
const ptr0 = passArray8ToWasm0(lane_key, wasm.__wbindgen_malloc);
|
|
310
|
-
const len0 = WASM_VECTOR_LEN;
|
|
311
|
-
const ptr1 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
312
|
-
const len1 = WASM_VECTOR_LEN;
|
|
313
|
-
const ret = wasm.posBurnAddress(ptr0, len0, chain_id, token_id, k, ptr1, len1);
|
|
314
|
-
if (ret[2]) {
|
|
315
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
316
|
-
}
|
|
317
|
-
return takeFromExternrefTable0(ret[0]);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
327
|
/**
|
|
321
328
|
* Seals a merge witness (JSON) to the merge prover's key, padded with spaces to `pad_to` bytes. Take the key from
|
|
322
329
|
* `verifyAttestation`, as for the attester's.
|
|
Binary file
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const aspLeaves: (a: number, b: number, c: bigint, d: number) => [number, number, number, number];
|
|
5
|
-
export const burnAddress: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number];
|
|
6
5
|
export const burnAddressOf: (a: bigint, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
7
|
-
export const
|
|
6
|
+
export const burnBlock: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number];
|
|
7
|
+
export const burnBlockFor: (a: bigint, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
8
|
+
export const codeSpendKey: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number];
|
|
8
9
|
export const hashChain: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
9
10
|
export const leaf: (a: number, b: number) => [number, number, number, number];
|
|
10
11
|
export const leaves: (a: number, b: number) => [number, number, number, number];
|
|
@@ -13,7 +14,6 @@ export const noteTag: (a: number, b: number, c: number) => [number, number, numb
|
|
|
13
14
|
export const nullifier: (a: bigint, b: bigint, c: number, d: number) => [number, number, number, number];
|
|
14
15
|
export const path: (a: bigint, b: bigint, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
|
|
15
16
|
export const pathRoot: (a: number, b: number, c: bigint, d: number, e: number) => [number, number, number, number];
|
|
16
|
-
export const posBurnAddress: (a: number, b: number, c: bigint, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
17
17
|
export const sealMergeWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
18
18
|
export const sealWitness: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
19
19
|
export const signMerge: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|