Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAY Algorand Assignment 제출합니다 #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,367 @@
#pragma version 10

smart_contracts.nft_marketplace.contract.NftMarketplace.approval_program:
txn ApplicationID
bnz main_entrypoint@2
callsub __init__

main_entrypoint@2:
// smart_contracts/nft_marketplace/contract.py:20
// class NftMarketplace(arc4.ARC4Contract):
txn NumAppArgs
bz main_bare_routing@9
method "bootstrap(asset,uint64,pay)void"
method "buy(pay,uint64)void"
method "withdraw_and_delete()void"
txna ApplicationArgs 0
match main_bootstrap_route@4 main_buy_route@5 main_withdraw_and_delete_route@6
err // reject transaction

main_bootstrap_route@4:
// smart_contracts/nft_marketplace/contract.py:90
// @arc4.abimethod
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// smart_contracts/nft_marketplace/contract.py:20
// class NftMarketplace(arc4.ARC4Contract):
txna ApplicationArgs 1
btoi
txnas Assets
txna ApplicationArgs 2
btoi
txn GroupIndex
int 1
-
dup
gtxns TypeEnum
int pay
==
assert // transaction type is pay
// smart_contracts/nft_marketplace/contract.py:90
// @arc4.abimethod
callsub bootstrap
int 1
return

main_buy_route@5:
// smart_contracts/nft_marketplace/contract.py:145
// @arc4.abimethod
txn OnCompletion
!
assert // OnCompletion is NoOp
txn ApplicationID
assert // is not creating
// smart_contracts/nft_marketplace/contract.py:20
// class NftMarketplace(arc4.ARC4Contract):
txn GroupIndex
int 1
-
dup
gtxns TypeEnum
int pay
==
assert // transaction type is pay
txna ApplicationArgs 1
btoi
// smart_contracts/nft_marketplace/contract.py:145
// @arc4.abimethod
callsub buy
int 1
return

main_withdraw_and_delete_route@6:
// smart_contracts/nft_marketplace/contract.py:208
// @arc4.abimethod(allow_actions=["DeleteApplication"])
txn OnCompletion
int DeleteApplication
==
assert // OnCompletion is DeleteApplication
txn ApplicationID
assert // is not creating
callsub withdraw_and_delete
int 1
return

main_bare_routing@9:
// smart_contracts/nft_marketplace/contract.py:20
// class NftMarketplace(arc4.ARC4Contract):
txn OnCompletion
!
assert // reject transaction
txn ApplicationID
!
assert // is creating
int 1
return


// smart_contracts.nft_marketplace.contract.NftMarketplace.bootstrap(asset: uint64, unitary_price: uint64, mbr_pay: uint64) -> void:
bootstrap:
// smart_contracts/nft_marketplace/contract.py:90-93
// @arc4.abimethod
// def bootstrap(
// self, asset: Asset, unitary_price: UInt64, mbr_pay: gtxn.PaymentTransaction
// ) -> None:
proto 3 0
// smart_contracts/nft_marketplace/contract.py:95
// assert Txn.sender == Global.creator_address, "Only creator can bootstrap"
txn Sender
global CreatorAddress
==
assert // Only creator can bootstrap
// smart_contracts/nft_marketplace/contract.py:96
// assert self.bootstrapped == False, "Already bootstrapped"
int 0
byte "bootstrapped"
app_global_get_ex
assert // check bootstrapped exists
!
assert // Already bootstrapped
// smart_contracts/nft_marketplace/contract.py:97
// assert mbr_pay.receiver == Global.current_application_address, "Payment receiver must be the contract address"
frame_dig -1
gtxns Receiver
global CurrentApplicationAddress
==
assert // Payment receiver must be the contract address
// smart_contracts/nft_marketplace/contract.py:98
// assert mbr_pay.amount == Global.min_balance + Global.asset_opt_in_min_balance, "Payment amount must be equal to the sum of the minimum balance and the minimum balance to opt in to the ASA"
frame_dig -1
gtxns Amount
global MinBalance
global AssetOptInMinBalance
+
==
assert // Payment amount must be equal to the sum of the minimum balance and the minimum balance to opt in to the ASA
// smart_contracts/nft_marketplace/contract.py:100
// self.asset_id = asset.id
byte "asset_id"
frame_dig -3
app_global_put
// smart_contracts/nft_marketplace/contract.py:101
// self.unitary_price = unitary_price
byte "unitary_price"
frame_dig -2
app_global_put
// smart_contracts/nft_marketplace/contract.py:102
// self.bootstrapped = True
byte "bootstrapped"
int 1
app_global_put
// smart_contracts/nft_marketplace/contract.py:104-108
// itxn.AssetTransfer(
// xfer_asset=self.asset_id,
// asset_receiver=Global.current_application_address,
// asset_amount=0,
// ).submit()
itxn_begin
// smart_contracts/nft_marketplace/contract.py:105
// xfer_asset=self.asset_id,
int 0
byte "asset_id"
app_global_get_ex
assert // check asset_id exists
// smart_contracts/nft_marketplace/contract.py:106
// asset_receiver=Global.current_application_address,
global CurrentApplicationAddress
// smart_contracts/nft_marketplace/contract.py:107
// asset_amount=0,
int 0
itxn_field AssetAmount
itxn_field AssetReceiver
itxn_field XferAsset
// smart_contracts/nft_marketplace/contract.py:104
// itxn.AssetTransfer(
int axfer
itxn_field TypeEnum
int 0
itxn_field Fee
// smart_contracts/nft_marketplace/contract.py:104-108
// itxn.AssetTransfer(
// xfer_asset=self.asset_id,
// asset_receiver=Global.current_application_address,
// asset_amount=0,
// ).submit()
itxn_submit
retsub


