-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathapproval.teal
897 lines (881 loc) · 9 KB
/
approval.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
#pragma version 8
txn NumAppArgs
int 0
==
bnz main_l34
txna ApplicationArgs 0
method "box_write(byte[],(uint64,uint64))void"
==
bnz main_l33
txna ApplicationArgs 0
method "box_read(byte[])(uint64,uint64)"
==
bnz main_l32
txna ApplicationArgs 0
method "add(uint64,uint64)uint64"
==
bnz main_l31
txna ApplicationArgs 0
method "sub(uint64,uint64)uint64"
==
bnz main_l30
txna ApplicationArgs 0
method "mul(uint64,uint64)uint64"
==
bnz main_l29
txna ApplicationArgs 0
method "div(uint64,uint64)uint64"
==
bnz main_l28
txna ApplicationArgs 0
method "mod(uint64,uint64)uint64"
==
bnz main_l27
txna ApplicationArgs 0
method "qrem(uint64,uint64)(uint64,uint64)"
==
bnz main_l26
txna ApplicationArgs 0
method "reverse(string)string"
==
bnz main_l25
txna ApplicationArgs 0
method "concat_strings(string[])string"
==
bnz main_l24
txna ApplicationArgs 0
method "make_array(uint64,uint64,uint64)uint64[]"
==
bnz main_l23
txna ApplicationArgs 0
method "sum_array(uint64[])uint64"
==
bnz main_l22
txna ApplicationArgs 0
method "manyargs(uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64)uint64"
==
bnz main_l21
txna ApplicationArgs 0
method "min_bal(account)uint64"
==
bnz main_l20
txna ApplicationArgs 0
method "no_return(uint64)void"
==
bnz main_l19
txna ApplicationArgs 0
method "txntest(uint64,pay,uint64)uint64"
==
bnz main_l18
err
main_l18:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 51
txna ApplicationArgs 2
btoi
store 53
txn GroupIndex
int 1
-
store 52
load 52
gtxns TypeEnum
int pay
==
assert
load 51
load 52
load 53
callsub txntest_15
store 54
byte 0x151f7c75
load 54
itob
concat
log
int 1
return
main_l19:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
callsub noreturn_14
int 1
return
main_l20:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
int 0
getbyte
callsub minbal_13
store 50
byte 0x151f7c75
load 50
itob
concat
log
int 1
return
main_l21:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 28
txna ApplicationArgs 2
btoi
store 29
txna ApplicationArgs 3
btoi
store 30
txna ApplicationArgs 4
btoi
store 31
txna ApplicationArgs 5
btoi
store 32
txna ApplicationArgs 6
btoi
store 33
txna ApplicationArgs 7
btoi
store 34
txna ApplicationArgs 8
btoi
store 35
txna ApplicationArgs 9
btoi
store 36
txna ApplicationArgs 10
btoi
store 37
txna ApplicationArgs 11
btoi
store 38
txna ApplicationArgs 12
btoi
store 39
txna ApplicationArgs 13
btoi
store 40
txna ApplicationArgs 14
btoi
store 41
txna ApplicationArgs 15
store 48
load 48
int 0
extract_uint64
store 42
load 48
int 8
extract_uint64
store 43
load 48
int 16
extract_uint64
store 44
load 48
int 24
extract_uint64
store 45
load 48
int 32
extract_uint64
store 46
load 48
int 40
extract_uint64
store 47
load 28
load 29
load 30
load 31
load 32
load 33
load 34
load 35
load 36
load 37
load 38
load 39
load 40
load 41
load 42
load 43
load 44
load 45
load 46
load 47
callsub manyargs_12
store 49
byte 0x151f7c75
load 49
itob
concat
log
int 1
return
main_l22:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
callsub sumarray_11
store 27
byte 0x151f7c75
load 27
itob
concat
log
int 1
return
main_l23:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 23
txna ApplicationArgs 2
btoi
store 24
txna ApplicationArgs 3
btoi
store 25
load 23
load 24
load 25
callsub makearray_10
store 26
byte 0x151f7c75
load 26
concat
log
int 1
return
main_l24:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
callsub concatstrings_9
store 22
byte 0x151f7c75
load 22
concat
log
int 1
return
main_l25:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
callsub reverse_8
store 21
byte 0x151f7c75
load 21
concat
log
int 1
return
main_l26:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 18
txna ApplicationArgs 2
btoi
store 19
load 18
load 19
callsub qrem_7
store 20
byte 0x151f7c75
load 20
concat
log
int 1
return
main_l27:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 15
txna ApplicationArgs 2
btoi
store 16
load 15
load 16
callsub mod_6
store 17
byte 0x151f7c75
load 17
itob
concat
log
int 1
return
main_l28:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 12
txna ApplicationArgs 2
btoi
store 13
load 12
load 13
callsub div_5
store 14
byte 0x151f7c75
load 14
itob
concat
log
int 1
return
main_l29:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 9
txna ApplicationArgs 2
btoi
store 10
load 9
load 10
callsub mul_4
store 11
byte 0x151f7c75
load 11
itob
concat
log
int 1
return
main_l30:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 6
txna ApplicationArgs 2
btoi
store 7
load 6
load 7
callsub sub_3
store 8
byte 0x151f7c75
load 8
itob
concat
log
int 1
return
main_l31:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
btoi
store 3
txna ApplicationArgs 2
btoi
store 4
load 3
load 4
callsub add_2
store 5
byte 0x151f7c75
load 5
itob
concat
log
int 1
return
main_l32:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
callsub boxread_1
store 2
byte 0x151f7c75
load 2
concat
log
int 1
return
main_l33:
txn OnCompletion
int NoOp
==
txn ApplicationID
int 0
!=
&&
assert
txna ApplicationArgs 1
store 0
txna ApplicationArgs 2
store 1
load 0
load 1
callsub boxwrite_0
int 1
return
main_l34:
txn OnCompletion
int NoOp
==
bnz main_l40
txn OnCompletion
int UpdateApplication
==
bnz main_l39
txn OnCompletion
int DeleteApplication
==
bnz main_l38
err
main_l38:
txn Sender
global CreatorAddress
==
return
main_l39:
txn Sender
global CreatorAddress
==
return
main_l40:
txn ApplicationID
int 0
==
assert
int 1
return
// box_write
boxwrite_0:
proto 2 0
frame_dig -2
extract 2 0
frame_dig -1
box_put
retsub
// box_read
boxread_1:
proto 1 1
byte ""
frame_dig -1
extract 2 0
box_get
store 56
store 55
load 56
assert
load 55
frame_bury 0
retsub
// add
add_2:
proto 2 1
int 0
frame_dig -2
frame_dig -1
+
frame_bury 0
retsub
// sub
sub_3:
proto 2 1
int 0
frame_dig -2
frame_dig -1
-
frame_bury 0
retsub
// mul
mul_4:
proto 2 1
int 0
frame_dig -2
frame_dig -1
*
frame_bury 0
retsub
// div
div_5:
proto 2 1
int 0
frame_dig -2
frame_dig -1
/
frame_bury 0
retsub
// mod
mod_6:
proto 2 1
int 0
frame_dig -2
frame_dig -1
%
frame_bury 0
retsub
// qrem
qrem_7:
proto 2 1
byte ""
int 0
dupn 3
byte ""
dup
frame_dig -2
frame_dig -1
/
frame_bury 1
frame_dig -2
frame_dig -1
%
frame_bury 2
frame_dig 1
itob
frame_dig 2
itob
concat
frame_bury 0
retsub
// reverse
reverse_8:
proto 1 1
byte ""
int 0
dupn 2
byte ""
store 58
int 0
store 57
reverse_8_l1:
load 57
frame_dig -1
int 0
extract_uint16
frame_bury 1
frame_dig 1
<
bz reverse_8_l3
frame_dig -1
int 1
load 57
*
int 2
+
getbyte
frame_bury 2
byte 0x00
int 0
frame_dig 2
setbyte
load 58
concat
store 58
load 57
int 1
+
store 57
b reverse_8_l1
reverse_8_l3:
load 58
frame_bury 0
frame_dig 0
len
itob
extract 6 0
frame_dig 0
concat
frame_bury 0
retsub
// concat_strings
concatstrings_9:
proto 1 1
byte ""
int 0
byte ""
int 0
byte ""
store 60
int 0
store 59
concatstrings_9_l1:
load 59
frame_dig -1
int 0
extract_uint16
frame_bury 1
frame_dig 1
<
bz concatstrings_9_l6
frame_dig -1
frame_dig -1
int 2
load 59
*
int 2
+
extract_uint16
int 2
+
load 59
int 1
+
frame_dig -1
int 0
extract_uint16
frame_bury 3
frame_dig 3
==
bnz concatstrings_9_l5
frame_dig -1
int 2
load 59
*
int 2
+
int 2
+
extract_uint16
int 2
+
concatstrings_9_l4:
substring3
frame_bury 2
load 60
frame_dig 2
extract 2 0
concat
store 60
load 59
int 1
+
store 59
b concatstrings_9_l1
concatstrings_9_l5:
frame_dig -1
len
b concatstrings_9_l4
concatstrings_9_l6:
load 60
frame_bury 0
frame_dig 0
len
itob
extract 6 0
frame_dig 0
concat
frame_bury 0
retsub
// make_array
makearray_10:
proto 3 1
byte ""
int 0
dup
byte ""
dup
int 0
int 3
frame_bury 5
frame_dig 5
itob
extract 6 0
frame_dig -3
itob
frame_dig -2
itob
concat
frame_dig -1
itob
concat
concat
frame_bury 0
retsub
// sum_array
sumarray_11:
proto 1 1
int 0
dupn 3
int 0
store 62
int 0
store 61
sumarray_11_l1:
load 61
frame_dig -1
int 0
extract_uint16
frame_bury 1
frame_dig 1
<
bz sumarray_11_l3
frame_dig -1
int 8
load 61
*
int 2
+
extract_uint64
frame_bury 2
frame_dig 2
load 62
+
store 62
load 61
int 1
+
store 61
b sumarray_11_l1
sumarray_11_l3:
load 62
frame_bury 0
retsub
// manyargs
manyargs_12:
proto 20 1
int 0
frame_dig -20
frame_bury 0
retsub
// min_bal
minbal_13:
proto 1 1
int 0
frame_dig -1
acct_params_get AcctMinBalance
store 63
frame_bury 0
retsub
// no_return
noreturn_14:
proto 1 0
int 1
assert
retsub
// txntest
txntest_15:
proto 3 1
int 0
frame_dig -2
gtxns TypeEnum
int pay
==
assert
frame_dig -2
gtxns Amount
frame_dig -3
==
assert
frame_dig -2
gtxns Fee
frame_dig -1
==
assert
frame_dig -2
gtxns Amount
frame_bury 0
retsub