@@ -20,29 +20,26 @@ def __init__(self, client: Web3, address: str):
2020 self .__abi_module = Market (client , address )
2121
2222 #todo: return types
23- def list_item (self , arg : ListArg ):
23+ def list (self , arg : ListArg ):
2424 from_address = self .get_signer_address ()
2525 client = self .get_client ()
2626 erc165 = ERC165 (client , arg .asset_contract )
27- isERC165 = erc165 .supports_interface (client , arg . asset_contract )
28- if isERC165 :
29- asset = NFT (client , arg .asset_contract )
27+ isERC721 = erc165 .supports_interface (client , interface_id = print ( bytearray . fromhex ( "80ac58cd" )) )
28+ if isERC721 :
29+ asset = NFT (from_address , arg .asset_contract )
3030 approved = asset .is_approved_for_all (
3131 arg .asset_contract , from_address )
3232 if not approved :
33- asset .approve_for_all (from_address , arg .asset_contract )
34- is_token_approved = (asset .get_approved (
35- arg .token_id ).lower () == self .address .lower ())
33+ asset .is_approve_for_all (from_address , arg .asset_contract )
34+ is_token_approved = (asset .is_approved_for_all (arg .token_id ).lower () == self .address .lower ())
3635 if not is_token_approved :
3736 asset .set_approval_for_all (arg .asset_contract , True )
3837 else :
39- asset = ERC1155 (client , arg .asset_contract )
40- approved = asset .is_approved_for_all (
41- arg .asset_contract , from_address )
38+ asset = ERC1155 (from_address , arg .asset_contract )
39+ approved = asset .is_approved_for_all (arg .asset_contract , from_address )
4240 if not approved :
43- asset .approve_for_all (from_address , arg .asset_contract )
44- is_token_approved = (asset .get_approved (
45- arg .token_id ).lower () == self .address .lower ())
41+ asset .set_approval_for_all (from_address , arg .asset_contract )
42+ is_token_approved = (asset .get_approved (arg .token_id ).lower () == self .address .lower ())
4643 if not is_token_approved :
4744 asset .set_approval_for_all (self .address , True )
4845
@@ -59,10 +56,9 @@ def list_item(self, arg: ListArg):
5956 )
6057
6158 receipt = self .execute_tx (tx )
62- result = self .__abi_module .get_minted_batch_event (
63- tx_hash = receipt .transactionHash .hex ())
59+ result = self .__abi_module .get_new_listing_event (tx_hash = receipt .transactionHash .hex ())
6460
65- def unlist_item (self , listing_id , quantity ):
61+ def unlist (self , listing_id , quantity ):
6662 tx = self .__abi_module .unlist .build_transaction (
6763 listing_id ,
6864 quantity ,
@@ -78,21 +74,19 @@ def buy(self, listing_id: int, quantity: int):
7874 if listing .currency_contract is not None and listing .currency_contract != "0x0000000000000000000000000000000000000000" :
7975 erc20 = ERC20 (self .get_client (), listing .currency_contract )
8076 allowance = erc20 .allowance (owner , spender )
81- if allowance <= total_price :
77+ if allowance < total_price :
8278 erc20 .increase_allowance (
8379 spender ,
8480 total_price ,
8581 self .get_transact_opts ()
8682 )
87-
8883 tx = self .__abi_module .buy .build_transaction (
8984 listing_id ,
9085 quantity ,
9186 self .get_transact_opts ()
9287 )
9388 receipt = self .execute_tx (tx )
94- result = self .__abi_module .get_minted_batch_event (
95- tx_hash = receipt .transactionHash .hex ())
89+ result = self .__abi_module .get_new_sale_event (tx_hash = receipt .transactionHash .hex ())
9690
9791 def set_market_fee_bps (self , amount : int ):
9892 tx = self .__abi_module .set_market_fee_bps .build_transaction (
0 commit comments