@invisi-labs/protocol 1.1.7 → 1.2.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.
Files changed (44) hide show
  1. package/README.md +5 -0
  2. package/dist/chunk-7SS2YSEF.js +199 -0
  3. package/dist/chunk-7SS2YSEF.js.map +1 -0
  4. package/dist/{chunk-BYJ4LXCJ.js → chunk-HHJLFLVJ.js} +616 -714
  5. package/dist/chunk-HHJLFLVJ.js.map +1 -0
  6. package/dist/chunk-MVQQD5W5.js +487 -0
  7. package/dist/chunk-MVQQD5W5.js.map +1 -0
  8. package/dist/chunk-Z2XPYNMC.js +446 -0
  9. package/dist/chunk-Z2XPYNMC.js.map +1 -0
  10. package/dist/contracts.cjs +615 -713
  11. package/dist/contracts.cjs.map +1 -1
  12. package/dist/contracts.d.cts +5 -5
  13. package/dist/contracts.d.ts +5 -5
  14. package/dist/contracts.js +1 -1
  15. package/dist/credit.cjs +3367 -0
  16. package/dist/credit.cjs.map +1 -0
  17. package/dist/credit.d.cts +252 -0
  18. package/dist/credit.d.ts +252 -0
  19. package/dist/credit.js +53 -0
  20. package/dist/credit.js.map +1 -0
  21. package/dist/index.cjs +6054 -6053
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +89 -893
  24. package/dist/index.d.ts +89 -893
  25. package/dist/index.js +2956 -3762
  26. package/dist/index.js.map +1 -1
  27. package/dist/note.cjs +3456 -0
  28. package/dist/note.cjs.map +1 -0
  29. package/dist/note.d.cts +232 -0
  30. package/dist/note.d.ts +232 -0
  31. package/dist/note.js +43 -0
  32. package/dist/note.js.map +1 -0
  33. package/dist/provenance.cjs +558 -0
  34. package/dist/provenance.cjs.map +1 -0
  35. package/dist/provenance.d.cts +188 -0
  36. package/dist/provenance.d.ts +188 -0
  37. package/dist/provenance.js +499 -0
  38. package/dist/provenance.js.map +1 -0
  39. package/dist/{types-Bvakbfeb.d.cts → types-CUnFzl5S.d.cts} +530 -590
  40. package/dist/{types-Bvakbfeb.d.ts → types-CUnFzl5S.d.ts} +530 -590
  41. package/dist/validation-8g0SQVE5.d.ts +235 -0
  42. package/dist/validation-MgURYiNF.d.cts +235 -0
  43. package/package.json +20 -5
  44. package/dist/chunk-BYJ4LXCJ.js.map +0 -1
