forked from joe-p/arc59
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMutableARC59.approval.teal
1114 lines (957 loc) · 23.5 KB
/
MutableARC59.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
// This TEAL was generated by TEALScript v0.90.3
// https://github.com/algorandfoundation/TEALScript
// This contract is compliant with and/or implements the following ARCs: [ ARC4 ]
// The following ten lines of TEAL handle initial program flow
// This pattern is used to make it easy for anyone to parse the start of the program and determine if a specific action is allowed
// Here, action refers to the OnComplete in combination with whether the app is being created or called
// Every possible action for this contract is represented in the switch statement
// If the action is not implemented in the contract, its respective branch will be "*NOT_IMPLEMENTED" which just contains "err"
txn ApplicationID
!
int 6
*
txn OnCompletion
+
switch *call_NoOp *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *call_UpdateApplication *NOT_IMPLEMENTED *create_NoOp *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED *NOT_IMPLEMENTED
*NOT_IMPLEMENTED:
err
// createApplication()void
*abi_route_createApplication:
// execute createApplication()void
callsub createApplication
int 1
return
// createApplication(): void
//
// Deploy ARC59 contract
createApplication:
proto 0 0
retsub
// arc59_optRouterIn(uint64)void
*abi_route_arc59_optRouterIn:
// asa: uint64
txna ApplicationArgs 1
btoi
// execute arc59_optRouterIn(uint64)void
callsub arc59_optRouterIn
int 1
return
// arc59_optRouterIn(asa: AssetID): void
//
// Opt the ARC59 router into the ASA. This is required before this app can be used to send the ASA to anyone.
//
// @param asa The ASA to opt into
arc59_optRouterIn:
proto 1 0
// contracts/arc59.algo.ts:46
// sendAssetTransfer({
// assetReceiver: this.app.address,
// assetAmount: 0,
// xferAsset: asa,
// })
itxn_begin
int axfer
itxn_field TypeEnum
// contracts/arc59.algo.ts:47
// assetReceiver: this.app.address
global CurrentApplicationAddress
itxn_field AssetReceiver
// contracts/arc59.algo.ts:48
// assetAmount: 0
int 0
itxn_field AssetAmount
// contracts/arc59.algo.ts:49
// xferAsset: asa
frame_dig -1 // asa: AssetID
itxn_field XferAsset
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
retsub
// arc59_getOrCreateInbox(address)address
*abi_route_arc59_getOrCreateInbox:
// The ABI return prefix
byte 0x151f7c75
// receiver: address
txna ApplicationArgs 1
dup
len
int 32
==
assert
// execute arc59_getOrCreateInbox(address)address
callsub arc59_getOrCreateInbox
concat
log
int 1
return
// arc59_getOrCreateInbox(receiver: Address): Address
//
// Gets the existing inbox for the receiver or creates a new one if it does not exist
//
// @param receiver The address to get or create the inbox for
// @returns The inbox address
arc59_getOrCreateInbox:
proto 1 1
// Push empty bytes after the frame pointer to reserve space for local variables
byte 0x
// *if0_condition
// contracts/arc59.algo.ts:60
// this.inboxes(receiver).exists
frame_dig -1 // receiver: Address
box_len
swap
pop
bz *if0_end
// *if0_consequent
// contracts/arc59.algo.ts:60
// return this.inboxes(receiver).value;
frame_dig -1 // receiver: Address
box_get
assert
b *arc59_getOrCreateInbox*return
*if0_end:
// contracts/arc59.algo.ts:62
// inbox = sendMethodCall<typeof ControlledAddress.prototype.new>({
// onCompletion: OnCompletion.DeleteApplication,
// approvalProgram: ControlledAddress.approvalProgram(),
// clearStateProgram: ControlledAddress.clearProgram(),
// })
itxn_begin
int appl
itxn_field TypeEnum
method "new()address"
itxn_field ApplicationArgs
// contracts/arc59.algo.ts:63
// onCompletion: OnCompletion.DeleteApplication
int 5 // DeleteApplication
itxn_field OnCompletion
// contracts/arc59.algo.ts:64
// approvalProgram: ControlledAddress.approvalProgram()
byte b64 CiABATEYFIEGCzEZCI0MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAIAEFR98dYgABFCwIkOKAAGxIrIQMQCyIIEAsgGzMgqJgARWHS/qNhoAjgH/0wA=
itxn_field ApprovalProgram
// contracts/arc59.algo.ts:65
// clearStateProgram: ControlledAddress.clearProgram()
byte b64 Cg==
itxn_field ClearStateProgram
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
itxn NumLogs
int 1
-
itxnas Logs
extract 4 0
frame_bury 0 // inbox: address
// contracts/arc59.algo.ts:68
// this.inboxes(receiver).value = inbox
frame_dig -1 // receiver: Address
frame_dig 0 // inbox: address
box_put
// contracts/arc59.algo.ts:70
// return inbox;
frame_dig 0 // inbox: address
*arc59_getOrCreateInbox*return:
// set the subroutine return value
frame_bury 0
retsub
// arc59_getSendAssetInfo(address,uint64)(uint64,uint64,bool,bool)
*abi_route_arc59_getSendAssetInfo:
// The ABI return prefix
byte 0x151f7c75
// asset: uint64
txna ApplicationArgs 2
btoi
// receiver: address
txna ApplicationArgs 1
dup
len
int 32
==
assert
// execute arc59_getSendAssetInfo(address,uint64)(uint64,uint64,bool,bool)
callsub arc59_getSendAssetInfo
concat
log
int 1
return
// arc59_getSendAssetInfo(receiver: Address, asset: AssetID): SendAssetInfo
//
//
// @param receiver The address to send the asset to
// @param asset The asset to send
//
// @returns Returns the following information for sending an asset:
// The number of itxns required, the MBR required, whether the router is opted in, and whether the receiver is opted in
arc59_getSendAssetInfo:
proto 2 1
// Push empty bytes after the frame pointer to reserve space for local variables
byte 0x
dupn 5
// contracts/arc59.algo.ts:82
// routerOptedIn = this.app.address.isOptedInToAsset(asset)
global CurrentApplicationAddress
frame_dig -2 // asset: AssetID
asset_holding_get AssetBalance
swap
pop
frame_bury 0 // routerOptedIn: bool
// contracts/arc59.algo.ts:83
// receiverOptedIn = receiver.isOptedInToAsset(asset)
frame_dig -1 // receiver: Address
frame_dig -2 // asset: AssetID
asset_holding_get AssetBalance
swap
pop
frame_bury 1 // receiverOptedIn: bool
// contracts/arc59.algo.ts:84
// info: SendAssetInfo = { itxns: 1, mbr: 0, routerOptedIn: routerOptedIn, receiverOptedIn: receiverOptedIn }
byte 0x00000000000000010000000000000000
byte 0x00
int 0
frame_dig 0 // routerOptedIn: bool
setbit
int 1
frame_dig 1 // receiverOptedIn: bool
setbit
concat
frame_bury 2 // info: SendAssetInfo
// *if1_condition
// contracts/arc59.algo.ts:86
// receiverOptedIn
frame_dig 1 // receiverOptedIn: bool
bz *if1_end
// *if1_consequent
// contracts/arc59.algo.ts:86
// return info;
frame_dig 2 // info: SendAssetInfo
b *arc59_getSendAssetInfo*return
*if1_end:
// *if2_condition
// contracts/arc59.algo.ts:88
// !routerOptedIn
frame_dig 0 // routerOptedIn: bool
!
bz *if2_end
// *if2_consequent
// contracts/arc59.algo.ts:89
// info.mbr += globals.assetOptInMinBalance
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 8
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 8 8
btoi
global AssetOptInMinBalance
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
// contracts/arc59.algo.ts:90
// info.itxns += 1
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 0
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 0 8
btoi
int 1
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
*if2_end:
// *if3_condition
// contracts/arc59.algo.ts:93
// !this.inboxes(receiver).exists
frame_dig -1 // receiver: Address
box_len
swap
pop
!
bz *if3_end
// *if3_consequent
// contracts/arc59.algo.ts:97
// info.itxns += 4
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 0
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 0 8
btoi
int 4
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
// contracts/arc59.algo.ts:100
// preMBR = globals.currentApplicationAddress.minBalance
global CurrentApplicationAddress
acct_params_get AcctMinBalance
pop
frame_bury 3 // preMBR: uint64
// contracts/arc59.algo.ts:101
// this.inboxes(receiver).value = globals.zeroAddress
frame_dig -1 // receiver: Address
global ZeroAddress
box_put
// contracts/arc59.algo.ts:102
// boxMbrDelta = globals.currentApplicationAddress.minBalance - preMBR
global CurrentApplicationAddress
acct_params_get AcctMinBalance
pop
frame_dig 3 // preMBR: uint64
-
frame_bury 4 // boxMbrDelta: uint64
// contracts/arc59.algo.ts:103
// this.inboxes(receiver).delete()
frame_dig -1 // receiver: Address
box_del
// contracts/arc59.algo.ts:106
// info.mbr += boxMbrDelta + globals.minBalance + globals.assetOptInMinBalance
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 8
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 8 8
btoi
frame_dig 4 // boxMbrDelta: uint64
global MinBalance
+
global AssetOptInMinBalance
+
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
// contracts/arc59.algo.ts:108
// return info;
frame_dig 2 // info: SendAssetInfo
b *arc59_getSendAssetInfo*return
*if3_end:
// contracts/arc59.algo.ts:111
// inbox = this.inboxes(receiver).value
frame_dig -1 // receiver: Address
box_get
assert
frame_bury 5 // inbox: address
// *if4_condition
// contracts/arc59.algo.ts:113
// !inbox.isOptedInToAsset(asset)
frame_dig 5 // inbox: address
frame_dig -2 // asset: AssetID
asset_holding_get AssetBalance
swap
pop
!
bz *if4_end
// *if4_consequent
// contracts/arc59.algo.ts:115
// info.itxns += 1
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 0
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 0 8
btoi
int 1
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
// *if5_condition
// contracts/arc59.algo.ts:117
// !(inbox.balance >= inbox.minBalance + globals.assetOptInMinBalance)
frame_dig 5 // inbox: address
acct_params_get AcctBalance
pop
frame_dig 5 // inbox: address
acct_params_get AcctMinBalance
pop
global AssetOptInMinBalance
+
>=
!
bz *if5_end
// *if5_consequent
// contracts/arc59.algo.ts:119
// info.itxns += 1
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 0
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 0 8
btoi
int 1
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
// contracts/arc59.algo.ts:122
// info.mbr += globals.assetOptInMinBalance
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
int 8
frame_dig 2 // info: SendAssetInfo
store 255 // full array
load 255 // full array
extract 8 8
btoi
global AssetOptInMinBalance
+
itob
replace3
frame_bury 2 // info: SendAssetInfo
*if5_end:
*if4_end:
// contracts/arc59.algo.ts:126
// return info;
frame_dig 2 // info: SendAssetInfo
*arc59_getSendAssetInfo*return:
// set the subroutine return value
frame_bury 0
// pop all local variables from the stack
popn 5
retsub
// arc59_sendAsset(axfer,address)address
*abi_route_arc59_sendAsset:
// The ABI return prefix
byte 0x151f7c75
// receiver: address
txna ApplicationArgs 1
dup
len
int 32
==
assert
// axfer: axfer
txn GroupIndex
int 1
-
dup
gtxns TypeEnum
int axfer
==
assert
// execute arc59_sendAsset(axfer,address)address
callsub arc59_sendAsset
concat
log
int 1
return
// arc59_sendAsset(axfer: AssetTransferTxn, receiver: Address): Address
//
// Send an asset to the receiver
//
// @param receiver The address to send the asset to
// @param axfer The asset transfer to this app
//
// @returns The address that the asset was sent to (either the receiver or their inbox)
arc59_sendAsset:
proto 2 1
// Push empty bytes after the frame pointer to reserve space for local variables
byte 0x
dupn 2
// contracts/arc59.algo.ts:138
// verifyAssetTransferTxn(axfer, {
// assetReceiver: this.app.address,
// })
// verify assetReceiver
frame_dig -1 // axfer: AssetTransferTxn
gtxns AssetReceiver
global CurrentApplicationAddress
==
assert
// *if6_condition
// contracts/arc59.algo.ts:143
// receiver.isOptedInToAsset(axfer.xferAsset)
frame_dig -2 // receiver: Address
frame_dig -1 // axfer: AssetTransferTxn
gtxns XferAsset
asset_holding_get AssetBalance
swap
pop
bz *if6_end
// *if6_consequent
// contracts/arc59.algo.ts:144
// sendAssetTransfer({
// assetReceiver: receiver,
// assetAmount: axfer.assetAmount,
// xferAsset: axfer.xferAsset,
// })
itxn_begin
int axfer
itxn_field TypeEnum
// contracts/arc59.algo.ts:145
// assetReceiver: receiver
frame_dig -2 // receiver: Address
itxn_field AssetReceiver
// contracts/arc59.algo.ts:146
// assetAmount: axfer.assetAmount
frame_dig -1 // axfer: AssetTransferTxn
gtxns AssetAmount
itxn_field AssetAmount
// contracts/arc59.algo.ts:147
// xferAsset: axfer.xferAsset
frame_dig -1 // axfer: AssetTransferTxn
gtxns XferAsset
itxn_field XferAsset
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
// contracts/arc59.algo.ts:150
// return receiver;
frame_dig -2 // receiver: Address
b *arc59_sendAsset*return
*if6_end:
// contracts/arc59.algo.ts:153
// inboxExisted = this.inboxes(receiver).exists
frame_dig -2 // receiver: Address
box_len
swap
pop
frame_bury 0 // inboxExisted: bool
// contracts/arc59.algo.ts:154
// inbox = this.arc59_getOrCreateInbox(receiver)
frame_dig -2 // receiver: Address
callsub arc59_getOrCreateInbox
frame_bury 1 // inbox: address
// *if7_condition
// contracts/arc59.algo.ts:156
// !inbox.isOptedInToAsset(axfer.xferAsset)
frame_dig 1 // inbox: address
frame_dig -1 // axfer: AssetTransferTxn
gtxns XferAsset
asset_holding_get AssetBalance
swap
pop
!
bz *if7_end
// *if7_consequent
// contracts/arc59.algo.ts:157
// inboxMbrDelta = globals.assetOptInMinBalance
global AssetOptInMinBalance
frame_bury 2 // inboxMbrDelta: uint64
// *if8_condition
// contracts/arc59.algo.ts:158
// !inboxExisted
frame_dig 0 // inboxExisted: bool
!
bz *if8_end
// *if8_consequent
// contracts/arc59.algo.ts:158
// inboxMbrDelta += globals.minBalance
frame_dig 2 // inboxMbrDelta: uint64
global MinBalance
+
frame_bury 2 // inboxMbrDelta: uint64
*if8_end:
// *if9_condition
// contracts/arc59.algo.ts:161
// inbox.balance < inbox.minBalance + inboxMbrDelta
frame_dig 1 // inbox: address
acct_params_get AcctBalance
pop
frame_dig 1 // inbox: address
acct_params_get AcctMinBalance
pop
frame_dig 2 // inboxMbrDelta: uint64
+
<
bz *if9_end
// *if9_consequent
// contracts/arc59.algo.ts:162
// sendPayment({
// receiver: inbox,
// amount: inboxMbrDelta,
// })
itxn_begin
int pay
itxn_field TypeEnum
// contracts/arc59.algo.ts:163
// receiver: inbox
frame_dig 1 // inbox: address
itxn_field Receiver
// contracts/arc59.algo.ts:164
// amount: inboxMbrDelta
frame_dig 2 // inboxMbrDelta: uint64
itxn_field Amount
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
*if9_end:
// contracts/arc59.algo.ts:169
// sendAssetTransfer({
// sender: inbox,
// assetReceiver: inbox,
// assetAmount: 0,
// xferAsset: axfer.xferAsset,
// })
itxn_begin
int axfer
itxn_field TypeEnum
// contracts/arc59.algo.ts:170
// sender: inbox
frame_dig 1 // inbox: address
itxn_field Sender
// contracts/arc59.algo.ts:171
// assetReceiver: inbox
frame_dig 1 // inbox: address
itxn_field AssetReceiver
// contracts/arc59.algo.ts:172
// assetAmount: 0
int 0
itxn_field AssetAmount
// contracts/arc59.algo.ts:173
// xferAsset: axfer.xferAsset
frame_dig -1 // axfer: AssetTransferTxn
gtxns XferAsset
itxn_field XferAsset
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
*if7_end:
// contracts/arc59.algo.ts:178
// sendAssetTransfer({
// assetReceiver: inbox,
// assetAmount: axfer.assetAmount,
// xferAsset: axfer.xferAsset,
// })
itxn_begin
int axfer
itxn_field TypeEnum
// contracts/arc59.algo.ts:179
// assetReceiver: inbox
frame_dig 1 // inbox: address
itxn_field AssetReceiver
// contracts/arc59.algo.ts:180
// assetAmount: axfer.assetAmount
frame_dig -1 // axfer: AssetTransferTxn
gtxns AssetAmount
itxn_field AssetAmount
// contracts/arc59.algo.ts:181
// xferAsset: axfer.xferAsset
frame_dig -1 // axfer: AssetTransferTxn
gtxns XferAsset
itxn_field XferAsset
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
// contracts/arc59.algo.ts:184
// return inbox;
frame_dig 1 // inbox: address
*arc59_sendAsset*return:
// set the subroutine return value
frame_bury 0
// pop all local variables from the stack
popn 2
retsub
// arc59_claim(uint64)void
*abi_route_arc59_claim:
// asa: uint64
txna ApplicationArgs 1
btoi
// execute arc59_claim(uint64)void
callsub arc59_claim
int 1
return
// arc59_claim(asa: AssetID): void
//
// Claim an ASA from the inbox
//
// @param asa The ASA to claim
arc59_claim:
proto 1 0
// Push empty bytes after the frame pointer to reserve space for local variables
byte 0x
// contracts/arc59.algo.ts:193
// inbox = this.inboxes(this.txn.sender).value
txn Sender
box_get
assert
frame_bury 0 // inbox: address
// contracts/arc59.algo.ts:195
// sendAssetTransfer({
// sender: inbox,
// assetReceiver: this.txn.sender,
// assetAmount: inbox.assetBalance(asa),
// xferAsset: asa,
// assetCloseTo: this.txn.sender,
// })
itxn_begin
int axfer
itxn_field TypeEnum
// contracts/arc59.algo.ts:196
// sender: inbox
frame_dig 0 // inbox: address
itxn_field Sender
// contracts/arc59.algo.ts:197
// assetReceiver: this.txn.sender
txn Sender
itxn_field AssetReceiver
// contracts/arc59.algo.ts:198
// assetAmount: inbox.assetBalance(asa)
frame_dig 0 // inbox: address
frame_dig -1 // asa: AssetID
asset_holding_get AssetBalance
pop
itxn_field AssetAmount
// contracts/arc59.algo.ts:199
// xferAsset: asa
frame_dig -1 // asa: AssetID
itxn_field XferAsset
// contracts/arc59.algo.ts:200
// assetCloseTo: this.txn.sender
txn Sender
itxn_field AssetCloseTo
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
// contracts/arc59.algo.ts:203
// sendPayment({
// sender: inbox,
// receiver: this.txn.sender,
// amount: inbox.balance - inbox.minBalance,
// })
itxn_begin
int pay
itxn_field TypeEnum
// contracts/arc59.algo.ts:204
// sender: inbox
frame_dig 0 // inbox: address
itxn_field Sender
// contracts/arc59.algo.ts:205
// receiver: this.txn.sender
txn Sender
itxn_field Receiver
// contracts/arc59.algo.ts:206
// amount: inbox.balance - inbox.minBalance
frame_dig 0 // inbox: address
acct_params_get AcctBalance
pop
frame_dig 0 // inbox: address
acct_params_get AcctMinBalance
pop
-
itxn_field Amount
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
retsub
// arc59_reject(uint64)void
*abi_route_arc59_reject:
// asa: uint64
txna ApplicationArgs 1
btoi
// execute arc59_reject(uint64)void
callsub arc59_reject
int 1
return
// arc59_reject(asa: AssetID): void
//
// Reject the ASA by closing it out to the ASA creator. Always sends two inner transactions.
// All non-MBR ALGO balance in the inbox will be sent to the caller.
//
// @param asa The ASA to reject
arc59_reject:
proto 1 0
// Push empty bytes after the frame pointer to reserve space for local variables
byte 0x
// contracts/arc59.algo.ts:217
// inbox = this.inboxes(this.txn.sender).value
txn Sender
box_get
assert
frame_bury 0 // inbox: address
// contracts/arc59.algo.ts:219
// sendAssetTransfer({
// sender: inbox,
// assetReceiver: asa.creator,
// assetAmount: inbox.assetBalance(asa),
// xferAsset: asa,
// assetCloseTo: asa.creator,
// })
itxn_begin
int axfer
itxn_field TypeEnum
// contracts/arc59.algo.ts:220
// sender: inbox
frame_dig 0 // inbox: address
itxn_field Sender
// contracts/arc59.algo.ts:221
// assetReceiver: asa.creator
frame_dig -1 // asa: AssetID
asset_params_get AssetCreator
pop
itxn_field AssetReceiver
// contracts/arc59.algo.ts:222
// assetAmount: inbox.assetBalance(asa)
frame_dig 0 // inbox: address
frame_dig -1 // asa: AssetID
asset_holding_get AssetBalance
pop
itxn_field AssetAmount
// contracts/arc59.algo.ts:223
// xferAsset: asa
frame_dig -1 // asa: AssetID
itxn_field XferAsset
// contracts/arc59.algo.ts:224
// assetCloseTo: asa.creator
frame_dig -1 // asa: AssetID
asset_params_get AssetCreator
pop
itxn_field AssetCloseTo
// Fee field not set, defaulting to 0
int 0
itxn_field Fee
// Submit inner transaction
itxn_submit
// contracts/arc59.algo.ts:227
// sendPayment({
// sender: inbox,
// receiver: this.txn.sender,
// amount: inbox.balance - inbox.minBalance,
// })
itxn_begin
int pay
itxn_field TypeEnum
// contracts/arc59.algo.ts:228
// sender: inbox
frame_dig 0 // inbox: address
itxn_field Sender
// contracts/arc59.algo.ts:229
// receiver: this.txn.sender