-
Notifications
You must be signed in to change notification settings - Fork 12
/
VotingRoundApp.approval.teal
1288 lines (1231 loc) · 32.2 KB
/
VotingRoundApp.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
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 10
examples.voting.voting.VotingRoundApp.approval_program:
txn ApplicationID
bnz main_entrypoint@2
callsub __init__
main_entrypoint@2:
callsub __puya_arc4_router__
return
// examples.voting.voting.VotingRoundApp.__puya_arc4_router__() -> uint64:
__puya_arc4_router__:
// voting/voting.py:49
// class VotingRoundApp(ARC4Contract):
proto 0 1
txn NumAppArgs
bz __puya_arc4_router___after_if_else@10
method "create(string,byte[],string,uint64,uint64,uint8[],uint64,string)void"
method "bootstrap(pay)void"
method "close()void"
method "get_preconditions(byte[])(uint64,uint64,uint64,uint64)"
method "vote(pay,byte[],uint8[])void"
txna ApplicationArgs 0
match __puya_arc4_router___create_route@2 __puya_arc4_router___bootstrap_route@3 __puya_arc4_router___close_route@4 __puya_arc4_router___get_preconditions_route@5 __puya_arc4_router___vote_route@6
int 0
retsub
__puya_arc4_router___create_route@2:
// voting/voting.py:58
// @arc4.abimethod(create="require")
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
!
assert // is creating
// voting/voting.py:49
// class VotingRoundApp(ARC4Contract):
txna ApplicationArgs 1
extract 2 0
txna ApplicationArgs 2
extract 2 0
txna ApplicationArgs 3
extract 2 0
txna ApplicationArgs 4
btoi
txna ApplicationArgs 5
btoi
txna ApplicationArgs 6
txna ApplicationArgs 7
btoi
txna ApplicationArgs 8
extract 2 0
// voting/voting.py:58
// @arc4.abimethod(create="require")
callsub create
int 1
retsub
__puya_arc4_router___bootstrap_route@3:
// voting/voting.py:82
// @arc4.abimethod
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// voting/voting.py:49
// class VotingRoundApp(ARC4Contract):
txn GroupIndex
int 1
-
dup
gtxns TypeEnum
int pay
==
assert // transaction type is pay
// voting/voting.py:82
// @arc4.abimethod
callsub bootstrap
int 1
retsub
__puya_arc4_router___close_route@4:
// voting/voting.py:110
// @arc4.abimethod
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
callsub close
int 1
retsub
__puya_arc4_router___get_preconditions_route@5:
// voting/voting.py:160
// @arc4.abimethod(readonly=True)
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// voting/voting.py:49
// class VotingRoundApp(ARC4Contract):
txna ApplicationArgs 1
extract 2 0
// voting/voting.py:160
// @arc4.abimethod(readonly=True)
callsub get_preconditions
byte 0x151f7c75
swap
concat
log
int 1
retsub
__puya_arc4_router___vote_route@6:
// voting/voting.py:169
// @arc4.abimethod
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// voting/voting.py:49
// class VotingRoundApp(ARC4Contract):
txn GroupIndex
int 1
-
dup
gtxns TypeEnum
int pay
==
assert // transaction type is pay
txna ApplicationArgs 1
extract 2 0
txna ApplicationArgs 2
// voting/voting.py:169
// @arc4.abimethod
callsub vote
int 1
retsub
__puya_arc4_router___after_if_else@10:
// voting/voting.py:49
// class VotingRoundApp(ARC4Contract):
int 0
retsub
// examples.voting.voting.VotingRoundApp.create(vote_id: bytes, snapshot_public_key: bytes, metadata_ipfs_cid: bytes, start_time: uint64, end_time: uint64, option_counts: bytes, quorum: uint64, nft_image_url: bytes) -> void:
create:
// voting/voting.py:58-69
// @arc4.abimethod(create="require")
// def create(
// self,
// vote_id: String,
// snapshot_public_key: Bytes,
// metadata_ipfs_cid: String,
// start_time: UInt64,
// end_time: UInt64,
// option_counts: VoteIndexArray,
// quorum: UInt64,
// nft_image_url: String,
// ) -> None:
proto 8 0
// voting/voting.py:70
// assert start_time < end_time, "End time should be after start time"
frame_dig -5
frame_dig -4
<
assert // End time should be after start time
// voting/voting.py:71
// assert end_time >= Global.latest_timestamp, "End time should be in the future"
frame_dig -4
global LatestTimestamp
>=
assert // End time should be in the future
// voting/voting.py:73
// self.vote_id = vote_id
byte "vote_id"
frame_dig -8
app_global_put
// voting/voting.py:74
// self.snapshot_public_key = snapshot_public_key
byte "snapshot_public_key"
frame_dig -7
app_global_put
// voting/voting.py:75
// self.metadata_ipfs_cid = metadata_ipfs_cid
byte "metadata_ipfs_cid"
frame_dig -6
app_global_put
// voting/voting.py:76
// self.start_time = start_time
byte "start_time"
frame_dig -5
app_global_put
// voting/voting.py:77
// self.end_time = end_time
byte "end_time"
frame_dig -4
app_global_put
// voting/voting.py:78
// self.quorum = quorum
byte "quorum"
frame_dig -2
app_global_put
// voting/voting.py:79
// self.nft_image_url = nft_image_url
byte "nft_image_url"
frame_dig -1
app_global_put
// voting/voting.py:80
// self.store_option_counts(option_counts.copy())
frame_dig -3
callsub store_option_counts
pop
retsub
// examples.voting.voting.VotingRoundApp.store_option_counts(option_counts: bytes) -> bytes:
store_option_counts:
// voting/voting.py:217-218
// @subroutine
// def store_option_counts(self, option_counts: VoteIndexArray) -> None:
proto 1 1
// voting/voting.py:219
// assert option_counts.length, "option_counts should be non-empty"
frame_dig -1
int 0
extract_uint16
dupn 2
assert // option_counts should be non-empty
// voting/voting.py:220
// assert option_counts.length <= 112, "Can't have more than 112 questions"
int 112
<=
assert // Can't have more than 112 questions
// voting/voting.py:222
// total_options = UInt64(0)
int 0
dup
store_option_counts_for_header@1:
// voting/voting.py:223
// for item in option_counts:
frame_dig 2
frame_dig 0
<
bz store_option_counts_after_for@4
frame_dig -1
extract 2 0
frame_dig 2
dup
cover 2
int 1
extract3 // on error: Index access is out of bounds
// voting/voting.py:224
// total_options += item.native
btoi
frame_dig 1
+
frame_bury 1
int 1
+
frame_bury 2
b store_option_counts_for_header@1
store_option_counts_after_for@4:
// voting/voting.py:225
// assert total_options <= 128, "Can't have more than 128 vote options"
frame_dig 1
dup
int 128
<=
assert // Can't have more than 128 vote options
// voting/voting.py:227
// self.option_counts = option_counts.copy()
byte "option_counts"
frame_dig -1
app_global_put
// voting/voting.py:228
// self.total_options = total_options
byte "total_options"
swap
app_global_put
frame_dig -1
frame_bury 0
retsub
// examples.voting.voting.VotingRoundApp.bootstrap(fund_min_bal_req: uint64) -> void:
bootstrap:
// voting/voting.py:82-83
// @arc4.abimethod
// def bootstrap(self, fund_min_bal_req: gtxn.PaymentTransaction) -> None:
proto 1 0
// voting/voting.py:84
// assert not self.is_bootstrapped, "Must not be already bootstrapped"
int 0
byte "is_bootstrapped"
app_global_get_ex
assert // check self.is_bootstrapped exists
!
assert // Must not be already bootstrapped
// voting/voting.py:85
// self.is_bootstrapped = True
byte "is_bootstrapped"
int 1
app_global_put
// voting/voting.py:88
// fund_min_bal_req.receiver == Global.current_application_address
frame_dig -1
gtxns Receiver
global CurrentApplicationAddress
==
// voting/voting.py:87-89
// assert (
// fund_min_bal_req.receiver == Global.current_application_address
// ), "Payment must be to app address"
assert // Payment must be to app address
// voting/voting.py:91
// tally_box_size = self.total_options * VOTE_COUNT_BYTES
int 0
byte "total_options"
app_global_get_ex
assert // check self.total_options exists
int 8
*
// voting/voting.py:101-102
// # tally box value
// + (tally_box_size * BOX_BYTE_MIN_BALANCE)
dup
int 400
*
// voting/voting.py:93-100
// # minimum balance req for: ALGOs + Vote result NFT asset
// ASSET_MIN_BALANCE * 2
// # create NFT fee
// + 1000
// # tally box
// + BOX_FLAT_MIN_BALANCE
// # tally box key "V"
// + BOX_BYTE_MIN_BALANCE
int 203900
// voting/voting.py:93-102
// # minimum balance req for: ALGOs + Vote result NFT asset
// ASSET_MIN_BALANCE * 2
// # create NFT fee
// + 1000
// # tally box
// + BOX_FLAT_MIN_BALANCE
// # tally box key "V"
// + BOX_BYTE_MIN_BALANCE
// # tally box value
// + (tally_box_size * BOX_BYTE_MIN_BALANCE)
+
// voting/voting.py:104
// log(min_balance_req)
dup
itob
log
// voting/voting.py:106
// fund_min_bal_req.amount == min_balance_req
frame_dig -1
gtxns Amount
==
// voting/voting.py:105-107
// assert (
// fund_min_bal_req.amount == min_balance_req
// ), "Payment must be for the exact min balance requirement"
assert // Payment must be for the exact min balance requirement
// voting/voting.py:108
// assert self.tally_box.create(size=tally_box_size)
byte "V"
swap
box_create
assert
retsub
// examples.voting.voting.VotingRoundApp.close() -> void:
close:
// voting/voting.py:110-111
// @arc4.abimethod
// def close(self) -> None:
proto 0 0
int 0
dup
byte ""
dupn 2
// voting/voting.py:112
// ensure_budget(20000, fee_source=OpUpFeeSource.GroupCredit)
int 20000
int 0
callsub ensure_budget
// voting/voting.py:113
// assert not self.close_time, "Already closed"
int 0
byte "close_time"
app_global_get_ex
bury 1
!
assert // Already closed
// voting/voting.py:114
// self.close_time.value = Global.latest_timestamp
byte "close_time"
global LatestTimestamp
app_global_put
// voting/voting.py:119
// + self.vote_id
int 0
byte "vote_id"
app_global_get_ex
assert // check self.vote_id exists
// voting/voting.py:117-118
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
byte "{\"standard\":\"arc69\",\"description\":\"This is a voting result NFT for voting round with ID "
// voting/voting.py:117-119
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
swap
concat
// voting/voting.py:120
// + '.","properties":{"metadata":"ipfs://'
byte ".\",\"properties\":{\"metadata\":\"ipfs://"
// voting/voting.py:117-120
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
concat
// voting/voting.py:121
// + self.metadata_ipfs_cid
int 0
byte "metadata_ipfs_cid"
app_global_get_ex
assert // check self.metadata_ipfs_cid exists
// voting/voting.py:117-121
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
concat
// voting/voting.py:122
// + '","id":"'
byte "\",\"id\":\""
// voting/voting.py:117-122
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
concat
// voting/voting.py:123
// + self.vote_id
int 0
byte "vote_id"
app_global_get_ex
assert // check self.vote_id exists
// voting/voting.py:117-123
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
// + self.vote_id
concat
// voting/voting.py:124
// + '","quorum":'
byte "\",\"quorum\":"
// voting/voting.py:117-124
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
// + self.vote_id
// + '","quorum":'
concat
// voting/voting.py:125
// + itoa(self.quorum)
int 0
byte "quorum"
app_global_get_ex
assert // check self.quorum exists
callsub itoa
// voting/voting.py:117-125
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
// + self.vote_id
// + '","quorum":'
// + itoa(self.quorum)
concat
// voting/voting.py:126
// + ',"voterCount":'
byte ",\"voterCount\":"
// voting/voting.py:117-126
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
// + self.vote_id
// + '","quorum":'
// + itoa(self.quorum)
// + ',"voterCount":'
concat
// voting/voting.py:127
// + itoa(self.voter_count)
int 0
byte "voter_count"
app_global_get_ex
assert // check self.voter_count exists
callsub itoa
// voting/voting.py:117-127
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
// + self.vote_id
// + '","quorum":'
// + itoa(self.quorum)
// + ',"voterCount":'
// + itoa(self.voter_count)
concat
// voting/voting.py:128
// + ',"tallies":['
byte ",\"tallies\":["
// voting/voting.py:117-128
// '{"standard":"arc69",'
// '"description":"This is a voting result NFT for voting round with ID '
// + self.vote_id
// + '.","properties":{"metadata":"ipfs://'
// + self.metadata_ipfs_cid
// + '","id":"'
// + self.vote_id
// + '","quorum":'
// + itoa(self.quorum)
// + ',"voterCount":'
// + itoa(self.voter_count)
// + ',"tallies":['
concat
// voting/voting.py:131
// current_index = UInt64(0)
int 0
// voting/voting.py:132
// for question_index, question_options in uenumerate(self.option_counts):
dup
byte "option_counts"
app_global_get_ex
swap
dup
uncover 2
assert // check self.option_counts exists
int 0
extract_uint16
int 0
close_for_header@1:
// voting/voting.py:132
// for question_index, question_options in uenumerate(self.option_counts):
frame_dig 9
frame_dig 8
<
bz close_after_for@14
frame_dig 7
extract 2 0
frame_dig 9
dup
cover 2
int 1
extract3 // on error: Index access is out of bounds
frame_bury 1
frame_dig 5
frame_bury 0
// voting/voting.py:133
// if question_index > 0:
bz close_after_if_else@4
// voting/voting.py:134
// note += ","
frame_dig 5
byte ","
concat
frame_bury 0
close_after_if_else@4:
frame_dig 0
dup
frame_bury 5
// voting/voting.py:135
// if question_options > 0:
frame_dig 1
byte 0x00
b>
frame_dig 6
frame_bury 2
swap
frame_bury 0
bz close_after_if_else@12
// voting/voting.py:136
// note += "["
frame_dig 5
byte "["
concat
frame_bury 5
// voting/voting.py:137
// for option_index in urange(question_options.native):
frame_dig 1
btoi
frame_bury 4
int 0
frame_bury 3
close_for_header@6:
// voting/voting.py:137
// for option_index in urange(question_options.native):
frame_dig 3
frame_dig 4
<
bz close_after_for@11
frame_dig 5
frame_bury 0
// voting/voting.py:138
// if option_index > 0:
frame_dig 3
bz close_after_if_else@9
// voting/voting.py:139
// note += ","
frame_dig 5
byte ","
concat
frame_bury 0
close_after_if_else@9:
frame_dig 0
// voting/voting.py:140
// votes_for_option = self.get_vote_from_box(current_index)
frame_dig 6
dup
cover 2
callsub get_vote_from_box
// voting/voting.py:141
// note += itoa(votes_for_option)
callsub itoa
concat
frame_bury 5
// voting/voting.py:142
// current_index += 1
int 1
+
frame_bury 6
// voting/voting.py:137
// for option_index in urange(question_options.native):
frame_dig 3
int 1
+
frame_bury 3
b close_for_header@6
close_after_for@11:
// voting/voting.py:143
// note += "]"
frame_dig 5
byte "]"
concat
frame_dig 6
frame_bury 2
frame_bury 0
close_after_if_else@12:
frame_dig 2
frame_bury 6
frame_dig 0
frame_bury 5
frame_dig 9
int 1
+
frame_bury 9
b close_for_header@1
close_after_for@14:
// voting/voting.py:144
// note += "]}}"
frame_dig 5
byte "]}}"
concat
// voting/voting.py:146-156
// itxn.AssetConfig(
// total=1,
// decimals=0,
// default_frozen=False,
// asset_name="[VOTE RESULT] " + self.vote_id,
// unit_name="VOTERSLT",
// url=self.nft_image_url,
// note=note,
// fee=Global.min_txn_fee,
// )
// .submit()
itxn_begin
// voting/voting.py:154
// fee=Global.min_txn_fee,
global MinTxnFee
swap
// voting/voting.py:150
// asset_name="[VOTE RESULT] " + self.vote_id,
int 0
byte "vote_id"
app_global_get_ex
assert // check self.vote_id exists
byte "[VOTE RESULT] "
swap
concat
// voting/voting.py:152
// url=self.nft_image_url,
int 0
byte "nft_image_url"
app_global_get_ex
assert // check self.nft_image_url exists
uncover 2
itxn_field Note
itxn_field ConfigAssetURL
// voting/voting.py:151
// unit_name="VOTERSLT",
byte "VOTERSLT"
itxn_field ConfigAssetUnitName
itxn_field ConfigAssetName
// voting/voting.py:149
// default_frozen=False,
int 0
itxn_field ConfigAssetDefaultFrozen
// voting/voting.py:148
// decimals=0,
int 0
itxn_field ConfigAssetDecimals
// voting/voting.py:147
// total=1,
int 1
itxn_field ConfigAssetTotal
// voting/voting.py:146
// itxn.AssetConfig(
int acfg
itxn_field TypeEnum
itxn_field Fee
// voting/voting.py:146-156
// itxn.AssetConfig(
// total=1,
// decimals=0,
// default_frozen=False,
// asset_name="[VOTE RESULT] " + self.vote_id,
// unit_name="VOTERSLT",
// url=self.nft_image_url,
// note=note,
// fee=Global.min_txn_fee,
// )
// .submit()
itxn_submit
// voting/voting.py:145
// self.nft_asset_id = (
byte "nft_asset_id"
// voting/voting.py:146-157
// itxn.AssetConfig(
// total=1,
// decimals=0,
// default_frozen=False,
// asset_name="[VOTE RESULT] " + self.vote_id,
// unit_name="VOTERSLT",
// url=self.nft_image_url,
// note=note,
// fee=Global.min_txn_fee,
// )
// .submit()
// .created_asset.id
itxn CreatedAssetID
// voting/voting.py:145-158
// self.nft_asset_id = (
// itxn.AssetConfig(
// total=1,
// decimals=0,
// default_frozen=False,
// asset_name="[VOTE RESULT] " + self.vote_id,
// unit_name="VOTERSLT",
// url=self.nft_image_url,
// note=note,
// fee=Global.min_txn_fee,
// )
// .submit()
// .created_asset.id
// )
app_global_put
retsub
// examples.voting.voting.itoa(i: uint64) -> bytes:
itoa:
// voting/voting.py:249-250
// @subroutine
// def itoa(i: UInt64) -> String:
proto 1 1
// voting/voting.py:253
// if i < radix:
frame_dig -1
// voting/voting.py:252
// radix = digits.length
int 10
// voting/voting.py:253
// if i < radix:
<
bz itoa_after_if_else@2
// voting/voting.py:254
// return String.from_bytes(digits[i])
frame_dig -1
int 1
+
// voting/voting.py:251
// digits = Bytes(b"0123456789")
byte 0x30313233343536373839
// voting/voting.py:254
// return String.from_bytes(digits[i])
frame_dig -1
uncover 2
substring3
retsub
itoa_after_if_else@2:
// voting/voting.py:255
// return itoa(i // radix) + String.from_bytes(digits[i % radix])
frame_dig -1
// voting/voting.py:252
// radix = digits.length
int 10
// voting/voting.py:255
// return itoa(i // radix) + String.from_bytes(digits[i % radix])
/
callsub itoa
frame_dig -1
// voting/voting.py:252
// radix = digits.length
int 10
// voting/voting.py:255
// return itoa(i // radix) + String.from_bytes(digits[i % radix])
%
dup
int 1
+
// voting/voting.py:251
// digits = Bytes(b"0123456789")
byte 0x30313233343536373839
// voting/voting.py:255
// return itoa(i // radix) + String.from_bytes(digits[i % radix])
cover 2
substring3
concat
retsub
// examples.voting.voting.VotingRoundApp.get_vote_from_box(index: uint64) -> uint64:
get_vote_from_box:
// voting/voting.py:239-240
// @subroutine
// def get_vote_from_box(self, index: UInt64) -> UInt64:
proto 1 1
// voting/voting.py:241
// return op.btoi(self.tally_box.extract(index, VOTE_COUNT_BYTES))
byte "V"
frame_dig -1
int 8
box_extract
btoi
retsub
// examples.voting.voting.VotingRoundApp.get_preconditions(signature: bytes) -> bytes:
get_preconditions:
// voting/voting.py:160-161
// @arc4.abimethod(readonly=True)
// def get_preconditions(self, signature: Bytes) -> VotingPreconditions:
proto 1 1
// voting/voting.py:163
// is_voting_open=arc4.UInt64(self.voting_open()),
callsub voting_open
itob
// voting/voting.py:164
// is_allowed_to_vote=arc4.UInt64(self.allowed_to_vote(signature)),
frame_dig -1
callsub allowed_to_vote
itob
// voting/voting.py:165
// has_already_voted=arc4.UInt64(self.already_voted()),
callsub already_voted
itob
// voting/voting.py:166
// current_time=arc4.UInt64(Global.latest_timestamp),
global LatestTimestamp
itob
// voting/voting.py:162-167
// return VotingPreconditions(
// is_voting_open=arc4.UInt64(self.voting_open()),
// is_allowed_to_vote=arc4.UInt64(self.allowed_to_vote(signature)),
// has_already_voted=arc4.UInt64(self.already_voted()),
// current_time=arc4.UInt64(Global.latest_timestamp),
// )
uncover 3
uncover 3
concat
uncover 2
concat
swap
concat
retsub
// examples.voting.voting.VotingRoundApp.voting_open() -> uint64:
voting_open:
// voting/voting.py:205-206
// @subroutine
// def voting_open(self) -> bool:
proto 0 1
byte ""
// voting/voting.py:208
// self.is_bootstrapped
int 0
byte "is_bootstrapped"
app_global_get_ex
assert // check self.is_bootstrapped exists
// voting/voting.py:208-210
// self.is_bootstrapped
// and not self.close_time
// and self.start_time <= Global.latest_timestamp <= self.end_time
bz voting_open_bool_false@5
// voting/voting.py:209
// and not self.close_time
int 0
byte "close_time"
app_global_get_ex
bury 1
bnz voting_open_bool_false@5
// voting/voting.py:210
// and self.start_time <= Global.latest_timestamp <= self.end_time
int 0
byte "start_time"
app_global_get_ex
assert // check self.start_time exists
global LatestTimestamp
dup
frame_bury 0
<=
bz voting_open_bool_false@5
int 0
byte "end_time"
app_global_get_ex
assert // check self.end_time exists
frame_dig 0
>=
bz voting_open_bool_false@5
int 1
b voting_open_bool_merge@6
voting_open_bool_false@5:
int 0
voting_open_bool_merge@6:
// voting/voting.py:207-211
// return (
// self.is_bootstrapped
// and not self.close_time
// and self.start_time <= Global.latest_timestamp <= self.end_time
// )
swap
retsub
// examples.voting.voting.VotingRoundApp.allowed_to_vote(signature: bytes) -> uint64:
allowed_to_vote:
// voting/voting.py:230-231
// @subroutine
// def allowed_to_vote(self, signature: Bytes) -> bool:
proto 1 1
// voting/voting.py:232
// ensure_budget(2000)
int 2000
int 0
callsub ensure_budget