@gitmyabi/gravity 1.0.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,1459 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+
5
+ /**
6
+ * ValsetArgs struct type
7
+ */
8
+ export type ValsetArgs = {
9
+ validators: `0x${string}`[];
10
+ powers: bigint[];
11
+ valsetNonce: bigint;
12
+ rewardAmount: bigint;
13
+ rewardToken: `0x${string}`;
14
+ };
15
+
16
+ /**
17
+ * Signature struct type
18
+ */
19
+ export type Signature = {
20
+ v: bigint;
21
+ r: `0x${string}`;
22
+ s: `0x${string}`;
23
+ };
24
+
25
+ /**
26
+ * LogicCallArgs struct type
27
+ */
28
+ export type LogicCallArgs = {
29
+ transferAmounts: bigint[];
30
+ transferTokenContracts: `0x${string}`[];
31
+ feeAmounts: bigint[];
32
+ feeTokenContracts: `0x${string}`[];
33
+ logicContractAddress: `0x${string}`;
34
+ payload: `0x${string}`;
35
+ timeOut: bigint;
36
+ invalidationId: `0x${string}`;
37
+ invalidationNonce: bigint;
38
+ };
39
+ /**
40
+ * Gravity_json ABI
41
+ *
42
+ * This ABI is typed using viem's type system for full type safety.
43
+ */
44
+ export const Gravity_jsonAbi = [
45
+ {
46
+ "inputs": [
47
+ {
48
+ "internalType": "bytes32",
49
+ "name": "_gravityId",
50
+ "type": "bytes32"
51
+ },
52
+ {
53
+ "internalType": "address[]",
54
+ "name": "_validators",
55
+ "type": "address[]"
56
+ },
57
+ {
58
+ "internalType": "uint256[]",
59
+ "name": "_powers",
60
+ "type": "uint256[]"
61
+ }
62
+ ],
63
+ "stateMutability": "nonpayable",
64
+ "type": "constructor"
65
+ },
66
+ {
67
+ "inputs": [],
68
+ "name": "BatchTimedOut",
69
+ "type": "error"
70
+ },
71
+ {
72
+ "inputs": [],
73
+ "name": "IncorrectCheckpoint",
74
+ "type": "error"
75
+ },
76
+ {
77
+ "inputs": [
78
+ {
79
+ "internalType": "uint256",
80
+ "name": "cumulativePower",
81
+ "type": "uint256"
82
+ },
83
+ {
84
+ "internalType": "uint256",
85
+ "name": "powerThreshold",
86
+ "type": "uint256"
87
+ }
88
+ ],
89
+ "name": "InsufficientPower",
90
+ "type": "error"
91
+ },
92
+ {
93
+ "inputs": [
94
+ {
95
+ "internalType": "uint256",
96
+ "name": "newNonce",
97
+ "type": "uint256"
98
+ },
99
+ {
100
+ "internalType": "uint256",
101
+ "name": "currentNonce",
102
+ "type": "uint256"
103
+ }
104
+ ],
105
+ "name": "InvalidBatchNonce",
106
+ "type": "error"
107
+ },
108
+ {
109
+ "inputs": [],
110
+ "name": "InvalidLogicCallFees",
111
+ "type": "error"
112
+ },
113
+ {
114
+ "inputs": [
115
+ {
116
+ "internalType": "uint256",
117
+ "name": "newNonce",
118
+ "type": "uint256"
119
+ },
120
+ {
121
+ "internalType": "uint256",
122
+ "name": "currentNonce",
123
+ "type": "uint256"
124
+ }
125
+ ],
126
+ "name": "InvalidLogicCallNonce",
127
+ "type": "error"
128
+ },
129
+ {
130
+ "inputs": [],
131
+ "name": "InvalidLogicCallTransfers",
132
+ "type": "error"
133
+ },
134
+ {
135
+ "inputs": [],
136
+ "name": "InvalidSendToCosmos",
137
+ "type": "error"
138
+ },
139
+ {
140
+ "inputs": [],
141
+ "name": "InvalidSignature",
142
+ "type": "error"
143
+ },
144
+ {
145
+ "inputs": [
146
+ {
147
+ "internalType": "uint256",
148
+ "name": "newNonce",
149
+ "type": "uint256"
150
+ },
151
+ {
152
+ "internalType": "uint256",
153
+ "name": "currentNonce",
154
+ "type": "uint256"
155
+ }
156
+ ],
157
+ "name": "InvalidValsetNonce",
158
+ "type": "error"
159
+ },
160
+ {
161
+ "inputs": [],
162
+ "name": "LogicCallTimedOut",
163
+ "type": "error"
164
+ },
165
+ {
166
+ "inputs": [],
167
+ "name": "MalformedBatch",
168
+ "type": "error"
169
+ },
170
+ {
171
+ "inputs": [],
172
+ "name": "MalformedCurrentValidatorSet",
173
+ "type": "error"
174
+ },
175
+ {
176
+ "inputs": [],
177
+ "name": "MalformedNewValidatorSet",
178
+ "type": "error"
179
+ },
180
+ {
181
+ "anonymous": false,
182
+ "inputs": [
183
+ {
184
+ "indexed": false,
185
+ "internalType": "string",
186
+ "name": "_cosmosDenom",
187
+ "type": "string"
188
+ },
189
+ {
190
+ "indexed": true,
191
+ "internalType": "address",
192
+ "name": "_tokenContract",
193
+ "type": "address"
194
+ },
195
+ {
196
+ "indexed": false,
197
+ "internalType": "string",
198
+ "name": "_name",
199
+ "type": "string"
200
+ },
201
+ {
202
+ "indexed": false,
203
+ "internalType": "string",
204
+ "name": "_symbol",
205
+ "type": "string"
206
+ },
207
+ {
208
+ "indexed": false,
209
+ "internalType": "uint8",
210
+ "name": "_decimals",
211
+ "type": "uint8"
212
+ },
213
+ {
214
+ "indexed": false,
215
+ "internalType": "uint256",
216
+ "name": "_eventNonce",
217
+ "type": "uint256"
218
+ }
219
+ ],
220
+ "name": "ERC20DeployedEvent",
221
+ "type": "event"
222
+ },
223
+ {
224
+ "anonymous": false,
225
+ "inputs": [
226
+ {
227
+ "indexed": false,
228
+ "internalType": "bytes32",
229
+ "name": "_invalidationId",
230
+ "type": "bytes32"
231
+ },
232
+ {
233
+ "indexed": false,
234
+ "internalType": "uint256",
235
+ "name": "_invalidationNonce",
236
+ "type": "uint256"
237
+ },
238
+ {
239
+ "indexed": false,
240
+ "internalType": "bytes",
241
+ "name": "_returnData",
242
+ "type": "bytes"
243
+ },
244
+ {
245
+ "indexed": false,
246
+ "internalType": "uint256",
247
+ "name": "_eventNonce",
248
+ "type": "uint256"
249
+ }
250
+ ],
251
+ "name": "LogicCallEvent",
252
+ "type": "event"
253
+ },
254
+ {
255
+ "anonymous": false,
256
+ "inputs": [
257
+ {
258
+ "indexed": true,
259
+ "internalType": "address",
260
+ "name": "_tokenContract",
261
+ "type": "address"
262
+ },
263
+ {
264
+ "indexed": true,
265
+ "internalType": "address",
266
+ "name": "_sender",
267
+ "type": "address"
268
+ },
269
+ {
270
+ "indexed": false,
271
+ "internalType": "string",
272
+ "name": "_destination",
273
+ "type": "string"
274
+ },
275
+ {
276
+ "indexed": false,
277
+ "internalType": "uint256",
278
+ "name": "_amount",
279
+ "type": "uint256"
280
+ },
281
+ {
282
+ "indexed": false,
283
+ "internalType": "uint256",
284
+ "name": "_eventNonce",
285
+ "type": "uint256"
286
+ }
287
+ ],
288
+ "name": "SendToCosmosEvent",
289
+ "type": "event"
290
+ },
291
+ {
292
+ "anonymous": false,
293
+ "inputs": [
294
+ {
295
+ "indexed": true,
296
+ "internalType": "uint256",
297
+ "name": "_batchNonce",
298
+ "type": "uint256"
299
+ },
300
+ {
301
+ "indexed": true,
302
+ "internalType": "address",
303
+ "name": "_token",
304
+ "type": "address"
305
+ },
306
+ {
307
+ "indexed": false,
308
+ "internalType": "uint256",
309
+ "name": "_eventNonce",
310
+ "type": "uint256"
311
+ }
312
+ ],
313
+ "name": "TransactionBatchExecutedEvent",
314
+ "type": "event"
315
+ },
316
+ {
317
+ "anonymous": false,
318
+ "inputs": [
319
+ {
320
+ "indexed": true,
321
+ "internalType": "uint256",
322
+ "name": "_newValsetNonce",
323
+ "type": "uint256"
324
+ },
325
+ {
326
+ "indexed": false,
327
+ "internalType": "uint256",
328
+ "name": "_eventNonce",
329
+ "type": "uint256"
330
+ },
331
+ {
332
+ "indexed": false,
333
+ "internalType": "uint256",
334
+ "name": "_rewardAmount",
335
+ "type": "uint256"
336
+ },
337
+ {
338
+ "indexed": false,
339
+ "internalType": "address",
340
+ "name": "_rewardToken",
341
+ "type": "address"
342
+ },
343
+ {
344
+ "indexed": false,
345
+ "internalType": "address[]",
346
+ "name": "_validators",
347
+ "type": "address[]"
348
+ },
349
+ {
350
+ "indexed": false,
351
+ "internalType": "uint256[]",
352
+ "name": "_powers",
353
+ "type": "uint256[]"
354
+ }
355
+ ],
356
+ "name": "ValsetUpdatedEvent",
357
+ "type": "event"
358
+ },
359
+ {
360
+ "inputs": [
361
+ {
362
+ "internalType": "string",
363
+ "name": "_cosmosDenom",
364
+ "type": "string"
365
+ },
366
+ {
367
+ "internalType": "string",
368
+ "name": "_name",
369
+ "type": "string"
370
+ },
371
+ {
372
+ "internalType": "string",
373
+ "name": "_symbol",
374
+ "type": "string"
375
+ },
376
+ {
377
+ "internalType": "uint8",
378
+ "name": "_decimals",
379
+ "type": "uint8"
380
+ }
381
+ ],
382
+ "name": "deployERC20",
383
+ "outputs": [],
384
+ "stateMutability": "nonpayable",
385
+ "type": "function"
386
+ },
387
+ {
388
+ "inputs": [
389
+ {
390
+ "internalType": "address",
391
+ "name": "_erc20Address",
392
+ "type": "address"
393
+ }
394
+ ],
395
+ "name": "lastBatchNonce",
396
+ "outputs": [
397
+ {
398
+ "internalType": "uint256",
399
+ "name": "",
400
+ "type": "uint256"
401
+ }
402
+ ],
403
+ "stateMutability": "view",
404
+ "type": "function"
405
+ },
406
+ {
407
+ "inputs": [
408
+ {
409
+ "internalType": "bytes32",
410
+ "name": "_invalidation_id",
411
+ "type": "bytes32"
412
+ }
413
+ ],
414
+ "name": "lastLogicCallNonce",
415
+ "outputs": [
416
+ {
417
+ "internalType": "uint256",
418
+ "name": "",
419
+ "type": "uint256"
420
+ }
421
+ ],
422
+ "stateMutability": "view",
423
+ "type": "function"
424
+ },
425
+ {
426
+ "inputs": [
427
+ {
428
+ "internalType": "address",
429
+ "name": "_tokenContract",
430
+ "type": "address"
431
+ },
432
+ {
433
+ "internalType": "string",
434
+ "name": "_destination",
435
+ "type": "string"
436
+ },
437
+ {
438
+ "internalType": "uint256",
439
+ "name": "_amount",
440
+ "type": "uint256"
441
+ }
442
+ ],
443
+ "name": "sendToCosmos",
444
+ "outputs": [],
445
+ "stateMutability": "nonpayable",
446
+ "type": "function"
447
+ },
448
+ {
449
+ "inputs": [],
450
+ "name": "state_gravityId",
451
+ "outputs": [
452
+ {
453
+ "internalType": "bytes32",
454
+ "name": "",
455
+ "type": "bytes32"
456
+ }
457
+ ],
458
+ "stateMutability": "view",
459
+ "type": "function"
460
+ },
461
+ {
462
+ "inputs": [
463
+ {
464
+ "internalType": "bytes32",
465
+ "name": "",
466
+ "type": "bytes32"
467
+ }
468
+ ],
469
+ "name": "state_invalidationMapping",
470
+ "outputs": [
471
+ {
472
+ "internalType": "uint256",
473
+ "name": "",
474
+ "type": "uint256"
475
+ }
476
+ ],
477
+ "stateMutability": "view",
478
+ "type": "function"
479
+ },
480
+ {
481
+ "inputs": [
482
+ {
483
+ "internalType": "address",
484
+ "name": "",
485
+ "type": "address"
486
+ }
487
+ ],
488
+ "name": "state_lastBatchNonces",
489
+ "outputs": [
490
+ {
491
+ "internalType": "uint256",
492
+ "name": "",
493
+ "type": "uint256"
494
+ }
495
+ ],
496
+ "stateMutability": "view",
497
+ "type": "function"
498
+ },
499
+ {
500
+ "inputs": [],
501
+ "name": "state_lastEventNonce",
502
+ "outputs": [
503
+ {
504
+ "internalType": "uint256",
505
+ "name": "",
506
+ "type": "uint256"
507
+ }
508
+ ],
509
+ "stateMutability": "view",
510
+ "type": "function"
511
+ },
512
+ {
513
+ "inputs": [],
514
+ "name": "state_lastValsetCheckpoint",
515
+ "outputs": [
516
+ {
517
+ "internalType": "bytes32",
518
+ "name": "",
519
+ "type": "bytes32"
520
+ }
521
+ ],
522
+ "stateMutability": "view",
523
+ "type": "function"
524
+ },
525
+ {
526
+ "inputs": [],
527
+ "name": "state_lastValsetNonce",
528
+ "outputs": [
529
+ {
530
+ "internalType": "uint256",
531
+ "name": "",
532
+ "type": "uint256"
533
+ }
534
+ ],
535
+ "stateMutability": "view",
536
+ "type": "function"
537
+ },
538
+ {
539
+ "inputs": [
540
+ {
541
+ "components": [
542
+ {
543
+ "internalType": "address[]",
544
+ "name": "validators",
545
+ "type": "address[]"
546
+ },
547
+ {
548
+ "internalType": "uint256[]",
549
+ "name": "powers",
550
+ "type": "uint256[]"
551
+ },
552
+ {
553
+ "internalType": "uint256",
554
+ "name": "valsetNonce",
555
+ "type": "uint256"
556
+ },
557
+ {
558
+ "internalType": "uint256",
559
+ "name": "rewardAmount",
560
+ "type": "uint256"
561
+ },
562
+ {
563
+ "internalType": "address",
564
+ "name": "rewardToken",
565
+ "type": "address"
566
+ }
567
+ ],
568
+ "internalType": "struct ValsetArgs",
569
+ "name": "_currentValset",
570
+ "type": "tuple"
571
+ },
572
+ {
573
+ "components": [
574
+ {
575
+ "internalType": "uint8",
576
+ "name": "v",
577
+ "type": "uint8"
578
+ },
579
+ {
580
+ "internalType": "bytes32",
581
+ "name": "r",
582
+ "type": "bytes32"
583
+ },
584
+ {
585
+ "internalType": "bytes32",
586
+ "name": "s",
587
+ "type": "bytes32"
588
+ }
589
+ ],
590
+ "internalType": "struct Signature[]",
591
+ "name": "_sigs",
592
+ "type": "tuple[]"
593
+ },
594
+ {
595
+ "internalType": "uint256[]",
596
+ "name": "_amounts",
597
+ "type": "uint256[]"
598
+ },
599
+ {
600
+ "internalType": "address[]",
601
+ "name": "_destinations",
602
+ "type": "address[]"
603
+ },
604
+ {
605
+ "internalType": "uint256[]",
606
+ "name": "_fees",
607
+ "type": "uint256[]"
608
+ },
609
+ {
610
+ "internalType": "uint256",
611
+ "name": "_batchNonce",
612
+ "type": "uint256"
613
+ },
614
+ {
615
+ "internalType": "address",
616
+ "name": "_tokenContract",
617
+ "type": "address"
618
+ },
619
+ {
620
+ "internalType": "uint256",
621
+ "name": "_batchTimeout",
622
+ "type": "uint256"
623
+ }
624
+ ],
625
+ "name": "submitBatch",
626
+ "outputs": [],
627
+ "stateMutability": "nonpayable",
628
+ "type": "function"
629
+ },
630
+ {
631
+ "inputs": [
632
+ {
633
+ "components": [
634
+ {
635
+ "internalType": "address[]",
636
+ "name": "validators",
637
+ "type": "address[]"
638
+ },
639
+ {
640
+ "internalType": "uint256[]",
641
+ "name": "powers",
642
+ "type": "uint256[]"
643
+ },
644
+ {
645
+ "internalType": "uint256",
646
+ "name": "valsetNonce",
647
+ "type": "uint256"
648
+ },
649
+ {
650
+ "internalType": "uint256",
651
+ "name": "rewardAmount",
652
+ "type": "uint256"
653
+ },
654
+ {
655
+ "internalType": "address",
656
+ "name": "rewardToken",
657
+ "type": "address"
658
+ }
659
+ ],
660
+ "internalType": "struct ValsetArgs",
661
+ "name": "_currentValset",
662
+ "type": "tuple"
663
+ },
664
+ {
665
+ "components": [
666
+ {
667
+ "internalType": "uint8",
668
+ "name": "v",
669
+ "type": "uint8"
670
+ },
671
+ {
672
+ "internalType": "bytes32",
673
+ "name": "r",
674
+ "type": "bytes32"
675
+ },
676
+ {
677
+ "internalType": "bytes32",
678
+ "name": "s",
679
+ "type": "bytes32"
680
+ }
681
+ ],
682
+ "internalType": "struct Signature[]",
683
+ "name": "_sigs",
684
+ "type": "tuple[]"
685
+ },
686
+ {
687
+ "components": [
688
+ {
689
+ "internalType": "uint256[]",
690
+ "name": "transferAmounts",
691
+ "type": "uint256[]"
692
+ },
693
+ {
694
+ "internalType": "address[]",
695
+ "name": "transferTokenContracts",
696
+ "type": "address[]"
697
+ },
698
+ {
699
+ "internalType": "uint256[]",
700
+ "name": "feeAmounts",
701
+ "type": "uint256[]"
702
+ },
703
+ {
704
+ "internalType": "address[]",
705
+ "name": "feeTokenContracts",
706
+ "type": "address[]"
707
+ },
708
+ {
709
+ "internalType": "address",
710
+ "name": "logicContractAddress",
711
+ "type": "address"
712
+ },
713
+ {
714
+ "internalType": "bytes",
715
+ "name": "payload",
716
+ "type": "bytes"
717
+ },
718
+ {
719
+ "internalType": "uint256",
720
+ "name": "timeOut",
721
+ "type": "uint256"
722
+ },
723
+ {
724
+ "internalType": "bytes32",
725
+ "name": "invalidationId",
726
+ "type": "bytes32"
727
+ },
728
+ {
729
+ "internalType": "uint256",
730
+ "name": "invalidationNonce",
731
+ "type": "uint256"
732
+ }
733
+ ],
734
+ "internalType": "struct LogicCallArgs",
735
+ "name": "_args",
736
+ "type": "tuple"
737
+ }
738
+ ],
739
+ "name": "submitLogicCall",
740
+ "outputs": [],
741
+ "stateMutability": "nonpayable",
742
+ "type": "function"
743
+ },
744
+ {
745
+ "inputs": [
746
+ {
747
+ "components": [
748
+ {
749
+ "internalType": "address[]",
750
+ "name": "validators",
751
+ "type": "address[]"
752
+ },
753
+ {
754
+ "internalType": "uint256[]",
755
+ "name": "powers",
756
+ "type": "uint256[]"
757
+ },
758
+ {
759
+ "internalType": "uint256",
760
+ "name": "valsetNonce",
761
+ "type": "uint256"
762
+ },
763
+ {
764
+ "internalType": "uint256",
765
+ "name": "rewardAmount",
766
+ "type": "uint256"
767
+ },
768
+ {
769
+ "internalType": "address",
770
+ "name": "rewardToken",
771
+ "type": "address"
772
+ }
773
+ ],
774
+ "internalType": "struct ValsetArgs",
775
+ "name": "_currentValset",
776
+ "type": "tuple"
777
+ },
778
+ {
779
+ "components": [
780
+ {
781
+ "internalType": "uint8",
782
+ "name": "v",
783
+ "type": "uint8"
784
+ },
785
+ {
786
+ "internalType": "bytes32",
787
+ "name": "r",
788
+ "type": "bytes32"
789
+ },
790
+ {
791
+ "internalType": "bytes32",
792
+ "name": "s",
793
+ "type": "bytes32"
794
+ }
795
+ ],
796
+ "internalType": "struct Signature[]",
797
+ "name": "_sigs",
798
+ "type": "tuple[]"
799
+ },
800
+ {
801
+ "internalType": "bytes32",
802
+ "name": "_theHash",
803
+ "type": "bytes32"
804
+ },
805
+ {
806
+ "internalType": "uint256",
807
+ "name": "_powerThreshold",
808
+ "type": "uint256"
809
+ }
810
+ ],
811
+ "name": "testCheckValidatorSignatures",
812
+ "outputs": [],
813
+ "stateMutability": "pure",
814
+ "type": "function"
815
+ },
816
+ {
817
+ "inputs": [
818
+ {
819
+ "components": [
820
+ {
821
+ "internalType": "address[]",
822
+ "name": "validators",
823
+ "type": "address[]"
824
+ },
825
+ {
826
+ "internalType": "uint256[]",
827
+ "name": "powers",
828
+ "type": "uint256[]"
829
+ },
830
+ {
831
+ "internalType": "uint256",
832
+ "name": "valsetNonce",
833
+ "type": "uint256"
834
+ },
835
+ {
836
+ "internalType": "uint256",
837
+ "name": "rewardAmount",
838
+ "type": "uint256"
839
+ },
840
+ {
841
+ "internalType": "address",
842
+ "name": "rewardToken",
843
+ "type": "address"
844
+ }
845
+ ],
846
+ "internalType": "struct ValsetArgs",
847
+ "name": "_valsetArgs",
848
+ "type": "tuple"
849
+ },
850
+ {
851
+ "internalType": "bytes32",
852
+ "name": "_gravityId",
853
+ "type": "bytes32"
854
+ }
855
+ ],
856
+ "name": "testMakeCheckpoint",
857
+ "outputs": [],
858
+ "stateMutability": "pure",
859
+ "type": "function"
860
+ },
861
+ {
862
+ "inputs": [
863
+ {
864
+ "components": [
865
+ {
866
+ "internalType": "address[]",
867
+ "name": "validators",
868
+ "type": "address[]"
869
+ },
870
+ {
871
+ "internalType": "uint256[]",
872
+ "name": "powers",
873
+ "type": "uint256[]"
874
+ },
875
+ {
876
+ "internalType": "uint256",
877
+ "name": "valsetNonce",
878
+ "type": "uint256"
879
+ },
880
+ {
881
+ "internalType": "uint256",
882
+ "name": "rewardAmount",
883
+ "type": "uint256"
884
+ },
885
+ {
886
+ "internalType": "address",
887
+ "name": "rewardToken",
888
+ "type": "address"
889
+ }
890
+ ],
891
+ "internalType": "struct ValsetArgs",
892
+ "name": "_newValset",
893
+ "type": "tuple"
894
+ },
895
+ {
896
+ "components": [
897
+ {
898
+ "internalType": "address[]",
899
+ "name": "validators",
900
+ "type": "address[]"
901
+ },
902
+ {
903
+ "internalType": "uint256[]",
904
+ "name": "powers",
905
+ "type": "uint256[]"
906
+ },
907
+ {
908
+ "internalType": "uint256",
909
+ "name": "valsetNonce",
910
+ "type": "uint256"
911
+ },
912
+ {
913
+ "internalType": "uint256",
914
+ "name": "rewardAmount",
915
+ "type": "uint256"
916
+ },
917
+ {
918
+ "internalType": "address",
919
+ "name": "rewardToken",
920
+ "type": "address"
921
+ }
922
+ ],
923
+ "internalType": "struct ValsetArgs",
924
+ "name": "_currentValset",
925
+ "type": "tuple"
926
+ },
927
+ {
928
+ "components": [
929
+ {
930
+ "internalType": "uint8",
931
+ "name": "v",
932
+ "type": "uint8"
933
+ },
934
+ {
935
+ "internalType": "bytes32",
936
+ "name": "r",
937
+ "type": "bytes32"
938
+ },
939
+ {
940
+ "internalType": "bytes32",
941
+ "name": "s",
942
+ "type": "bytes32"
943
+ }
944
+ ],
945
+ "internalType": "struct Signature[]",
946
+ "name": "_sigs",
947
+ "type": "tuple[]"
948
+ }
949
+ ],
950
+ "name": "updateValset",
951
+ "outputs": [],
952
+ "stateMutability": "nonpayable",
953
+ "type": "function"
954
+ }
955
+ ] as const satisfies Abi;
956
+
957
+ /**
958
+ * Type-safe ABI for Gravity_json
959
+ */
960
+ export type Gravity_jsonAbi = typeof Gravity_jsonAbi;
961
+
962
+ /**
963
+ * Contract instance type for Gravity_json
964
+ */
965
+ // Use any for contract type to avoid complex viem type issues
966
+ // The runtime behavior is type-safe through viem's ABI typing
967
+ export type Gravity_jsonContract = any;
968
+
969
+ /**
970
+ * Gravity_json Contract Class
971
+ *
972
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
973
+ *
974
+ * @example
975
+ * ```typescript
976
+ * import { createPublicClient, createWalletClient, http } from 'viem';
977
+ * import { mainnet } from 'viem/chains';
978
+ * import { Gravity_json } from 'Gravity_json';
979
+ *
980
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
981
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
982
+ *
983
+ * const contract = new Gravity_json('0x...', { publicClient, walletClient });
984
+ *
985
+ * // Read functions
986
+ * const result = await contract.balanceOf('0x...');
987
+ *
988
+ * // Write functions
989
+ * const hash = await contract.transfer('0x...', 1000n);
990
+ *
991
+ * // Simulate transactions (dry-run)
992
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
993
+ * console.log('Gas estimate:', simulation.request.gas);
994
+ *
995
+ * // Watch events
996
+ * const unwatch = contract.watch.Transfer((event) => {
997
+ * console.log('Transfer event:', event);
998
+ * });
999
+ * ```
1000
+ */
1001
+ export class Gravity_json {
1002
+ private contract: Gravity_jsonContract;
1003
+ private contractAddress: Address;
1004
+ private publicClient: PublicClient;
1005
+
1006
+ constructor(
1007
+ address: Address,
1008
+ clients: {
1009
+ publicClient: PublicClient;
1010
+ walletClient?: WalletClient;
1011
+ }
1012
+ ) {
1013
+ this.contractAddress = address;
1014
+ this.publicClient = clients.publicClient;
1015
+ this.contract = getContract({
1016
+ address,
1017
+ abi: Gravity_jsonAbi,
1018
+ client: {
1019
+ public: clients.publicClient,
1020
+ wallet: clients.walletClient,
1021
+ },
1022
+ });
1023
+ }
1024
+
1025
+ /**
1026
+ * Get the contract address
1027
+ */
1028
+ get address(): Address {
1029
+ return this.contractAddress;
1030
+ }
1031
+
1032
+ /**
1033
+ * Get the underlying viem contract instance
1034
+ */
1035
+ getContract(): Gravity_jsonContract {
1036
+ return this.contract;
1037
+ }
1038
+
1039
+ /**
1040
+ * lastBatchNonce
1041
+ * view
1042
+ */
1043
+ async lastBatchNonce(_erc20Address: `0x${string}`): Promise<bigint> {
1044
+ return this.contract.read.lastBatchNonce([_erc20Address] as const) as Promise<bigint>;
1045
+ }
1046
+
1047
+ /**
1048
+ * lastLogicCallNonce
1049
+ * view
1050
+ */
1051
+ async lastLogicCallNonce(_invalidation_id: `0x${string}`): Promise<bigint> {
1052
+ return this.contract.read.lastLogicCallNonce([_invalidation_id] as const) as Promise<bigint>;
1053
+ }
1054
+
1055
+ /**
1056
+ * state_gravityId
1057
+ * view
1058
+ */
1059
+ async state_gravityId(): Promise<`0x${string}`> {
1060
+ return this.contract.read.state_gravityId() as Promise<`0x${string}`>;
1061
+ }
1062
+
1063
+ /**
1064
+ * state_invalidationMapping
1065
+ * view
1066
+ */
1067
+ async state_invalidationMapping(arg0: `0x${string}`): Promise<bigint> {
1068
+ return this.contract.read.state_invalidationMapping([arg0] as const) as Promise<bigint>;
1069
+ }
1070
+
1071
+ /**
1072
+ * state_lastBatchNonces
1073
+ * view
1074
+ */
1075
+ async state_lastBatchNonces(arg0: `0x${string}`): Promise<bigint> {
1076
+ return this.contract.read.state_lastBatchNonces([arg0] as const) as Promise<bigint>;
1077
+ }
1078
+
1079
+ /**
1080
+ * state_lastEventNonce
1081
+ * view
1082
+ */
1083
+ async state_lastEventNonce(): Promise<bigint> {
1084
+ return this.contract.read.state_lastEventNonce() as Promise<bigint>;
1085
+ }
1086
+
1087
+ /**
1088
+ * state_lastValsetCheckpoint
1089
+ * view
1090
+ */
1091
+ async state_lastValsetCheckpoint(): Promise<`0x${string}`> {
1092
+ return this.contract.read.state_lastValsetCheckpoint() as Promise<`0x${string}`>;
1093
+ }
1094
+
1095
+ /**
1096
+ * state_lastValsetNonce
1097
+ * view
1098
+ */
1099
+ async state_lastValsetNonce(): Promise<bigint> {
1100
+ return this.contract.read.state_lastValsetNonce() as Promise<bigint>;
1101
+ }
1102
+
1103
+ /**
1104
+ * testCheckValidatorSignatures
1105
+ * pure
1106
+ */
1107
+ async testCheckValidatorSignatures(_currentValset: ValsetArgs, _sigs: Signature[], _theHash: `0x${string}`, _powerThreshold: bigint): Promise<void> {
1108
+ return this.contract.read.testCheckValidatorSignatures([_currentValset, _sigs, _theHash, _powerThreshold] as const) as Promise<void>;
1109
+ }
1110
+
1111
+ /**
1112
+ * testMakeCheckpoint
1113
+ * pure
1114
+ */
1115
+ async testMakeCheckpoint(_valsetArgs: ValsetArgs, _gravityId: `0x${string}`): Promise<void> {
1116
+ return this.contract.read.testMakeCheckpoint([_valsetArgs, _gravityId] as const) as Promise<void>;
1117
+ }
1118
+
1119
+ /**
1120
+ * deployERC20
1121
+ * nonpayable
1122
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1123
+ */
1124
+ async deployERC20(_cosmosDenom: string, _name: string, _symbol: string, _decimals: bigint, options?: {
1125
+ accessList?: import('viem').AccessList;
1126
+ authorizationList?: import('viem').AuthorizationList;
1127
+ chain?: import('viem').Chain | null;
1128
+ dataSuffix?: `0x${string}`;
1129
+ gas?: bigint;
1130
+ gasPrice?: bigint;
1131
+ maxFeePerGas?: bigint;
1132
+ maxPriorityFeePerGas?: bigint;
1133
+ nonce?: number;
1134
+ value?: bigint;
1135
+ }): Promise<`0x${string}`> {
1136
+ if (!this.contract.write) {
1137
+ throw new Error('Wallet client is required for write operations');
1138
+ }
1139
+ return this.contract.write.deployERC20([_cosmosDenom, _name, _symbol, _decimals] as const, options) as Promise<`0x${string}`>;
1140
+ }
1141
+
1142
+ /**
1143
+ * sendToCosmos
1144
+ * nonpayable
1145
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1146
+ */
1147
+ async sendToCosmos(_tokenContract: `0x${string}`, _destination: string, _amount: bigint, options?: {
1148
+ accessList?: import('viem').AccessList;
1149
+ authorizationList?: import('viem').AuthorizationList;
1150
+ chain?: import('viem').Chain | null;
1151
+ dataSuffix?: `0x${string}`;
1152
+ gas?: bigint;
1153
+ gasPrice?: bigint;
1154
+ maxFeePerGas?: bigint;
1155
+ maxPriorityFeePerGas?: bigint;
1156
+ nonce?: number;
1157
+ value?: bigint;
1158
+ }): Promise<`0x${string}`> {
1159
+ if (!this.contract.write) {
1160
+ throw new Error('Wallet client is required for write operations');
1161
+ }
1162
+ return this.contract.write.sendToCosmos([_tokenContract, _destination, _amount] as const, options) as Promise<`0x${string}`>;
1163
+ }
1164
+
1165
+ /**
1166
+ * submitBatch
1167
+ * nonpayable
1168
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1169
+ */
1170
+ async submitBatch(_currentValset: ValsetArgs, _sigs: Signature[], _amounts: bigint[], _destinations: `0x${string}`[], _fees: bigint[], _batchNonce: bigint, _tokenContract: `0x${string}`, _batchTimeout: bigint, options?: {
1171
+ accessList?: import('viem').AccessList;
1172
+ authorizationList?: import('viem').AuthorizationList;
1173
+ chain?: import('viem').Chain | null;
1174
+ dataSuffix?: `0x${string}`;
1175
+ gas?: bigint;
1176
+ gasPrice?: bigint;
1177
+ maxFeePerGas?: bigint;
1178
+ maxPriorityFeePerGas?: bigint;
1179
+ nonce?: number;
1180
+ value?: bigint;
1181
+ }): Promise<`0x${string}`> {
1182
+ if (!this.contract.write) {
1183
+ throw new Error('Wallet client is required for write operations');
1184
+ }
1185
+ return this.contract.write.submitBatch([_currentValset, _sigs, _amounts, _destinations, _fees, _batchNonce, _tokenContract, _batchTimeout] as const, options) as Promise<`0x${string}`>;
1186
+ }
1187
+
1188
+ /**
1189
+ * submitLogicCall
1190
+ * nonpayable
1191
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1192
+ */
1193
+ async submitLogicCall(_currentValset: ValsetArgs, _sigs: Signature[], _args: LogicCallArgs, options?: {
1194
+ accessList?: import('viem').AccessList;
1195
+ authorizationList?: import('viem').AuthorizationList;
1196
+ chain?: import('viem').Chain | null;
1197
+ dataSuffix?: `0x${string}`;
1198
+ gas?: bigint;
1199
+ gasPrice?: bigint;
1200
+ maxFeePerGas?: bigint;
1201
+ maxPriorityFeePerGas?: bigint;
1202
+ nonce?: number;
1203
+ value?: bigint;
1204
+ }): Promise<`0x${string}`> {
1205
+ if (!this.contract.write) {
1206
+ throw new Error('Wallet client is required for write operations');
1207
+ }
1208
+ return this.contract.write.submitLogicCall([_currentValset, _sigs, _args] as const, options) as Promise<`0x${string}`>;
1209
+ }
1210
+
1211
+ /**
1212
+ * updateValset
1213
+ * nonpayable
1214
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1215
+ */
1216
+ async updateValset(_newValset: ValsetArgs, _currentValset: ValsetArgs, _sigs: Signature[], options?: {
1217
+ accessList?: import('viem').AccessList;
1218
+ authorizationList?: import('viem').AuthorizationList;
1219
+ chain?: import('viem').Chain | null;
1220
+ dataSuffix?: `0x${string}`;
1221
+ gas?: bigint;
1222
+ gasPrice?: bigint;
1223
+ maxFeePerGas?: bigint;
1224
+ maxPriorityFeePerGas?: bigint;
1225
+ nonce?: number;
1226
+ value?: bigint;
1227
+ }): Promise<`0x${string}`> {
1228
+ if (!this.contract.write) {
1229
+ throw new Error('Wallet client is required for write operations');
1230
+ }
1231
+ return this.contract.write.updateValset([_newValset, _currentValset, _sigs] as const, options) as Promise<`0x${string}`>;
1232
+ }
1233
+
1234
+
1235
+
1236
+ /**
1237
+ * Simulate contract write operations (dry-run without sending transaction)
1238
+ *
1239
+ * @example
1240
+ * const result = await contract.simulate.transfer('0x...', 1000n);
1241
+ * console.log('Gas estimate:', result.request.gas);
1242
+ * console.log('Would succeed:', result.result);
1243
+ */
1244
+ get simulate() {
1245
+ const contract = this.contract;
1246
+ if (!contract.simulate) {
1247
+ throw new Error('Public client is required for simulation');
1248
+ }
1249
+ return {
1250
+ /**
1251
+ * Simulate deployERC20
1252
+ * Returns gas estimate and result without sending transaction
1253
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1254
+ */
1255
+ async deployERC20(_cosmosDenom: string, _name: string, _symbol: string, _decimals: bigint, options?: {
1256
+ accessList?: import('viem').AccessList;
1257
+ authorizationList?: import('viem').AuthorizationList;
1258
+ chain?: import('viem').Chain | null;
1259
+ dataSuffix?: `0x${string}`;
1260
+ gas?: bigint;
1261
+ gasPrice?: bigint;
1262
+ maxFeePerGas?: bigint;
1263
+ maxPriorityFeePerGas?: bigint;
1264
+ nonce?: number;
1265
+ value?: bigint;
1266
+ }): Promise<void> {
1267
+ return contract.simulate.deployERC20([_cosmosDenom, _name, _symbol, _decimals] as const, options) as Promise<void>;
1268
+ },
1269
+ /**
1270
+ * Simulate sendToCosmos
1271
+ * Returns gas estimate and result without sending transaction
1272
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1273
+ */
1274
+ async sendToCosmos(_tokenContract: `0x${string}`, _destination: string, _amount: bigint, options?: {
1275
+ accessList?: import('viem').AccessList;
1276
+ authorizationList?: import('viem').AuthorizationList;
1277
+ chain?: import('viem').Chain | null;
1278
+ dataSuffix?: `0x${string}`;
1279
+ gas?: bigint;
1280
+ gasPrice?: bigint;
1281
+ maxFeePerGas?: bigint;
1282
+ maxPriorityFeePerGas?: bigint;
1283
+ nonce?: number;
1284
+ value?: bigint;
1285
+ }): Promise<void> {
1286
+ return contract.simulate.sendToCosmos([_tokenContract, _destination, _amount] as const, options) as Promise<void>;
1287
+ },
1288
+ /**
1289
+ * Simulate submitBatch
1290
+ * Returns gas estimate and result without sending transaction
1291
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1292
+ */
1293
+ async submitBatch(_currentValset: ValsetArgs, _sigs: Signature[], _amounts: bigint[], _destinations: `0x${string}`[], _fees: bigint[], _batchNonce: bigint, _tokenContract: `0x${string}`, _batchTimeout: bigint, options?: {
1294
+ accessList?: import('viem').AccessList;
1295
+ authorizationList?: import('viem').AuthorizationList;
1296
+ chain?: import('viem').Chain | null;
1297
+ dataSuffix?: `0x${string}`;
1298
+ gas?: bigint;
1299
+ gasPrice?: bigint;
1300
+ maxFeePerGas?: bigint;
1301
+ maxPriorityFeePerGas?: bigint;
1302
+ nonce?: number;
1303
+ value?: bigint;
1304
+ }): Promise<void> {
1305
+ return contract.simulate.submitBatch([_currentValset, _sigs, _amounts, _destinations, _fees, _batchNonce, _tokenContract, _batchTimeout] as const, options) as Promise<void>;
1306
+ },
1307
+ /**
1308
+ * Simulate submitLogicCall
1309
+ * Returns gas estimate and result without sending transaction
1310
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1311
+ */
1312
+ async submitLogicCall(_currentValset: ValsetArgs, _sigs: Signature[], _args: LogicCallArgs, options?: {
1313
+ accessList?: import('viem').AccessList;
1314
+ authorizationList?: import('viem').AuthorizationList;
1315
+ chain?: import('viem').Chain | null;
1316
+ dataSuffix?: `0x${string}`;
1317
+ gas?: bigint;
1318
+ gasPrice?: bigint;
1319
+ maxFeePerGas?: bigint;
1320
+ maxPriorityFeePerGas?: bigint;
1321
+ nonce?: number;
1322
+ value?: bigint;
1323
+ }): Promise<void> {
1324
+ return contract.simulate.submitLogicCall([_currentValset, _sigs, _args] as const, options) as Promise<void>;
1325
+ },
1326
+ /**
1327
+ * Simulate updateValset
1328
+ * Returns gas estimate and result without sending transaction
1329
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
1330
+ */
1331
+ async updateValset(_newValset: ValsetArgs, _currentValset: ValsetArgs, _sigs: Signature[], options?: {
1332
+ accessList?: import('viem').AccessList;
1333
+ authorizationList?: import('viem').AuthorizationList;
1334
+ chain?: import('viem').Chain | null;
1335
+ dataSuffix?: `0x${string}`;
1336
+ gas?: bigint;
1337
+ gasPrice?: bigint;
1338
+ maxFeePerGas?: bigint;
1339
+ maxPriorityFeePerGas?: bigint;
1340
+ nonce?: number;
1341
+ value?: bigint;
1342
+ }): Promise<void> {
1343
+ return contract.simulate.updateValset([_newValset, _currentValset, _sigs] as const, options) as Promise<void>;
1344
+ }
1345
+ };
1346
+ }
1347
+
1348
+ /**
1349
+ * Watch contract events
1350
+ *
1351
+ * @example
1352
+ * // Watch all Transfer events
1353
+ * const unwatch = contract.watch.Transfer((event) => {
1354
+ * console.log('Transfer:', event);
1355
+ * });
1356
+ *
1357
+ * // Stop watching
1358
+ * unwatch();
1359
+ */
1360
+ get watch() {
1361
+ return {
1362
+ /**
1363
+ * Watch ERC20DeployedEvent events
1364
+ * @param callback Function to call when event is emitted
1365
+ * @param filter Optional filter for indexed parameters
1366
+ * @returns Unwatch function to stop listening
1367
+ */
1368
+ ERC20DeployedEvent: (callback: (event: { _tokenContract: `0x${string}`; _cosmosDenom: string; _name: string; _symbol: string; _decimals: bigint; _eventNonce: bigint }) => void, filter?: { _tokenContract: `0x${string}` }) => {
1369
+ return this.publicClient.watchContractEvent({
1370
+ address: this.contractAddress,
1371
+ abi: Gravity_jsonAbi,
1372
+ eventName: 'ERC20DeployedEvent',
1373
+ args: filter,
1374
+ onLogs: (logs: any[]) => {
1375
+ logs.forEach((log: any) => {
1376
+ callback(log.args as any);
1377
+ });
1378
+ },
1379
+ }) as () => void;
1380
+ },
1381
+ /**
1382
+ * Watch LogicCallEvent events
1383
+ * @param callback Function to call when event is emitted
1384
+ * @param filter Optional filter for indexed parameters
1385
+ * @returns Unwatch function to stop listening
1386
+ */
1387
+ LogicCallEvent: (callback: (event: { _invalidationId: `0x${string}`; _invalidationNonce: bigint; _returnData: `0x${string}`; _eventNonce: bigint }) => void) => {
1388
+ return this.publicClient.watchContractEvent({
1389
+ address: this.contractAddress,
1390
+ abi: Gravity_jsonAbi,
1391
+ eventName: 'LogicCallEvent',
1392
+
1393
+ onLogs: (logs: any[]) => {
1394
+ logs.forEach((log: any) => {
1395
+ callback(log.args as any);
1396
+ });
1397
+ },
1398
+ }) as () => void;
1399
+ },
1400
+ /**
1401
+ * Watch SendToCosmosEvent events
1402
+ * @param callback Function to call when event is emitted
1403
+ * @param filter Optional filter for indexed parameters
1404
+ * @returns Unwatch function to stop listening
1405
+ */
1406
+ SendToCosmosEvent: (callback: (event: { _tokenContract: `0x${string}`; _sender: `0x${string}`; _destination: string; _amount: bigint; _eventNonce: bigint }) => void, filter?: { _tokenContract: `0x${string}`; _sender: `0x${string}` }) => {
1407
+ return this.publicClient.watchContractEvent({
1408
+ address: this.contractAddress,
1409
+ abi: Gravity_jsonAbi,
1410
+ eventName: 'SendToCosmosEvent',
1411
+ args: filter,
1412
+ onLogs: (logs: any[]) => {
1413
+ logs.forEach((log: any) => {
1414
+ callback(log.args as any);
1415
+ });
1416
+ },
1417
+ }) as () => void;
1418
+ },
1419
+ /**
1420
+ * Watch TransactionBatchExecutedEvent events
1421
+ * @param callback Function to call when event is emitted
1422
+ * @param filter Optional filter for indexed parameters
1423
+ * @returns Unwatch function to stop listening
1424
+ */
1425
+ TransactionBatchExecutedEvent: (callback: (event: { _batchNonce: bigint; _token: `0x${string}`; _eventNonce: bigint }) => void, filter?: { _batchNonce: bigint; _token: `0x${string}` }) => {
1426
+ return this.publicClient.watchContractEvent({
1427
+ address: this.contractAddress,
1428
+ abi: Gravity_jsonAbi,
1429
+ eventName: 'TransactionBatchExecutedEvent',
1430
+ args: filter,
1431
+ onLogs: (logs: any[]) => {
1432
+ logs.forEach((log: any) => {
1433
+ callback(log.args as any);
1434
+ });
1435
+ },
1436
+ }) as () => void;
1437
+ },
1438
+ /**
1439
+ * Watch ValsetUpdatedEvent events
1440
+ * @param callback Function to call when event is emitted
1441
+ * @param filter Optional filter for indexed parameters
1442
+ * @returns Unwatch function to stop listening
1443
+ */
1444
+ ValsetUpdatedEvent: (callback: (event: { _newValsetNonce: bigint; _eventNonce: bigint; _rewardAmount: bigint; _rewardToken: `0x${string}`; _validators: `0x${string}`[]; _powers: bigint[] }) => void, filter?: { _newValsetNonce: bigint }) => {
1445
+ return this.publicClient.watchContractEvent({
1446
+ address: this.contractAddress,
1447
+ abi: Gravity_jsonAbi,
1448
+ eventName: 'ValsetUpdatedEvent',
1449
+ args: filter,
1450
+ onLogs: (logs: any[]) => {
1451
+ logs.forEach((log: any) => {
1452
+ callback(log.args as any);
1453
+ });
1454
+ },
1455
+ }) as () => void;
1456
+ }
1457
+ };
1458
+ }
1459
+ }