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