@skalenetwork/privacy-sdk 0.1.0-develop.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.
@@ -0,0 +1,2982 @@
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/actions/index.ts
21
+ var actions_exports = {};
22
+ __export(actions_exports, {
23
+ approve: () => approve,
24
+ authorizeHistoricViewForRange: () => authorizeHistoricViewForRange,
25
+ authorizeHistoricViewForTransfer: () => authorizeHistoricViewForTransfer,
26
+ decryptHistoricTransferData: () => decryptHistoricTransferData,
27
+ decryptTokenBalance: () => decryptTokenBalance,
28
+ fundCtxBalance: () => fundCtxBalance,
29
+ getCtxBalance: () => getCtxBalance,
30
+ getCtxFee: () => getCtxFee,
31
+ getTransferId: () => getTransferId,
32
+ getValueForCtx: () => getValueForCtx,
33
+ registerViewerKey: () => registerViewerKey,
34
+ requestTransferDecryption: () => requestTransferDecryption,
35
+ revokeHistoricView: () => revokeHistoricView,
36
+ transfer: () => transfer,
37
+ unwrap: () => unwrap,
38
+ wrap: () => wrap
39
+ });
40
+ module.exports = __toCommonJS(actions_exports);
41
+
42
+ // src/actions/transfers.ts
43
+ var import_viem2 = require("viem");
44
+
45
+ // src/abi/confidentialWrapper.ts
46
+ var confidentialWrapperAbi = [
47
+ {
48
+ inputs: [
49
+ {
50
+ internalType: "contract IERC20Metadata",
51
+ name: "underlyingToken",
52
+ type: "address"
53
+ },
54
+ {
55
+ internalType: "string",
56
+ name: "version_",
57
+ type: "string"
58
+ },
59
+ {
60
+ internalType: "address",
61
+ name: "initialAuthority",
62
+ type: "address"
63
+ }
64
+ ],
65
+ stateMutability: "nonpayable",
66
+ type: "constructor"
67
+ },
68
+ {
69
+ inputs: [
70
+ {
71
+ internalType: "address",
72
+ name: "authority",
73
+ type: "address"
74
+ }
75
+ ],
76
+ name: "AccessManagedInvalidAuthority",
77
+ type: "error"
78
+ },
79
+ {
80
+ inputs: [
81
+ {
82
+ internalType: "address",
83
+ name: "caller",
84
+ type: "address"
85
+ },
86
+ {
87
+ internalType: "uint32",
88
+ name: "delay",
89
+ type: "uint32"
90
+ }
91
+ ],
92
+ name: "AccessManagedRequiredDelay",
93
+ type: "error"
94
+ },
95
+ {
96
+ inputs: [
97
+ {
98
+ internalType: "address",
99
+ name: "caller",
100
+ type: "address"
101
+ }
102
+ ],
103
+ name: "AccessManagedUnauthorized",
104
+ type: "error"
105
+ },
106
+ {
107
+ inputs: [],
108
+ name: "AccessViolation",
109
+ type: "error"
110
+ },
111
+ {
112
+ inputs: [],
113
+ name: "ActionNotRecognized",
114
+ type: "error"
115
+ },
116
+ {
117
+ inputs: [
118
+ {
119
+ internalType: "uint256",
120
+ name: "validBefore",
121
+ type: "uint256"
122
+ }
123
+ ],
124
+ name: "AuthorizationIsExpired",
125
+ type: "error"
126
+ },
127
+ {
128
+ inputs: [
129
+ {
130
+ internalType: "uint256",
131
+ name: "validAfter",
132
+ type: "uint256"
133
+ }
134
+ ],
135
+ name: "AuthorizationIsNotYetValid",
136
+ type: "error"
137
+ },
138
+ {
139
+ inputs: [
140
+ {
141
+ internalType: "address",
142
+ name: "authorizer",
143
+ type: "address"
144
+ },
145
+ {
146
+ internalType: "bytes32",
147
+ name: "nonce",
148
+ type: "bytes32"
149
+ }
150
+ ],
151
+ name: "AuthorizationUsedError",
152
+ type: "error"
153
+ },
154
+ {
155
+ inputs: [
156
+ {
157
+ internalType: "uint256",
158
+ name: "errorCode",
159
+ type: "uint256"
160
+ }
161
+ ],
162
+ name: "CTXAbiToRlpConversionFailed",
163
+ type: "error"
164
+ },
165
+ {
166
+ inputs: [
167
+ {
168
+ internalType: "uint256",
169
+ name: "errorCode",
170
+ type: "uint256"
171
+ }
172
+ ],
173
+ name: "CTXAbiToRlpUnknownError",
174
+ type: "error"
175
+ },
176
+ {
177
+ inputs: [
178
+ {
179
+ internalType: "uint256",
180
+ name: "errorCode",
181
+ type: "uint256"
182
+ }
183
+ ],
184
+ name: "CTXCountNotVerifyTransaction",
185
+ type: "error"
186
+ },
187
+ {
188
+ inputs: [
189
+ {
190
+ internalType: "uint256",
191
+ name: "errorCode",
192
+ type: "uint256"
193
+ }
194
+ ],
195
+ name: "CTXDataOffsetOutOfBounds",
196
+ type: "error"
197
+ },
198
+ {
199
+ inputs: [
200
+ {
201
+ internalType: "uint256",
202
+ name: "errorCode",
203
+ type: "uint256"
204
+ }
205
+ ],
206
+ name: "CTXDataTooShort",
207
+ type: "error"
208
+ },
209
+ {
210
+ inputs: [
211
+ {
212
+ internalType: "uint256",
213
+ name: "errorCode",
214
+ type: "uint256"
215
+ }
216
+ ],
217
+ name: "CTXInputTooShort",
218
+ type: "error"
219
+ },
220
+ {
221
+ inputs: [
222
+ {
223
+ internalType: "uint256",
224
+ name: "errorCode",
225
+ type: "uint256"
226
+ }
227
+ ],
228
+ name: "CTXInvalidDestination",
229
+ type: "error"
230
+ },
231
+ {
232
+ inputs: [
233
+ {
234
+ internalType: "uint256",
235
+ name: "errorCode",
236
+ type: "uint256"
237
+ }
238
+ ],
239
+ name: "CTXInvalidGasLimit",
240
+ type: "error"
241
+ },
242
+ {
243
+ inputs: [
244
+ {
245
+ internalType: "uint256",
246
+ name: "errorCode",
247
+ type: "uint256"
248
+ }
249
+ ],
250
+ name: "CTXInvalidSignature",
251
+ type: "error"
252
+ },
253
+ {
254
+ inputs: [
255
+ {
256
+ internalType: "uint256",
257
+ name: "errorCode",
258
+ type: "uint256"
259
+ }
260
+ ],
261
+ name: "CTXInvalidTransaction",
262
+ type: "error"
263
+ },
264
+ {
265
+ inputs: [
266
+ {
267
+ internalType: "uint256",
268
+ name: "errorCode",
269
+ type: "uint256"
270
+ }
271
+ ],
272
+ name: "CTXUnknownError",
273
+ type: "error"
274
+ },
275
+ {
276
+ inputs: [
277
+ {
278
+ internalType: "address",
279
+ name: "caller",
280
+ type: "address"
281
+ },
282
+ {
283
+ internalType: "address",
284
+ name: "payee",
285
+ type: "address"
286
+ }
287
+ ],
288
+ name: "CallerMustBeThePayee",
289
+ type: "error"
290
+ },
291
+ {
292
+ inputs: [
293
+ {
294
+ internalType: "uint256",
295
+ name: "errorCode",
296
+ type: "uint256"
297
+ }
298
+ ],
299
+ name: "DataLengthMismatch",
300
+ type: "error"
301
+ },
302
+ {
303
+ inputs: [],
304
+ name: "DecryptionBadFormat",
305
+ type: "error"
306
+ },
307
+ {
308
+ inputs: [],
309
+ name: "ECDSAInvalidSignature",
310
+ type: "error"
311
+ },
312
+ {
313
+ inputs: [
314
+ {
315
+ internalType: "uint256",
316
+ name: "length",
317
+ type: "uint256"
318
+ }
319
+ ],
320
+ name: "ECDSAInvalidSignatureLength",
321
+ type: "error"
322
+ },
323
+ {
324
+ inputs: [
325
+ {
326
+ internalType: "bytes32",
327
+ name: "s",
328
+ type: "bytes32"
329
+ }
330
+ ],
331
+ name: "ECDSAInvalidSignatureS",
332
+ type: "error"
333
+ },
334
+ {
335
+ inputs: [
336
+ {
337
+ internalType: "uint256",
338
+ name: "errorCode",
339
+ type: "uint256"
340
+ }
341
+ ],
342
+ name: "ECIESEncryptionFailed",
343
+ type: "error"
344
+ },
345
+ {
346
+ inputs: [
347
+ {
348
+ internalType: "uint256",
349
+ name: "errorCode",
350
+ type: "uint256"
351
+ }
352
+ ],
353
+ name: "ECIESInvalidPublicKey",
354
+ type: "error"
355
+ },
356
+ {
357
+ inputs: [
358
+ {
359
+ internalType: "address",
360
+ name: "spender",
361
+ type: "address"
362
+ },
363
+ {
364
+ internalType: "uint256",
365
+ name: "allowance",
366
+ type: "uint256"
367
+ },
368
+ {
369
+ internalType: "uint256",
370
+ name: "needed",
371
+ type: "uint256"
372
+ }
373
+ ],
374
+ name: "ERC20InsufficientAllowance",
375
+ type: "error"
376
+ },
377
+ {
378
+ inputs: [
379
+ {
380
+ internalType: "address",
381
+ name: "sender",
382
+ type: "address"
383
+ },
384
+ {
385
+ internalType: "uint256",
386
+ name: "balance",
387
+ type: "uint256"
388
+ },
389
+ {
390
+ internalType: "uint256",
391
+ name: "needed",
392
+ type: "uint256"
393
+ }
394
+ ],
395
+ name: "ERC20InsufficientBalance",
396
+ type: "error"
397
+ },
398
+ {
399
+ inputs: [
400
+ {
401
+ internalType: "address",
402
+ name: "approver",
403
+ type: "address"
404
+ }
405
+ ],
406
+ name: "ERC20InvalidApprover",
407
+ type: "error"
408
+ },
409
+ {
410
+ inputs: [
411
+ {
412
+ internalType: "address",
413
+ name: "receiver",
414
+ type: "address"
415
+ }
416
+ ],
417
+ name: "ERC20InvalidReceiver",
418
+ type: "error"
419
+ },
420
+ {
421
+ inputs: [
422
+ {
423
+ internalType: "address",
424
+ name: "sender",
425
+ type: "address"
426
+ }
427
+ ],
428
+ name: "ERC20InvalidSender",
429
+ type: "error"
430
+ },
431
+ {
432
+ inputs: [
433
+ {
434
+ internalType: "address",
435
+ name: "spender",
436
+ type: "address"
437
+ }
438
+ ],
439
+ name: "ERC20InvalidSpender",
440
+ type: "error"
441
+ },
442
+ {
443
+ inputs: [
444
+ {
445
+ internalType: "address",
446
+ name: "token",
447
+ type: "address"
448
+ }
449
+ ],
450
+ name: "ERC20InvalidUnderlying",
451
+ type: "error"
452
+ },
453
+ {
454
+ inputs: [
455
+ {
456
+ internalType: "uint256",
457
+ name: "deadline",
458
+ type: "uint256"
459
+ }
460
+ ],
461
+ name: "ERC2612ExpiredSignature",
462
+ type: "error"
463
+ },
464
+ {
465
+ inputs: [
466
+ {
467
+ internalType: "address",
468
+ name: "signer",
469
+ type: "address"
470
+ },
471
+ {
472
+ internalType: "address",
473
+ name: "owner",
474
+ type: "address"
475
+ }
476
+ ],
477
+ name: "ERC2612InvalidSigner",
478
+ type: "error"
479
+ },
480
+ {
481
+ inputs: [
482
+ {
483
+ internalType: "address",
484
+ name: "precompiledContract",
485
+ type: "address"
486
+ }
487
+ ],
488
+ name: "EmptyReturnData",
489
+ type: "error"
490
+ },
491
+ {
492
+ inputs: [],
493
+ name: "FailedCall",
494
+ type: "error"
495
+ },
496
+ {
497
+ inputs: [
498
+ {
499
+ internalType: "address",
500
+ name: "precompiledContract",
501
+ type: "address"
502
+ },
503
+ {
504
+ internalType: "uint256",
505
+ name: "expected",
506
+ type: "uint256"
507
+ },
508
+ {
509
+ internalType: "uint256",
510
+ name: "actual",
511
+ type: "uint256"
512
+ }
513
+ ],
514
+ name: "IncorrectReturnDataLength",
515
+ type: "error"
516
+ },
517
+ {
518
+ inputs: [
519
+ {
520
+ internalType: "uint256",
521
+ name: "errorCode",
522
+ type: "uint256"
523
+ }
524
+ ],
525
+ name: "InputNot32ByteAligned",
526
+ type: "error"
527
+ },
528
+ {
529
+ inputs: [
530
+ {
531
+ internalType: "uint256",
532
+ name: "errorCode",
533
+ type: "uint256"
534
+ }
535
+ ],
536
+ name: "InputTooLarge",
537
+ type: "error"
538
+ },
539
+ {
540
+ inputs: [
541
+ {
542
+ internalType: "uint256",
543
+ name: "errorCode",
544
+ type: "uint256"
545
+ }
546
+ ],
547
+ name: "InputTooShort",
548
+ type: "error"
549
+ },
550
+ {
551
+ inputs: [
552
+ {
553
+ internalType: "uint256",
554
+ name: "balance",
555
+ type: "uint256"
556
+ },
557
+ {
558
+ internalType: "uint256",
559
+ name: "needed",
560
+ type: "uint256"
561
+ }
562
+ ],
563
+ name: "InsufficientBalance",
564
+ type: "error"
565
+ },
566
+ {
567
+ inputs: [],
568
+ name: "InsufficientBalance",
569
+ type: "error"
570
+ },
571
+ {
572
+ inputs: [
573
+ {
574
+ internalType: "uint256",
575
+ name: "required",
576
+ type: "uint256"
577
+ },
578
+ {
579
+ internalType: "uint256",
580
+ name: "available",
581
+ type: "uint256"
582
+ }
583
+ ],
584
+ name: "InsufficientGasToken",
585
+ type: "error"
586
+ },
587
+ {
588
+ inputs: [
589
+ {
590
+ internalType: "address",
591
+ name: "account",
592
+ type: "address"
593
+ },
594
+ {
595
+ internalType: "uint256",
596
+ name: "currentNonce",
597
+ type: "uint256"
598
+ }
599
+ ],
600
+ name: "InvalidAccountNonce",
601
+ type: "error"
602
+ },
603
+ {
604
+ inputs: [
605
+ {
606
+ internalType: "uint256",
607
+ name: "errorCode",
608
+ type: "uint256"
609
+ }
610
+ ],
611
+ name: "InvalidDataOffset",
612
+ type: "error"
613
+ },
614
+ {
615
+ inputs: [],
616
+ name: "InvalidPublicKey",
617
+ type: "error"
618
+ },
619
+ {
620
+ inputs: [
621
+ {
622
+ internalType: "address",
623
+ name: "precompiledContract",
624
+ type: "address"
625
+ },
626
+ {
627
+ internalType: "uint256",
628
+ name: "expectedMin",
629
+ type: "uint256"
630
+ },
631
+ {
632
+ internalType: "uint256",
633
+ name: "actual",
634
+ type: "uint256"
635
+ }
636
+ ],
637
+ name: "InvalidReturnDataSize",
638
+ type: "error"
639
+ },
640
+ {
641
+ inputs: [],
642
+ name: "InvalidShortString",
643
+ type: "error"
644
+ },
645
+ {
646
+ inputs: [],
647
+ name: "InvalidSignature",
648
+ type: "error"
649
+ },
650
+ {
651
+ inputs: [
652
+ {
653
+ internalType: "uint256",
654
+ name: "fromTimestamp",
655
+ type: "uint256"
656
+ },
657
+ {
658
+ internalType: "uint256",
659
+ name: "toTimestamp",
660
+ type: "uint256"
661
+ }
662
+ ],
663
+ name: "InvalidTimeRange",
664
+ type: "error"
665
+ },
666
+ {
667
+ inputs: [
668
+ {
669
+ internalType: "uint256",
670
+ name: "transferId",
671
+ type: "uint256"
672
+ }
673
+ ],
674
+ name: "InvalidTransferId",
675
+ type: "error"
676
+ },
677
+ {
678
+ inputs: [
679
+ {
680
+ internalType: "address",
681
+ name: "holder",
682
+ type: "address"
683
+ }
684
+ ],
685
+ name: "NoViewerRegisteredForHolder",
686
+ type: "error"
687
+ },
688
+ {
689
+ inputs: [
690
+ {
691
+ internalType: "address",
692
+ name: "to",
693
+ type: "address"
694
+ },
695
+ {
696
+ internalType: "uint256",
697
+ name: "value",
698
+ type: "uint256"
699
+ }
700
+ ],
701
+ name: "OutdatedMint",
702
+ type: "error"
703
+ },
704
+ {
705
+ inputs: [
706
+ {
707
+ internalType: "address",
708
+ name: "viewer",
709
+ type: "address"
710
+ }
711
+ ],
712
+ name: "PublicKeyIsNotRegistered",
713
+ type: "error"
714
+ },
715
+ {
716
+ inputs: [
717
+ {
718
+ internalType: "address",
719
+ name: "token",
720
+ type: "address"
721
+ }
722
+ ],
723
+ name: "SafeERC20FailedOperation",
724
+ type: "error"
725
+ },
726
+ {
727
+ inputs: [
728
+ {
729
+ internalType: "string",
730
+ name: "str",
731
+ type: "string"
732
+ }
733
+ ],
734
+ name: "StringTooLong",
735
+ type: "error"
736
+ },
737
+ {
738
+ inputs: [
739
+ {
740
+ internalType: "uint256",
741
+ name: "errorCode",
742
+ type: "uint256"
743
+ }
744
+ ],
745
+ name: "TrailingPaddingNotZeros",
746
+ type: "error"
747
+ },
748
+ {
749
+ inputs: [
750
+ {
751
+ internalType: "uint256",
752
+ name: "errorCode",
753
+ type: "uint256"
754
+ }
755
+ ],
756
+ name: "UnknownEncryptionError",
757
+ type: "error"
758
+ },
759
+ {
760
+ inputs: [
761
+ {
762
+ internalType: "bytes",
763
+ name: "errorData",
764
+ type: "bytes"
765
+ }
766
+ ],
767
+ name: "UnknownError",
768
+ type: "error"
769
+ },
770
+ {
771
+ inputs: [
772
+ {
773
+ internalType: "address",
774
+ name: "viewer",
775
+ type: "address"
776
+ },
777
+ {
778
+ internalType: "uint256",
779
+ name: "transferId",
780
+ type: "uint256"
781
+ }
782
+ ],
783
+ name: "UserIsNotAuthorizedToDecryptTransfer",
784
+ type: "error"
785
+ },
786
+ {
787
+ inputs: [],
788
+ name: "ValueIsEncrypted",
789
+ type: "error"
790
+ },
791
+ {
792
+ inputs: [],
793
+ name: "ValueWasNotEncryptedCorrectly",
794
+ type: "error"
795
+ },
796
+ {
797
+ inputs: [],
798
+ name: "WrongPlaintextFormat",
799
+ type: "error"
800
+ },
801
+ {
802
+ inputs: [],
803
+ name: "ZeroAddress",
804
+ type: "error"
805
+ },
806
+ {
807
+ inputs: [],
808
+ name: "ZeroValue",
809
+ type: "error"
810
+ },
811
+ {
812
+ anonymous: false,
813
+ inputs: [
814
+ {
815
+ indexed: true,
816
+ internalType: "address",
817
+ name: "owner",
818
+ type: "address"
819
+ },
820
+ {
821
+ indexed: true,
822
+ internalType: "address",
823
+ name: "spender",
824
+ type: "address"
825
+ },
826
+ {
827
+ indexed: false,
828
+ internalType: "uint256",
829
+ name: "value",
830
+ type: "uint256"
831
+ }
832
+ ],
833
+ name: "Approval",
834
+ type: "event"
835
+ },
836
+ {
837
+ anonymous: false,
838
+ inputs: [
839
+ {
840
+ indexed: false,
841
+ internalType: "address",
842
+ name: "authority",
843
+ type: "address"
844
+ }
845
+ ],
846
+ name: "AuthorityUpdated",
847
+ type: "event"
848
+ },
849
+ {
850
+ anonymous: false,
851
+ inputs: [
852
+ {
853
+ indexed: true,
854
+ internalType: "address",
855
+ name: "authorizer",
856
+ type: "address"
857
+ },
858
+ {
859
+ indexed: true,
860
+ internalType: "bytes32",
861
+ name: "nonce",
862
+ type: "bytes32"
863
+ }
864
+ ],
865
+ name: "AuthorizationCanceled",
866
+ type: "event"
867
+ },
868
+ {
869
+ anonymous: false,
870
+ inputs: [
871
+ {
872
+ indexed: true,
873
+ internalType: "address",
874
+ name: "authorizer",
875
+ type: "address"
876
+ },
877
+ {
878
+ indexed: true,
879
+ internalType: "bytes32",
880
+ name: "nonce",
881
+ type: "bytes32"
882
+ }
883
+ ],
884
+ name: "AuthorizationUsed",
885
+ type: "event"
886
+ },
887
+ {
888
+ anonymous: false,
889
+ inputs: [
890
+ {
891
+ indexed: true,
892
+ internalType: "address",
893
+ name: "callbackSender",
894
+ type: "address"
895
+ }
896
+ ],
897
+ name: "CTXResubmitted",
898
+ type: "event"
899
+ },
900
+ {
901
+ anonymous: false,
902
+ inputs: [
903
+ {
904
+ indexed: true,
905
+ internalType: "address",
906
+ name: "callbackSender",
907
+ type: "address"
908
+ }
909
+ ],
910
+ name: "CTXSubmitted",
911
+ type: "event"
912
+ },
913
+ {
914
+ anonymous: false,
915
+ inputs: [
916
+ {
917
+ indexed: true,
918
+ internalType: "uint256",
919
+ name: "newFee",
920
+ type: "uint256"
921
+ }
922
+ ],
923
+ name: "CallbackFeeChanged",
924
+ type: "event"
925
+ },
926
+ {
927
+ anonymous: false,
928
+ inputs: [],
929
+ name: "EIP712DomainChanged",
930
+ type: "event"
931
+ },
932
+ {
933
+ anonymous: false,
934
+ inputs: [
935
+ {
936
+ indexed: true,
937
+ internalType: "address",
938
+ name: "newAddress",
939
+ type: "address"
940
+ }
941
+ ],
942
+ name: "EncryptECIESAddressChanged",
943
+ type: "event"
944
+ },
945
+ {
946
+ anonymous: false,
947
+ inputs: [
948
+ {
949
+ indexed: true,
950
+ internalType: "address",
951
+ name: "newAddress",
952
+ type: "address"
953
+ }
954
+ ],
955
+ name: "EncryptTEAddressChanged",
956
+ type: "event"
957
+ },
958
+ {
959
+ anonymous: false,
960
+ inputs: [
961
+ {
962
+ indexed: true,
963
+ internalType: "uint256",
964
+ name: "transferId",
965
+ type: "uint256"
966
+ },
967
+ {
968
+ indexed: true,
969
+ internalType: "address",
970
+ name: "from",
971
+ type: "address"
972
+ },
973
+ {
974
+ indexed: true,
975
+ internalType: "address",
976
+ name: "to",
977
+ type: "address"
978
+ },
979
+ {
980
+ indexed: false,
981
+ internalType: "bytes",
982
+ name: "encryptedData",
983
+ type: "bytes"
984
+ }
985
+ ],
986
+ name: "EncryptedTransfer",
987
+ type: "event"
988
+ },
989
+ {
990
+ anonymous: false,
991
+ inputs: [
992
+ {
993
+ indexed: true,
994
+ internalType: "address",
995
+ name: "sender",
996
+ type: "address"
997
+ },
998
+ {
999
+ indexed: true,
1000
+ internalType: "address",
1001
+ name: "receiver",
1002
+ type: "address"
1003
+ },
1004
+ {
1005
+ indexed: true,
1006
+ internalType: "uint256",
1007
+ name: "value",
1008
+ type: "uint256"
1009
+ }
1010
+ ],
1011
+ name: "GasTokenBalanceToppedUp",
1012
+ type: "event"
1013
+ },
1014
+ {
1015
+ anonymous: false,
1016
+ inputs: [
1017
+ {
1018
+ indexed: true,
1019
+ internalType: "address",
1020
+ name: "receiver",
1021
+ type: "address"
1022
+ },
1023
+ {
1024
+ indexed: true,
1025
+ internalType: "uint256",
1026
+ name: "value",
1027
+ type: "uint256"
1028
+ }
1029
+ ],
1030
+ name: "GasTokenWithdrawn",
1031
+ type: "event"
1032
+ },
1033
+ {
1034
+ anonymous: false,
1035
+ inputs: [
1036
+ {
1037
+ indexed: true,
1038
+ internalType: "address",
1039
+ name: "holder",
1040
+ type: "address"
1041
+ },
1042
+ {
1043
+ indexed: true,
1044
+ internalType: "address",
1045
+ name: "viewer",
1046
+ type: "address"
1047
+ }
1048
+ ],
1049
+ name: "HistoricViewPermissionsRevoked",
1050
+ type: "event"
1051
+ },
1052
+ {
1053
+ anonymous: false,
1054
+ inputs: [
1055
+ {
1056
+ indexed: true,
1057
+ internalType: "address",
1058
+ name: "holder",
1059
+ type: "address"
1060
+ },
1061
+ {
1062
+ indexed: true,
1063
+ internalType: "address",
1064
+ name: "viewer",
1065
+ type: "address"
1066
+ },
1067
+ {
1068
+ indexed: false,
1069
+ internalType: "uint256",
1070
+ name: "fromTimestamp",
1071
+ type: "uint256"
1072
+ },
1073
+ {
1074
+ indexed: false,
1075
+ internalType: "uint256",
1076
+ name: "toTimestamp",
1077
+ type: "uint256"
1078
+ }
1079
+ ],
1080
+ name: "HistoricViewTimeRangeAuthorized",
1081
+ type: "event"
1082
+ },
1083
+ {
1084
+ anonymous: false,
1085
+ inputs: [
1086
+ {
1087
+ indexed: true,
1088
+ internalType: "address",
1089
+ name: "holder",
1090
+ type: "address"
1091
+ },
1092
+ {
1093
+ indexed: true,
1094
+ internalType: "address",
1095
+ name: "viewer",
1096
+ type: "address"
1097
+ }
1098
+ ],
1099
+ name: "HistoricViewTimeRangeRevoked",
1100
+ type: "event"
1101
+ },
1102
+ {
1103
+ anonymous: false,
1104
+ inputs: [
1105
+ {
1106
+ indexed: true,
1107
+ internalType: "address",
1108
+ name: "holder",
1109
+ type: "address"
1110
+ },
1111
+ {
1112
+ indexed: true,
1113
+ internalType: "address",
1114
+ name: "viewer",
1115
+ type: "address"
1116
+ },
1117
+ {
1118
+ indexed: true,
1119
+ internalType: "uint256",
1120
+ name: "transferId",
1121
+ type: "uint256"
1122
+ }
1123
+ ],
1124
+ name: "HistoricViewTransferIdAuthorized",
1125
+ type: "event"
1126
+ },
1127
+ {
1128
+ anonymous: false,
1129
+ inputs: [
1130
+ {
1131
+ indexed: true,
1132
+ internalType: "address",
1133
+ name: "holder",
1134
+ type: "address"
1135
+ },
1136
+ {
1137
+ indexed: true,
1138
+ internalType: "address",
1139
+ name: "viewer",
1140
+ type: "address"
1141
+ },
1142
+ {
1143
+ indexed: true,
1144
+ internalType: "uint256",
1145
+ name: "transferId",
1146
+ type: "uint256"
1147
+ }
1148
+ ],
1149
+ name: "HistoricViewTransferIdRevoked",
1150
+ type: "event"
1151
+ },
1152
+ {
1153
+ anonymous: false,
1154
+ inputs: [
1155
+ {
1156
+ indexed: true,
1157
+ internalType: "address",
1158
+ name: "viewer",
1159
+ type: "address"
1160
+ }
1161
+ ],
1162
+ name: "PublicKeyRegistered",
1163
+ type: "event"
1164
+ },
1165
+ {
1166
+ anonymous: false,
1167
+ inputs: [
1168
+ {
1169
+ indexed: true,
1170
+ internalType: "address",
1171
+ name: "viewer",
1172
+ type: "address"
1173
+ },
1174
+ {
1175
+ indexed: true,
1176
+ internalType: "address",
1177
+ name: "from",
1178
+ type: "address"
1179
+ },
1180
+ {
1181
+ indexed: true,
1182
+ internalType: "address",
1183
+ name: "to",
1184
+ type: "address"
1185
+ },
1186
+ {
1187
+ indexed: false,
1188
+ internalType: "bytes",
1189
+ name: "encryptedTransfer",
1190
+ type: "bytes"
1191
+ }
1192
+ ],
1193
+ name: "ReEncryptedTransfer",
1194
+ type: "event"
1195
+ },
1196
+ {
1197
+ anonymous: false,
1198
+ inputs: [
1199
+ {
1200
+ indexed: true,
1201
+ internalType: "address",
1202
+ name: "newAddress",
1203
+ type: "address"
1204
+ }
1205
+ ],
1206
+ name: "SubmitCTXAddressChanged",
1207
+ type: "event"
1208
+ },
1209
+ {
1210
+ anonymous: false,
1211
+ inputs: [
1212
+ {
1213
+ indexed: true,
1214
+ internalType: "address",
1215
+ name: "from",
1216
+ type: "address"
1217
+ },
1218
+ {
1219
+ indexed: true,
1220
+ internalType: "address",
1221
+ name: "to",
1222
+ type: "address"
1223
+ },
1224
+ {
1225
+ indexed: false,
1226
+ internalType: "uint256",
1227
+ name: "value",
1228
+ type: "uint256"
1229
+ }
1230
+ ],
1231
+ name: "Transfer",
1232
+ type: "event"
1233
+ },
1234
+ {
1235
+ anonymous: false,
1236
+ inputs: [
1237
+ {
1238
+ indexed: true,
1239
+ internalType: "address",
1240
+ name: "from",
1241
+ type: "address"
1242
+ },
1243
+ {
1244
+ indexed: true,
1245
+ internalType: "address",
1246
+ name: "to",
1247
+ type: "address"
1248
+ }
1249
+ ],
1250
+ name: "Transfer",
1251
+ type: "event"
1252
+ },
1253
+ {
1254
+ anonymous: false,
1255
+ inputs: [
1256
+ {
1257
+ indexed: true,
1258
+ internalType: "address",
1259
+ name: "from",
1260
+ type: "address"
1261
+ },
1262
+ {
1263
+ indexed: true,
1264
+ internalType: "address",
1265
+ name: "to",
1266
+ type: "address"
1267
+ },
1268
+ {
1269
+ indexed: true,
1270
+ internalType: "uint256",
1271
+ name: "transferId",
1272
+ type: "uint256"
1273
+ },
1274
+ {
1275
+ indexed: false,
1276
+ internalType: "bytes",
1277
+ name: "encryptedValue",
1278
+ type: "bytes"
1279
+ }
1280
+ ],
1281
+ name: "TransferValueEncryptedForRecipient",
1282
+ type: "event"
1283
+ },
1284
+ {
1285
+ anonymous: false,
1286
+ inputs: [
1287
+ {
1288
+ indexed: true,
1289
+ internalType: "address",
1290
+ name: "from",
1291
+ type: "address"
1292
+ },
1293
+ {
1294
+ indexed: true,
1295
+ internalType: "address",
1296
+ name: "to",
1297
+ type: "address"
1298
+ },
1299
+ {
1300
+ indexed: true,
1301
+ internalType: "uint256",
1302
+ name: "transferId",
1303
+ type: "uint256"
1304
+ },
1305
+ {
1306
+ indexed: false,
1307
+ internalType: "bytes",
1308
+ name: "encryptedValue",
1309
+ type: "bytes"
1310
+ }
1311
+ ],
1312
+ name: "TransferValueEncryptedForSender",
1313
+ type: "event"
1314
+ },
1315
+ {
1316
+ anonymous: false,
1317
+ inputs: [
1318
+ {
1319
+ indexed: true,
1320
+ internalType: "address",
1321
+ name: "holder",
1322
+ type: "address"
1323
+ },
1324
+ {
1325
+ indexed: true,
1326
+ internalType: "address",
1327
+ name: "newViewer",
1328
+ type: "address"
1329
+ }
1330
+ ],
1331
+ name: "ViewerChanged",
1332
+ type: "event"
1333
+ },
1334
+ {
1335
+ inputs: [],
1336
+ name: "CANCEL_AUTHORIZATION_TYPEHASH",
1337
+ outputs: [
1338
+ {
1339
+ internalType: "bytes32",
1340
+ name: "",
1341
+ type: "bytes32"
1342
+ }
1343
+ ],
1344
+ stateMutability: "view",
1345
+ type: "function"
1346
+ },
1347
+ {
1348
+ inputs: [],
1349
+ name: "DOMAIN_SEPARATOR",
1350
+ outputs: [
1351
+ {
1352
+ internalType: "bytes32",
1353
+ name: "",
1354
+ type: "bytes32"
1355
+ }
1356
+ ],
1357
+ stateMutability: "view",
1358
+ type: "function"
1359
+ },
1360
+ {
1361
+ inputs: [],
1362
+ name: "ENCRYPTED_RECEIVE_WITH_AUTHORIZATION_TYPEHASH",
1363
+ outputs: [
1364
+ {
1365
+ internalType: "bytes32",
1366
+ name: "",
1367
+ type: "bytes32"
1368
+ }
1369
+ ],
1370
+ stateMutability: "view",
1371
+ type: "function"
1372
+ },
1373
+ {
1374
+ inputs: [],
1375
+ name: "ENCRYPTED_TRANSFER_WITH_AUTHORIZATION_TYPEHASH",
1376
+ outputs: [
1377
+ {
1378
+ internalType: "bytes32",
1379
+ name: "",
1380
+ type: "bytes32"
1381
+ }
1382
+ ],
1383
+ stateMutability: "view",
1384
+ type: "function"
1385
+ },
1386
+ {
1387
+ inputs: [],
1388
+ name: "RECEIVE_WITH_AUTHORIZATION_TYPEHASH",
1389
+ outputs: [
1390
+ {
1391
+ internalType: "bytes32",
1392
+ name: "",
1393
+ type: "bytes32"
1394
+ }
1395
+ ],
1396
+ stateMutability: "view",
1397
+ type: "function"
1398
+ },
1399
+ {
1400
+ inputs: [],
1401
+ name: "TRANSFER_WITH_AUTHORIZATION_TYPEHASH",
1402
+ outputs: [
1403
+ {
1404
+ internalType: "bytes32",
1405
+ name: "",
1406
+ type: "bytes32"
1407
+ }
1408
+ ],
1409
+ stateMutability: "view",
1410
+ type: "function"
1411
+ },
1412
+ {
1413
+ inputs: [
1414
+ {
1415
+ internalType: "address",
1416
+ name: "owner",
1417
+ type: "address"
1418
+ },
1419
+ {
1420
+ internalType: "address",
1421
+ name: "spender",
1422
+ type: "address"
1423
+ }
1424
+ ],
1425
+ name: "allowance",
1426
+ outputs: [
1427
+ {
1428
+ internalType: "uint256",
1429
+ name: "",
1430
+ type: "uint256"
1431
+ }
1432
+ ],
1433
+ stateMutability: "view",
1434
+ type: "function"
1435
+ },
1436
+ {
1437
+ inputs: [
1438
+ {
1439
+ internalType: "address",
1440
+ name: "spender",
1441
+ type: "address"
1442
+ },
1443
+ {
1444
+ internalType: "uint256",
1445
+ name: "value",
1446
+ type: "uint256"
1447
+ }
1448
+ ],
1449
+ name: "approve",
1450
+ outputs: [
1451
+ {
1452
+ internalType: "bool",
1453
+ name: "",
1454
+ type: "bool"
1455
+ }
1456
+ ],
1457
+ stateMutability: "nonpayable",
1458
+ type: "function"
1459
+ },
1460
+ {
1461
+ inputs: [],
1462
+ name: "authority",
1463
+ outputs: [
1464
+ {
1465
+ internalType: "address",
1466
+ name: "",
1467
+ type: "address"
1468
+ }
1469
+ ],
1470
+ stateMutability: "view",
1471
+ type: "function"
1472
+ },
1473
+ {
1474
+ inputs: [
1475
+ {
1476
+ internalType: "address",
1477
+ name: "authorizer",
1478
+ type: "address"
1479
+ },
1480
+ {
1481
+ internalType: "bytes32",
1482
+ name: "nonce",
1483
+ type: "bytes32"
1484
+ }
1485
+ ],
1486
+ name: "authorizationState",
1487
+ outputs: [
1488
+ {
1489
+ internalType: "bool",
1490
+ name: "used",
1491
+ type: "bool"
1492
+ }
1493
+ ],
1494
+ stateMutability: "view",
1495
+ type: "function"
1496
+ },
1497
+ {
1498
+ inputs: [
1499
+ {
1500
+ internalType: "address",
1501
+ name: "viewer",
1502
+ type: "address"
1503
+ },
1504
+ {
1505
+ internalType: "uint256",
1506
+ name: "fromTimestamp",
1507
+ type: "uint256"
1508
+ },
1509
+ {
1510
+ internalType: "uint256",
1511
+ name: "toTimestamp",
1512
+ type: "uint256"
1513
+ }
1514
+ ],
1515
+ name: "authorizeHistoricViewTimeRange",
1516
+ outputs: [
1517
+ {
1518
+ internalType: "bool",
1519
+ name: "success",
1520
+ type: "bool"
1521
+ }
1522
+ ],
1523
+ stateMutability: "nonpayable",
1524
+ type: "function"
1525
+ },
1526
+ {
1527
+ inputs: [
1528
+ {
1529
+ internalType: "address",
1530
+ name: "viewer",
1531
+ type: "address"
1532
+ },
1533
+ {
1534
+ internalType: "uint256",
1535
+ name: "transferId",
1536
+ type: "uint256"
1537
+ }
1538
+ ],
1539
+ name: "authorizeHistoricViewTransferId",
1540
+ outputs: [
1541
+ {
1542
+ internalType: "bool",
1543
+ name: "success",
1544
+ type: "bool"
1545
+ }
1546
+ ],
1547
+ stateMutability: "nonpayable",
1548
+ type: "function"
1549
+ },
1550
+ {
1551
+ inputs: [
1552
+ {
1553
+ internalType: "address",
1554
+ name: "account",
1555
+ type: "address"
1556
+ }
1557
+ ],
1558
+ name: "balanceOf",
1559
+ outputs: [
1560
+ {
1561
+ internalType: "uint256",
1562
+ name: "balance",
1563
+ type: "uint256"
1564
+ }
1565
+ ],
1566
+ stateMutability: "pure",
1567
+ type: "function"
1568
+ },
1569
+ {
1570
+ inputs: [],
1571
+ name: "callbackFee",
1572
+ outputs: [
1573
+ {
1574
+ internalType: "uint256",
1575
+ name: "",
1576
+ type: "uint256"
1577
+ }
1578
+ ],
1579
+ stateMutability: "view",
1580
+ type: "function"
1581
+ },
1582
+ {
1583
+ inputs: [
1584
+ {
1585
+ internalType: "address",
1586
+ name: "viewer",
1587
+ type: "address"
1588
+ },
1589
+ {
1590
+ internalType: "uint256",
1591
+ name: "transferId",
1592
+ type: "uint256"
1593
+ },
1594
+ {
1595
+ internalType: "address",
1596
+ name: "from",
1597
+ type: "address"
1598
+ },
1599
+ {
1600
+ internalType: "address",
1601
+ name: "to",
1602
+ type: "address"
1603
+ },
1604
+ {
1605
+ internalType: "uint256",
1606
+ name: "timestamp",
1607
+ type: "uint256"
1608
+ }
1609
+ ],
1610
+ name: "canDecryptHistoricTransfer",
1611
+ outputs: [
1612
+ {
1613
+ internalType: "bool",
1614
+ name: "canDecrypt",
1615
+ type: "bool"
1616
+ }
1617
+ ],
1618
+ stateMutability: "view",
1619
+ type: "function"
1620
+ },
1621
+ {
1622
+ inputs: [
1623
+ {
1624
+ internalType: "address",
1625
+ name: "authorizer",
1626
+ type: "address"
1627
+ },
1628
+ {
1629
+ internalType: "bytes32",
1630
+ name: "nonce",
1631
+ type: "bytes32"
1632
+ },
1633
+ {
1634
+ internalType: "uint8",
1635
+ name: "v",
1636
+ type: "uint8"
1637
+ },
1638
+ {
1639
+ internalType: "bytes32",
1640
+ name: "r",
1641
+ type: "bytes32"
1642
+ },
1643
+ {
1644
+ internalType: "bytes32",
1645
+ name: "s",
1646
+ type: "bytes32"
1647
+ }
1648
+ ],
1649
+ name: "cancelAuthorization",
1650
+ outputs: [],
1651
+ stateMutability: "nonpayable",
1652
+ type: "function"
1653
+ },
1654
+ {
1655
+ inputs: [],
1656
+ name: "decimals",
1657
+ outputs: [
1658
+ {
1659
+ internalType: "uint8",
1660
+ name: "decimalsValue",
1661
+ type: "uint8"
1662
+ }
1663
+ ],
1664
+ stateMutability: "view",
1665
+ type: "function"
1666
+ },
1667
+ {
1668
+ inputs: [
1669
+ {
1670
+ internalType: "address",
1671
+ name: "account",
1672
+ type: "address"
1673
+ },
1674
+ {
1675
+ internalType: "uint256",
1676
+ name: "value",
1677
+ type: "uint256"
1678
+ }
1679
+ ],
1680
+ name: "depositFor",
1681
+ outputs: [
1682
+ {
1683
+ internalType: "bool",
1684
+ name: "success",
1685
+ type: "bool"
1686
+ }
1687
+ ],
1688
+ stateMutability: "nonpayable",
1689
+ type: "function"
1690
+ },
1691
+ {
1692
+ inputs: [
1693
+ {
1694
+ internalType: "address",
1695
+ name: "account",
1696
+ type: "address"
1697
+ },
1698
+ {
1699
+ internalType: "uint256",
1700
+ name: "value",
1701
+ type: "uint256"
1702
+ }
1703
+ ],
1704
+ name: "depositForWithGasToken",
1705
+ outputs: [
1706
+ {
1707
+ internalType: "bool",
1708
+ name: "success",
1709
+ type: "bool"
1710
+ }
1711
+ ],
1712
+ stateMutability: "payable",
1713
+ type: "function"
1714
+ },
1715
+ {
1716
+ inputs: [],
1717
+ name: "eip712Domain",
1718
+ outputs: [
1719
+ {
1720
+ internalType: "bytes1",
1721
+ name: "fields",
1722
+ type: "bytes1"
1723
+ },
1724
+ {
1725
+ internalType: "string",
1726
+ name: "name",
1727
+ type: "string"
1728
+ },
1729
+ {
1730
+ internalType: "string",
1731
+ name: "version",
1732
+ type: "string"
1733
+ },
1734
+ {
1735
+ internalType: "uint256",
1736
+ name: "chainId",
1737
+ type: "uint256"
1738
+ },
1739
+ {
1740
+ internalType: "address",
1741
+ name: "verifyingContract",
1742
+ type: "address"
1743
+ },
1744
+ {
1745
+ internalType: "bytes32",
1746
+ name: "salt",
1747
+ type: "bytes32"
1748
+ },
1749
+ {
1750
+ internalType: "uint256[]",
1751
+ name: "extensions",
1752
+ type: "uint256[]"
1753
+ }
1754
+ ],
1755
+ stateMutability: "view",
1756
+ type: "function"
1757
+ },
1758
+ {
1759
+ inputs: [],
1760
+ name: "encryptECIESAddress",
1761
+ outputs: [
1762
+ {
1763
+ internalType: "address",
1764
+ name: "",
1765
+ type: "address"
1766
+ }
1767
+ ],
1768
+ stateMutability: "view",
1769
+ type: "function"
1770
+ },
1771
+ {
1772
+ inputs: [],
1773
+ name: "encryptTEAddress",
1774
+ outputs: [
1775
+ {
1776
+ internalType: "address",
1777
+ name: "",
1778
+ type: "address"
1779
+ }
1780
+ ],
1781
+ stateMutability: "view",
1782
+ type: "function"
1783
+ },
1784
+ {
1785
+ inputs: [
1786
+ {
1787
+ internalType: "address",
1788
+ name: "holder",
1789
+ type: "address"
1790
+ }
1791
+ ],
1792
+ name: "encryptedBalanceOf",
1793
+ outputs: [
1794
+ {
1795
+ internalType: "bytes",
1796
+ name: "encryptedBalance",
1797
+ type: "bytes"
1798
+ }
1799
+ ],
1800
+ stateMutability: "view",
1801
+ type: "function"
1802
+ },
1803
+ {
1804
+ inputs: [
1805
+ {
1806
+ internalType: "address",
1807
+ name: "from",
1808
+ type: "address"
1809
+ },
1810
+ {
1811
+ internalType: "address",
1812
+ name: "to",
1813
+ type: "address"
1814
+ },
1815
+ {
1816
+ internalType: "bytes",
1817
+ name: "value",
1818
+ type: "bytes"
1819
+ },
1820
+ {
1821
+ internalType: "uint256",
1822
+ name: "validAfter",
1823
+ type: "uint256"
1824
+ },
1825
+ {
1826
+ internalType: "uint256",
1827
+ name: "validBefore",
1828
+ type: "uint256"
1829
+ },
1830
+ {
1831
+ internalType: "bytes32",
1832
+ name: "nonce",
1833
+ type: "bytes32"
1834
+ },
1835
+ {
1836
+ internalType: "uint8",
1837
+ name: "v",
1838
+ type: "uint8"
1839
+ },
1840
+ {
1841
+ internalType: "bytes32",
1842
+ name: "r",
1843
+ type: "bytes32"
1844
+ },
1845
+ {
1846
+ internalType: "bytes32",
1847
+ name: "s",
1848
+ type: "bytes32"
1849
+ }
1850
+ ],
1851
+ name: "encryptedReceiveWithAuthorization",
1852
+ outputs: [],
1853
+ stateMutability: "nonpayable",
1854
+ type: "function"
1855
+ },
1856
+ {
1857
+ inputs: [
1858
+ {
1859
+ internalType: "address",
1860
+ name: "to",
1861
+ type: "address"
1862
+ },
1863
+ {
1864
+ internalType: "bytes",
1865
+ name: "value",
1866
+ type: "bytes"
1867
+ }
1868
+ ],
1869
+ name: "encryptedTransfer",
1870
+ outputs: [],
1871
+ stateMutability: "payable",
1872
+ type: "function"
1873
+ },
1874
+ {
1875
+ inputs: [
1876
+ {
1877
+ internalType: "address",
1878
+ name: "from",
1879
+ type: "address"
1880
+ },
1881
+ {
1882
+ internalType: "address",
1883
+ name: "to",
1884
+ type: "address"
1885
+ },
1886
+ {
1887
+ internalType: "bytes",
1888
+ name: "value",
1889
+ type: "bytes"
1890
+ }
1891
+ ],
1892
+ name: "encryptedTransferFrom",
1893
+ outputs: [],
1894
+ stateMutability: "payable",
1895
+ type: "function"
1896
+ },
1897
+ {
1898
+ inputs: [
1899
+ {
1900
+ internalType: "address",
1901
+ name: "from",
1902
+ type: "address"
1903
+ },
1904
+ {
1905
+ internalType: "address",
1906
+ name: "to",
1907
+ type: "address"
1908
+ },
1909
+ {
1910
+ internalType: "bytes",
1911
+ name: "value",
1912
+ type: "bytes"
1913
+ },
1914
+ {
1915
+ internalType: "uint256",
1916
+ name: "validAfter",
1917
+ type: "uint256"
1918
+ },
1919
+ {
1920
+ internalType: "uint256",
1921
+ name: "validBefore",
1922
+ type: "uint256"
1923
+ },
1924
+ {
1925
+ internalType: "bytes32",
1926
+ name: "nonce",
1927
+ type: "bytes32"
1928
+ },
1929
+ {
1930
+ internalType: "uint8",
1931
+ name: "v",
1932
+ type: "uint8"
1933
+ },
1934
+ {
1935
+ internalType: "bytes32",
1936
+ name: "r",
1937
+ type: "bytes32"
1938
+ },
1939
+ {
1940
+ internalType: "bytes32",
1941
+ name: "s",
1942
+ type: "bytes32"
1943
+ }
1944
+ ],
1945
+ name: "encryptedTransferWithAuthorization",
1946
+ outputs: [],
1947
+ stateMutability: "payable",
1948
+ type: "function"
1949
+ },
1950
+ {
1951
+ inputs: [
1952
+ {
1953
+ internalType: "address",
1954
+ name: "receiver",
1955
+ type: "address"
1956
+ }
1957
+ ],
1958
+ name: "fundWithGasToken",
1959
+ outputs: [],
1960
+ stateMutability: "payable",
1961
+ type: "function"
1962
+ },
1963
+ {
1964
+ inputs: [
1965
+ {
1966
+ internalType: "address",
1967
+ name: "holder",
1968
+ type: "address"
1969
+ }
1970
+ ],
1971
+ name: "gasTokenBalanceOf",
1972
+ outputs: [
1973
+ {
1974
+ internalType: "uint256",
1975
+ name: "balance",
1976
+ type: "uint256"
1977
+ }
1978
+ ],
1979
+ stateMutability: "view",
1980
+ type: "function"
1981
+ },
1982
+ {
1983
+ inputs: [],
1984
+ name: "isConsumingScheduledOp",
1985
+ outputs: [
1986
+ {
1987
+ internalType: "bytes4",
1988
+ name: "",
1989
+ type: "bytes4"
1990
+ }
1991
+ ],
1992
+ stateMutability: "view",
1993
+ type: "function"
1994
+ },
1995
+ {
1996
+ inputs: [],
1997
+ name: "name",
1998
+ outputs: [
1999
+ {
2000
+ internalType: "string",
2001
+ name: "",
2002
+ type: "string"
2003
+ }
2004
+ ],
2005
+ stateMutability: "view",
2006
+ type: "function"
2007
+ },
2008
+ {
2009
+ inputs: [
2010
+ {
2011
+ internalType: "address",
2012
+ name: "owner",
2013
+ type: "address"
2014
+ }
2015
+ ],
2016
+ name: "nonces",
2017
+ outputs: [
2018
+ {
2019
+ internalType: "uint256",
2020
+ name: "",
2021
+ type: "uint256"
2022
+ }
2023
+ ],
2024
+ stateMutability: "view",
2025
+ type: "function"
2026
+ },
2027
+ {
2028
+ inputs: [
2029
+ {
2030
+ internalType: "bytes[]",
2031
+ name: "decryptedArguments",
2032
+ type: "bytes[]"
2033
+ },
2034
+ {
2035
+ internalType: "bytes[]",
2036
+ name: "plaintextArguments",
2037
+ type: "bytes[]"
2038
+ }
2039
+ ],
2040
+ name: "onDecrypt",
2041
+ outputs: [],
2042
+ stateMutability: "nonpayable",
2043
+ type: "function"
2044
+ },
2045
+ {
2046
+ inputs: [
2047
+ {
2048
+ internalType: "address",
2049
+ name: "owner",
2050
+ type: "address"
2051
+ },
2052
+ {
2053
+ internalType: "address",
2054
+ name: "spender",
2055
+ type: "address"
2056
+ },
2057
+ {
2058
+ internalType: "uint256",
2059
+ name: "value",
2060
+ type: "uint256"
2061
+ },
2062
+ {
2063
+ internalType: "uint256",
2064
+ name: "deadline",
2065
+ type: "uint256"
2066
+ },
2067
+ {
2068
+ internalType: "uint8",
2069
+ name: "v",
2070
+ type: "uint8"
2071
+ },
2072
+ {
2073
+ internalType: "bytes32",
2074
+ name: "r",
2075
+ type: "bytes32"
2076
+ },
2077
+ {
2078
+ internalType: "bytes32",
2079
+ name: "s",
2080
+ type: "bytes32"
2081
+ }
2082
+ ],
2083
+ name: "permit",
2084
+ outputs: [],
2085
+ stateMutability: "nonpayable",
2086
+ type: "function"
2087
+ },
2088
+ {
2089
+ inputs: [
2090
+ {
2091
+ internalType: "address",
2092
+ name: "accountAddress",
2093
+ type: "address"
2094
+ }
2095
+ ],
2096
+ name: "publicKeys",
2097
+ outputs: [
2098
+ {
2099
+ internalType: "bytes32",
2100
+ name: "x",
2101
+ type: "bytes32"
2102
+ },
2103
+ {
2104
+ internalType: "bytes32",
2105
+ name: "y",
2106
+ type: "bytes32"
2107
+ }
2108
+ ],
2109
+ stateMutability: "view",
2110
+ type: "function"
2111
+ },
2112
+ {
2113
+ inputs: [
2114
+ {
2115
+ internalType: "address",
2116
+ name: "from",
2117
+ type: "address"
2118
+ },
2119
+ {
2120
+ internalType: "address",
2121
+ name: "to",
2122
+ type: "address"
2123
+ },
2124
+ {
2125
+ internalType: "uint256",
2126
+ name: "value",
2127
+ type: "uint256"
2128
+ },
2129
+ {
2130
+ internalType: "uint256",
2131
+ name: "validAfter",
2132
+ type: "uint256"
2133
+ },
2134
+ {
2135
+ internalType: "uint256",
2136
+ name: "validBefore",
2137
+ type: "uint256"
2138
+ },
2139
+ {
2140
+ internalType: "bytes32",
2141
+ name: "nonce",
2142
+ type: "bytes32"
2143
+ },
2144
+ {
2145
+ internalType: "uint8",
2146
+ name: "v",
2147
+ type: "uint8"
2148
+ },
2149
+ {
2150
+ internalType: "bytes32",
2151
+ name: "r",
2152
+ type: "bytes32"
2153
+ },
2154
+ {
2155
+ internalType: "bytes32",
2156
+ name: "s",
2157
+ type: "bytes32"
2158
+ }
2159
+ ],
2160
+ name: "receiveWithAuthorization",
2161
+ outputs: [],
2162
+ stateMutability: "nonpayable",
2163
+ type: "function"
2164
+ },
2165
+ {
2166
+ inputs: [
2167
+ {
2168
+ components: [
2169
+ {
2170
+ internalType: "bytes32",
2171
+ name: "x",
2172
+ type: "bytes32"
2173
+ },
2174
+ {
2175
+ internalType: "bytes32",
2176
+ name: "y",
2177
+ type: "bytes32"
2178
+ }
2179
+ ],
2180
+ internalType: "struct PublicKey",
2181
+ name: "publicKey",
2182
+ type: "tuple"
2183
+ }
2184
+ ],
2185
+ name: "registerPublicKey",
2186
+ outputs: [],
2187
+ stateMutability: "nonpayable",
2188
+ type: "function"
2189
+ },
2190
+ {
2191
+ inputs: [
2192
+ {
2193
+ internalType: "address",
2194
+ name: "account",
2195
+ type: "address"
2196
+ },
2197
+ {
2198
+ internalType: "uint256",
2199
+ name: "value",
2200
+ type: "uint256"
2201
+ }
2202
+ ],
2203
+ name: "releaseTo",
2204
+ outputs: [],
2205
+ stateMutability: "nonpayable",
2206
+ type: "function"
2207
+ },
2208
+ {
2209
+ inputs: [
2210
+ {
2211
+ internalType: "address",
2212
+ name: "viewer",
2213
+ type: "address"
2214
+ }
2215
+ ],
2216
+ name: "removeHistoricViewAuth",
2217
+ outputs: [
2218
+ {
2219
+ internalType: "bool",
2220
+ name: "success",
2221
+ type: "bool"
2222
+ }
2223
+ ],
2224
+ stateMutability: "nonpayable",
2225
+ type: "function"
2226
+ },
2227
+ {
2228
+ inputs: [
2229
+ {
2230
+ internalType: "address",
2231
+ name: "viewer",
2232
+ type: "address"
2233
+ }
2234
+ ],
2235
+ name: "removeHistoricViewTimeRange",
2236
+ outputs: [
2237
+ {
2238
+ internalType: "bool",
2239
+ name: "success",
2240
+ type: "bool"
2241
+ }
2242
+ ],
2243
+ stateMutability: "nonpayable",
2244
+ type: "function"
2245
+ },
2246
+ {
2247
+ inputs: [
2248
+ {
2249
+ internalType: "address",
2250
+ name: "viewer",
2251
+ type: "address"
2252
+ },
2253
+ {
2254
+ internalType: "uint256",
2255
+ name: "transferId",
2256
+ type: "uint256"
2257
+ }
2258
+ ],
2259
+ name: "removeHistoricViewTransferId",
2260
+ outputs: [
2261
+ {
2262
+ internalType: "bool",
2263
+ name: "success",
2264
+ type: "bool"
2265
+ }
2266
+ ],
2267
+ stateMutability: "nonpayable",
2268
+ type: "function"
2269
+ },
2270
+ {
2271
+ inputs: [
2272
+ {
2273
+ internalType: "bytes",
2274
+ name: "encryptedTransferData",
2275
+ type: "bytes"
2276
+ }
2277
+ ],
2278
+ name: "requestDecryptHistoricTransfer",
2279
+ outputs: [],
2280
+ stateMutability: "payable",
2281
+ type: "function"
2282
+ },
2283
+ {
2284
+ inputs: [
2285
+ {
2286
+ internalType: "bytes",
2287
+ name: "encryptedTransferData",
2288
+ type: "bytes"
2289
+ },
2290
+ {
2291
+ internalType: "address",
2292
+ name: "historicViewer",
2293
+ type: "address"
2294
+ }
2295
+ ],
2296
+ name: "requestDecryptHistoricTransferFor",
2297
+ outputs: [],
2298
+ stateMutability: "payable",
2299
+ type: "function"
2300
+ },
2301
+ {
2302
+ inputs: [
2303
+ {
2304
+ internalType: "address",
2305
+ name: "holder",
2306
+ type: "address"
2307
+ }
2308
+ ],
2309
+ name: "requestedMints",
2310
+ outputs: [
2311
+ {
2312
+ internalType: "uint256",
2313
+ name: "value",
2314
+ type: "uint256"
2315
+ }
2316
+ ],
2317
+ stateMutability: "view",
2318
+ type: "function"
2319
+ },
2320
+ {
2321
+ inputs: [
2322
+ {
2323
+ internalType: "uint256",
2324
+ name: "value",
2325
+ type: "uint256"
2326
+ },
2327
+ {
2328
+ internalType: "address",
2329
+ name: "receiver",
2330
+ type: "address"
2331
+ }
2332
+ ],
2333
+ name: "retrieveGasToken",
2334
+ outputs: [],
2335
+ stateMutability: "nonpayable",
2336
+ type: "function"
2337
+ },
2338
+ {
2339
+ inputs: [
2340
+ {
2341
+ internalType: "address",
2342
+ name: "newAuthority",
2343
+ type: "address"
2344
+ }
2345
+ ],
2346
+ name: "setAuthority",
2347
+ outputs: [],
2348
+ stateMutability: "nonpayable",
2349
+ type: "function"
2350
+ },
2351
+ {
2352
+ inputs: [
2353
+ {
2354
+ internalType: "uint256",
2355
+ name: "newFee",
2356
+ type: "uint256"
2357
+ }
2358
+ ],
2359
+ name: "setCallbackFee",
2360
+ outputs: [],
2361
+ stateMutability: "nonpayable",
2362
+ type: "function"
2363
+ },
2364
+ {
2365
+ inputs: [
2366
+ {
2367
+ internalType: "address",
2368
+ name: "newAddress",
2369
+ type: "address"
2370
+ }
2371
+ ],
2372
+ name: "setEncryptECIESAddress",
2373
+ outputs: [],
2374
+ stateMutability: "nonpayable",
2375
+ type: "function"
2376
+ },
2377
+ {
2378
+ inputs: [
2379
+ {
2380
+ internalType: "address",
2381
+ name: "newAddress",
2382
+ type: "address"
2383
+ }
2384
+ ],
2385
+ name: "setEncryptTEAddress",
2386
+ outputs: [],
2387
+ stateMutability: "nonpayable",
2388
+ type: "function"
2389
+ },
2390
+ {
2391
+ inputs: [
2392
+ {
2393
+ internalType: "address",
2394
+ name: "newAddress",
2395
+ type: "address"
2396
+ }
2397
+ ],
2398
+ name: "setSubmitCTXAddress",
2399
+ outputs: [],
2400
+ stateMutability: "nonpayable",
2401
+ type: "function"
2402
+ },
2403
+ {
2404
+ inputs: [
2405
+ {
2406
+ internalType: "address",
2407
+ name: "viewer",
2408
+ type: "address"
2409
+ }
2410
+ ],
2411
+ name: "setViewerAddress",
2412
+ outputs: [],
2413
+ stateMutability: "payable",
2414
+ type: "function"
2415
+ },
2416
+ {
2417
+ inputs: [
2418
+ {
2419
+ components: [
2420
+ {
2421
+ internalType: "bytes32",
2422
+ name: "x",
2423
+ type: "bytes32"
2424
+ },
2425
+ {
2426
+ internalType: "bytes32",
2427
+ name: "y",
2428
+ type: "bytes32"
2429
+ }
2430
+ ],
2431
+ internalType: "struct PublicKey",
2432
+ name: "publicKey",
2433
+ type: "tuple"
2434
+ }
2435
+ ],
2436
+ name: "setViewerPublicKey",
2437
+ outputs: [],
2438
+ stateMutability: "payable",
2439
+ type: "function"
2440
+ },
2441
+ {
2442
+ inputs: [],
2443
+ name: "submitCTXAddress",
2444
+ outputs: [
2445
+ {
2446
+ internalType: "address",
2447
+ name: "",
2448
+ type: "address"
2449
+ }
2450
+ ],
2451
+ stateMutability: "view",
2452
+ type: "function"
2453
+ },
2454
+ {
2455
+ inputs: [],
2456
+ name: "symbol",
2457
+ outputs: [
2458
+ {
2459
+ internalType: "string",
2460
+ name: "",
2461
+ type: "string"
2462
+ }
2463
+ ],
2464
+ stateMutability: "view",
2465
+ type: "function"
2466
+ },
2467
+ {
2468
+ inputs: [],
2469
+ name: "totalSupply",
2470
+ outputs: [
2471
+ {
2472
+ internalType: "uint256",
2473
+ name: "supply",
2474
+ type: "uint256"
2475
+ }
2476
+ ],
2477
+ stateMutability: "view",
2478
+ type: "function"
2479
+ },
2480
+ {
2481
+ inputs: [
2482
+ {
2483
+ internalType: "address",
2484
+ name: "to",
2485
+ type: "address"
2486
+ },
2487
+ {
2488
+ internalType: "uint256",
2489
+ name: "value",
2490
+ type: "uint256"
2491
+ }
2492
+ ],
2493
+ name: "transfer",
2494
+ outputs: [
2495
+ {
2496
+ internalType: "bool",
2497
+ name: "",
2498
+ type: "bool"
2499
+ }
2500
+ ],
2501
+ stateMutability: "nonpayable",
2502
+ type: "function"
2503
+ },
2504
+ {
2505
+ inputs: [
2506
+ {
2507
+ internalType: "address",
2508
+ name: "from",
2509
+ type: "address"
2510
+ },
2511
+ {
2512
+ internalType: "address",
2513
+ name: "to",
2514
+ type: "address"
2515
+ },
2516
+ {
2517
+ internalType: "uint256",
2518
+ name: "value",
2519
+ type: "uint256"
2520
+ }
2521
+ ],
2522
+ name: "transferFrom",
2523
+ outputs: [
2524
+ {
2525
+ internalType: "bool",
2526
+ name: "result",
2527
+ type: "bool"
2528
+ }
2529
+ ],
2530
+ stateMutability: "nonpayable",
2531
+ type: "function"
2532
+ },
2533
+ {
2534
+ inputs: [
2535
+ {
2536
+ internalType: "address",
2537
+ name: "from",
2538
+ type: "address"
2539
+ },
2540
+ {
2541
+ internalType: "address",
2542
+ name: "to",
2543
+ type: "address"
2544
+ },
2545
+ {
2546
+ internalType: "uint256",
2547
+ name: "value",
2548
+ type: "uint256"
2549
+ },
2550
+ {
2551
+ internalType: "uint256",
2552
+ name: "validAfter",
2553
+ type: "uint256"
2554
+ },
2555
+ {
2556
+ internalType: "uint256",
2557
+ name: "validBefore",
2558
+ type: "uint256"
2559
+ },
2560
+ {
2561
+ internalType: "bytes32",
2562
+ name: "nonce",
2563
+ type: "bytes32"
2564
+ },
2565
+ {
2566
+ internalType: "uint8",
2567
+ name: "v",
2568
+ type: "uint8"
2569
+ },
2570
+ {
2571
+ internalType: "bytes32",
2572
+ name: "r",
2573
+ type: "bytes32"
2574
+ },
2575
+ {
2576
+ internalType: "bytes32",
2577
+ name: "s",
2578
+ type: "bytes32"
2579
+ }
2580
+ ],
2581
+ name: "transferWithAuthorization",
2582
+ outputs: [],
2583
+ stateMutability: "nonpayable",
2584
+ type: "function"
2585
+ },
2586
+ {
2587
+ inputs: [],
2588
+ name: "underlying",
2589
+ outputs: [
2590
+ {
2591
+ internalType: "contract IERC20",
2592
+ name: "",
2593
+ type: "address"
2594
+ }
2595
+ ],
2596
+ stateMutability: "view",
2597
+ type: "function"
2598
+ },
2599
+ {
2600
+ inputs: [],
2601
+ name: "version",
2602
+ outputs: [
2603
+ {
2604
+ internalType: "string",
2605
+ name: "",
2606
+ type: "string"
2607
+ }
2608
+ ],
2609
+ stateMutability: "view",
2610
+ type: "function"
2611
+ },
2612
+ {
2613
+ inputs: [
2614
+ {
2615
+ internalType: "address",
2616
+ name: "holder",
2617
+ type: "address"
2618
+ }
2619
+ ],
2620
+ name: "viewerAddresses",
2621
+ outputs: [
2622
+ {
2623
+ internalType: "address",
2624
+ name: "viewerAddress",
2625
+ type: "address"
2626
+ }
2627
+ ],
2628
+ stateMutability: "view",
2629
+ type: "function"
2630
+ },
2631
+ {
2632
+ inputs: [
2633
+ {
2634
+ internalType: "address",
2635
+ name: "account",
2636
+ type: "address"
2637
+ },
2638
+ {
2639
+ internalType: "uint256",
2640
+ name: "value",
2641
+ type: "uint256"
2642
+ }
2643
+ ],
2644
+ name: "withdrawTo",
2645
+ outputs: [
2646
+ {
2647
+ internalType: "bool",
2648
+ name: "success",
2649
+ type: "bool"
2650
+ }
2651
+ ],
2652
+ stateMutability: "nonpayable",
2653
+ type: "function"
2654
+ },
2655
+ {
2656
+ inputs: [
2657
+ {
2658
+ internalType: "address",
2659
+ name: "account",
2660
+ type: "address"
2661
+ },
2662
+ {
2663
+ internalType: "uint256",
2664
+ name: "value",
2665
+ type: "uint256"
2666
+ }
2667
+ ],
2668
+ name: "withdrawToWithGasToken",
2669
+ outputs: [
2670
+ {
2671
+ internalType: "bool",
2672
+ name: "success",
2673
+ type: "bool"
2674
+ }
2675
+ ],
2676
+ stateMutability: "payable",
2677
+ type: "function"
2678
+ },
2679
+ {
2680
+ stateMutability: "payable",
2681
+ type: "receive"
2682
+ }
2683
+ ];
2684
+
2685
+ // src/actions/funding.ts
2686
+ var import_viem = require("viem");
2687
+ var CTX_RESERVE_THRESHOLD = 1n;
2688
+ async function getCtxBalance(config) {
2689
+ return await config.publicClient.readContract({
2690
+ address: config.address,
2691
+ abi: confidentialWrapperAbi,
2692
+ functionName: "gasTokenBalanceOf",
2693
+ args: [config.signer.address]
2694
+ });
2695
+ }
2696
+ async function getCtxFee(config) {
2697
+ return await config.publicClient.readContract({
2698
+ address: config.address,
2699
+ abi: confidentialWrapperAbi,
2700
+ functionName: "callbackFee"
2701
+ });
2702
+ }
2703
+ async function fundCtxBalance(config, params) {
2704
+ const data = (0, import_viem.encodeFunctionData)({
2705
+ abi: confidentialWrapperAbi,
2706
+ functionName: "fundWithGasToken",
2707
+ args: [config.signer.address]
2708
+ });
2709
+ return config.signer.sendTransaction({
2710
+ to: config.address,
2711
+ data,
2712
+ value: params.amount
2713
+ });
2714
+ }
2715
+ async function getValueForCtx(config) {
2716
+ const [fee, balance] = await Promise.all([getCtxFee(config), getCtxBalance(config)]);
2717
+ const topUp = CTX_RESERVE_THRESHOLD * fee - balance;
2718
+ return fee + (topUp > 0n ? topUp : 0n);
2719
+ }
2720
+
2721
+ // src/actions/transfers.ts
2722
+ async function approve(config, params) {
2723
+ const data = (0, import_viem2.encodeFunctionData)({
2724
+ abi: confidentialWrapperAbi,
2725
+ functionName: "approve",
2726
+ args: [params.spender, params.amount]
2727
+ });
2728
+ return config.signer.sendTransaction({ to: config.address, data });
2729
+ }
2730
+ async function transfer(config, params) {
2731
+ const value = await getValueForCtx(config);
2732
+ const valueHex = (0, import_viem2.toHex)(params.amount, { size: 32 });
2733
+ const encryptedValue = await config.bite.encryptMessageForCTX(valueHex, config.address);
2734
+ const data = (0, import_viem2.encodeFunctionData)({
2735
+ abi: confidentialWrapperAbi,
2736
+ functionName: "encryptedTransfer",
2737
+ args: [params.to, encryptedValue]
2738
+ });
2739
+ return config.signer.sendTransaction({ to: config.address, data, value });
2740
+ }
2741
+ async function wrap(config, params) {
2742
+ const value = await getValueForCtx(config);
2743
+ const data = (0, import_viem2.encodeFunctionData)({
2744
+ abi: confidentialWrapperAbi,
2745
+ functionName: "depositForWithGasToken",
2746
+ args: [params.receiver, params.amount]
2747
+ });
2748
+ return config.signer.sendTransaction({ to: config.address, data, value });
2749
+ }
2750
+ async function unwrap(config, params) {
2751
+ const value = await getValueForCtx(config);
2752
+ const data = (0, import_viem2.encodeFunctionData)({
2753
+ abi: confidentialWrapperAbi,
2754
+ functionName: "withdrawToWithGasToken",
2755
+ args: [params.receiver, params.amount]
2756
+ });
2757
+ return config.signer.sendTransaction({ to: config.address, data, value });
2758
+ }
2759
+
2760
+ // src/actions/decrypt.ts
2761
+ var import_viem4 = require("viem");
2762
+
2763
+ // src/utils/crypto.ts
2764
+ var import_secp256k1 = require("@noble/curves/secp256k1");
2765
+ var import_sha256 = require("@noble/hashes/sha256");
2766
+ var import_aes = require("@noble/ciphers/aes");
2767
+ var import_viem3 = require("viem");
2768
+ function bytesToBigInt(bytes) {
2769
+ if (bytes.length === 0) {
2770
+ return 0n;
2771
+ }
2772
+ const hexValue = (0, import_viem3.bytesToHex)(bytes);
2773
+ return BigInt(hexValue === "0x" ? "0x0" : hexValue);
2774
+ }
2775
+ function decryptEciesPayload(encryptedHex, privateKey) {
2776
+ const payload = (0, import_viem3.hexToBytes)(encryptedHex);
2777
+ if (payload.length < 65) {
2778
+ throw new Error("Encrypted payload is too short.");
2779
+ }
2780
+ const iv = payload.slice(0, 16);
2781
+ const ephemeralCompressedPublicKey = payload.slice(16, 49);
2782
+ const ciphertext = payload.slice(49);
2783
+ if (ephemeralCompressedPublicKey.length !== 33) {
2784
+ throw new Error("Invalid ephemeral public key length in encrypted payload.");
2785
+ }
2786
+ if (ciphertext.length === 0 || ciphertext.length % 16 !== 0) {
2787
+ throw new Error("Invalid AES-CBC ciphertext length.");
2788
+ }
2789
+ const sharedSecret = import_secp256k1.secp256k1.getSharedSecret(
2790
+ (0, import_viem3.hexToBytes)(privateKey),
2791
+ ephemeralCompressedPublicKey,
2792
+ true
2793
+ );
2794
+ const encryptionKey = (0, import_sha256.sha256)(sharedSecret.slice(1));
2795
+ const keyMaterial = Uint8Array.from(encryptionKey);
2796
+ return (0, import_aes.cbc)(keyMaterial, iv).decrypt(ciphertext);
2797
+ }
2798
+ function tryDecodeTransferData(encoded) {
2799
+ try {
2800
+ const [from, to, value, timestamp, transferId] = (0, import_viem3.decodeAbiParameters)(
2801
+ [
2802
+ { type: "address" },
2803
+ { type: "address" },
2804
+ { type: "uint256" },
2805
+ { type: "uint256" },
2806
+ { type: "uint256" }
2807
+ ],
2808
+ encoded
2809
+ );
2810
+ return { from, to, value, timestamp, transferId };
2811
+ } catch {
2812
+ return void 0;
2813
+ }
2814
+ }
2815
+ async function decryptBalance(encryptedHex, privateKey) {
2816
+ const plaintext = decryptEciesPayload(encryptedHex, privateKey);
2817
+ if (plaintext.length <= 32) {
2818
+ return bytesToBigInt(plaintext);
2819
+ }
2820
+ return bytesToBigInt(plaintext.slice(-32));
2821
+ }
2822
+ async function decryptTransferData(encryptedHex, privateKey) {
2823
+ const plaintext = decryptEciesPayload(encryptedHex, privateKey);
2824
+ const direct = tryDecodeTransferData((0, import_viem3.bytesToHex)(plaintext));
2825
+ if (direct) {
2826
+ return direct;
2827
+ }
2828
+ const structSizeBytes = 32 * 5;
2829
+ if (plaintext.length >= structSizeBytes) {
2830
+ const trailing = plaintext.slice(-structSizeBytes);
2831
+ const trailingDecoded = tryDecodeTransferData((0, import_viem3.bytesToHex)(trailing));
2832
+ if (trailingDecoded) {
2833
+ return trailingDecoded;
2834
+ }
2835
+ }
2836
+ throw new Error("Unable to decode decrypted transfer payload as TransferData struct.");
2837
+ }
2838
+
2839
+ // src/actions/decrypt.ts
2840
+ async function decryptTokenBalance(config, params) {
2841
+ const raw = await config.publicClient.readContract({
2842
+ address: config.address,
2843
+ abi: confidentialWrapperAbi,
2844
+ functionName: "encryptedBalanceOf",
2845
+ args: [config.signer.address]
2846
+ });
2847
+ const encryptedHex = typeof raw === "string" ? raw : (0, import_viem4.bytesToHex)(raw);
2848
+ return decryptBalance(encryptedHex, params.viewerKey);
2849
+ }
2850
+ async function decryptHistoricTransferData(params) {
2851
+ return decryptTransferData(params.encryptedData, params.viewerKey);
2852
+ }
2853
+ async function getTransferId(config, params) {
2854
+ const receipt = await config.publicClient.waitForTransactionReceipt({ hash: params.ctxHash });
2855
+ const events = (0, import_viem4.parseEventLogs)({
2856
+ abi: confidentialWrapperAbi,
2857
+ logs: receipt.logs,
2858
+ eventName: "EncryptedTransfer"
2859
+ });
2860
+ const event = events[0];
2861
+ if (!event) {
2862
+ throw new Error("CTX receipt does not contain an EncryptedTransfer event.");
2863
+ }
2864
+ const transferId = event.args.transferId;
2865
+ if (transferId === void 0) {
2866
+ throw new Error("CTX receipt does not contain an EncryptedTransfer event.");
2867
+ }
2868
+ return transferId;
2869
+ }
2870
+
2871
+ // src/actions/access.ts
2872
+ var import_viem6 = require("viem");
2873
+
2874
+ // src/utils/viewerKey.ts
2875
+ var import_viem5 = require("viem");
2876
+ var import_utils = require("viem/utils");
2877
+ var import_secp256k12 = require("@noble/curves/secp256k1");
2878
+ function parsePublicKeyCoordinates(publicKey) {
2879
+ const raw = publicKey.startsWith("0x04") ? publicKey.slice(4) : publicKey.slice(2);
2880
+ if (raw.length !== 128) {
2881
+ throw new Error("Public key must be an uncompressed key (65 bytes with 0x04 prefix).");
2882
+ }
2883
+ return {
2884
+ x: `0x${raw.slice(0, 64)}`,
2885
+ y: `0x${raw.slice(64, 128)}`
2886
+ };
2887
+ }
2888
+
2889
+ // src/actions/access.ts
2890
+ async function registerViewerKey(config, params) {
2891
+ const { x, y } = parsePublicKeyCoordinates(params.publicKey);
2892
+ const data = (0, import_viem6.encodeFunctionData)({
2893
+ abi: confidentialWrapperAbi,
2894
+ functionName: "setViewerPublicKey",
2895
+ args: [{ x, y }]
2896
+ });
2897
+ return config.signer.sendTransaction({ to: config.address, data });
2898
+ }
2899
+ async function authorizeHistoricViewForRange(config, params) {
2900
+ const data = (0, import_viem6.encodeFunctionData)({
2901
+ abi: confidentialWrapperAbi,
2902
+ functionName: "authorizeHistoricViewTimeRange",
2903
+ args: [params.address, params.fromTimestamp, params.toTimestamp]
2904
+ });
2905
+ return config.signer.sendTransaction({ to: config.address, data });
2906
+ }
2907
+ async function authorizeHistoricViewForTransfer(config, params) {
2908
+ const data = (0, import_viem6.encodeFunctionData)({
2909
+ abi: confidentialWrapperAbi,
2910
+ functionName: "authorizeHistoricViewTransferId",
2911
+ args: [params.address, params.transferId]
2912
+ });
2913
+ return config.signer.sendTransaction({ to: config.address, data });
2914
+ }
2915
+ async function revokeHistoricView(config, params) {
2916
+ const data = (0, import_viem6.encodeFunctionData)({
2917
+ abi: confidentialWrapperAbi,
2918
+ functionName: "removeHistoricViewAuth",
2919
+ args: [params.address]
2920
+ });
2921
+ return config.signer.sendTransaction({ to: config.address, data });
2922
+ }
2923
+ async function requestTransferDecryption(config, params) {
2924
+ const value = await getValueForCtx(config);
2925
+ const receipt = await config.publicClient.waitForTransactionReceipt({ hash: params.ctxHash });
2926
+ const events = (0, import_viem6.parseEventLogs)({
2927
+ abi: confidentialWrapperAbi,
2928
+ logs: receipt.logs,
2929
+ eventName: "EncryptedTransfer"
2930
+ });
2931
+ const event = events[0];
2932
+ if (!event) {
2933
+ throw new Error("CTX receipt does not contain an EncryptedTransfer event.");
2934
+ }
2935
+ const args = event.args;
2936
+ const { encryptedData, transferId, from, to } = args;
2937
+ if (!encryptedData || transferId === void 0 || !from || !to) {
2938
+ throw new Error("CTX receipt does not contain an EncryptedTransfer event.");
2939
+ }
2940
+ const viewerAddress = await config.publicClient.readContract({
2941
+ address: config.address,
2942
+ abi: confidentialWrapperAbi,
2943
+ functionName: "viewerAddresses",
2944
+ args: [config.signer.address]
2945
+ });
2946
+ const block = await config.publicClient.getBlock({ blockNumber: receipt.blockNumber });
2947
+ const canDecrypt = await config.publicClient.readContract({
2948
+ address: config.address,
2949
+ abi: confidentialWrapperAbi,
2950
+ functionName: "canDecryptHistoricTransfer",
2951
+ args: [viewerAddress, transferId, from, to, block.timestamp]
2952
+ });
2953
+ if (!canDecrypt) {
2954
+ throw new Error("Viewer is not authorized to decrypt this historic transfer.");
2955
+ }
2956
+ const data = (0, import_viem6.encodeFunctionData)({
2957
+ abi: confidentialWrapperAbi,
2958
+ functionName: "requestDecryptHistoricTransferFor",
2959
+ args: [encryptedData, viewerAddress]
2960
+ });
2961
+ return config.signer.sendTransaction({ to: config.address, data, value });
2962
+ }
2963
+ // Annotate the CommonJS export names for ESM import in node:
2964
+ 0 && (module.exports = {
2965
+ approve,
2966
+ authorizeHistoricViewForRange,
2967
+ authorizeHistoricViewForTransfer,
2968
+ decryptHistoricTransferData,
2969
+ decryptTokenBalance,
2970
+ fundCtxBalance,
2971
+ getCtxBalance,
2972
+ getCtxFee,
2973
+ getTransferId,
2974
+ getValueForCtx,
2975
+ registerViewerKey,
2976
+ requestTransferDecryption,
2977
+ revokeHistoricView,
2978
+ transfer,
2979
+ unwrap,
2980
+ wrap
2981
+ });
2982
+ //# sourceMappingURL=index.cjs.map