@zerc20/wallet-sdk 0.0.0-stage → 0.1.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/LICENSE +24 -0
- package/README.md +26 -2
- package/dist/burnWorker.d.ts +1 -0
- package/dist/burnWorker.js +21 -0
- package/dist/burnWorker.js.map +1 -0
- package/dist/chain.d.ts +345 -0
- package/dist/chain.js +149 -0
- package/dist/chain.js.map +1 -0
- package/dist/context.d.ts +48 -0
- package/dist/context.js +40 -0
- package/dist/context.js.map +1 -0
- package/dist/core.d.ts +43 -0
- package/dist/core.js +106 -0
- package/dist/core.js.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/network.d.ts +66 -0
- package/dist/network.js +55 -0
- package/dist/network.js.map +1 -0
- package/dist/pos.d.ts +93 -0
- package/dist/pos.js +302 -0
- package/dist/pos.js.map +1 -0
- package/dist/prove.d.ts +13 -0
- package/dist/prove.js +53 -0
- package/dist/prove.js.map +1 -0
- package/dist/rageExit.d.ts +5 -0
- package/dist/rageExit.js +146 -0
- package/dist/rageExit.js.map +1 -0
- package/dist/scan.d.ts +17 -0
- package/dist/scan.js +47 -0
- package/dist/scan.js.map +1 -0
- package/dist/seed.d.ts +8 -0
- package/dist/seed.js +35 -0
- package/dist/seed.js.map +1 -0
- package/dist/servers.d.ts +60 -0
- package/dist/servers.js +117 -0
- package/dist/servers.js.map +1 -0
- package/dist/services.d.ts +62 -0
- package/dist/services.js +128 -0
- package/dist/services.js.map +1 -0
- package/dist/spend.d.ts +151 -0
- package/dist/spend.js +745 -0
- package/dist/spend.js.map +1 -0
- package/dist/state.d.ts +174 -0
- package/dist/state.js +45 -0
- package/dist/state.js.map +1 -0
- package/dist/sync.d.ts +84 -0
- package/dist/sync.js +615 -0
- package/dist/sync.js.map +1 -0
- package/dist/tree.d.ts +19 -0
- package/dist/tree.js +63 -0
- package/dist/tree.js.map +1 -0
- package/dist/wallet.d.ts +301 -0
- package/dist/wallet.js +992 -0
- package/dist/wallet.js.map +1 -0
- package/package.json +60 -4
- package/src/burnWorker.ts +25 -0
- package/src/chain.ts +205 -0
- package/src/context.ts +84 -0
- package/src/core.ts +147 -0
- package/src/errors.ts +61 -0
- package/src/index.ts +41 -0
- package/src/network.ts +94 -0
- package/src/pos.ts +415 -0
- package/src/prove.ts +67 -0
- package/src/rageExit.ts +168 -0
- package/src/scan.ts +62 -0
- package/src/seed.ts +46 -0
- package/src/servers.ts +172 -0
- package/src/services.ts +184 -0
- package/src/snarkjs.d.ts +11 -0
- package/src/spend.ts +912 -0
- package/src/state.ts +211 -0
- package/src/sync.ts +698 -0
- package/src/tree.ts +108 -0
- package/src/wallet.ts +1297 -0
- package/wasm/zerc20_wallet_core.d.ts +176 -0
- package/wasm/zerc20_wallet_core.js +783 -0
- package/wasm/zerc20_wallet_core_bg.wasm +0 -0
- package/wasm/zerc20_wallet_core_bg.wasm.d.ts +32 -0
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
/* @ts-self-types="./zerc20_wallet_core.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The ASP tree's leaves for `count` positions from `first`, from an ASP `/bitmap/{c}` page (position `first + j` is
|
|
5
|
+
* bit `j % 8`, least significant first, of byte `j / 8`): `asp_leaf(position)` where approved, 0 elsewhere.
|
|
6
|
+
* @param {Uint8Array} bitmap
|
|
7
|
+
* @param {bigint} first
|
|
8
|
+
* @param {number} count
|
|
9
|
+
* @returns {Uint8Array}
|
|
10
|
+
*/
|
|
11
|
+
export function aspLeaves(bitmap, first, count) {
|
|
12
|
+
const ptr0 = passArray8ToWasm0(bitmap, wasm.__wbindgen_malloc);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ret = wasm.aspLeaves(ptr0, len0, first, count);
|
|
15
|
+
if (ret[3]) {
|
|
16
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
17
|
+
}
|
|
18
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
19
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
20
|
+
return v2;
|
|
21
|
+
}
|
|
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
|
+
/**
|
|
42
|
+
* @param {bigint} chain_id
|
|
43
|
+
* @param {string} public_key
|
|
44
|
+
* @param {string} salt
|
|
45
|
+
* @returns {string | undefined}
|
|
46
|
+
*/
|
|
47
|
+
export function burnAddressOf(chain_id, public_key, salt) {
|
|
48
|
+
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
49
|
+
const len0 = WASM_VECTOR_LEN;
|
|
50
|
+
const ptr1 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
|
+
const len1 = WASM_VECTOR_LEN;
|
|
52
|
+
const ret = wasm.burnAddressOf(chain_id, ptr0, len0, ptr1, len1);
|
|
53
|
+
if (ret[3]) {
|
|
54
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
55
|
+
}
|
|
56
|
+
let v3;
|
|
57
|
+
if (ret[0] !== 0) {
|
|
58
|
+
v3 = getStringFromWasm0(ret[0], ret[1]);
|
|
59
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
60
|
+
}
|
|
61
|
+
return v3;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The key that owns the notes paid to a seed's `index`-th receive code for one chain and token, shaped like
|
|
66
|
+
* `spendKey`.
|
|
67
|
+
* @param {Uint8Array} seed
|
|
68
|
+
* @param {bigint} chain_id
|
|
69
|
+
* @param {number} token_id
|
|
70
|
+
* @param {number} index
|
|
71
|
+
* @returns {any}
|
|
72
|
+
*/
|
|
73
|
+
export function codeKey(seed, chain_id, token_id, index) {
|
|
74
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
75
|
+
const len0 = WASM_VECTOR_LEN;
|
|
76
|
+
const ret = wasm.codeKey(ptr0, len0, chain_id, token_id, index);
|
|
77
|
+
if (ret[2]) {
|
|
78
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
79
|
+
}
|
|
80
|
+
return takeFromExternrefTable0(ret[0]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* `CommitmentLedger`'s hash chain after appending a commitment with `fields` to `prev`.
|
|
85
|
+
* @param {string} prev
|
|
86
|
+
* @param {string[]} fields
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
export function hashChain(prev, fields) {
|
|
90
|
+
let deferred4_0;
|
|
91
|
+
let deferred4_1;
|
|
92
|
+
try {
|
|
93
|
+
const ptr0 = passStringToWasm0(prev, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
94
|
+
const len0 = WASM_VECTOR_LEN;
|
|
95
|
+
const ptr1 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
|
|
96
|
+
const len1 = WASM_VECTOR_LEN;
|
|
97
|
+
const ret = wasm.hashChain(ptr0, len0, ptr1, len1);
|
|
98
|
+
var ptr3 = ret[0];
|
|
99
|
+
var len3 = ret[1];
|
|
100
|
+
if (ret[3]) {
|
|
101
|
+
ptr3 = 0; len3 = 0;
|
|
102
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
103
|
+
}
|
|
104
|
+
deferred4_0 = ptr3;
|
|
105
|
+
deferred4_1 = len3;
|
|
106
|
+
return getStringFromWasm0(ptr3, len3);
|
|
107
|
+
} finally {
|
|
108
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* One commitment's leaf, from its 4 fields.
|
|
114
|
+
* @param {string[]} fields
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
export function leaf(fields) {
|
|
118
|
+
let deferred3_0;
|
|
119
|
+
let deferred3_1;
|
|
120
|
+
try {
|
|
121
|
+
const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
|
|
122
|
+
const len0 = WASM_VECTOR_LEN;
|
|
123
|
+
const ret = wasm.leaf(ptr0, len0);
|
|
124
|
+
var ptr2 = ret[0];
|
|
125
|
+
var len2 = ret[1];
|
|
126
|
+
if (ret[3]) {
|
|
127
|
+
ptr2 = 0; len2 = 0;
|
|
128
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
129
|
+
}
|
|
130
|
+
deferred3_0 = ptr2;
|
|
131
|
+
deferred3_1 = len2;
|
|
132
|
+
return getStringFromWasm0(ptr2, len2);
|
|
133
|
+
} finally {
|
|
134
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The leaves of commitments in the indexer's layout (4 fields of 32 bytes each, as after a `/commitments/{p}` page's
|
|
140
|
+
* 32-byte header), 32 bytes each.
|
|
141
|
+
* @param {Uint8Array} entries
|
|
142
|
+
* @returns {Uint8Array}
|
|
143
|
+
*/
|
|
144
|
+
export function leaves(entries) {
|
|
145
|
+
const ptr0 = passArray8ToWasm0(entries, wasm.__wbindgen_malloc);
|
|
146
|
+
const len0 = WASM_VECTOR_LEN;
|
|
147
|
+
const ret = wasm.leaves(ptr0, len0);
|
|
148
|
+
if (ret[3]) {
|
|
149
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
150
|
+
}
|
|
151
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
152
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
153
|
+
return v2;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The note hash a note's opening commits to.
|
|
158
|
+
* @param {bigint} chain_id
|
|
159
|
+
* @param {string} public_key
|
|
160
|
+
* @param {string} value
|
|
161
|
+
* @param {number} token_id
|
|
162
|
+
* @param {string} salt
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*/
|
|
165
|
+
export function noteHash(chain_id, public_key, value, token_id, salt) {
|
|
166
|
+
let deferred5_0;
|
|
167
|
+
let deferred5_1;
|
|
168
|
+
try {
|
|
169
|
+
const ptr0 = passStringToWasm0(public_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
const len0 = WASM_VECTOR_LEN;
|
|
171
|
+
const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
172
|
+
const len1 = WASM_VECTOR_LEN;
|
|
173
|
+
const ptr2 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
174
|
+
const len2 = WASM_VECTOR_LEN;
|
|
175
|
+
const ret = wasm.noteHash(chain_id, ptr0, len0, ptr1, len1, token_id, ptr2, len2);
|
|
176
|
+
var ptr4 = ret[0];
|
|
177
|
+
var len4 = ret[1];
|
|
178
|
+
if (ret[3]) {
|
|
179
|
+
ptr4 = 0; len4 = 0;
|
|
180
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
181
|
+
}
|
|
182
|
+
deferred5_0 = ptr4;
|
|
183
|
+
deferred5_1 = len4;
|
|
184
|
+
return getStringFromWasm0(ptr4, len4);
|
|
185
|
+
} finally {
|
|
186
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The tag of a note commitment.
|
|
192
|
+
* @param {number} token_id
|
|
193
|
+
* @param {string} note_hash
|
|
194
|
+
* @returns {number}
|
|
195
|
+
*/
|
|
196
|
+
export function noteTag(token_id, note_hash) {
|
|
197
|
+
const ptr0 = passStringToWasm0(note_hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
198
|
+
const len0 = WASM_VECTOR_LEN;
|
|
199
|
+
const ret = wasm.noteTag(token_id, ptr0, len0);
|
|
200
|
+
if (ret[2]) {
|
|
201
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
202
|
+
}
|
|
203
|
+
return ret[0] >>> 0;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* The nullifier that spending the note or deposit at `commitment_index` publishes.
|
|
208
|
+
* @param {bigint} chain_id
|
|
209
|
+
* @param {bigint} commitment_index
|
|
210
|
+
* @param {string} nullifying_key
|
|
211
|
+
* @returns {string}
|
|
212
|
+
*/
|
|
213
|
+
export function nullifier(chain_id, commitment_index, nullifying_key) {
|
|
214
|
+
let deferred3_0;
|
|
215
|
+
let deferred3_1;
|
|
216
|
+
try {
|
|
217
|
+
const ptr0 = passStringToWasm0(nullifying_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
219
|
+
const ret = wasm.nullifier(chain_id, commitment_index, ptr0, len0);
|
|
220
|
+
var ptr2 = ret[0];
|
|
221
|
+
var len2 = ret[1];
|
|
222
|
+
if (ret[3]) {
|
|
223
|
+
ptr2 = 0; len2 = 0;
|
|
224
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
225
|
+
}
|
|
226
|
+
deferred3_0 = ptr2;
|
|
227
|
+
deferred3_1 = len2;
|
|
228
|
+
return getStringFromWasm0(ptr2, len2);
|
|
229
|
+
} finally {
|
|
230
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The sibling path (32 hex values) of position `i` in the tree at `n` leaves, from what a wallet downloads: the leaves
|
|
236
|
+
* of `i`'s chunk, the chunk roots of `i`'s page, the page roots, and the root entry's partial chunk and page roots
|
|
237
|
+
* (zero or absent where there is none). Lists may run past `n`. Check the path with `pathRoot` against a root the chain
|
|
238
|
+
* accepts.
|
|
239
|
+
* @param {bigint} i
|
|
240
|
+
* @param {bigint} n
|
|
241
|
+
* @param {Uint8Array} chunk_leaves
|
|
242
|
+
* @param {Uint8Array} page_chunks
|
|
243
|
+
* @param {Uint8Array} page_roots
|
|
244
|
+
* @param {string | null} [partial_chunk]
|
|
245
|
+
* @param {string | null} [partial_page]
|
|
246
|
+
* @returns {string[]}
|
|
247
|
+
*/
|
|
248
|
+
export function path(i, n, chunk_leaves, page_chunks, page_roots, partial_chunk, partial_page) {
|
|
249
|
+
const ptr0 = passArray8ToWasm0(chunk_leaves, wasm.__wbindgen_malloc);
|
|
250
|
+
const len0 = WASM_VECTOR_LEN;
|
|
251
|
+
const ptr1 = passArray8ToWasm0(page_chunks, wasm.__wbindgen_malloc);
|
|
252
|
+
const len1 = WASM_VECTOR_LEN;
|
|
253
|
+
const ptr2 = passArray8ToWasm0(page_roots, wasm.__wbindgen_malloc);
|
|
254
|
+
const len2 = WASM_VECTOR_LEN;
|
|
255
|
+
var ptr3 = isLikeNone(partial_chunk) ? 0 : passStringToWasm0(partial_chunk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
256
|
+
var len3 = WASM_VECTOR_LEN;
|
|
257
|
+
var ptr4 = isLikeNone(partial_page) ? 0 : passStringToWasm0(partial_page, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
258
|
+
var len4 = WASM_VECTOR_LEN;
|
|
259
|
+
const ret = wasm.path(i, n, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
260
|
+
if (ret[3]) {
|
|
261
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
262
|
+
}
|
|
263
|
+
var v6 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
264
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
265
|
+
return v6;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* The root of the tree holding `leaf` at position `i` with path `siblings`.
|
|
270
|
+
* @param {string} leaf
|
|
271
|
+
* @param {bigint} i
|
|
272
|
+
* @param {string[]} siblings
|
|
273
|
+
* @returns {string}
|
|
274
|
+
*/
|
|
275
|
+
export function pathRoot(leaf, i, siblings) {
|
|
276
|
+
let deferred4_0;
|
|
277
|
+
let deferred4_1;
|
|
278
|
+
try {
|
|
279
|
+
const ptr0 = passStringToWasm0(leaf, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
280
|
+
const len0 = WASM_VECTOR_LEN;
|
|
281
|
+
const ptr1 = passArrayJsValueToWasm0(siblings, wasm.__wbindgen_malloc);
|
|
282
|
+
const len1 = WASM_VECTOR_LEN;
|
|
283
|
+
const ret = wasm.pathRoot(ptr0, len0, i, ptr1, len1);
|
|
284
|
+
var ptr3 = ret[0];
|
|
285
|
+
var len3 = ret[1];
|
|
286
|
+
if (ret[3]) {
|
|
287
|
+
ptr3 = 0; len3 = 0;
|
|
288
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
289
|
+
}
|
|
290
|
+
deferred4_0 = ptr3;
|
|
291
|
+
deferred4_1 = len3;
|
|
292
|
+
return getStringFromWasm0(ptr3, len3);
|
|
293
|
+
} finally {
|
|
294
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
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
|
+
/**
|
|
321
|
+
* Seals a merge witness (JSON) to the merge prover's key, padded with spaces to `pad_to` bytes. Take the key from
|
|
322
|
+
* `verifyAttestation`, as for the attester's.
|
|
323
|
+
* @param {Uint8Array} public_key
|
|
324
|
+
* @param {string} witness
|
|
325
|
+
* @param {number} pad_to
|
|
326
|
+
* @returns {Uint8Array}
|
|
327
|
+
*/
|
|
328
|
+
export function sealMergeWitness(public_key, witness, pad_to) {
|
|
329
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
330
|
+
const len0 = WASM_VECTOR_LEN;
|
|
331
|
+
const ptr1 = passStringToWasm0(witness, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
332
|
+
const len1 = WASM_VECTOR_LEN;
|
|
333
|
+
const ret = wasm.sealMergeWitness(ptr0, len0, ptr1, len1, pad_to);
|
|
334
|
+
if (ret[3]) {
|
|
335
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
336
|
+
}
|
|
337
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
338
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
339
|
+
return v3;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Seals a witness (JSON) to an attester's key, padded with spaces to `pad_to` bytes so its length is the same for
|
|
344
|
+
* every amount. Take the key from `verifyAttestation`; only a development attester, which has no document, is taken
|
|
345
|
+
* at its word.
|
|
346
|
+
* @param {Uint8Array} public_key
|
|
347
|
+
* @param {string} witness
|
|
348
|
+
* @param {number} pad_to
|
|
349
|
+
* @returns {Uint8Array}
|
|
350
|
+
*/
|
|
351
|
+
export function sealWitness(public_key, witness, pad_to) {
|
|
352
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
353
|
+
const len0 = WASM_VECTOR_LEN;
|
|
354
|
+
const ptr1 = passStringToWasm0(witness, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
355
|
+
const len1 = WASM_VECTOR_LEN;
|
|
356
|
+
const ret = wasm.sealWitness(ptr0, len0, ptr1, len1, pad_to);
|
|
357
|
+
if (ret[3]) {
|
|
358
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
359
|
+
}
|
|
360
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
361
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
362
|
+
return v3;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* The statement a merge witness proves and the witness the attester and the merge prover take, as [`sign_transact`]
|
|
367
|
+
* for a JoinSplit: `{statement, witness}`. `statement` holds the public inputs and the fee (JSON with `tokenId`,
|
|
368
|
+
* `chainId`, `commitmentRoot`, `aspRoot`, `fee` and `feeRecipient`), and `witness` is the attester's merge witness
|
|
369
|
+
* JSON with each input's `private_key` in place of its keys. The statement gains the nullifiers and the note.
|
|
370
|
+
* @param {string} statement
|
|
371
|
+
* @param {string} witness
|
|
372
|
+
* @returns {string}
|
|
373
|
+
*/
|
|
374
|
+
export function signMerge(statement, witness) {
|
|
375
|
+
let deferred4_0;
|
|
376
|
+
let deferred4_1;
|
|
377
|
+
try {
|
|
378
|
+
const ptr0 = passStringToWasm0(statement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
379
|
+
const len0 = WASM_VECTOR_LEN;
|
|
380
|
+
const ptr1 = passStringToWasm0(witness, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
381
|
+
const len1 = WASM_VECTOR_LEN;
|
|
382
|
+
const ret = wasm.signMerge(ptr0, len0, ptr1, len1);
|
|
383
|
+
var ptr3 = ret[0];
|
|
384
|
+
var len3 = ret[1];
|
|
385
|
+
if (ret[3]) {
|
|
386
|
+
ptr3 = 0; len3 = 0;
|
|
387
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
388
|
+
}
|
|
389
|
+
deferred4_0 = ptr3;
|
|
390
|
+
deferred4_1 = len3;
|
|
391
|
+
return getStringFromWasm0(ptr3, len3);
|
|
392
|
+
} finally {
|
|
393
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* The statement a JoinSplit witness (snarkjs's input JSON) proves, given the public inputs in `statement` (JSON with
|
|
399
|
+
* `tokenId`, `chainId`, `commitmentRoot` and `aspRoot`; the rest is ignored), and the attester's witness for it:
|
|
400
|
+
* `{statement, witness}`. The statement is the public signals the proof and the attestation cover. The attester's
|
|
401
|
+
* witness has each input's private key replaced by its signing and nullifying keys, and its owner's signature on the
|
|
402
|
+
* statement. Fails with the attester's own reason when the attester would refuse the witness.
|
|
403
|
+
* @param {string} statement
|
|
404
|
+
* @param {string} witness
|
|
405
|
+
* @returns {string}
|
|
406
|
+
*/
|
|
407
|
+
export function signTransact(statement, witness) {
|
|
408
|
+
let deferred4_0;
|
|
409
|
+
let deferred4_1;
|
|
410
|
+
try {
|
|
411
|
+
const ptr0 = passStringToWasm0(statement, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
412
|
+
const len0 = WASM_VECTOR_LEN;
|
|
413
|
+
const ptr1 = passStringToWasm0(witness, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
414
|
+
const len1 = WASM_VECTOR_LEN;
|
|
415
|
+
const ret = wasm.signTransact(ptr0, len0, ptr1, len1);
|
|
416
|
+
var ptr3 = ret[0];
|
|
417
|
+
var len3 = ret[1];
|
|
418
|
+
if (ret[3]) {
|
|
419
|
+
ptr3 = 0; len3 = 0;
|
|
420
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
421
|
+
}
|
|
422
|
+
deferred4_0 = ptr3;
|
|
423
|
+
deferred4_1 = len3;
|
|
424
|
+
return getStringFromWasm0(ptr3, len3);
|
|
425
|
+
} finally {
|
|
426
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* The key that owns a seed's notes and deposits on every chain and token: `{secret, authKeyHash, publicKey,
|
|
432
|
+
* nullifyingKey}`.
|
|
433
|
+
* @param {Uint8Array} seed
|
|
434
|
+
* @returns {any}
|
|
435
|
+
*/
|
|
436
|
+
export function spendKey(seed) {
|
|
437
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
438
|
+
const len0 = WASM_VECTOR_LEN;
|
|
439
|
+
const ret = wasm.spendKey(ptr0, len0);
|
|
440
|
+
if (ret[2]) {
|
|
441
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
442
|
+
}
|
|
443
|
+
return takeFromExternrefTable0(ret[0]);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The tag of a transfer to `to` (`0x` address), such as a deposit to a burn address.
|
|
448
|
+
* @param {number} token_id
|
|
449
|
+
* @param {string} to
|
|
450
|
+
* @returns {number}
|
|
451
|
+
*/
|
|
452
|
+
export function transferTag(token_id, to) {
|
|
453
|
+
const ptr0 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
454
|
+
const len0 = WASM_VECTOR_LEN;
|
|
455
|
+
const ret = wasm.transferTag(token_id, ptr0, len0);
|
|
456
|
+
if (ret[2]) {
|
|
457
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
458
|
+
}
|
|
459
|
+
return ret[0] >>> 0;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* The key an attester's enclave opens witnesses with, once its `/attestation` document (`attestation`, decoded from
|
|
464
|
+
* base64) checks out: signed by a certificate chain up to the root whose DER has SHA-256 `root_sha256` (hex), valid
|
|
465
|
+
* at `now` (Unix seconds), and measuring `pcr0` (hex).
|
|
466
|
+
* @param {Uint8Array} attestation
|
|
467
|
+
* @param {string} root_sha256
|
|
468
|
+
* @param {string} pcr0
|
|
469
|
+
* @param {bigint} now
|
|
470
|
+
* @returns {Uint8Array}
|
|
471
|
+
*/
|
|
472
|
+
export function verifyAttestation(attestation, root_sha256, pcr0, now) {
|
|
473
|
+
const ptr0 = passArray8ToWasm0(attestation, wasm.__wbindgen_malloc);
|
|
474
|
+
const len0 = WASM_VECTOR_LEN;
|
|
475
|
+
const ptr1 = passStringToWasm0(root_sha256, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
476
|
+
const len1 = WASM_VECTOR_LEN;
|
|
477
|
+
const ptr2 = passStringToWasm0(pcr0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
478
|
+
const len2 = WASM_VECTOR_LEN;
|
|
479
|
+
const ret = wasm.verifyAttestation(ptr0, len0, ptr1, len1, ptr2, len2, now);
|
|
480
|
+
if (ret[3]) {
|
|
481
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
482
|
+
}
|
|
483
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
484
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
485
|
+
return v4;
|
|
486
|
+
}
|
|
487
|
+
function __wbg_get_imports() {
|
|
488
|
+
const import0 = {
|
|
489
|
+
__proto__: null,
|
|
490
|
+
__wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
|
|
491
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
492
|
+
return ret;
|
|
493
|
+
},
|
|
494
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
495
|
+
const ret = String(arg1);
|
|
496
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
497
|
+
const len1 = WASM_VECTOR_LEN;
|
|
498
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
499
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
500
|
+
},
|
|
501
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
502
|
+
const obj = arg1;
|
|
503
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
504
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
505
|
+
var len1 = WASM_VECTOR_LEN;
|
|
506
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
507
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
508
|
+
},
|
|
509
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
510
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
511
|
+
},
|
|
512
|
+
__wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
|
|
513
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
514
|
+
}, arguments); },
|
|
515
|
+
__wbg_new_617a8cdb8bb1130e: function() {
|
|
516
|
+
const ret = new Object();
|
|
517
|
+
return ret;
|
|
518
|
+
},
|
|
519
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
520
|
+
arg0[arg1] = arg2;
|
|
521
|
+
},
|
|
522
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
523
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
524
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
525
|
+
return ret;
|
|
526
|
+
},
|
|
527
|
+
__wbindgen_init_externref_table: function() {
|
|
528
|
+
const table = wasm.__wbindgen_externrefs;
|
|
529
|
+
const offset = table.grow(4);
|
|
530
|
+
table.set(0, undefined);
|
|
531
|
+
table.set(offset + 0, undefined);
|
|
532
|
+
table.set(offset + 1, null);
|
|
533
|
+
table.set(offset + 2, true);
|
|
534
|
+
table.set(offset + 3, false);
|
|
535
|
+
},
|
|
536
|
+
};
|
|
537
|
+
return {
|
|
538
|
+
__proto__: null,
|
|
539
|
+
"./zerc20_wallet_core_bg.js": import0,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function addToExternrefTable0(obj) {
|
|
544
|
+
const idx = wasm.__externref_table_alloc();
|
|
545
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
546
|
+
return idx;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
550
|
+
ptr = ptr >>> 0;
|
|
551
|
+
const mem = getDataViewMemory0();
|
|
552
|
+
const result = [];
|
|
553
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
554
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
555
|
+
}
|
|
556
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
557
|
+
return result;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
561
|
+
ptr = ptr >>> 0;
|
|
562
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
let cachedDataViewMemory0 = null;
|
|
566
|
+
function getDataViewMemory0() {
|
|
567
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
568
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
569
|
+
}
|
|
570
|
+
return cachedDataViewMemory0;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function getStringFromWasm0(ptr, len) {
|
|
574
|
+
return decodeText(ptr >>> 0, len);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
let cachedUint8ArrayMemory0 = null;
|
|
578
|
+
function getUint8ArrayMemory0() {
|
|
579
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
580
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
581
|
+
}
|
|
582
|
+
return cachedUint8ArrayMemory0;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
function handleError(f, args) {
|
|
586
|
+
try {
|
|
587
|
+
return f.apply(this, args);
|
|
588
|
+
} catch (e) {
|
|
589
|
+
const idx = addToExternrefTable0(e);
|
|
590
|
+
wasm.__wbindgen_exn_store(idx);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function isLikeNone(x) {
|
|
595
|
+
return x === undefined || x === null;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
599
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
600
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
601
|
+
WASM_VECTOR_LEN = arg.length;
|
|
602
|
+
return ptr;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
606
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
607
|
+
for (let i = 0; i < array.length; i++) {
|
|
608
|
+
const add = addToExternrefTable0(array[i]);
|
|
609
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
610
|
+
}
|
|
611
|
+
WASM_VECTOR_LEN = array.length;
|
|
612
|
+
return ptr;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
616
|
+
if (realloc === undefined) {
|
|
617
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
618
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
619
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
620
|
+
WASM_VECTOR_LEN = buf.length;
|
|
621
|
+
return ptr;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
let len = arg.length;
|
|
625
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
626
|
+
|
|
627
|
+
const mem = getUint8ArrayMemory0();
|
|
628
|
+
|
|
629
|
+
let offset = 0;
|
|
630
|
+
|
|
631
|
+
for (; offset < len; offset++) {
|
|
632
|
+
const code = arg.charCodeAt(offset);
|
|
633
|
+
if (code > 0x7F) break;
|
|
634
|
+
mem[ptr + offset] = code;
|
|
635
|
+
}
|
|
636
|
+
if (offset !== len) {
|
|
637
|
+
if (offset !== 0) {
|
|
638
|
+
arg = arg.slice(offset);
|
|
639
|
+
}
|
|
640
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
641
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
642
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
643
|
+
|
|
644
|
+
offset += ret.written;
|
|
645
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
WASM_VECTOR_LEN = offset;
|
|
649
|
+
return ptr;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function takeFromExternrefTable0(idx) {
|
|
653
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
654
|
+
wasm.__externref_table_dealloc(idx);
|
|
655
|
+
return value;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
659
|
+
cachedTextDecoder.decode();
|
|
660
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
661
|
+
let numBytesDecoded = 0;
|
|
662
|
+
function decodeText(ptr, len) {
|
|
663
|
+
numBytesDecoded += len;
|
|
664
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
665
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
666
|
+
cachedTextDecoder.decode();
|
|
667
|
+
numBytesDecoded = len;
|
|
668
|
+
}
|
|
669
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
const cachedTextEncoder = new TextEncoder();
|
|
673
|
+
|
|
674
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
675
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
676
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
677
|
+
view.set(buf);
|
|
678
|
+
return {
|
|
679
|
+
read: arg.length,
|
|
680
|
+
written: buf.length
|
|
681
|
+
};
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
let WASM_VECTOR_LEN = 0;
|
|
686
|
+
|
|
687
|
+
let wasmModule, wasmInstance, wasm;
|
|
688
|
+
function __wbg_finalize_init(instance, module) {
|
|
689
|
+
wasmInstance = instance;
|
|
690
|
+
wasm = instance.exports;
|
|
691
|
+
wasmModule = module;
|
|
692
|
+
cachedDataViewMemory0 = null;
|
|
693
|
+
cachedUint8ArrayMemory0 = null;
|
|
694
|
+
wasm.__wbindgen_start();
|
|
695
|
+
return wasm;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
async function __wbg_load(module, imports) {
|
|
699
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
700
|
+
if (!module.ok) {
|
|
701
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
705
|
+
try {
|
|
706
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
707
|
+
} catch (e) {
|
|
708
|
+
const validResponse = expectedResponseType(module.type);
|
|
709
|
+
|
|
710
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
711
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
712
|
+
|
|
713
|
+
} else { throw e; }
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const bytes = await module.arrayBuffer();
|
|
718
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
719
|
+
} else {
|
|
720
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
721
|
+
|
|
722
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
723
|
+
return { instance, module };
|
|
724
|
+
} else {
|
|
725
|
+
return instance;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function expectedResponseType(type) {
|
|
730
|
+
switch (type) {
|
|
731
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
732
|
+
}
|
|
733
|
+
return false;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
function initSync(module) {
|
|
738
|
+
if (wasm !== undefined) return wasm;
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
if (module !== undefined) {
|
|
742
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
743
|
+
({module} = module)
|
|
744
|
+
} else {
|
|
745
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const imports = __wbg_get_imports();
|
|
750
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
751
|
+
module = new WebAssembly.Module(module);
|
|
752
|
+
}
|
|
753
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
754
|
+
return __wbg_finalize_init(instance, module);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
async function __wbg_init(module_or_path) {
|
|
758
|
+
if (wasm !== undefined) return wasm;
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
if (module_or_path !== undefined) {
|
|
762
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
763
|
+
({module_or_path} = module_or_path)
|
|
764
|
+
} else {
|
|
765
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
if (module_or_path === undefined) {
|
|
770
|
+
module_or_path = new URL('zerc20_wallet_core_bg.wasm', import.meta.url);
|
|
771
|
+
}
|
|
772
|
+
const imports = __wbg_get_imports();
|
|
773
|
+
|
|
774
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
775
|
+
module_or_path = fetch(module_or_path);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
779
|
+
|
|
780
|
+
return __wbg_finalize_init(instance, module);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export { initSync, __wbg_init as default };
|