// smart_contracts.nft_marketplace.contract.NftMarketplace.buy(buyer_txn: uint64, quantity: uint64) -> void:
buy:
// smart_contracts/nft_marketplace/contract.py:145-150
// @arc4.abimethod
// def buy(
// self,
// buyer_txn: gtxn.PaymentTransaction,
// quantity: UInt64,
// ) -> None:
proto 2 0
// smart_contracts/nft_marketplace/contract.py:151
// assert self.bootstrapped == True, "Not bootstrapped"
int 0
byte "bootstrapped"
app_global_get_ex
assert // check bootstrapped exists
int 1
==
assert // Not bootstrapped
// smart_contracts/nft_marketplace/contract.py:152
// assert buyer_txn.sender == Txn.sender, "Sender must be the caller"
frame_dig -2
gtxns Sender
dup
txn Sender
==
assert // Sender must be the caller
// smart_contracts/nft_marketplace/contract.py:153
// assert buyer_txn.receiver == Global.current_application_address, "Receiver must be the contract address"
frame_dig -2
gtxns Receiver
global CurrentApplicationAddress
==
assert // Receiver must be the contract address
// smart_contracts/nft_marketplace/contract.py:154
// assert buyer_txn.amount == self.unitary_price * quantity, "Amount must be equal to the unitary price times the quantity"
frame_dig -2
gtxns Amount
int 0
byte "unitary_price"
app_global_get_ex
assert // check unitary_price exists
frame_dig -1
*
==
assert // Amount must be equal to the unitary price times the quantity
// smart_contracts/nft_marketplace/contract.py:157-161
// itxn.AssetTransfer(
// xfer_asset=self.asset_id,
// asset_receiver=buyer_txn.sender,
// asset_amount=quantity,
// ).submit()
itxn_begin
// smart_contracts/nft_marketplace/contract.py:158
// xfer_asset=self.asset_id,
int 0
byte "asset_id"
app_global_get_ex
assert // check asset_id exists
frame_dig -1
itxn_field AssetAmount
itxn_field XferAsset
itxn_field AssetReceiver
// smart_contracts/nft_marketplace/contract.py:157
// itxn.AssetTransfer(
int axfer
itxn_field TypeEnum
int 0
itxn_field Fee
// smart_contracts/nft_marketplace/contract.py:157-161
// itxn.AssetTransfer(
// xfer_asset=self.asset_id,
// asset_receiver=buyer_txn.sender,
// asset_amount=quantity,
// ).submit()
itxn_submit
retsub


// smart_contracts.nft_marketplace.contract.NftMarketplace.withdraw_and_delete() -> void:
withdraw_and_delete:
// smart_contracts/nft_marketplace/contract.py:208-209
// @arc4.abimethod(allow_actions=["DeleteApplication"])
// def withdraw_and_delete(self) -> None:
proto 0 0
// smart_contracts/nft_marketplace/contract.py:210
// assert Txn.sender == Global.creator_address, "Only creator can withdraw and delete"
txn Sender
global CreatorAddress
==
assert // Only creator can withdraw and delete
// smart_contracts/nft_marketplace/contract.py:213-217
// itxn.AssetTransfer(
// xfer_asset=self.asset_id,
// asset_receiver=Global.creator_address,
// asset_close_to=Global.creator_address,
// ).submit()
itxn_begin
// smart_contracts/nft_marketplace/contract.py:214
// xfer_asset=self.asset_id,
int 0
byte "asset_id"
app_global_get_ex
assert // check asset_id exists
// smart_contracts/nft_marketplace/contract.py:215
// asset_receiver=Global.creator_address,
global CreatorAddress
// smart_contracts/nft_marketplace/contract.py:216
// asset_close_to=Global.creator_address,
dup
itxn_field AssetCloseTo
itxn_field AssetReceiver
itxn_field XferAsset
// smart_contracts/nft_marketplace/contract.py:213
// itxn.AssetTransfer(
int axfer
itxn_field TypeEnum
int 0
itxn_field Fee
// smart_contracts/nft_marketplace/contract.py:213-217
// itxn.AssetTransfer(
// xfer_asset=self.asset_id,
// asset_receiver=Global.creator_address,
// asset_close_to=Global.creator_address,
// ).submit()
itxn_submit
// smart_contracts/nft_marketplace/contract.py:220-223
// itxn.Payment(
// receiver=Global.creator_address,
// close_remainder_to=Global.creator_address,
// ).submit()
itxn_begin
// smart_contracts/nft_marketplace/contract.py:221
// receiver=Global.creator_address,
global CreatorAddress
// smart_contracts/nft_marketplace/contract.py:222
// close_remainder_to=Global.creator_address,
dup
itxn_field CloseRemainderTo
itxn_field Receiver
// smart_contracts/nft_marketplace/contract.py:220
// itxn.Payment(
int pay
itxn_field TypeEnum
int 0
itxn_field Fee
// smart_contracts/nft_marketplace/contract.py:220-223
// itxn.Payment(
// receiver=Global.creator_address,
// close_remainder_to=Global.creator_address,
// ).submit()
itxn_submit
retsub


// smart_contracts.nft_marketplace.contract.NftMarketplace.__init__() -> void:
__init__:
// smart_contracts/nft_marketplace/contract.py:45
// def __init__(self) -> None:
proto 0 0
// smart_contracts/nft_marketplace/contract.py:47
// self.asset_id = UInt64(0)
byte "asset_id"
int 0
app_global_put
// smart_contracts/nft_marketplace/contract.py:48
// self.unitary_price = UInt64(0)
byte "unitary_price"
int 0
app_global_put
// smart_contracts/nft_marketplace/contract.py:49
// self.bootstrapped = bool(False)
byte "bootstrapped"
int 0
app_global_put
retsub
Loading