package/dist/note.cjs ADDED
@@ -0,0 +1,3456 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/note/index.ts
21
+ var note_exports = {};
22
+ __export(note_exports, {
23
+ AGGREGATE_ROUTES: () => AGGREGATE_ROUTES,
24
+ TRANSACT_CAPACITIES: () => TRANSACT_CAPACITIES,
25
+ aggregateMemberRequestHash: () => aggregateMemberRequestHash,
26
+ aggregatePublicInputs: () => aggregatePublicInputs,
27
+ buildShieldCalldata: () => buildShieldCalldata,
28
+ buildTransactAggregateCalldata: () => buildTransactAggregateCalldata,
29
+ buildTransactCalldata: () => buildTransactCalldata,
30
+ encodeAggregateFundingTypedData: () => encodeAggregateFundingTypedData,
31
+ encodeShieldFundingTypedData: () => encodeShieldFundingTypedData,
32
+ encodeTransactFundingTypedData: () => encodeTransactFundingTypedData,
33
+ encodeTransactTypedData: () => encodeTransactTypedData,
34
+ normalizeTransactRequest: () => normalizeTransactRequest,
35
+ selectAggregateRoute: () => selectAggregateRoute,
36
+ selectTransactCapacity: () => selectTransactCapacity,
37
+ shieldFundingRequestHash: () => shieldFundingRequestHash,
38
+ transactFundingRequestHash: () => transactFundingRequestHash,
39
+ transactPublicInputs: () => transactPublicInputs,
40
+ validateShieldRequest: () => validateShieldRequest
41
+ });
42
+ module.exports = __toCommonJS(note_exports);
43
+
44
+ // src/note/request.ts
45
+ var import_ethers2 = require("ethers");
46
+
47
+ // src/validation.ts
48
+ var import_primitives = require("@invisi-labs/primitives");
49
+ var import_ethers = require("ethers");
50
+ var FIELD_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
51
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
52
+ var ZERO_WORD = (0, import_ethers.toBeHex)(0n, 32);
53
+ var EMPTY_PERMIT = {
54
+ deadline: 0n,
55
+ v: 0,
56
+ r: ZERO_WORD,
57
+ s: ZERO_WORD
58
+ };
59
+ var EMPTY_FUNDING = {
60
+ payer: ZERO_ADDRESS,
61
+ amount: 0n,
62
+ sigNonce: 0n,
63
+ deadline: 0n,
64
+ signature: "0x",
65
+ permit: EMPTY_PERMIT
66
+ };
67
+ function uint(v, bits, name = "value") {
68
+ if (typeof v !== "bigint" && typeof v !== "number" && typeof v !== "string" || typeof v === "number" && !Number.isSafeInteger(v))
69
+ throw new Error(`${name} must be an integer`);
70
+ const n = BigInt(v);
71
+ if (n < 0n || n >= 1n << BigInt(bits)) throw new Error(`${name} exceeds u${bits}`);
72
+ return n;
73
+ }
74
+ function field(v, name = "field") {
75
+ const n = uint(v, 256, name);
76
+ if (n >= FIELD_MODULUS) throw new Error(`${name} is noncanonical field`);
77
+ return n;
78
+ }
79
+ var word = (v) => (0, import_ethers.toBeHex)(typeof v === "bigint" ? v : BigInt(v), 32);
80
+ function dense(v, name) {
81
+ if (!Array.isArray(v)) throw new Error(`${name} must be array`);
82
+ for (let i = 0; i < v.length; i++)
83
+ if (!Object.hasOwn(v, i) || v[i] === void 0 || v[i] === null)
84
+ throw new Error(`${name} has missing or sparse entries`);
85
+ return v;
86
+ }
87
+ function known(v, keys, name = "params") {
88
+ if (!v || typeof v !== "object" || Array.isArray(v) || Object.keys(v).some((k) => !keys.includes(k)))
89
+ throw new Error(`${name} has unsupported fields`);
90
+ }
91
+ function notes(v, name) {
92
+ const r = dense(v, name).map((v2) => word(field(v2, name)));
93
+ if (r.some((v2) => BigInt(v2) === 0n) || new Set(r).size !== r.length)
94
+ throw new Error(`duplicate or zero ${name}`);
95
+ return r;
96
+ }
97
+ function envelope(v, length, version, maximum = length) {
98
+ if (!(0, import_ethers.isHexString)(v) || !/^0x(?:[a-fA-F0-9]{2})*$/.test(v) || (0, import_ethers.dataLength)(v) < length || (0, import_ethers.dataLength)(v) > maximum)
99
+ throw new Error(`ciphertext must be ${length} bytes`);
100
+ if (version !== void 0 && Number.parseInt(v.slice(2, 4), 16) !== version)
101
+ throw new Error("unsupported ciphertext envelope version");
102
+ return v;
103
+ }
104
+ function normalizeContext(c) {
105
+ return {
106
+ ...c,
107
+ chainId: uint(c.chainId, 64, "chainId"),
108
+ protocolAddress: (0, import_ethers.getAddress)(c.protocolAddress),
109
+ tokenAddress: (0, import_ethers.getAddress)(c.tokenAddress)
110
+ };
111
+ }
112
+ function checkDeadline(c, value) {
113
+ const n = uint(value, 64, "deadline");
114
+ if (c.now !== void 0 && n < uint(c.now, 64, "now")) throw new Error("deadline has expired");
115
+ return n;
116
+ }
117
+ function normalizeSources(sources, inputCount, capacity) {
118
+ dense(sources, "sources");
119
+ if (inputCount < 0 || inputCount > capacity || sources.length > inputCount || (inputCount === 0 ? sources.length !== 0 : sources.length === 0))
120
+ throw new Error("source count must be 1..inputCount, or empty for zero inputs");
121
+ let previous = 0n;
122
+ return sources.map((s) => {
123
+ known(s, ["treeId", "merkleRoot"], "source");
124
+ const treeId = uint(s.treeId, 64, "treeId"), merkleRoot = word(field(s.merkleRoot, "merkleRoot"));
125
+ if (treeId === 0n || treeId <= previous || BigInt(merkleRoot) === 0n)
126
+ throw new Error("sources must have positive roots and strictly ascending tree IDs");
127
+ previous = treeId;
128
+ return { treeId, merkleRoot };
129
+ });
130
+ }
131
+ var pad = (v, n) => [
132
+ ...v,
133
+ ...Array(n - v.length).fill(0n)
134
+ ];
135
+ function normalizeOpaqueDelivery(value, options = {}) {
136
+ known(value, ["ciphertext", "clue"], "delivery");
137
+ if (options.empty) {
138
+ if (value.ciphertext !== "0x" || value.clue !== "0x")
139
+ throw new Error("absent output requires an empty delivery");
140
+ return { ciphertext: "0x", clue: "0x" };
141
+ }
142
+ if (options.allowEmpty && value.ciphertext === "0x" && value.clue === "0x")
143
+ return { ciphertext: "0x", clue: "0x" };
144
+ const ciphertext = envelope(value.ciphertext, 1, void 0, import_primitives.MAX_CIPHERTEXT_BYTES);
145
+ const clue = envelope(value.clue, 68);
146
+ if (clue.slice(130, 132).toLowerCase() !== "18") throw new Error("clue precision must be 24");
147
+ return { ciphertext, clue };
148
+ }
149
+ var deliveriesHash = (v) => (0, import_ethers.keccak256)(
150
+ import_ethers.AbiCoder.defaultAbiCoder().encode(
151
+ [
152
+ {
153
+ type: "tuple[]",
154
+ components: [
155
+ { name: "ciphertext", type: "bytes" },
156
+ { name: "clue", type: "bytes" }
157
+ ]
158
+ }
159
+ ].map((parameter) => import_ethers.ParamType.from(parameter)),
160
+ [dense(v, "deliveries")]
161
+ )
162
+ );
163
+ function normalizeFunding(input = {}) {
164
+ const f = { ...EMPTY_FUNDING, ...input };
165
+ (0, import_ethers.getAddress)(f.payer);
166
+ uint(f.amount, 128, "depositAmount");
167
+ uint(f.sigNonce, 256, "sigNonce");
168
+ uint(f.deadline, 256, "funding deadline");
169
+ if (!(0, import_ethers.isHexString)(f.signature) || !/^0x(?:[a-fA-F0-9]{2})*$/.test(f.signature))
170
+ throw new Error("invalid signature bytes");
171
+ const p = f.permit;
172
+ uint(p.deadline, 256);
173
+ uint(p.v, 8);
174
+ for (const v of [p.r, p.s])
175
+ if (!(0, import_ethers.isHexString)(v) || (0, import_ethers.dataLength)(v) !== 32) throw new Error("permit r/s must be bytes32");
176
+ if (f.amount === 0n !== (BigInt(f.payer) === 0n))
177
+ throw new Error("deposit amount and payer must both be zero or positive");
178
+ if (f.amount === 0n && (f.sigNonce !== 0n || f.deadline !== 0n || f.signature !== "0x" || p.deadline !== 0n || p.v !== 0 || BigInt(p.r) !== 0n || BigInt(p.s) !== 0n))
179
+ throw new Error("zero funding must be entirely empty");
180
+ return { ...f, payer: (0, import_ethers.getAddress)(f.payer) };
181
+ }
182
+ function validateFundingSubmission(f, caller, now) {
183
+ if (f.signature !== "0x" && now !== void 0 && uint(now, 64, "now") > f.deadline)
184
+ throw new Error("funding authorization has expired");
185
+ if (f.signature === "0x" && (f.sigNonce !== 0n || f.deadline !== 0n || caller !== void 0 && f.amount > 0n && (0, import_ethers.getAddress)(caller) !== f.payer))
186
+ throw new Error("direct funding requires payer caller and zero nonce/deadline");
187
+ }
188
+ var getEIP712Domain = (c) => ({
189
+ name: "InvisibleProtocol",
190
+ version: "1",
191
+ chainId: uint(c.chainId, 64),
192
+ verifyingContract: (0, import_ethers.getAddress)(c.protocolAddress)
193
+ });
194
+ var fundingFields = [
195
+ { name: "requestHash", type: "bytes32" },
196
+ { name: "payer", type: "address" },
197
+ { name: "amount", type: "uint256" },
198
+ { name: "sigNonce", type: "uint256" },
199
+ { name: "deadline", type: "uint256" }
200
+ ];
201
+
202
+ // src/note/request.ts
203
+ var TRANSACT_CAPACITIES = [
204
+ 1,
205
+ 2,
206
+ 3,
207
+ 4,
208
+ 5,
209
+ 6,
210
+ 7,
211
+ 8,
212
+ 9,
213
+ 10,
214
+ 20,
215
+ 30,
216
+ 40,
217
+ 50,
218
+ 60,
219
+ 70,
220
+ 80,
221
+ 90,
222
+ 100,
223
+ 110,
224
+ 120,
225
+ 130,
226
+ 140,
227
+ 150,
228
+ 160,
229
+ 170,
230
+ 180,
231
+ 190
232
+ ];
233
+ function selectTransactCapacity(inputs, outputs) {
234
+ if (!Number.isInteger(inputs) || !Number.isInteger(outputs) || inputs < 0 || outputs < 0 || inputs + outputs < 1 || inputs === 0 && outputs < 2 || inputs + outputs > 190)
235
+ throw new Error("unsupported transact shape");
236
+ return TRANSACT_CAPACITIES.find((n) => inputs + outputs <= n);
237
+ }
238
+ function normalizeTransactRequest(c, p, cs, funding = {}) {
239
+ const ctx = normalizeContext(c);
240
+ if ((0, import_ethers2.getAddress)(p.token) !== ctx.tokenAddress)
241
+ throw new Error("request token mismatch");
242
+ known(p, [
243
+ "token",
244
+ "sources",
245
+ "nullifiers",
246
+ "noteCommitments",
247
+ "withdrawalAddress",
248
+ "withdrawalAmount",
249
+ "deadline",
250
+ "feeRecipient",
251
+ "feeAmount"
252
+ ]);
253
+ const ns = notes(p.nullifiers, "nullifiers"), os = notes(p.noteCommitments, "noteCommitments"), capacity = selectTransactCapacity(ns.length, os.length);
254
+ const sources = normalizeSources(p.sources, ns.length, capacity), deliveries = dense(cs, "deliveries").map(
255
+ (v) => normalizeOpaqueDelivery(v, { allowEmpty: true })
256
+ );
257
+ if (deliveries.length !== os.length) throw new Error("deliveries count mismatch");
258
+ const withdrawalAmount = uint(p.withdrawalAmount, 128, "withdrawalAmount"), withdrawalAddress = (0, import_ethers2.getAddress)(p.withdrawalAddress), f = normalizeFunding(funding);
259
+ const feeAmount = uint(p.feeAmount ?? 0n, 128, "feeAmount");
260
+ const feeRecipient = (0, import_ethers2.getAddress)(
261
+ p.feeRecipient ?? "0x0000000000000000000000000000000000000000"
262
+ );
263
+ if (feeAmount === 0n !== (BigInt(feeRecipient) === 0n)) throw new Error("invalid fee");
264
+ if (withdrawalAmount === 0n !== (BigInt(withdrawalAddress) === 0n) || os.length === 0 && withdrawalAmount === 0n)
265
+ throw new Error("invalid withdrawal");
266
+ if (ns.length === 0 && (f.amount === 0n || withdrawalAmount !== 0n))
267
+ throw new Error("zero inputs require positive funding and zero withdrawal");
268
+ return {
269
+ ...ctx,
270
+ capacity,
271
+ sources,
272
+ nullifiers: ns,
273
+ noteCommitments: os,
274
+ inputCount: ns.length,
275
+ outputCount: os.length,
276
+ sourceCount: sources.length,
277
+ inputTreeIds: pad(
278
+ sources.map((s) => s.treeId),
279
+ capacity
280
+ ),
281
+ merkleRoots: pad(
282
+ sources.map((s) => BigInt(s.merkleRoot)),
283
+ capacity
284
+ ),
285
+ slotValues: pad([...ns, ...os].map(BigInt), capacity),
286
+ deliveries,
287
+ deliveriesHash: deliveriesHash(deliveries),
288
+ withdrawalAddress,
289
+ withdrawalAmount,
290
+ feeRecipient,
291
+ feeAmount,
292
+ deadline: checkDeadline(c, p.deadline),
293
+ depositAmount: f.amount,
294
+ depositPayer: f.payer,
295
+ funding: f
296
+ };
297
+ }
298
+ function transactPublicInputs(c, p, cs, f = {}) {
299
+ const r = normalizeTransactRequest(c, p, cs, f), h = BigInt(r.deliveriesHash);
300
+ return [
301
+ r.chainId,
302
+ BigInt(r.protocolAddress),
303
+ BigInt(r.tokenAddress),
304
+ BigInt(r.inputCount),
305
+ BigInt(r.outputCount),
306
+ BigInt(r.sourceCount),
307
+ ...r.inputTreeIds,
308
+ ...r.merkleRoots,
309
+ ...r.slotValues,
310
+ h >> 128n,
311
+ h & (1n << 128n) - 1n,
312
+ BigInt(r.withdrawalAddress),
313
+ r.withdrawalAmount,
314
+ r.deadline,
315
+ r.depositAmount,
316
+ BigInt(r.depositPayer),
317
+ BigInt(r.feeRecipient),
318
+ r.feeAmount
319
+ ].map(word);
320
+ }
321
+
322
+ // src/note/calldata.ts
323
+ var import_ethers3 = require("ethers");
324
+
325
+ // src/contracts/abis/InvisiProtocol.ts
326
+ var invisiProtocolAbi = [
327
+ {
328
+ "type": "constructor",
329
+ "inputs": [
330
+ {
331
+ "name": "params",
332
+ "type": "tuple",
333
+ "internalType": "struct InstanceParams",
334
+ "components": [
335
+ {
336
+ "name": "factory",
337
+ "type": "address",
338
+ "internalType": "address"
339
+ },
340
+ {
341
+ "name": "initialOwner",
342
+ "type": "address",
343
+ "internalType": "address"
344
+ },
345
+ {
346
+ "name": "globalEmergency",
347
+ "type": "address",
348
+ "internalType": "address"
349
+ },
350
+ {
351
+ "name": "emergencyAdmin",
352
+ "type": "address",
353
+ "internalType": "address"
354
+ },
355
+ {
356
+ "name": "verifierRouter",
357
+ "type": "address",
358
+ "internalType": "contract IVerifierRouter"
359
+ }
360
+ ]
361
+ },
362
+ {
363
+ "name": "_screener",
364
+ "type": "address",
365
+ "internalType": "address"
366
+ },
367
+ {
368
+ "name": "_addressRegistry",
369
+ "type": "address",
370
+ "internalType": "address"
371
+ }
372
+ ],
373
+ "stateMutability": "nonpayable"
374
+ },
375
+ {
376
+ "type": "function",
377
+ "name": "CHAIN_ID",
378
+ "inputs": [],
379
+ "outputs": [
380
+ {
381
+ "name": "",
382
+ "type": "uint256",
383
+ "internalType": "uint256"
384
+ }
385
+ ],
386
+ "stateMutability": "view"
387
+ },
388
+ {
389
+ "type": "function",
390
+ "name": "FUND_SHIELD_TYPEHASH",
391
+ "inputs": [],
392
+ "outputs": [
393
+ {
394
+ "name": "",
395
+ "type": "bytes32",
396
+ "internalType": "bytes32"
397
+ }
398
+ ],
399
+ "stateMutability": "view"
400
+ },
401
+ {
402
+ "type": "function",
403
+ "name": "FUND_TRANSACT_TYPEHASH",
404
+ "inputs": [],
405
+ "outputs": [
406
+ {
407
+ "name": "",
408
+ "type": "bytes32",
409
+ "internalType": "bytes32"
410
+ }
411
+ ],
412
+ "stateMutability": "view"
413
+ },
414
+ {
415
+ "type": "function",
416
+ "name": "VERSION",
417
+ "inputs": [],
418
+ "outputs": [
419
+ {
420
+ "name": "",
421
+ "type": "uint256",
422
+ "internalType": "uint256"
423
+ }
424
+ ],
425
+ "stateMutability": "view"
426
+ },
427
+ {
428
+ "type": "function",
429
+ "name": "acceptOwnership",
430
+ "inputs": [],
431
+ "outputs": [],
432
+ "stateMutability": "nonpayable"
433
+ },
434
+ {
435
+ "type": "function",
436
+ "name": "activeNoteTreeId",
437
+ "inputs": [],
438
+ "outputs": [
439
+ {
440
+ "name": "",
441
+ "type": "uint256",
442
+ "internalType": "uint256"
443
+ }
444
+ ],
445
+ "stateMutability": "view"
446
+ },
447
+ {
448
+ "type": "function",
449
+ "name": "addressRegistry",
450
+ "inputs": [],
451
+ "outputs": [
452
+ {
453
+ "name": "",
454
+ "type": "address",
455
+ "internalType": "contract IAddressRegistry"
456
+ }
457
+ ],
458
+ "stateMutability": "view"
459
+ },
460
+ {
461
+ "type": "function",
462
+ "name": "broadcasterFeeBalance",
463
+ "inputs": [
464
+ {
465
+ "name": "token",
466
+ "type": "address",
467
+ "internalType": "address"
468
+ },
469
+ {
470
+ "name": "recipient",
471
+ "type": "address",
472
+ "internalType": "address"
473
+ }
474
+ ],
475
+ "outputs": [
476
+ {
477
+ "name": "",
478
+ "type": "uint256",
479
+ "internalType": "uint256"
480
+ }
481
+ ],
482
+ "stateMutability": "view"
483
+ },
484
+ {
485
+ "type": "function",
486
+ "name": "circuitPaused",
487
+ "inputs": [],
488
+ "outputs": [
489
+ {
490
+ "name": "",
491
+ "type": "bool",
492
+ "internalType": "bool"
493
+ }
494
+ ],
495
+ "stateMutability": "view"
496
+ },
497
+ {
498
+ "type": "function",
499
+ "name": "createCredit",
500
+ "inputs": [
501
+ {
502
+ "name": "",
503
+ "type": "bytes",
504
+ "internalType": "bytes"
505
+ },
506
+ {
507
+ "name": "p",
508
+ "type": "tuple",
509
+ "internalType": "struct IInvisiProtocol.CreateCreditParams",
510
+ "components": [
511
+ {
512
+ "name": "token",
513
+ "type": "address",
514
+ "internalType": "address"
515
+ },
516
+ {
517
+ "name": "owner",
518
+ "type": "address",
519
+ "internalType": "address"
520
+ },
521
+ {
522
+ "name": "revocationShard",
523
+ "type": "uint64",
524
+ "internalType": "uint64"
525
+ },
526
+ {
527
+ "name": "revocationSlot",
528
+ "type": "uint16",
529
+ "internalType": "uint16"
530
+ },
531
+ {
532
+ "name": "creditCommitment",
533
+ "type": "bytes32",
534
+ "internalType": "bytes32"
535
+ },
536
+ {
537
+ "name": "deadline",
538
+ "type": "uint256",
539
+ "internalType": "uint256"
540
+ },
541
+ {
542
+ "name": "feeRecipient",
543
+ "type": "address",
544
+ "internalType": "address"
545
+ },
546
+ {
547
+ "name": "feeAmount",
548
+ "type": "uint256",
549
+ "internalType": "uint256"
550
+ }
551
+ ]
552
+ },
553
+ {
554
+ "name": "",
555
+ "type": "tuple[]",
556
+ "internalType": "struct IInvisiProtocol.Delivery[]",
557
+ "components": [
558
+ {
559
+ "name": "ciphertext",
560
+ "type": "bytes",
561
+ "internalType": "bytes"
562
+ },
563
+ {
564
+ "name": "clue",
565
+ "type": "bytes",
566
+ "internalType": "bytes"
567
+ }
568
+ ]
569
+ }
570
+ ],
571
+ "outputs": [],
572
+ "stateMutability": "nonpayable"
573
+ },
574
+ {
575
+ "type": "function",
576
+ "name": "creditAllocation",
577
+ "inputs": [
578
+ {
579
+ "name": "owner",
580
+ "type": "address",
581
+ "internalType": "address"
582
+ },
583
+ {
584
+ "name": "token",
585
+ "type": "address",
586
+ "internalType": "address"
587
+ }
588
+ ],
589
+ "outputs": [
590
+ {
591
+ "name": "shard",
592
+ "type": "uint64",
593
+ "internalType": "uint64"
594
+ },
595
+ {
596
+ "name": "slot",
597
+ "type": "uint16",
598
+ "internalType": "uint16"
599
+ }
600
+ ],
601
+ "stateMutability": "view"
602
+ },
603
+ {
604
+ "type": "function",
605
+ "name": "creditDraw",
606
+ "inputs": [
607
+ {
608
+ "name": "",
609
+ "type": "bytes",
610
+ "internalType": "bytes"
611
+ },
612
+ {
613
+ "name": "p",
614
+ "type": "tuple",
615
+ "internalType": "struct IInvisiProtocol.CreditDrawParams",
616
+ "components": [
617
+ {
618
+ "name": "token",
619
+ "type": "address",
620
+ "internalType": "address"
621
+ },
622
+ {
623
+ "name": "sources",
624
+ "type": "tuple[]",
625
+ "internalType": "struct IInvisiProtocol.InputSource[]",
626
+ "components": [
627
+ {
628
+ "name": "treeId",
629
+ "type": "uint256",
630
+ "internalType": "uint256"
631
+ },
632
+ {
633
+ "name": "merkleRoot",
634
+ "type": "bytes32",
635
+ "internalType": "bytes32"
636
+ }
637
+ ]
638
+ },
639
+ {
640
+ "name": "payers",
641
+ "type": "tuple[]",
642
+ "internalType": "struct IInvisiProtocol.CreditPayer[]",
643
+ "components": [
644
+ {
645
+ "name": "payer",
646
+ "type": "address",
647
+ "internalType": "address"
648
+ },
649
+ {
650
+ "name": "amount",
651
+ "type": "uint256",
652
+ "internalType": "uint256"
653
+ }
654
+ ]
655
+ },
656
+ {
657
+ "name": "grantRefs",
658
+ "type": "tuple[]",
659
+ "internalType": "struct IInvisiProtocol.CreditGrantRef[]",
660
+ "components": [
661
+ {
662
+ "name": "payerIndex",
663
+ "type": "uint256",
664
+ "internalType": "uint256"
665
+ },
666
+ {
667
+ "name": "shard",
668
+ "type": "uint64",
669
+ "internalType": "uint64"
670
+ },
671
+ {
672
+ "name": "slot",
673
+ "type": "uint16",
674
+ "internalType": "uint16"
675
+ }
676
+ ]
677
+ },
678
+ {
679
+ "name": "nullifiers",
680
+ "type": "bytes32[]",
681
+ "internalType": "bytes32[]"
682
+ },
683
+ {
684
+ "name": "creditCommitments",
685
+ "type": "bytes32[]",
686
+ "internalType": "bytes32[]"
687
+ },
688
+ {
689
+ "name": "recoveryAmounts",
690
+ "type": "bytes32[]",
691
+ "internalType": "bytes32[]"
692
+ },
693
+ {
694
+ "name": "noteCommitment",
695
+ "type": "bytes32",
696
+ "internalType": "bytes32"
697
+ },
698
+ {
699
+ "name": "totalAmount",
700
+ "type": "uint256",
701
+ "internalType": "uint256"
702
+ },
703
+ {
704
+ "name": "deadline",
705
+ "type": "uint256",
706
+ "internalType": "uint256"
707
+ },
708
+ {
709
+ "name": "feeRecipient",
710
+ "type": "address",
711
+ "internalType": "address"
712
+ },
713
+ {
714
+ "name": "feeAmount",
715
+ "type": "uint256",
716
+ "internalType": "uint256"
717
+ }
718
+ ]
719
+ },
720
+ {
721
+ "name": "",
722
+ "type": "tuple[]",
723
+ "internalType": "struct IInvisiProtocol.Delivery[]",
724
+ "components": [
725
+ {
726
+ "name": "ciphertext",
727
+ "type": "bytes",
728
+ "internalType": "bytes"
729
+ },
730
+ {
731
+ "name": "clue",
732
+ "type": "bytes",
733
+ "internalType": "bytes"
734
+ }
735
+ ]
736
+ }
737
+ ],
738
+ "outputs": [],
739
+ "stateMutability": "nonpayable"
740
+ },
741
+ {
742
+ "type": "function",
743
+ "name": "creditRevocationBitmap",
744
+ "inputs": [
745
+ {
746
+ "name": "owner",
747
+ "type": "address",
748
+ "internalType": "address"
749
+ },
750
+ {
751
+ "name": "token",
752
+ "type": "address",
753
+ "internalType": "address"
754
+ },
755
+ {
756
+ "name": "shard",
757
+ "type": "uint64",
758
+ "internalType": "uint64"
759
+ },
760
+ {
761
+ "name": "word",
762
+ "type": "uint8",
763
+ "internalType": "uint8"
764
+ }
765
+ ],
766
+ "outputs": [
767
+ {
768
+ "name": "",
769
+ "type": "uint256",
770
+ "internalType": "uint256"
771
+ }
772
+ ],
773
+ "stateMutability": "view"
774
+ },
775
+ {
776
+ "type": "function",
777
+ "name": "eip712Domain",
778
+ "inputs": [],
779
+ "outputs": [
780
+ {
781
+ "name": "fields",
782
+ "type": "bytes1",
783
+ "internalType": "bytes1"
784
+ },
785
+ {
786
+ "name": "name",
787
+ "type": "string",
788
+ "internalType": "string"
789
+ },
790
+ {
791
+ "name": "version",
792
+ "type": "string",
793
+ "internalType": "string"
794
+ },
795
+ {
796
+ "name": "chainId",
797
+ "type": "uint256",
798
+ "internalType": "uint256"
799
+ },
800
+ {
801
+ "name": "verifyingContract",
802
+ "type": "address",
803
+ "internalType": "address"
804
+ },
805
+ {
806
+ "name": "salt",
807
+ "type": "bytes32",
808
+ "internalType": "bytes32"
809
+ },
810
+ {
811
+ "name": "extensions",
812
+ "type": "uint256[]",
813
+ "internalType": "uint256[]"
814
+ }
815
+ ],
816
+ "stateMutability": "view"
817
+ },
818
+ {
819
+ "type": "function",
820
+ "name": "emergencyAdmin",
821
+ "inputs": [],
822
+ "outputs": [
823
+ {
824
+ "name": "",
825
+ "type": "address",
826
+ "internalType": "address"
827
+ }
828
+ ],
829
+ "stateMutability": "view"
830
+ },
831
+ {
832
+ "type": "function",
833
+ "name": "factory",
834
+ "inputs": [],
835
+ "outputs": [
836
+ {
837
+ "name": "",
838
+ "type": "address",
839
+ "internalType": "address"
840
+ }
841
+ ],
842
+ "stateMutability": "view"
843
+ },
844
+ {
845
+ "type": "function",
846
+ "name": "getNoteTreeNextLeafIndex",
847
+ "inputs": [
848
+ {
849
+ "name": "treeId",
850
+ "type": "uint256",
851
+ "internalType": "uint256"
852
+ }
853
+ ],
854
+ "outputs": [
855
+ {
856
+ "name": "",
857
+ "type": "uint32",
858
+ "internalType": "uint32"
859
+ }
860
+ ],
861
+ "stateMutability": "view"
862
+ },
863
+ {
864
+ "type": "function",
865
+ "name": "getNoteTreeRoot",
866
+ "inputs": [
867
+ {
868
+ "name": "treeId",
869
+ "type": "uint256",
870
+ "internalType": "uint256"
871
+ }
872
+ ],
873
+ "outputs": [
874
+ {
875
+ "name": "",
876
+ "type": "bytes32",
877
+ "internalType": "bytes32"
878
+ }
879
+ ],
880
+ "stateMutability": "view"
881
+ },
882
+ {
883
+ "type": "function",
884
+ "name": "getTreeCount",
885
+ "inputs": [],
886
+ "outputs": [
887
+ {
888
+ "name": "count",
889
+ "type": "uint256",
890
+ "internalType": "uint256"
891
+ }
892
+ ],
893
+ "stateMutability": "view"
894
+ },
895
+ {
896
+ "type": "function",
897
+ "name": "globalEmergency",
898
+ "inputs": [],
899
+ "outputs": [
900
+ {
901
+ "name": "",
902
+ "type": "address",
903
+ "internalType": "address"
904
+ }
905
+ ],
906
+ "stateMutability": "view"
907
+ },
908
+ {
909
+ "type": "function",
910
+ "name": "invalidateNonce",
911
+ "inputs": [],
912
+ "outputs": [],
913
+ "stateMutability": "nonpayable"
914
+ },
915
+ {
916
+ "type": "function",
917
+ "name": "isCommitmentRegistered",
918
+ "inputs": [
919
+ {
920
+ "name": "commitment",
921
+ "type": "bytes32",
922
+ "internalType": "bytes32"
923
+ }
924
+ ],
925
+ "outputs": [
926
+ {
927
+ "name": "",
928
+ "type": "bool",
929
+ "internalType": "bool"
930
+ }
931
+ ],
932
+ "stateMutability": "view"
933
+ },
934
+ {
935
+ "type": "function",
936
+ "name": "isNullifierSpent",
937
+ "inputs": [
938
+ {
939
+ "name": "nullifier",
940
+ "type": "bytes32",
941
+ "internalType": "bytes32"
942
+ }
943
+ ],
944
+ "outputs": [
945
+ {
946
+ "name": "",
947
+ "type": "bool",
948
+ "internalType": "bool"
949
+ }
950
+ ],
951
+ "stateMutability": "view"
952
+ },
953
+ {
954
+ "type": "function",
955
+ "name": "isTreeFull",
956
+ "inputs": [
957
+ {
958
+ "name": "treeId",
959
+ "type": "uint256",
960
+ "internalType": "uint256"
961
+ }
962
+ ],
963
+ "outputs": [
964
+ {
965
+ "name": "",
966
+ "type": "bool",
967
+ "internalType": "bool"
968
+ }
969
+ ],
970
+ "stateMutability": "view"
971
+ },
972
+ {
973
+ "type": "function",
974
+ "name": "nonces",
975
+ "inputs": [
976
+ {
977
+ "name": "",
978
+ "type": "address",
979
+ "internalType": "address"
980
+ }
981
+ ],
982
+ "outputs": [
983
+ {
984
+ "name": "",
985
+ "type": "uint256",
986
+ "internalType": "uint256"
987
+ }
988
+ ],
989
+ "stateMutability": "view"
990
+ },
991
+ {
992
+ "type": "function",
993
+ "name": "owner",
994
+ "inputs": [],
995
+ "outputs": [
996
+ {
997
+ "name": "",
998
+ "type": "address",
999
+ "internalType": "address"
1000
+ }
1001
+ ],
1002
+ "stateMutability": "view"
1003
+ },
1004
+ {
1005
+ "type": "function",
1006
+ "name": "pause",
1007
+ "inputs": [],
1008
+ "outputs": [],
1009
+ "stateMutability": "nonpayable"
1010
+ },
1011
+ {
1012
+ "type": "function",
1013
+ "name": "pauseCircuit",
1014
+ "inputs": [],
1015
+ "outputs": [],
1016
+ "stateMutability": "nonpayable"
1017
+ },
1018
+ {
1019
+ "type": "function",
1020
+ "name": "paused",
1021
+ "inputs": [],
1022
+ "outputs": [
1023
+ {
1024
+ "name": "",
1025
+ "type": "bool",
1026
+ "internalType": "bool"
1027
+ }
1028
+ ],
1029
+ "stateMutability": "view"
1030
+ },
1031
+ {
1032
+ "type": "function",
1033
+ "name": "pendingOwner",
1034
+ "inputs": [],
1035
+ "outputs": [
1036
+ {
1037
+ "name": "",
1038
+ "type": "address",
1039
+ "internalType": "address"
1040
+ }
1041
+ ],
1042
+ "stateMutability": "view"
1043
+ },
1044
+ {
1045
+ "type": "function",
1046
+ "name": "renounceOwnership",
1047
+ "inputs": [],
1048
+ "outputs": [],
1049
+ "stateMutability": "nonpayable"
1050
+ },
1051
+ {
1052
+ "type": "function",
1053
+ "name": "revokeCredit",
1054
+ "inputs": [
1055
+ {
1056
+ "name": "token",
1057
+ "type": "address",
1058
+ "internalType": "address"
1059
+ },
1060
+ {
1061
+ "name": "owner",
1062
+ "type": "address",
1063
+ "internalType": "address"
1064
+ },
1065
+ {
1066
+ "name": "shard",
1067
+ "type": "uint64",
1068
+ "internalType": "uint64"
1069
+ },
1070
+ {
1071
+ "name": "slot",
1072
+ "type": "uint16",
1073
+ "internalType": "uint16"
1074
+ },
1075
+ {
1076
+ "name": "deadline",
1077
+ "type": "uint256",
1078
+ "internalType": "uint256"
1079
+ },
1080
+ {
1081
+ "name": "feeRecipient",
1082
+ "type": "address",
1083
+ "internalType": "address"
1084
+ },
1085
+ {
1086
+ "name": "feeAmount",
1087
+ "type": "uint256",
1088
+ "internalType": "uint256"
1089
+ },
1090
+ {
1091
+ "name": "signature",
1092
+ "type": "bytes",
1093
+ "internalType": "bytes"
1094
+ }
1095
+ ],
1096
+ "outputs": [],
1097
+ "stateMutability": "nonpayable"
1098
+ },
1099
+ {
1100
+ "type": "function",
1101
+ "name": "rootHistory",
1102
+ "inputs": [
1103
+ {
1104
+ "name": "",
1105
+ "type": "uint256",
1106
+ "internalType": "uint256"
1107
+ },
1108
+ {
1109
+ "name": "",
1110
+ "type": "bytes32",
1111
+ "internalType": "bytes32"
1112
+ }
1113
+ ],
1114
+ "outputs": [
1115
+ {
1116
+ "name": "",
1117
+ "type": "bool",
1118
+ "internalType": "bool"
1119
+ }
1120
+ ],
1121
+ "stateMutability": "view"
1122
+ },
1123
+ {
1124
+ "type": "function",
1125
+ "name": "screener",
1126
+ "inputs": [],
1127
+ "outputs": [
1128
+ {
1129
+ "name": "",
1130
+ "type": "address",
1131
+ "internalType": "address"
1132
+ }
1133
+ ],
1134
+ "stateMutability": "view"
1135
+ },
1136
+ {
1137
+ "type": "function",
1138
+ "name": "setScreener",
1139
+ "inputs": [
1140
+ {
1141
+ "name": "newScreener",
1142
+ "type": "address",
1143
+ "internalType": "address"
1144
+ }
1145
+ ],
1146
+ "outputs": [],
1147
+ "stateMutability": "nonpayable"
1148
+ },
1149
+ {
1150
+ "type": "function",
1151
+ "name": "shield",
1152
+ "inputs": [
1153
+ {
1154
+ "name": "p",
1155
+ "type": "tuple",
1156
+ "internalType": "struct IInvisiProtocol.ShieldParams",
1157
+ "components": [
1158
+ {
1159
+ "name": "token",
1160
+ "type": "address",
1161
+ "internalType": "address"
1162
+ },
1163
+ {
1164
+ "name": "noteCommitments",
1165
+ "type": "bytes32[]",
1166
+ "internalType": "bytes32[]"
1167
+ },
1168
+ {
1169
+ "name": "deadline",
1170
+ "type": "uint256",
1171
+ "internalType": "uint256"
1172
+ },
1173
+ {
1174
+ "name": "feeRecipient",
1175
+ "type": "address",
1176
+ "internalType": "address"
1177
+ },
1178
+ {
1179
+ "name": "feeAmount",
1180
+ "type": "uint256",
1181
+ "internalType": "uint256"
1182
+ }
1183
+ ]
1184
+ },
1185
+ {
1186
+ "name": "",
1187
+ "type": "tuple[]",
1188
+ "internalType": "struct IInvisiProtocol.ShieldOutput[]",
1189
+ "components": [
1190
+ {
1191
+ "name": "identity",
1192
+ "type": "bytes32",
1193
+ "internalType": "bytes32"
1194
+ },
1195
+ {
1196
+ "name": "amount",
1197
+ "type": "uint256",
1198
+ "internalType": "uint256"
1199
+ }
1200
+ ]
1201
+ },
1202
+ {
1203
+ "name": "",
1204
+ "type": "tuple[]",
1205
+ "internalType": "struct IInvisiProtocol.Delivery[]",
1206
+ "components": [
1207
+ {
1208
+ "name": "ciphertext",
1209
+ "type": "bytes",
1210
+ "internalType": "bytes"
1211
+ },
1212
+ {
1213
+ "name": "clue",
1214
+ "type": "bytes",
1215
+ "internalType": "bytes"
1216
+ }
1217
+ ]
1218
+ },
1219
+ {
1220
+ "name": "",
1221
+ "type": "tuple",
1222
+ "internalType": "struct IInvisiProtocol.FundingParams",
1223
+ "components": [
1224
+ {
1225
+ "name": "payer",
1226
+ "type": "address",
1227
+ "internalType": "address"
1228
+ },
1229
+ {
1230
+ "name": "amount",
1231
+ "type": "uint256",
1232
+ "internalType": "uint256"
1233
+ },
1234
+ {
1235
+ "name": "sigNonce",
1236
+ "type": "uint256",
1237
+ "internalType": "uint256"
1238
+ },
1239
+ {
1240
+ "name": "deadline",
1241
+ "type": "uint256",
1242
+ "internalType": "uint256"
1243
+ },
1244
+ {
1245
+ "name": "signature",
1246
+ "type": "bytes",
1247
+ "internalType": "bytes"
1248
+ },
1249
+ {
1250
+ "name": "permit",
1251
+ "type": "tuple",
1252
+ "internalType": "struct IMetaTx.TokenPermit",
1253
+ "components": [
1254
+ {
1255
+ "name": "deadline",
1256
+ "type": "uint256",
1257
+ "internalType": "uint256"
1258
+ },
1259
+ {
1260
+ "name": "v",
1261
+ "type": "uint8",
1262
+ "internalType": "uint8"
1263
+ },
1264
+ {
1265
+ "name": "r",
1266
+ "type": "bytes32",
1267
+ "internalType": "bytes32"
1268
+ },
1269
+ {
1270
+ "name": "s",
1271
+ "type": "bytes32",
1272
+ "internalType": "bytes32"
1273
+ }
1274
+ ]
1275
+ }
1276
+ ]
1277
+ }
1278
+ ],
1279
+ "outputs": [],
1280
+ "stateMutability": "nonpayable"
1281
+ },
1282
+ {
1283
+ "type": "function",
1284
+ "name": "transact",
1285
+ "inputs": [
1286
+ {
1287
+ "name": "",
1288
+ "type": "bytes",
1289
+ "internalType": "bytes"
1290
+ },
1291
+ {
1292
+ "name": "r",
1293
+ "type": "tuple",
1294
+ "internalType": "struct IInvisiProtocol.TransactRequest",
1295
+ "components": [
1296
+ {
1297
+ "name": "params",
1298
+ "type": "tuple",
1299
+ "internalType": "struct IInvisiProtocol.CrossTreeTransactParams",
1300
+ "components": [
1301
+ {
1302
+ "name": "token",
1303
+ "type": "address",
1304
+ "internalType": "address"
1305
+ },
1306
+ {
1307
+ "name": "sources",
1308
+ "type": "tuple[]",
1309
+ "internalType": "struct IInvisiProtocol.InputSource[]",
1310
+ "components": [
1311
+ {
1312
+ "name": "treeId",
1313
+ "type": "uint256",
1314
+ "internalType": "uint256"
1315
+ },
1316
+ {
1317
+ "name": "merkleRoot",
1318
+ "type": "bytes32",
1319
+ "internalType": "bytes32"
1320
+ }
1321
+ ]
1322
+ },
1323
+ {
1324
+ "name": "nullifiers",
1325
+ "type": "bytes32[]",
1326
+ "internalType": "bytes32[]"
1327
+ },
1328
+ {
1329
+ "name": "noteCommitments",
1330
+ "type": "bytes32[]",
1331
+ "internalType": "bytes32[]"
1332
+ },
1333
+ {
1334
+ "name": "withdrawalAddress",
1335
+ "type": "address",
1336
+ "internalType": "address"
1337
+ },
1338
+ {
1339
+ "name": "withdrawalAmount",
1340
+ "type": "uint256",
1341
+ "internalType": "uint256"
1342
+ },
1343
+ {
1344
+ "name": "deadline",
1345
+ "type": "uint256",
1346
+ "internalType": "uint256"
1347
+ },
1348
+ {
1349
+ "name": "feeRecipient",
1350
+ "type": "address",
1351
+ "internalType": "address"
1352
+ },
1353
+ {
1354
+ "name": "feeAmount",
1355
+ "type": "uint256",
1356
+ "internalType": "uint256"
1357
+ }
1358
+ ]
1359
+ },
1360
+ {
1361
+ "name": "deliveries",
1362
+ "type": "tuple[]",
1363
+ "internalType": "struct IInvisiProtocol.Delivery[]",
1364
+ "components": [
1365
+ {
1366
+ "name": "ciphertext",
1367
+ "type": "bytes",
1368
+ "internalType": "bytes"
1369
+ },
1370
+ {
1371
+ "name": "clue",
1372
+ "type": "bytes",
1373
+ "internalType": "bytes"
1374
+ }
1375
+ ]
1376
+ },
1377
+ {
1378
+ "name": "funding",
1379
+ "type": "tuple",
1380
+ "internalType": "struct IInvisiProtocol.FundingParams",
1381
+ "components": [
1382
+ {
1383
+ "name": "payer",
1384
+ "type": "address",
1385
+ "internalType": "address"
1386
+ },
1387
+ {
1388
+ "name": "amount",
1389
+ "type": "uint256",
1390
+ "internalType": "uint256"
1391
+ },
1392
+ {
1393
+ "name": "sigNonce",
1394
+ "type": "uint256",
1395
+ "internalType": "uint256"
1396
+ },
1397
+ {
1398
+ "name": "deadline",
1399
+ "type": "uint256",
1400
+ "internalType": "uint256"
1401
+ },
1402
+ {
1403
+ "name": "signature",
1404
+ "type": "bytes",
1405
+ "internalType": "bytes"
1406
+ },
1407
+ {
1408
+ "name": "permit",
1409
+ "type": "tuple",
1410
+ "internalType": "struct IMetaTx.TokenPermit",
1411
+ "components": [
1412
+ {
1413
+ "name": "deadline",
1414
+ "type": "uint256",
1415
+ "internalType": "uint256"
1416
+ },
1417
+ {
1418
+ "name": "v",
1419
+ "type": "uint8",
1420
+ "internalType": "uint8"
1421
+ },
1422
+ {
1423
+ "name": "r",
1424
+ "type": "bytes32",
1425
+ "internalType": "bytes32"
1426
+ },
1427
+ {
1428
+ "name": "s",
1429
+ "type": "bytes32",
1430
+ "internalType": "bytes32"
1431
+ }
1432
+ ]
1433
+ }
1434
+ ]
1435
+ }
1436
+ ]
1437
+ }
1438
+ ],
1439
+ "outputs": [],
1440
+ "stateMutability": "nonpayable"
1441
+ },
1442
+ {
1443
+ "type": "function",
1444
+ "name": "transact",
1445
+ "inputs": [
1446
+ {
1447
+ "name": "",
1448
+ "type": "bytes",
1449
+ "internalType": "bytes"
1450
+ },
1451
+ {
1452
+ "name": "requests",
1453
+ "type": "tuple[]",
1454
+ "internalType": "struct IInvisiProtocol.TransactRequest[]",
1455
+ "components": [
1456
+ {
1457
+ "name": "params",
1458
+ "type": "tuple",
1459
+ "internalType": "struct IInvisiProtocol.CrossTreeTransactParams",
1460
+ "components": [
1461
+ {
1462
+ "name": "token",
1463
+ "type": "address",
1464
+ "internalType": "address"
1465
+ },
1466
+ {
1467
+ "name": "sources",
1468
+ "type": "tuple[]",
1469
+ "internalType": "struct IInvisiProtocol.InputSource[]",
1470
+ "components": [
1471
+ {
1472
+ "name": "treeId",
1473
+ "type": "uint256",
1474
+ "internalType": "uint256"
1475
+ },
1476
+ {
1477
+ "name": "merkleRoot",
1478
+ "type": "bytes32",
1479
+ "internalType": "bytes32"
1480
+ }
1481
+ ]
1482
+ },
1483
+ {
1484
+ "name": "nullifiers",
1485
+ "type": "bytes32[]",
1486
+ "internalType": "bytes32[]"
1487
+ },
1488
+ {
1489
+ "name": "noteCommitments",
1490
+ "type": "bytes32[]",
1491
+ "internalType": "bytes32[]"
1492
+ },
1493
+ {
1494
+ "name": "withdrawalAddress",
1495
+ "type": "address",
1496
+ "internalType": "address"
1497
+ },
1498
+ {
1499
+ "name": "withdrawalAmount",
1500
+ "type": "uint256",
1501
+ "internalType": "uint256"
1502
+ },
1503
+ {
1504
+ "name": "deadline",
1505
+ "type": "uint256",
1506
+ "internalType": "uint256"
1507
+ },
1508
+ {
1509
+ "name": "feeRecipient",
1510
+ "type": "address",
1511
+ "internalType": "address"
1512
+ },
1513
+ {
1514
+ "name": "feeAmount",
1515
+ "type": "uint256",
1516
+ "internalType": "uint256"
1517
+ }
1518
+ ]
1519
+ },
1520
+ {
1521
+ "name": "deliveries",
1522
+ "type": "tuple[]",
1523
+ "internalType": "struct IInvisiProtocol.Delivery[]",
1524
+ "components": [
1525
+ {
1526
+ "name": "ciphertext",
1527
+ "type": "bytes",
1528
+ "internalType": "bytes"
1529
+ },
1530
+ {
1531
+ "name": "clue",
1532
+ "type": "bytes",
1533
+ "internalType": "bytes"
1534
+ }
1535
+ ]
1536
+ },
1537
+ {
1538
+ "name": "funding",
1539
+ "type": "tuple",
1540
+ "internalType": "struct IInvisiProtocol.FundingParams",
1541
+ "components": [
1542
+ {
1543
+ "name": "payer",
1544
+ "type": "address",
1545
+ "internalType": "address"
1546
+ },
1547
+ {
1548
+ "name": "amount",
1549
+ "type": "uint256",
1550
+ "internalType": "uint256"
1551
+ },
1552
+ {
1553
+ "name": "sigNonce",
1554
+ "type": "uint256",
1555
+ "internalType": "uint256"
1556
+ },
1557
+ {
1558
+ "name": "deadline",
1559
+ "type": "uint256",
1560
+ "internalType": "uint256"
1561
+ },
1562
+ {
1563
+ "name": "signature",
1564
+ "type": "bytes",
1565
+ "internalType": "bytes"
1566
+ },
1567
+ {
1568
+ "name": "permit",
1569
+ "type": "tuple",
1570
+ "internalType": "struct IMetaTx.TokenPermit",
1571
+ "components": [
1572
+ {
1573
+ "name": "deadline",
1574
+ "type": "uint256",
1575
+ "internalType": "uint256"
1576
+ },
1577
+ {
1578
+ "name": "v",
1579
+ "type": "uint8",
1580
+ "internalType": "uint8"
1581
+ },
1582
+ {
1583
+ "name": "r",
1584
+ "type": "bytes32",
1585
+ "internalType": "bytes32"
1586
+ },
1587
+ {
1588
+ "name": "s",
1589
+ "type": "bytes32",
1590
+ "internalType": "bytes32"
1591
+ }
1592
+ ]
1593
+ }
1594
+ ]
1595
+ }
1596
+ ]
1597
+ }
1598
+ ],
1599
+ "outputs": [],
1600
+ "stateMutability": "nonpayable"
1601
+ },
1602
+ {
1603
+ "type": "function",
1604
+ "name": "transferOwnership",
1605
+ "inputs": [
1606
+ {
1607
+ "name": "newOwner",
1608
+ "type": "address",
1609
+ "internalType": "address"
1610
+ }
1611
+ ],
1612
+ "outputs": [],
1613
+ "stateMutability": "nonpayable"
1614
+ },
1615
+ {
1616
+ "type": "function",
1617
+ "name": "unpause",
1618
+ "inputs": [],
1619
+ "outputs": [],
1620
+ "stateMutability": "nonpayable"
1621
+ },
1622
+ {
1623
+ "type": "function",
1624
+ "name": "unpauseCircuit",
1625
+ "inputs": [],
1626
+ "outputs": [],
1627
+ "stateMutability": "nonpayable"
1628
+ },
1629
+ {
1630
+ "type": "function",
1631
+ "name": "updateCredit",
1632
+ "inputs": [
1633
+ {
1634
+ "name": "",
1635
+ "type": "bytes",
1636
+ "internalType": "bytes"
1637
+ },
1638
+ {
1639
+ "name": "p",
1640
+ "type": "tuple",
1641
+ "internalType": "struct IInvisiProtocol.UpdateCreditParams",
1642
+ "components": [
1643
+ {
1644
+ "name": "token",
1645
+ "type": "address",
1646
+ "internalType": "address"
1647
+ },
1648
+ {
1649
+ "name": "owner",
1650
+ "type": "address",
1651
+ "internalType": "address"
1652
+ },
1653
+ {
1654
+ "name": "source",
1655
+ "type": "tuple",
1656
+ "internalType": "struct IInvisiProtocol.InputSource",
1657
+ "components": [
1658
+ {
1659
+ "name": "treeId",
1660
+ "type": "uint256",
1661
+ "internalType": "uint256"
1662
+ },
1663
+ {
1664
+ "name": "merkleRoot",
1665
+ "type": "bytes32",
1666
+ "internalType": "bytes32"
1667
+ }
1668
+ ]
1669
+ },
1670
+ {
1671
+ "name": "nullifier",
1672
+ "type": "bytes32",
1673
+ "internalType": "bytes32"
1674
+ },
1675
+ {
1676
+ "name": "creditCommitment",
1677
+ "type": "bytes32",
1678
+ "internalType": "bytes32"
1679
+ },
1680
+ {
1681
+ "name": "revocationShard",
1682
+ "type": "uint64",
1683
+ "internalType": "uint64"
1684
+ },
1685
+ {
1686
+ "name": "revocationSlot",
1687
+ "type": "uint16",
1688
+ "internalType": "uint16"
1689
+ },
1690
+ {
1691
+ "name": "deadline",
1692
+ "type": "uint256",
1693
+ "internalType": "uint256"
1694
+ },
1695
+ {
1696
+ "name": "feeRecipient",
1697
+ "type": "address",
1698
+ "internalType": "address"
1699
+ },
1700
+ {
1701
+ "name": "feeAmount",
1702
+ "type": "uint256",
1703
+ "internalType": "uint256"
1704
+ }
1705
+ ]
1706
+ },
1707
+ {
1708
+ "name": "",
1709
+ "type": "tuple[]",
1710
+ "internalType": "struct IInvisiProtocol.Delivery[]",
1711
+ "components": [
1712
+ {
1713
+ "name": "ciphertext",
1714
+ "type": "bytes",
1715
+ "internalType": "bytes"
1716
+ },
1717
+ {
1718
+ "name": "clue",
1719
+ "type": "bytes",
1720
+ "internalType": "bytes"
1721
+ }
1722
+ ]
1723
+ }
1724
+ ],
1725
+ "outputs": [],
1726
+ "stateMutability": "nonpayable"
1727
+ },
1728
+ {
1729
+ "type": "function",
1730
+ "name": "verifierRouter",
1731
+ "inputs": [],
1732
+ "outputs": [
1733
+ {
1734
+ "name": "",
1735
+ "type": "address",
1736
+ "internalType": "contract IVerifierRouter"
1737
+ }
1738
+ ],
1739
+ "stateMutability": "view"
1740
+ },
1741
+ {
1742
+ "type": "function",
1743
+ "name": "withdrawBroadcasterFees",
1744
+ "inputs": [
1745
+ {
1746
+ "name": "token",
1747
+ "type": "address",
1748
+ "internalType": "address"
1749
+ },
1750
+ {
1751
+ "name": "recipient",
1752
+ "type": "address",
1753
+ "internalType": "address"
1754
+ }
1755
+ ],
1756
+ "outputs": [
1757
+ {
1758
+ "name": "",
1759
+ "type": "uint256",
1760
+ "internalType": "uint256"
1761
+ }
1762
+ ],
1763
+ "stateMutability": "nonpayable"
1764
+ },
1765
+ {
1766
+ "type": "event",
1767
+ "name": "BatchOutputs",
1768
+ "inputs": [
1769
+ {
1770
+ "name": "treeId",
1771
+ "type": "uint256",
1772
+ "indexed": true,
1773
+ "internalType": "uint256"
1774
+ },
1775
+ {
1776
+ "name": "startLeafIndex",
1777
+ "type": "uint32",
1778
+ "indexed": false,
1779
+ "internalType": "uint32"
1780
+ },
1781
+ {
1782
+ "name": "firstOutputOffset",
1783
+ "type": "uint256",
1784
+ "indexed": false,
1785
+ "internalType": "uint256"
1786
+ },
1787
+ {
1788
+ "name": "tokens",
1789
+ "type": "address[]",
1790
+ "indexed": false,
1791
+ "internalType": "address[]"
1792
+ },
1793
+ {
1794
+ "name": "noteCommitments",
1795
+ "type": "bytes32[]",
1796
+ "indexed": false,
1797
+ "internalType": "bytes32[]"
1798
+ },
1799
+ {
1800
+ "name": "packedDeliveries",
1801
+ "type": "bytes",
1802
+ "indexed": false,
1803
+ "internalType": "bytes"
1804
+ }
1805
+ ],
1806
+ "anonymous": false
1807
+ },
1808
+ {
1809
+ "type": "event",
1810
+ "name": "BatchRequest",
1811
+ "inputs": [
1812
+ {
1813
+ "name": "token",
1814
+ "type": "address",
1815
+ "indexed": false,
1816
+ "internalType": "address"
1817
+ },
1818
+ {
1819
+ "name": "requestIndex",
1820
+ "type": "uint256",
1821
+ "indexed": true,
1822
+ "internalType": "uint256"
1823
+ },
1824
+ {
1825
+ "name": "capacity",
1826
+ "type": "uint256",
1827
+ "indexed": false,
1828
+ "internalType": "uint256"
1829
+ },
1830
+ {
1831
+ "name": "sources",
1832
+ "type": "tuple[]",
1833
+ "indexed": false,
1834
+ "internalType": "struct IInvisiProtocol.InputSource[]",
1835
+ "components": [
1836
+ {
1837
+ "name": "treeId",
1838
+ "type": "uint256",
1839
+ "internalType": "uint256"
1840
+ },
1841
+ {
1842
+ "name": "merkleRoot",
1843
+ "type": "bytes32",
1844
+ "internalType": "bytes32"
1845
+ }
1846
+ ]
1847
+ },
1848
+ {
1849
+ "name": "nullifiers",
1850
+ "type": "bytes32[]",
1851
+ "indexed": false,
1852
+ "internalType": "bytes32[]"
1853
+ },
1854
+ {
1855
+ "name": "outputCount",
1856
+ "type": "uint256",
1857
+ "indexed": false,
1858
+ "internalType": "uint256"
1859
+ },
1860
+ {
1861
+ "name": "payer",
1862
+ "type": "address",
1863
+ "indexed": false,
1864
+ "internalType": "address"
1865
+ },
1866
+ {
1867
+ "name": "depositAmount",
1868
+ "type": "uint256",
1869
+ "indexed": false,
1870
+ "internalType": "uint256"
1871
+ },
1872
+ {
1873
+ "name": "withdrawalAddress",
1874
+ "type": "address",
1875
+ "indexed": false,
1876
+ "internalType": "address"
1877
+ },
1878
+ {
1879
+ "name": "withdrawalAmount",
1880
+ "type": "uint256",
1881
+ "indexed": false,
1882
+ "internalType": "uint256"
1883
+ },
1884
+ {
1885
+ "name": "deadline",
1886
+ "type": "uint256",
1887
+ "indexed": false,
1888
+ "internalType": "uint256"
1889
+ },
1890
+ {
1891
+ "name": "statementHash",
1892
+ "type": "bytes32",
1893
+ "indexed": false,
1894
+ "internalType": "bytes32"
1895
+ }
1896
+ ],
1897
+ "anonymous": false
1898
+ },
1899
+ {
1900
+ "type": "event",
1901
+ "name": "BroadcasterFee",
1902
+ "inputs": [
1903
+ {
1904
+ "name": "token",
1905
+ "type": "address",
1906
+ "indexed": true,
1907
+ "internalType": "address"
1908
+ },
1909
+ {
1910
+ "name": "recipient",
1911
+ "type": "address",
1912
+ "indexed": true,
1913
+ "internalType": "address"
1914
+ },
1915
+ {
1916
+ "name": "amount",
1917
+ "type": "uint256",
1918
+ "indexed": false,
1919
+ "internalType": "uint256"
1920
+ }
1921
+ ],
1922
+ "anonymous": false
1923
+ },
1924
+ {
1925
+ "type": "event",
1926
+ "name": "BroadcasterFeeWithdrawn",
1927
+ "inputs": [
1928
+ {
1929
+ "name": "token",
1930
+ "type": "address",
1931
+ "indexed": true,
1932
+ "internalType": "address"
1933
+ },
1934
+ {
1935
+ "name": "recipient",
1936
+ "type": "address",
1937
+ "indexed": true,
1938
+ "internalType": "address"
1939
+ },
1940
+ {
1941
+ "name": "amount",
1942
+ "type": "uint256",
1943
+ "indexed": false,
1944
+ "internalType": "uint256"
1945
+ }
1946
+ ],
1947
+ "anonymous": false
1948
+ },
1949
+ {
1950
+ "type": "event",
1951
+ "name": "CircuitPauseUpdated",
1952
+ "inputs": [
1953
+ {
1954
+ "name": "paused",
1955
+ "type": "bool",
1956
+ "indexed": false,
1957
+ "internalType": "bool"
1958
+ }
1959
+ ],
1960
+ "anonymous": false
1961
+ },
1962
+ {
1963
+ "type": "event",
1964
+ "name": "CommitmentsInserted",
1965
+ "inputs": [
1966
+ {
1967
+ "name": "treeId",
1968
+ "type": "uint256",
1969
+ "indexed": true,
1970
+ "internalType": "uint256"
1971
+ },
1972
+ {
1973
+ "name": "startLeafIndex",
1974
+ "type": "uint32",
1975
+ "indexed": false,
1976
+ "internalType": "uint32"
1977
+ },
1978
+ {
1979
+ "name": "commitments",
1980
+ "type": "bytes32[]",
1981
+ "indexed": false,
1982
+ "internalType": "bytes32[]"
1983
+ }
1984
+ ],
1985
+ "anonymous": false
1986
+ },
1987
+ {
1988
+ "type": "event",
1989
+ "name": "CreditCreated",
1990
+ "inputs": [
1991
+ {
1992
+ "name": "token",
1993
+ "type": "address",
1994
+ "indexed": true,
1995
+ "internalType": "address"
1996
+ },
1997
+ {
1998
+ "name": "owner",
1999
+ "type": "address",
2000
+ "indexed": true,
2001
+ "internalType": "address"
2002
+ },
2003
+ {
2004
+ "name": "outputTreeId",
2005
+ "type": "uint256",
2006
+ "indexed": true,
2007
+ "internalType": "uint256"
2008
+ },
2009
+ {
2010
+ "name": "revocationShard",
2011
+ "type": "uint64",
2012
+ "indexed": false,
2013
+ "internalType": "uint64"
2014
+ },
2015
+ {
2016
+ "name": "revocationSlot",
2017
+ "type": "uint16",
2018
+ "indexed": false,
2019
+ "internalType": "uint16"
2020
+ },
2021
+ {
2022
+ "name": "creditCommitment",
2023
+ "type": "bytes32",
2024
+ "indexed": false,
2025
+ "internalType": "bytes32"
2026
+ },
2027
+ {
2028
+ "name": "leafIndex",
2029
+ "type": "uint32",
2030
+ "indexed": false,
2031
+ "internalType": "uint32"
2032
+ },
2033
+ {
2034
+ "name": "deliveries",
2035
+ "type": "tuple[]",
2036
+ "indexed": false,
2037
+ "internalType": "struct IInvisiProtocol.Delivery[]",
2038
+ "components": [
2039
+ {
2040
+ "name": "ciphertext",
2041
+ "type": "bytes",
2042
+ "internalType": "bytes"
2043
+ },
2044
+ {
2045
+ "name": "clue",
2046
+ "type": "bytes",
2047
+ "internalType": "bytes"
2048
+ }
2049
+ ]
2050
+ },
2051
+ {
2052
+ "name": "deadline",
2053
+ "type": "uint256",
2054
+ "indexed": false,
2055
+ "internalType": "uint256"
2056
+ },
2057
+ {
2058
+ "name": "feeRecipient",
2059
+ "type": "address",
2060
+ "indexed": false,
2061
+ "internalType": "address"
2062
+ },
2063
+ {
2064
+ "name": "feeAmount",
2065
+ "type": "uint256",
2066
+ "indexed": false,
2067
+ "internalType": "uint256"
2068
+ }
2069
+ ],
2070
+ "anonymous": false
2071
+ },
2072
+ {
2073
+ "type": "event",
2074
+ "name": "CreditDraw",
2075
+ "inputs": [
2076
+ {
2077
+ "name": "outputTreeId",
2078
+ "type": "uint256",
2079
+ "indexed": true,
2080
+ "internalType": "uint256"
2081
+ },
2082
+ {
2083
+ "name": "params",
2084
+ "type": "tuple",
2085
+ "indexed": false,
2086
+ "internalType": "struct IInvisiProtocol.CreditDrawParams",
2087
+ "components": [
2088
+ {
2089
+ "name": "token",
2090
+ "type": "address",
2091
+ "internalType": "address"
2092
+ },
2093
+ {
2094
+ "name": "sources",
2095
+ "type": "tuple[]",
2096
+ "internalType": "struct IInvisiProtocol.InputSource[]",
2097
+ "components": [
2098
+ {
2099
+ "name": "treeId",
2100
+ "type": "uint256",
2101
+ "internalType": "uint256"
2102
+ },
2103
+ {
2104
+ "name": "merkleRoot",
2105
+ "type": "bytes32",
2106
+ "internalType": "bytes32"
2107
+ }
2108
+ ]
2109
+ },
2110
+ {
2111
+ "name": "payers",
2112
+ "type": "tuple[]",
2113
+ "internalType": "struct IInvisiProtocol.CreditPayer[]",
2114
+ "components": [
2115
+ {
2116
+ "name": "payer",
2117
+ "type": "address",
2118
+ "internalType": "address"
2119
+ },
2120
+ {
2121
+ "name": "amount",
2122
+ "type": "uint256",
2123
+ "internalType": "uint256"
2124
+ }
2125
+ ]
2126
+ },
2127
+ {
2128
+ "name": "grantRefs",
2129
+ "type": "tuple[]",
2130
+ "internalType": "struct IInvisiProtocol.CreditGrantRef[]",
2131
+ "components": [
2132
+ {
2133
+ "name": "payerIndex",
2134
+ "type": "uint256",
2135
+ "internalType": "uint256"
2136
+ },
2137
+ {
2138
+ "name": "shard",
2139
+ "type": "uint64",
2140
+ "internalType": "uint64"
2141
+ },
2142
+ {
2143
+ "name": "slot",
2144
+ "type": "uint16",
2145
+ "internalType": "uint16"
2146
+ }
2147
+ ]
2148
+ },
2149
+ {
2150
+ "name": "nullifiers",
2151
+ "type": "bytes32[]",
2152
+ "internalType": "bytes32[]"
2153
+ },
2154
+ {
2155
+ "name": "creditCommitments",
2156
+ "type": "bytes32[]",
2157
+ "internalType": "bytes32[]"
2158
+ },
2159
+ {
2160
+ "name": "recoveryAmounts",
2161
+ "type": "bytes32[]",
2162
+ "internalType": "bytes32[]"
2163
+ },
2164
+ {
2165
+ "name": "noteCommitment",
2166
+ "type": "bytes32",
2167
+ "internalType": "bytes32"
2168
+ },
2169
+ {
2170
+ "name": "totalAmount",
2171
+ "type": "uint256",
2172
+ "internalType": "uint256"
2173
+ },
2174
+ {
2175
+ "name": "deadline",
2176
+ "type": "uint256",
2177
+ "internalType": "uint256"
2178
+ },
2179
+ {
2180
+ "name": "feeRecipient",
2181
+ "type": "address",
2182
+ "internalType": "address"
2183
+ },
2184
+ {
2185
+ "name": "feeAmount",
2186
+ "type": "uint256",
2187
+ "internalType": "uint256"
2188
+ }
2189
+ ]
2190
+ },
2191
+ {
2192
+ "name": "leafIndices",
2193
+ "type": "uint32[]",
2194
+ "indexed": false,
2195
+ "internalType": "uint32[]"
2196
+ },
2197
+ {
2198
+ "name": "deliveries",
2199
+ "type": "tuple[]",
2200
+ "indexed": false,
2201
+ "internalType": "struct IInvisiProtocol.Delivery[]",
2202
+ "components": [
2203
+ {
2204
+ "name": "ciphertext",
2205
+ "type": "bytes",
2206
+ "internalType": "bytes"
2207
+ },
2208
+ {
2209
+ "name": "clue",
2210
+ "type": "bytes",
2211
+ "internalType": "bytes"
2212
+ }
2213
+ ]
2214
+ }
2215
+ ],
2216
+ "anonymous": false
2217
+ },
2218
+ {
2219
+ "type": "event",
2220
+ "name": "CreditRevoked",
2221
+ "inputs": [
2222
+ {
2223
+ "name": "owner",
2224
+ "type": "address",
2225
+ "indexed": true,
2226
+ "internalType": "address"
2227
+ },
2228
+ {
2229
+ "name": "token",
2230
+ "type": "address",
2231
+ "indexed": true,
2232
+ "internalType": "address"
2233
+ },
2234
+ {
2235
+ "name": "shard",
2236
+ "type": "uint64",
2237
+ "indexed": true,
2238
+ "internalType": "uint64"
2239
+ },
2240
+ {
2241
+ "name": "slot",
2242
+ "type": "uint16",
2243
+ "indexed": false,
2244
+ "internalType": "uint16"
2245
+ },
2246
+ {
2247
+ "name": "feeRecipient",
2248
+ "type": "address",
2249
+ "indexed": false,
2250
+ "internalType": "address"
2251
+ },
2252
+ {
2253
+ "name": "feeAmount",
2254
+ "type": "uint256",
2255
+ "indexed": false,
2256
+ "internalType": "uint256"
2257
+ }
2258
+ ],
2259
+ "anonymous": false
2260
+ },
2261
+ {
2262
+ "type": "event",
2263
+ "name": "CreditUpdated",
2264
+ "inputs": [
2265
+ {
2266
+ "name": "owner",
2267
+ "type": "address",
2268
+ "indexed": true,
2269
+ "internalType": "address"
2270
+ },
2271
+ {
2272
+ "name": "outputTreeId",
2273
+ "type": "uint256",
2274
+ "indexed": true,
2275
+ "internalType": "uint256"
2276
+ },
2277
+ {
2278
+ "name": "params",
2279
+ "type": "tuple",
2280
+ "indexed": false,
2281
+ "internalType": "struct IInvisiProtocol.UpdateCreditParams",
2282
+ "components": [
2283
+ {
2284
+ "name": "token",
2285
+ "type": "address",
2286
+ "internalType": "address"
2287
+ },
2288
+ {
2289
+ "name": "owner",
2290
+ "type": "address",
2291
+ "internalType": "address"
2292
+ },
2293
+ {
2294
+ "name": "source",
2295
+ "type": "tuple",
2296
+ "internalType": "struct IInvisiProtocol.InputSource",
2297
+ "components": [
2298
+ {
2299
+ "name": "treeId",
2300
+ "type": "uint256",
2301
+ "internalType": "uint256"
2302
+ },
2303
+ {
2304
+ "name": "merkleRoot",
2305
+ "type": "bytes32",
2306
+ "internalType": "bytes32"
2307
+ }
2308
+ ]
2309
+ },
2310
+ {
2311
+ "name": "nullifier",
2312
+ "type": "bytes32",
2313
+ "internalType": "bytes32"
2314
+ },
2315
+ {
2316
+ "name": "creditCommitment",
2317
+ "type": "bytes32",
2318
+ "internalType": "bytes32"
2319
+ },
2320
+ {
2321
+ "name": "revocationShard",
2322
+ "type": "uint64",
2323
+ "internalType": "uint64"
2324
+ },
2325
+ {
2326
+ "name": "revocationSlot",
2327
+ "type": "uint16",
2328
+ "internalType": "uint16"
2329
+ },
2330
+ {
2331
+ "name": "deadline",
2332
+ "type": "uint256",
2333
+ "internalType": "uint256"
2334
+ },
2335
+ {
2336
+ "name": "feeRecipient",
2337
+ "type": "address",
2338
+ "internalType": "address"
2339
+ },
2340
+ {
2341
+ "name": "feeAmount",
2342
+ "type": "uint256",
2343
+ "internalType": "uint256"
2344
+ }
2345
+ ]
2346
+ },
2347
+ {
2348
+ "name": "leafIndex",
2349
+ "type": "uint32",
2350
+ "indexed": false,
2351
+ "internalType": "uint32"
2352
+ },
2353
+ {
2354
+ "name": "deliveries",
2355
+ "type": "tuple[]",
2356
+ "indexed": false,
2357
+ "internalType": "struct IInvisiProtocol.Delivery[]",
2358
+ "components": [
2359
+ {
2360
+ "name": "ciphertext",
2361
+ "type": "bytes",
2362
+ "internalType": "bytes"
2363
+ },
2364
+ {
2365
+ "name": "clue",
2366
+ "type": "bytes",
2367
+ "internalType": "bytes"
2368
+ }
2369
+ ]
2370
+ }
2371
+ ],
2372
+ "anonymous": false
2373
+ },
2374
+ {
2375
+ "type": "event",
2376
+ "name": "CrossTreeTransact",
2377
+ "inputs": [
2378
+ {
2379
+ "name": "token",
2380
+ "type": "address",
2381
+ "indexed": false,
2382
+ "internalType": "address"
2383
+ },
2384
+ {
2385
+ "name": "outputTreeId",
2386
+ "type": "uint256",
2387
+ "indexed": true,
2388
+ "internalType": "uint256"
2389
+ },
2390
+ {
2391
+ "name": "sources",
2392
+ "type": "tuple[]",
2393
+ "indexed": false,
2394
+ "internalType": "struct IInvisiProtocol.InputSource[]",
2395
+ "components": [
2396
+ {
2397
+ "name": "treeId",
2398
+ "type": "uint256",
2399
+ "internalType": "uint256"
2400
+ },
2401
+ {
2402
+ "name": "merkleRoot",
2403
+ "type": "bytes32",
2404
+ "internalType": "bytes32"
2405
+ }
2406
+ ]
2407
+ },
2408
+ {
2409
+ "name": "nullifiers",
2410
+ "type": "bytes32[]",
2411
+ "indexed": false,
2412
+ "internalType": "bytes32[]"
2413
+ },
2414
+ {
2415
+ "name": "noteCommitments",
2416
+ "type": "bytes32[]",
2417
+ "indexed": false,
2418
+ "internalType": "bytes32[]"
2419
+ },
2420
+ {
2421
+ "name": "leafIndices",
2422
+ "type": "uint32[]",
2423
+ "indexed": false,
2424
+ "internalType": "uint32[]"
2425
+ },
2426
+ {
2427
+ "name": "deliveries",
2428
+ "type": "tuple[]",
2429
+ "indexed": false,
2430
+ "internalType": "struct IInvisiProtocol.Delivery[]",
2431
+ "components": [
2432
+ {
2433
+ "name": "ciphertext",
2434
+ "type": "bytes",
2435
+ "internalType": "bytes"
2436
+ },
2437
+ {
2438
+ "name": "clue",
2439
+ "type": "bytes",
2440
+ "internalType": "bytes"
2441
+ }
2442
+ ]
2443
+ },
2444
+ {
2445
+ "name": "withdrawalAddress",
2446
+ "type": "address",
2447
+ "indexed": false,
2448
+ "internalType": "address"
2449
+ },
2450
+ {
2451
+ "name": "withdrawalAmount",
2452
+ "type": "uint256",
2453
+ "indexed": false,
2454
+ "internalType": "uint256"
2455
+ },
2456
+ {
2457
+ "name": "deadline",
2458
+ "type": "uint256",
2459
+ "indexed": false,
2460
+ "internalType": "uint256"
2461
+ }
2462
+ ],
2463
+ "anonymous": false
2464
+ },
2465
+ {
2466
+ "type": "event",
2467
+ "name": "EIP712DomainChanged",
2468
+ "inputs": [],
2469
+ "anonymous": false
2470
+ },
2471
+ {
2472
+ "type": "event",
2473
+ "name": "NonceInvalidated",
2474
+ "inputs": [
2475
+ {
2476
+ "name": "signer",
2477
+ "type": "address",
2478
+ "indexed": true,
2479
+ "internalType": "address"
2480
+ },
2481
+ {
2482
+ "name": "newNonce",
2483
+ "type": "uint256",
2484
+ "indexed": false,
2485
+ "internalType": "uint256"
2486
+ }
2487
+ ],
2488
+ "anonymous": false
2489
+ },
2490
+ {
2491
+ "type": "event",
2492
+ "name": "OwnershipTransferStarted",
2493
+ "inputs": [
2494
+ {
2495
+ "name": "previousOwner",
2496
+ "type": "address",
2497
+ "indexed": true,
2498
+ "internalType": "address"
2499
+ },
2500
+ {
2501
+ "name": "newOwner",
2502
+ "type": "address",
2503
+ "indexed": true,
2504
+ "internalType": "address"
2505
+ }
2506
+ ],
2507
+ "anonymous": false
2508
+ },
2509
+ {
2510
+ "type": "event",
2511
+ "name": "OwnershipTransferred",
2512
+ "inputs": [
2513
+ {
2514
+ "name": "previousOwner",
2515
+ "type": "address",
2516
+ "indexed": true,
2517
+ "internalType": "address"
2518
+ },
2519
+ {
2520
+ "name": "newOwner",
2521
+ "type": "address",
2522
+ "indexed": true,
2523
+ "internalType": "address"
2524
+ }
2525
+ ],
2526
+ "anonymous": false
2527
+ },
2528
+ {
2529
+ "type": "event",
2530
+ "name": "Paused",
2531
+ "inputs": [
2532
+ {
2533
+ "name": "account",
2534
+ "type": "address",
2535
+ "indexed": false,
2536
+ "internalType": "address"
2537
+ }
2538
+ ],
2539
+ "anonymous": false
2540
+ },
2541
+ {
2542
+ "type": "event",
2543
+ "name": "PublicDeposit",
2544
+ "inputs": [
2545
+ {
2546
+ "name": "token",
2547
+ "type": "address",
2548
+ "indexed": true,
2549
+ "internalType": "address"
2550
+ },
2551
+ {
2552
+ "name": "payer",
2553
+ "type": "address",
2554
+ "indexed": true,
2555
+ "internalType": "address"
2556
+ },
2557
+ {
2558
+ "name": "amount",
2559
+ "type": "uint256",
2560
+ "indexed": false,
2561
+ "internalType": "uint256"
2562
+ },
2563
+ {
2564
+ "name": "proofHash",
2565
+ "type": "bytes32",
2566
+ "indexed": false,
2567
+ "internalType": "bytes32"
2568
+ }
2569
+ ],
2570
+ "anonymous": false
2571
+ },
2572
+ {
2573
+ "type": "event",
2574
+ "name": "ScreenerUpdated",
2575
+ "inputs": [
2576
+ {
2577
+ "name": "newScreener",
2578
+ "type": "address",
2579
+ "indexed": true,
2580
+ "internalType": "address"
2581
+ }
2582
+ ],
2583
+ "anonymous": false
2584
+ },
2585
+ {
2586
+ "type": "event",
2587
+ "name": "Shield",
2588
+ "inputs": [
2589
+ {
2590
+ "name": "token",
2591
+ "type": "address",
2592
+ "indexed": true,
2593
+ "internalType": "address"
2594
+ },
2595
+ {
2596
+ "name": "payer",
2597
+ "type": "address",
2598
+ "indexed": true,
2599
+ "internalType": "address"
2600
+ },
2601
+ {
2602
+ "name": "amount",
2603
+ "type": "uint256",
2604
+ "indexed": false,
2605
+ "internalType": "uint256"
2606
+ },
2607
+ {
2608
+ "name": "treeId",
2609
+ "type": "uint256",
2610
+ "indexed": true,
2611
+ "internalType": "uint256"
2612
+ },
2613
+ {
2614
+ "name": "startLeafIndex",
2615
+ "type": "uint32",
2616
+ "indexed": false,
2617
+ "internalType": "uint32"
2618
+ },
2619
+ {
2620
+ "name": "deliveries",
2621
+ "type": "tuple[]",
2622
+ "indexed": false,
2623
+ "internalType": "struct IInvisiProtocol.Delivery[]",
2624
+ "components": [
2625
+ {
2626
+ "name": "ciphertext",
2627
+ "type": "bytes",
2628
+ "internalType": "bytes"
2629
+ },
2630
+ {
2631
+ "name": "clue",
2632
+ "type": "bytes",
2633
+ "internalType": "bytes"
2634
+ }
2635
+ ]
2636
+ },
2637
+ {
2638
+ "name": "deadline",
2639
+ "type": "uint256",
2640
+ "indexed": false,
2641
+ "internalType": "uint256"
2642
+ }
2643
+ ],
2644
+ "anonymous": false
2645
+ },
2646
+ {
2647
+ "type": "event",
2648
+ "name": "Transact",
2649
+ "inputs": [
2650
+ {
2651
+ "name": "token",
2652
+ "type": "address",
2653
+ "indexed": false,
2654
+ "internalType": "address"
2655
+ },
2656
+ {
2657
+ "name": "inputTreeId",
2658
+ "type": "uint256",
2659
+ "indexed": true,
2660
+ "internalType": "uint256"
2661
+ },
2662
+ {
2663
+ "name": "outputTreeId",
2664
+ "type": "uint256",
2665
+ "indexed": true,
2666
+ "internalType": "uint256"
2667
+ },
2668
+ {
2669
+ "name": "nullifiers",
2670
+ "type": "bytes32[]",
2671
+ "indexed": false,
2672
+ "internalType": "bytes32[]"
2673
+ },
2674
+ {
2675
+ "name": "noteCommitments",
2676
+ "type": "bytes32[]",
2677
+ "indexed": false,
2678
+ "internalType": "bytes32[]"
2679
+ },
2680
+ {
2681
+ "name": "leafIndices",
2682
+ "type": "uint32[]",
2683
+ "indexed": false,
2684
+ "internalType": "uint32[]"
2685
+ },
2686
+ {
2687
+ "name": "deliveries",
2688
+ "type": "tuple[]",
2689
+ "indexed": false,
2690
+ "internalType": "struct IInvisiProtocol.Delivery[]",
2691
+ "components": [
2692
+ {
2693
+ "name": "ciphertext",
2694
+ "type": "bytes",
2695
+ "internalType": "bytes"
2696
+ },
2697
+ {
2698
+ "name": "clue",
2699
+ "type": "bytes",
2700
+ "internalType": "bytes"
2701
+ }
2702
+ ]
2703
+ },
2704
+ {
2705
+ "name": "withdrawalAddress",
2706
+ "type": "address",
2707
+ "indexed": false,
2708
+ "internalType": "address"
2709
+ },
2710
+ {
2711
+ "name": "withdrawalAmount",
2712
+ "type": "uint256",
2713
+ "indexed": false,
2714
+ "internalType": "uint256"
2715
+ },
2716
+ {
2717
+ "name": "deadline",
2718
+ "type": "uint256",
2719
+ "indexed": false,
2720
+ "internalType": "uint256"
2721
+ }
2722
+ ],
2723
+ "anonymous": false
2724
+ },
2725
+ {
2726
+ "type": "event",
2727
+ "name": "TransactAggregated",
2728
+ "inputs": [
2729
+ {
2730
+ "name": "proofHash",
2731
+ "type": "bytes32",
2732
+ "indexed": true,
2733
+ "internalType": "bytes32"
2734
+ },
2735
+ {
2736
+ "name": "requestCount",
2737
+ "type": "uint256",
2738
+ "indexed": false,
2739
+ "internalType": "uint256"
2740
+ }
2741
+ ],
2742
+ "anonymous": false
2743
+ },
2744
+ {
2745
+ "type": "event",
2746
+ "name": "TreeCreated",
2747
+ "inputs": [
2748
+ {
2749
+ "name": "treeId",
2750
+ "type": "uint256",
2751
+ "indexed": true,
2752
+ "internalType": "uint256"
2753
+ }
2754
+ ],
2755
+ "anonymous": false
2756
+ },
2757
+ {
2758
+ "type": "event",
2759
+ "name": "Unpaused",
2760
+ "inputs": [
2761
+ {
2762
+ "name": "account",
2763
+ "type": "address",
2764
+ "indexed": false,
2765
+ "internalType": "address"
2766
+ }
2767
+ ],
2768
+ "anonymous": false
2769
+ },
2770
+ {
2771
+ "type": "error",
2772
+ "name": "AddressEmptyCode",
2773
+ "inputs": [
2774
+ {
2775
+ "name": "target",
2776
+ "type": "address",
2777
+ "internalType": "address"
2778
+ }
2779
+ ]
2780
+ },
2781
+ {
2782
+ "type": "error",
2783
+ "name": "AddressInsufficientBalance",
2784
+ "inputs": [
2785
+ {
2786
+ "name": "account",
2787
+ "type": "address",
2788
+ "internalType": "address"
2789
+ }
2790
+ ]
2791
+ },
2792
+ {
2793
+ "type": "error",
2794
+ "name": "AddressScreeningFailed",
2795
+ "inputs": [
2796
+ {
2797
+ "name": "account",
2798
+ "type": "address",
2799
+ "internalType": "address"
2800
+ }
2801
+ ]
2802
+ },
2803
+ {
2804
+ "type": "error",
2805
+ "name": "ChainIdMismatch",
2806
+ "inputs": []
2807
+ },
2808
+ {
2809
+ "type": "error",
2810
+ "name": "CommitmentAlreadyRegistered",
2811
+ "inputs": [
2812
+ {
2813
+ "name": "commitment",
2814
+ "type": "bytes32",
2815
+ "internalType": "bytes32"
2816
+ }
2817
+ ]
2818
+ },
2819
+ {
2820
+ "type": "error",
2821
+ "name": "CreditAlreadyRevoked",
2822
+ "inputs": []
2823
+ },
2824
+ {
2825
+ "type": "error",
2826
+ "name": "DoubleSpend",
2827
+ "inputs": [
2828
+ {
2829
+ "name": "nullifier",
2830
+ "type": "bytes32",
2831
+ "internalType": "bytes32"
2832
+ }
2833
+ ]
2834
+ },
2835
+ {
2836
+ "type": "error",
2837
+ "name": "EnforcedPause",
2838
+ "inputs": []
2839
+ },
2840
+ {
2841
+ "type": "error",
2842
+ "name": "ExpectedPause",
2843
+ "inputs": []
2844
+ },
2845
+ {
2846
+ "type": "error",
2847
+ "name": "FailedInnerCall",
2848
+ "inputs": []
2849
+ },
2850
+ {
2851
+ "type": "error",
2852
+ "name": "InexactTokenReceipt",
2853
+ "inputs": [
2854
+ {
2855
+ "name": "requested",
2856
+ "type": "uint256",
2857
+ "internalType": "uint256"
2858
+ },
2859
+ {
2860
+ "name": "received",
2861
+ "type": "uint256",
2862
+ "internalType": "uint256"
2863
+ }
2864
+ ]
2865
+ },
2866
+ {
2867
+ "type": "error",
2868
+ "name": "InvalidAddressRegistry",
2869
+ "inputs": []
2870
+ },
2871
+ {
2872
+ "type": "error",
2873
+ "name": "InvalidAggregateBatch",
2874
+ "inputs": []
2875
+ },
2876
+ {
2877
+ "type": "error",
2878
+ "name": "InvalidAmount",
2879
+ "inputs": []
2880
+ },
2881
+ {
2882
+ "type": "error",
2883
+ "name": "InvalidBatchSize",
2884
+ "inputs": []
2885
+ },
2886
+ {
2887
+ "type": "error",
2888
+ "name": "InvalidCommitment",
2889
+ "inputs": []
2890
+ },
2891
+ {
2892
+ "type": "error",
2893
+ "name": "InvalidCreditAllocation",
2894
+ "inputs": []
2895
+ },
2896
+ {
2897
+ "type": "error",
2898
+ "name": "InvalidDelivery",
2899
+ "inputs": []
2900
+ },
2901
+ {
2902
+ "type": "error",
2903
+ "name": "InvalidFunding",
2904
+ "inputs": []
2905
+ },
2906
+ {
2907
+ "type": "error",
2908
+ "name": "InvalidMerkleRoot",
2909
+ "inputs": [
2910
+ {
2911
+ "name": "root",
2912
+ "type": "bytes32",
2913
+ "internalType": "bytes32"
2914
+ }
2915
+ ]
2916
+ },
2917
+ {
2918
+ "type": "error",
2919
+ "name": "InvalidNonce",
2920
+ "inputs": []
2921
+ },
2922
+ {
2923
+ "type": "error",
2924
+ "name": "InvalidPrivateTransferContext",
2925
+ "inputs": []
2926
+ },
2927
+ {
2928
+ "type": "error",
2929
+ "name": "InvalidPrivateTransferShape",
2930
+ "inputs": [
2931
+ {
2932
+ "name": "inputs",
2933
+ "type": "uint256",
2934
+ "internalType": "uint256"
2935
+ },
2936
+ {
2937
+ "name": "outputs",
2938
+ "type": "uint256",
2939
+ "internalType": "uint256"
2940
+ }
2941
+ ]
2942
+ },
2943
+ {
2944
+ "type": "error",
2945
+ "name": "InvalidProof",
2946
+ "inputs": []
2947
+ },
2948
+ {
2949
+ "type": "error",
2950
+ "name": "InvalidReceivingAddress",
2951
+ "inputs": []
2952
+ },
2953
+ {
2954
+ "type": "error",
2955
+ "name": "InvalidShieldContext",
2956
+ "inputs": []
2957
+ },
2958
+ {
2959
+ "type": "error",
2960
+ "name": "InvalidShieldOutputCount",
2961
+ "inputs": [
2962
+ {
2963
+ "name": "outputs",
2964
+ "type": "uint256",
2965
+ "internalType": "uint256"
2966
+ }
2967
+ ]
2968
+ },
2969
+ {
2970
+ "type": "error",
2971
+ "name": "InvalidShortString",
2972
+ "inputs": []
2973
+ },
2974
+ {
2975
+ "type": "error",
2976
+ "name": "InvalidSignature",
2977
+ "inputs": []
2978
+ },
2979
+ {
2980
+ "type": "error",
2981
+ "name": "InvalidToken",
2982
+ "inputs": [
2983
+ {
2984
+ "name": "token",
2985
+ "type": "address",
2986
+ "internalType": "address"
2987
+ }
2988
+ ]
2989
+ },
2990
+ {
2991
+ "type": "error",
2992
+ "name": "InvalidTree",
2993
+ "inputs": [
2994
+ {
2995
+ "name": "treeId",
2996
+ "type": "uint256",
2997
+ "internalType": "uint256"
2998
+ }
2999
+ ]
3000
+ },
3001
+ {
3002
+ "type": "error",
3003
+ "name": "LengthMismatch",
3004
+ "inputs": []
3005
+ },
3006
+ {
3007
+ "type": "error",
3008
+ "name": "NoBroadcasterFees",
3009
+ "inputs": []
3010
+ },
3011
+ {
3012
+ "type": "error",
3013
+ "name": "NotEmergencyAdmin",
3014
+ "inputs": []
3015
+ },
3016
+ {
3017
+ "type": "error",
3018
+ "name": "NotGlobalEmergency",
3019
+ "inputs": []
3020
+ },
3021
+ {
3022
+ "type": "error",
3023
+ "name": "OwnableInvalidOwner",
3024
+ "inputs": [
3025
+ {
3026
+ "name": "owner",
3027
+ "type": "address",
3028
+ "internalType": "address"
3029
+ }
3030
+ ]
3031
+ },
3032
+ {
3033
+ "type": "error",
3034
+ "name": "OwnableUnauthorizedAccount",
3035
+ "inputs": [
3036
+ {
3037
+ "name": "account",
3038
+ "type": "address",
3039
+ "internalType": "address"
3040
+ }
3041
+ ]
3042
+ },
3043
+ {
3044
+ "type": "error",
3045
+ "name": "PrivateTransferExpired",
3046
+ "inputs": []
3047
+ },
3048
+ {
3049
+ "type": "error",
3050
+ "name": "ReentrancyGuardReentrantCall",
3051
+ "inputs": []
3052
+ },
3053
+ {
3054
+ "type": "error",
3055
+ "name": "SafeERC20FailedOperation",
3056
+ "inputs": [
3057
+ {
3058
+ "name": "token",
3059
+ "type": "address",
3060
+ "internalType": "address"
3061
+ }
3062
+ ]
3063
+ },
3064
+ {
3065
+ "type": "error",
3066
+ "name": "ShieldExpired",
3067
+ "inputs": []
3068
+ },
3069
+ {
3070
+ "type": "error",
3071
+ "name": "SignatureExpired",
3072
+ "inputs": []
3073
+ },
3074
+ {
3075
+ "type": "error",
3076
+ "name": "StaleRoot",
3077
+ "inputs": [
3078
+ {
3079
+ "name": "root",
3080
+ "type": "bytes32",
3081
+ "internalType": "bytes32"
3082
+ }
3083
+ ]
3084
+ },
3085
+ {
3086
+ "type": "error",
3087
+ "name": "StringTooLong",
3088
+ "inputs": [
3089
+ {
3090
+ "name": "str",
3091
+ "type": "string",
3092
+ "internalType": "string"
3093
+ }
3094
+ ]
3095
+ },
3096
+ {
3097
+ "type": "error",
3098
+ "name": "ZeroNullifier",
3099
+ "inputs": []
3100
+ }
3101
+ ];
3102
+
3103
+ // src/note/calldata.ts
3104
+ function buildTransactCalldata(p) {
3105
+ const r = normalizeTransactRequest(p.context, p.params, p.deliveries, p.funding);
3106
+ validateFundingSubmission(r.funding, p.caller, p.context.now);
3107
+ const request = {
3108
+ params: {
3109
+ token: r.tokenAddress,
3110
+ sources: r.sources,
3111
+ nullifiers: r.nullifiers,
3112
+ noteCommitments: r.noteCommitments,
3113
+ withdrawalAddress: r.withdrawalAddress,
3114
+ withdrawalAmount: r.withdrawalAmount,
3115
+ deadline: r.deadline,
3116
+ feeRecipient: r.feeRecipient,
3117
+ feeAmount: r.feeAmount
3118
+ },
3119
+ deliveries: p.deliveries,
3120
+ funding: r.funding
3121
+ };
3122
+ const abi = invisiProtocolAbi.filter(
3123
+ (item) => item.type === "function" && item.name === "transact" && item.inputs.length === 2 && item.inputs[1]?.type === "tuple"
3124
+ );
3125
+ const data = new import_ethers3.Interface(abi).encodeFunctionData("transact", [p.proof, request]);
3126
+ return { data, capacity: r.capacity, approveAmount: r.depositAmount };
3127
+ }
3128
+
3129
+ // src/note/funding.ts
3130
+ var import_primitives2 = require("@invisi-labs/primitives");
3131
+ var import_ethers4 = require("ethers");
3132
+
3133
+ // src/note/abi-tuples.ts
3134
+ var singleTuple = [
3135
+ "(address token,bytes32 merkleRoot,bytes32[] nullifiers,bytes32[] noteCommitments,uint256 inputTreeId,address withdrawalAddress,uint256 withdrawalAmount,uint256 deadline,address feeRecipient,uint256 feeAmount)"
3136
+ ][0];
3137
+ var crossTuple = [
3138
+ "(address token,(uint256 treeId,bytes32 merkleRoot)[] sources,bytes32[] nullifiers,bytes32[] noteCommitments,address withdrawalAddress,uint256 withdrawalAmount,uint256 deadline,address feeRecipient,uint256 feeAmount)"
3139
+ ][0];
3140
+
3141
+ // src/note/funding.ts
3142
+ function encodeTransactTypedData(c, p, deliveries, f = {}) {
3143
+ const r = normalizeTransactRequest(c, p, deliveries, f);
3144
+ return (0, import_primitives2.walletAuthorizationTypedData)({
3145
+ context: { chainId: r.chainId, protocolAddress: BigInt(r.protocolAddress) },
3146
+ operation: "transact",
3147
+ capacity: r.capacity,
3148
+ words: transactPublicInputs(c, p, deliveries, f).map(BigInt)
3149
+ });
3150
+ }
3151
+ function transactFundingRequestHash(proof, p, cs) {
3152
+ const single = {
3153
+ token: p.token,
3154
+ merkleRoot: p.sources[0]?.merkleRoot ?? word(0n),
3155
+ nullifiers: p.nullifiers,
3156
+ noteCommitments: p.noteCommitments,
3157
+ inputTreeId: p.sources[0]?.treeId ?? 0n,
3158
+ withdrawalAddress: p.withdrawalAddress,
3159
+ withdrawalAmount: p.withdrawalAmount,
3160
+ deadline: p.deadline,
3161
+ feeRecipient: p.feeRecipient ?? "0x0000000000000000000000000000000000000000",
3162
+ feeAmount: p.feeAmount ?? 0n
3163
+ };
3164
+ return p.sources.length > 1 ? (0, import_ethers4.keccak256)(
3165
+ import_ethers4.AbiCoder.defaultAbiCoder().encode(
3166
+ [{ type: "bytes32" }, { type: "bytes32" }, crossTuple, { type: "bytes32" }].map(
3167
+ (parameter) => import_ethers4.ParamType.from(parameter)
3168
+ ),
3169
+ [
3170
+ (0, import_ethers4.keccak256)(new TextEncoder().encode("InvisiCrossTreeTransact")),
3171
+ (0, import_ethers4.keccak256)(proof),
3172
+ { ...p, feeRecipient: single.feeRecipient, feeAmount: single.feeAmount },
3173
+ deliveriesHash(cs)
3174
+ ]
3175
+ )
3176
+ ) : (0, import_ethers4.keccak256)(
3177
+ import_ethers4.AbiCoder.defaultAbiCoder().encode(
3178
+ [{ type: "bytes32" }, singleTuple, { type: "bytes32" }].map(
3179
+ (parameter) => import_ethers4.ParamType.from(parameter)
3180
+ ),
3181
+ [(0, import_ethers4.keccak256)(proof), single, deliveriesHash(cs)]
3182
+ )
3183
+ );
3184
+ }
3185
+ function encodeTransactFundingTypedData(c, proof, p, cs, funding) {
3186
+ normalizeTransactRequest(c, p, cs, funding);
3187
+ const f = normalizeFunding(funding);
3188
+ if (f.amount === 0n) throw new Error("funding authorization requires positive deposit");
3189
+ return {
3190
+ domain: getEIP712Domain(c),
3191
+ primaryType: "FundTransact",
3192
+ types: { FundTransact: fundingFields },
3193
+ message: {
3194
+ requestHash: transactFundingRequestHash(proof, p, cs),
3195
+ payer: f.payer,
3196
+ amount: f.amount,
3197
+ sigNonce: f.sigNonce,
3198
+ deadline: f.deadline
3199
+ }
3200
+ };
3201
+ }
3202
+
3203
+ // src/note/aggregate-routes.ts
3204
+ var AGGREGATE_ROUTES = Object.freeze(
3205
+ [
3206
+ ...Array.from({ length: 10 }, (_, i) => i + 1).flatMap(
3207
+ (capacity) => [1, 2, 5].map((count) => ({
3208
+ kind: "dedicated",
3209
+ capacity,
3210
+ count,
3211
+ name: `transact_aggregate_${capacity}_${count}`,
3212
+ publicInputCount: (17 + 3 * capacity) * count + 1
3213
+ }))
3214
+ ),
3215
+ ...[2, 3, 4, 5].map((count) => ({
3216
+ kind: "mixed",
3217
+ capacity: 0,
3218
+ count,
3219
+ name: `transact_aggregate_mixed_1_5_${count}`,
3220
+ publicInputCount: 33 * count + 5
3221
+ }))
3222
+ ].map((route) => Object.freeze(route))
3223
+ );
3224
+ function selectAggregateRoute(capacities) {
3225
+ if (!capacities.length || Array.from(
3226
+ { length: capacities.length },
3227
+ (_, i) => Number.isInteger(capacities[i]) && capacities[i] >= 1 && capacities[i] <= 10
3228
+ ).some((v) => !v))
3229
+ throw Error("unsupported aggregate capacities");
3230
+ const count = capacities.length, dedicated = AGGREGATE_ROUTES.find(
3231
+ (r) => r.kind === "dedicated" && r.capacity === capacities[0] && r.count === count
3232
+ );
3233
+ if (dedicated && capacities.every((c) => c === capacities[0])) return dedicated;
3234
+ const mixed = AGGREGATE_ROUTES.find((r) => r.kind === "mixed" && r.count === count);
3235
+ if (mixed && capacities.every((c) => c <= 5)) return mixed;
3236
+ throw Error("unsupported aggregate capacity/count combination");
3237
+ }
3238
+
3239
+ // src/note/aggregate.ts
3240
+ var import_ethers5 = require("ethers");
3241
+ function buildTransactAggregateCalldata(p) {
3242
+ const route = selectAggregateRoute(
3243
+ dense(p.requests, "requests").map(
3244
+ (r) => selectTransactCapacity(r.params.nullifiers.length, r.params.noteCommitments.length)
3245
+ )
3246
+ );
3247
+ const requests = p.requests.map((request) => {
3248
+ const r = normalizeTransactRequest(
3249
+ { ...p.context, tokenAddress: request.params.token },
3250
+ request.params,
3251
+ request.deliveries,
3252
+ request.funding
3253
+ );
3254
+ if (r.capacity > 10) throw Error("aggregate supports C1..C10");
3255
+ validateFundingSubmission(r.funding, p.caller, p.context.now);
3256
+ return {
3257
+ ...request,
3258
+ params: { ...request.params, feeRecipient: r.feeRecipient, feeAmount: r.feeAmount }
3259
+ };
3260
+ });
3261
+ const approvalRequirements = [];
3262
+ for (const request of requests) {
3263
+ const funding = normalizeFunding(request.funding);
3264
+ if (funding.amount === 0n) continue;
3265
+ const token = request.params.token;
3266
+ const existing = approvalRequirements.find(
3267
+ (item) => item.token.toLowerCase() === token.toLowerCase() && item.payer.toLowerCase() === funding.payer.toLowerCase()
3268
+ );
3269
+ if (existing) existing.amount += funding.amount;
3270
+ else approvalRequirements.push({ token, payer: funding.payer, amount: funding.amount });
3271
+ }
3272
+ return {
3273
+ data: new import_ethers5.Interface(
3274
+ invisiProtocolAbi.filter(
3275
+ (item) => item.type === "function" && item.name === "transact" && item.inputs[1]?.type === "tuple[]"
3276
+ )
3277
+ ).encodeFunctionData("transact", [p.proof, requests]),
3278
+ capacity: route.capacity,
3279
+ approvalRequirements
3280
+ };
3281
+ }
3282
+ function aggregateMemberRequestHash(c, r) {
3283
+ const capacity = selectTransactCapacity(
3284
+ r.params.nullifiers.length,
3285
+ r.params.noteCommitments.length
3286
+ );
3287
+ if (capacity > 10) throw Error("aggregate supports C1..C10");
3288
+ return (0, import_ethers5.keccak256)(
3289
+ import_ethers5.AbiCoder.defaultAbiCoder().encode(
3290
+ ["bytes32", "uint256", "bytes32[]"].map((parameter) => import_ethers5.ParamType.from(parameter)),
3291
+ [
3292
+ (0, import_ethers5.keccak256)(new TextEncoder().encode("InvisiAtomicBatchMemberV1")),
3293
+ BigInt(capacity),
3294
+ transactPublicInputs(c, r.params, r.deliveries, r.funding)
3295
+ ]
3296
+ )
3297
+ );
3298
+ }
3299
+ function aggregatePublicInputs(c, requests) {
3300
+ selectAggregateRoute(
3301
+ dense(requests, "requests").map(
3302
+ (r) => selectTransactCapacity(r.params.nullifiers.length, r.params.noteCommitments.length)
3303
+ )
3304
+ );
3305
+ return requests.flatMap((r) => {
3306
+ const context = { ...c, tokenAddress: r.params.token };
3307
+ aggregateMemberRequestHash(context, r);
3308
+ return [
3309
+ word(
3310
+ BigInt(
3311
+ selectTransactCapacity(
3312
+ r.params.nullifiers.length,
3313
+ r.params.noteCommitments.length
3314
+ )
3315
+ )
3316
+ ),
3317
+ ...transactPublicInputs(context, r.params, r.deliveries, r.funding)
3318
+ ];
3319
+ });
3320
+ }
3321
+ function encodeAggregateFundingTypedData(c, r) {
3322
+ const f = normalizeFunding(r.funding);
3323
+ if (f.amount === 0n) throw new Error("funding authorization requires positive deposit");
3324
+ return {
3325
+ domain: getEIP712Domain(c),
3326
+ primaryType: "FundTransact",
3327
+ types: { FundTransact: fundingFields },
3328
+ message: {
3329
+ requestHash: aggregateMemberRequestHash(c, r),
3330
+ payer: f.payer,
3331
+ amount: f.amount,
3332
+ sigNonce: f.sigNonce,
3333
+ deadline: f.deadline
3334
+ }
3335
+ };
3336
+ }
3337
+
3338
+ // src/note/shield.ts
3339
+ var import_primitives3 = require("@invisi-labs/primitives");
3340
+ var import_ethers7 = require("ethers");
3341
+
3342
+ // src/fees/fee.ts
3343
+ var import_ethers6 = require("ethers");
3344
+ function normalizeFee(p) {
3345
+ const feeRecipient = (0, import_ethers6.getAddress)(p.feeRecipient ?? ZERO_ADDRESS);
3346
+ const feeAmount = uint(p.feeAmount ?? 0n, 128, "feeAmount");
3347
+ if (BigInt(feeRecipient) === 0n !== (feeAmount === 0n))
3348
+ throw new Error("invalid fee context");
3349
+ return { feeRecipient, feeAmount };
3350
+ }
3351
+
3352
+ // src/note/shield.ts
3353
+ async function validateShieldRequest(p) {
3354
+ normalizeContext(p.context);
3355
+ if ((0, import_ethers7.getAddress)(p.params.token) !== (0, import_ethers7.getAddress)(p.context.tokenAddress))
3356
+ throw new Error("request token mismatch");
3357
+ known(p.params, ["token", "noteCommitments", "deadline", "feeRecipient", "feeAmount"]);
3358
+ checkDeadline(p.context, p.params.deadline);
3359
+ const outputs = dense(p.outputs, "outputs"), commitments = notes(p.params.noteCommitments, "noteCommitments"), cs = dense(p.deliveries, "deliveries"), f = normalizeFunding(p.funding);
3360
+ if (outputs.length < 1 || outputs.length > 10 || commitments.length !== outputs.length || cs.length !== outputs.length)
3361
+ throw new Error("shield requires 1..10 outputs and matching deliveries");
3362
+ let total = 0n;
3363
+ for (const [i, o] of outputs.entries()) {
3364
+ known(o, ["identity", "amount"], "output");
3365
+ uint(o.amount, 128, "amount");
3366
+ if (o.amount === 0n) throw new Error("amount must be positive");
3367
+ field(o.identity);
3368
+ normalizeOpaqueDelivery(cs[i], { allowEmpty: true });
3369
+ if (await (0, import_primitives3.computeNoteCommitment)(
3370
+ p.context.chainId,
3371
+ BigInt(p.context.protocolAddress),
3372
+ o.identity,
3373
+ BigInt(p.context.tokenAddress),
3374
+ o.amount
3375
+ ) !== commitments[i])
3376
+ throw new Error("output commitment mismatch");
3377
+ total += o.amount;
3378
+ }
3379
+ if (total + normalizeFee(p.params).feeAmount !== f.amount)
3380
+ throw new Error("funding must equal output total plus fee");
3381
+ return f;
3382
+ }
3383
+ async function encodeShieldFundingTypedData(p) {
3384
+ const f = await validateShieldRequest(p);
3385
+ return {
3386
+ domain: getEIP712Domain(p.context),
3387
+ primaryType: "FundShield",
3388
+ types: { FundShield: fundingFields },
3389
+ message: {
3390
+ requestHash: shieldFundingRequestHash(p.params, p.outputs, p.deliveries),
3391
+ payer: f.payer,
3392
+ amount: f.amount,
3393
+ sigNonce: f.sigNonce,
3394
+ deadline: f.deadline
3395
+ }
3396
+ };
3397
+ }
3398
+ async function buildShieldCalldata(p) {
3399
+ const f = await validateShieldRequest(p);
3400
+ validateFundingSubmission(f, p.caller, p.context.now);
3401
+ return {
3402
+ data: new import_ethers7.Interface(invisiProtocolAbi).encodeFunctionData("shield", [
3403
+ { ...p.params, ...normalizeFee(p.params) },
3404
+ p.outputs,
3405
+ p.deliveries,
3406
+ f
3407
+ ]),
3408
+ approveAmount: f.amount
3409
+ };
3410
+ }
3411
+ function shieldFundingRequestHash(params, outputs, cs) {
3412
+ const outputHash = (0, import_ethers7.keccak256)(
3413
+ import_ethers7.AbiCoder.defaultAbiCoder().encode(
3414
+ ["(bytes32 identity,uint256 amount)[]"].map((parameter) => import_ethers7.ParamType.from(parameter)),
3415
+ [outputs]
3416
+ )
3417
+ );
3418
+ return (0, import_ethers7.keccak256)(
3419
+ import_ethers7.AbiCoder.defaultAbiCoder().encode(
3420
+ [
3421
+ "bytes32",
3422
+ "(address token,bytes32[] noteCommitments,uint256 deadline,address feeRecipient,uint256 feeAmount)",
3423
+ "bytes32",
3424
+ "bytes32"
3425
+ ].map((parameter) => import_ethers7.ParamType.from(parameter)),
3426
+ [
3427
+ (0, import_ethers7.keccak256)(new TextEncoder().encode("InvisiShield")),
3428
+ { ...params, ...normalizeFee(params) },
3429
+ outputHash,
3430
+ deliveriesHash(cs)
3431
+ ]
3432
+ )
3433
+ );
3434
+ }
3435
+ // Annotate the CommonJS export names for ESM import in node:
3436
+ 0 && (module.exports = {
3437
+ AGGREGATE_ROUTES,
3438
+ TRANSACT_CAPACITIES,
3439
+ aggregateMemberRequestHash,
3440
+ aggregatePublicInputs,
3441
+ buildShieldCalldata,
3442
+ buildTransactAggregateCalldata,
3443
+ buildTransactCalldata,
3444
+ encodeAggregateFundingTypedData,
3445
+ encodeShieldFundingTypedData,
3446
+ encodeTransactFundingTypedData,
3447
+ encodeTransactTypedData,
3448
+ normalizeTransactRequest,
3449
+ selectAggregateRoute,
3450
+ selectTransactCapacity,
3451
+ shieldFundingRequestHash,
3452
+ transactFundingRequestHash,
3453
+ transactPublicInputs,
3454
+ validateShieldRequest
3455
+ });
3456
+ //# sourceMappingURL=note.cjs.map