forked from wormhole-foundation/wormhole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken_approve.teal
2291 lines (2268 loc) · 25.6 KB
/
token_approve.teal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma version 6
intcblock 0 1 2 127 133 128 255
bytecblock 0x 0x636f72656964 0x436861696e 0x6e6174697665 0x7075626c6973684d657373616765 0x6e6f70 0x766572696679564141 0x0008 0x76616c6964557064617465417070726f766548617368 0x414c474f 0x50726f6772616d 0x636f726541646472
txn ApplicationID
intc_0 // 0
==
bnz main_l81
txn OnCompletion
pushint 4 // UpdateApplication
==
bnz main_l80
txn OnCompletion
pushint 5 // DeleteApplication
==
bnz main_l79
txn OnCompletion
intc_1 // OptIn
==
bnz main_l78
txn OnCompletion
intc_0 // NoOp
==
bnz main_l6
err
main_l6:
txna ApplicationArgs 0
bytec 5 // "nop"
==
bnz main_l77
txna ApplicationArgs 0
pushbytes 0x72656365697665417474657374 // "receiveAttest"
==
bnz main_l70
txna ApplicationArgs 0
pushbytes 0x617474657374546f6b656e // "attestToken"
==
bnz main_l58
txna ApplicationArgs 0
pushbytes 0x636f6d706c6574655472616e73666572 // "completeTransfer"
==
bnz main_l41
txna ApplicationArgs 0
pushbytes 0x73656e645472616e73666572 // "sendTransfer"
==
bnz main_l21
txna ApplicationArgs 0
pushbytes 0x6f7074696e // "optin"
==
bnz main_l20
txna ApplicationArgs 0
pushbytes 0x676f7665726e616e6365 // "governance"
==
bnz main_l14
err
main_l14:
callsub checkForDuplicate_21
callsub governanceSet_7
store 67
txna ApplicationArgs 1
extract 1 4
btoi
load 67
==
assert
txna ApplicationArgs 1
extract 5 1
btoi
pushint 66 // 66
*
pushint 14 // 14
+
store 62
txn GroupIndex
intc_1 // 1
-
store 68
load 68
gtxns TypeEnum
pushint 6 // appl
==
load 68
gtxns ApplicationID
bytec_1 // "coreid"
app_global_get
==
&&
load 68
gtxnsa ApplicationArgs 0
bytec 6 // "verifyVAA"
==
&&
load 68
gtxns Sender
txn Sender
==
&&
load 68
gtxns OnCompletion
intc_0 // NoOp
==
&&
load 68
gtxnsa ApplicationArgs 1
txna ApplicationArgs 1
==
&&
load 68
gtxnsa Accounts 0
txna Accounts 0
==
&&
load 68
gtxnsa Accounts 1
txna Accounts 1
==
&&
load 68
gtxnsa Accounts 2
txna Accounts 2
==
&&
txna ApplicationArgs 1
load 62
intc_2 // 2
extract3
pushbytes 0x0001 // 0x0001
==
&&
txna ApplicationArgs 1
load 62
intc_2 // 2
+
pushint 32 // 32
extract3
pushint 31 // 31
bzero
pushbytes 0x04 // 0x04
concat
==
&&
assert
load 68
gtxns RekeyTo
global ZeroAddress
==
load 68
gtxns CloseRemainderTo
global ZeroAddress
==
&&
load 68
gtxns AssetCloseTo
global ZeroAddress
==
&&
load 68
gtxns OnCompletion
intc_0 // NoOp
==
&&
assert
txn RekeyTo
global ZeroAddress
==
txn CloseRemainderTo
global ZeroAddress
==
&&
txn AssetCloseTo
global ZeroAddress
==
&&
txn OnCompletion
intc_0 // NoOp
==
&&
assert
txna ApplicationArgs 1
load 62
pushint 43 // 43
+
pushint 32 // 32
extract3
pushint 21 // 21
bzero
pushbytes 0x546f6b656e427269646765 // 0x546f6b656e427269646765
concat
==
assert
txna ApplicationArgs 1
load 62
pushint 75 // 75
+
intc_1 // 1
extract3
btoi
store 63
load 62
pushint 76 // 76
+
store 62
load 63
intc_1 // 1
==
bnz main_l19
load 63
intc_2 // 2
==
bnz main_l17
err
main_l17:
txna ApplicationArgs 1
load 62
intc_2 // 2
extract3
bytec 7 // 0x0008
==
assert
bytec 8 // "validUpdateApproveHash"
txna ApplicationArgs 1
load 62
intc_2 // 2
+
pushint 32 // 32
extract3
app_global_put
main_l18:
intc_1 // 1
return
main_l19:
txna ApplicationArgs 1
load 62
intc_2 // 2
extract3
btoi
store 64
load 64
intc_0 // 0
==
load 64
pushint 8 // 8
==
||
assert
txna ApplicationArgs 1
load 62
intc_2 // 2
+
intc_2 // 2
extract3
store 65
txna ApplicationArgs 1
load 62
pushint 4 // 4
+
pushint 32 // 32
extract3
store 66
bytec_2 // "Chain"
load 65
concat
app_global_get
intc_0 // 0
==
assert
bytec_2 // "Chain"
load 65
concat
load 66
app_global_put
b main_l18
main_l20:
txna Accounts 1
txna ApplicationArgs 1
btoi
bytec_3 // "native"
callsub getsigaddress_15
==
assert
txn RekeyTo
global ZeroAddress
==
txn CloseRemainderTo
global ZeroAddress
==
&&
txn AssetCloseTo
global ZeroAddress
==
&&
txn OnCompletion
intc_0 // NoOp
==
&&
assert
itxn_begin
txna Accounts 1
itxn_field Sender
pushint 4 // axfer
itxn_field TypeEnum
txna ApplicationArgs 1
btoi
itxn_field XferAsset
intc_0 // 0
itxn_field AssetAmount
txna Accounts 1
itxn_field AssetReceiver
intc_0 // 0
itxn_field Fee
itxn_submit
intc_1 // 1
return
main_l21:
callsub getMessageFee_8
store 23
pushint 32 // 32
bzero
store 59
txna ApplicationArgs 1
btoi
store 52
txna ApplicationArgs 5
btoi
store 61
intc_2 // 2
callsub checkFeePmt_10
txn GroupIndex
intc_1 // 1
-
store 22
load 52
intc_0 // 0
==
bnz main_l40
load 22
gtxns TypeEnum
pushint 4 // axfer
==
load 22
gtxns Sender
txn Sender
==
&&
load 22
gtxns XferAsset
load 52
==
&&
load 22
gtxns AssetReceiver
txna Accounts 2
==
&&
assert
load 22
gtxns RekeyTo
global ZeroAddress
==
load 22
gtxns CloseRemainderTo
global ZeroAddress
==
&&
load 22
gtxns AssetCloseTo
global ZeroAddress
==
&&
load 22
gtxns OnCompletion
intc_0 // NoOp
==
&&
assert
load 22
gtxns AssetAmount
store 53
load 61
load 53
<=
assert
load 52
callsub extractdecimal_20
btoi
callsub getFactor_14
store 60
load 60
intc_1 // 1
!=
bnz main_l39
main_l23:
load 53
intc_0 // 0
>
load 61
intc_0 // 0
>=
&&
assert
load 52
intc_0 // 0
!=
bnz main_l38
bytec_0 // ""
store 56
main_l25:
load 56
global CurrentApplicationAddress
==
bnz main_l37
txna Accounts 2
load 52
bytec_3 // "native"
callsub getsigaddress_15
==
assert
bytec 7 // 0x0008
store 58
txna ApplicationArgs 1
store 57
main_l27:
load 57
len
pushint 32 // 32
<=
load 58
len
intc_2 // 2
==
&&
txna ApplicationArgs 3
len
pushint 32 // 32
<=
&&
txn NumAppArgs
pushint 7 // 7
<=
&&
assert
txn NumAppArgs
pushint 7 // 7
==
bnz main_l36
pushbytes 0x01 // 0x01
main_l29:
load 59
extract 0 24
concat
load 53
itob
concat
load 59
intc_0 // 0
pushint 32 // 32
load 57
len
-
extract3
concat
load 57
concat
load 58
concat
load 59
intc_0 // 0
pushint 32 // 32
txna ApplicationArgs 3
len
-
extract3
concat
txna ApplicationArgs 3
concat
txna ApplicationArgs 4
extract 6 2
concat
txn NumAppArgs
pushint 7 // 7
==
bnz main_l35
load 59
extract 0 24
load 61
itob
concat
main_l31:
concat
store 54
txn NumAppArgs
pushint 7 // 7
==
bnz main_l34
load 54
len
intc 4 // 133
==
assert
main_l33:
itxn_begin
callsub sendMfee_11
pushint 6 // appl
itxn_field TypeEnum
bytec_1 // "coreid"
app_global_get
itxn_field ApplicationID
bytec 4 // "publishMessage"
itxn_field ApplicationArgs
load 54
itxn_field ApplicationArgs
intc_0 // 0
itob
itxn_field ApplicationArgs
txna Accounts 1
itxn_field Accounts
bytec 4 // "publishMessage"
itxn_field Note
intc_0 // 0
itxn_field Fee
itxn_submit
intc_1 // 1
return
main_l34:
load 54
len
intc 4 // 133
txna ApplicationArgs 6
len
+
==
assert
b main_l33
main_l35:
txn Sender
txna ApplicationArgs 6
concat
b main_l31
main_l36:
pushbytes 0x03 // 0x03
b main_l29
main_l37:
intc_2 // 2
intc_0 // 0
pushint 8 // 8
callsub read_4
store 55
txna ApplicationArgs 1
load 55
==
assert
intc_2 // 2
pushint 60 // 60
pushint 92 // 92
callsub read_4
store 57
intc_2 // 2
pushint 92 // 92
pushint 94 // 94
callsub read_4
store 58
txna Accounts 2
load 58
btoi
load 57
callsub getsigaddress_15
==
assert
b main_l27
main_l38:
load 52
callsub extractcreator_18
callsub authaddr_16
store 56
b main_l25
main_l39:
load 53
load 60
/
store 53
load 61
load 60
/
store 61
b main_l23
main_l40:
load 22
gtxns TypeEnum
intc_1 // pay
==
load 22
gtxns Sender
txn Sender
==
&&
load 22
gtxns Receiver
txna Accounts 2
==
&&
assert
load 22
gtxns RekeyTo
global ZeroAddress
==
load 22
gtxns CloseRemainderTo
global ZeroAddress
==
&&
load 22
gtxns AssetCloseTo
global ZeroAddress
==
&&
load 22
gtxns OnCompletion
intc_0 // NoOp
==
&&
assert
load 22
gtxns Amount
store 53
load 61
load 53
<=
assert
b main_l23
main_l41:
callsub checkForDuplicate_21
pushint 32 // 32
bzero
store 49
txn GroupIndex
intc_1 // 1
-
store 22
load 22
gtxns TypeEnum
pushint 6 // appl
==
load 22
gtxns ApplicationID
bytec_1 // "coreid"
app_global_get
==
&&
load 22
gtxnsa ApplicationArgs 0
bytec 6 // "verifyVAA"
==
&&
load 22
gtxns Sender
txn Sender
==
&&
load 22
gtxns OnCompletion
intc_0 // NoOp
==
&&
load 22
gtxnsa ApplicationArgs 1
txna ApplicationArgs 1
==
&&
load 22
gtxnsa Accounts 0
txna Accounts 0
==
&&
load 22
gtxnsa Accounts 1
txna Accounts 1
==
&&
load 22
gtxnsa Accounts 2
txna Accounts 2
==
&&
assert
load 22
gtxns RekeyTo
global ZeroAddress
==
load 22
gtxns CloseRemainderTo
global ZeroAddress
==
&&
load 22
gtxns AssetCloseTo
global ZeroAddress
==
&&
load 22
gtxns OnCompletion
intc_0 // NoOp
==
&&
assert
txn RekeyTo
global ZeroAddress
==
txn CloseRemainderTo
global ZeroAddress
==
&&
txn AssetCloseTo
global ZeroAddress
==
&&
txn OnCompletion
intc_0 // NoOp
==
&&
assert
txna ApplicationArgs 1
extract 5 1
btoi
pushint 66 // 66
*
pushint 6 // 6
+
pushint 8 // 8
+
store 39
txna ApplicationArgs 1
load 39
intc_2 // 2
extract3
btoi
store 40
txna ApplicationArgs 1
load 39
intc_2 // 2
+
pushint 32 // 32
extract3
store 41
load 40
pushint 8 // 8
==
bnz main_l57
bytec_2 // "Chain"
txna ApplicationArgs 1
load 39
intc_2 // 2
extract3
concat
app_global_get
load 41
==
assert
main_l43:
load 39
pushint 43 // 43
+
store 39
txna ApplicationArgs 1
load 39
intc_1 // 1
extract3
btoi
store 50
load 50
intc_1 // 1
==
load 50
pushint 3 // 3
==
||
assert
txna ApplicationArgs 1
load 39
intc_1 // 1
+
pushint 24 // 24
extract3
load 49
extract 0 24
==
assert
txna ApplicationArgs 1
load 39
pushint 25 // 25
+
pushint 8 // 8
extract3
btoi
store 42
txna ApplicationArgs 1
load 39
pushint 33 // 33
+
pushint 32 // 32
extract3
store 43
txna ApplicationArgs 1
load 39
pushint 65 // 65
+
intc_2 // 2
extract3
btoi
store 44
txna ApplicationArgs 1
load 39
pushint 67 // 67
+
pushint 32 // 32
extract3
store 45
txna ApplicationArgs 1
load 39
pushint 99 // 99
+
intc_2 // 2
extract3
btoi
pushint 8 // 8
==
assert
load 50
pushint 3 // 3
==
bnz main_l56
txna ApplicationArgs 1
load 39
pushint 101 // 101
+
pushint 24 // 24
extract3
load 49
extract 0 24
==
assert
txna ApplicationArgs 1
load 39
pushint 125 // 125
+
pushint 8 // 8
extract3
btoi
store 46
load 46
load 42
<=
assert
load 42
load 46
-
store 42
main_l45:
load 44
pushint 8 // 8
==
bnz main_l50
pushint 3 // 3
intc_0 // 0
pushint 8 // 8
callsub read_4
btoi
store 47
load 47
intc_0 // 0
!=
txna Accounts 3
load 44
load 43
callsub getsigaddress_15
==
&&
assert
main_l47:
itxn_begin
txna Accounts 3
itxn_field Sender
pushint 4 // axfer
itxn_field TypeEnum
load 47
itxn_field XferAsset
load 42
itxn_field AssetAmount
load 45
itxn_field AssetReceiver
intc_0 // 0
itxn_field Fee
load 46
intc_0 // 0
>
bnz main_l49
main_l48:
itxn_submit
intc_1 // 1
return
main_l49:
itxn_next
txna Accounts 3
itxn_field Sender
pushint 4 // axfer
itxn_field TypeEnum
load 47
itxn_field XferAsset
load 46
itxn_field AssetAmount
txn Sender
itxn_field AssetReceiver
intc_0 // 0
itxn_field Fee
b main_l48
main_l50:
load 43
extract 24 8
btoi
store 47
txna Accounts 3
load 47
bytec_3 // "native"
callsub getsigaddress_15
==
assert
load 47
intc_0 // 0
==
bnz main_l53
load 47
callsub extractdecimal_20
btoi
callsub getFactor_14
store 48
load 48
intc_1 // 1
!=
bz main_l47
load 42
load 48
*
store 42
load 46
load 48
*
store 46
b main_l47
main_l53:
itxn_begin
txna Accounts 3
itxn_field Sender
intc_1 // pay
itxn_field TypeEnum
load 45
itxn_field Receiver
load 42
itxn_field Amount
intc_0 // 0
itxn_field Fee
load 46
intc_0 // 0
>
bnz main_l55
main_l54:
itxn_submit
intc_1 // 1
return
main_l55:
itxn_next
txna Accounts 3
itxn_field Sender
intc_1 // pay
itxn_field TypeEnum
txn Sender
itxn_field Receiver
load 46
itxn_field Amount
intc_0 // 0
itxn_field Fee
b main_l54
main_l56:
load 45
extract 24 8
btoi
store 51
txn GroupIndex
intc_1 // 1
+
store 22
load 22
gtxns TypeEnum
pushint 6 // appl
==
load 22
gtxnsa ApplicationArgs 0
pushbytes 0x903f4535 // "portal_transfer(byte[])byte[]"
==
&&
load 22
gtxnsa ApplicationArgs 1
txna ApplicationArgs 1