@invisi-labs/protocol 1.1.7 → 1.2.1

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