10
10
from ..abi .nft_collection import NFTCollection
11
11
from web3 import Web3
12
12
13
- from ..types .collection import CollectionMetadata , CreateCollectionArg
13
+ from ..types .collection import CollectionMetadata , CreateCollectionArg , MintCollectionArg
14
14
15
15
16
16
class CollectionModule (_BaseModule ):
@@ -90,10 +90,10 @@ def create_and_mint_batch(self, meta_with_supply: List[CreateCollectionArg]) ->
90
90
token_ids = result [0 ]['args' ]['tokenIds' ]
91
91
return [self .get (i ) for i in token_ids ]
92
92
93
- def create_with_erc20 (self , token_contract : str , token_amount : int , metadata : CreateCollectionArg ):
94
- uri = self .get_storage ().upload (metadata .metadata , self .address , self .get_signer_address ())
93
+ def create_with_erc20 (self , token_contract : str , token_amount : int , arg : CreateCollectionArg ):
94
+ uri = self .get_storage ().upload (arg .metadata , self .address , self .get_signer_address ())
95
95
self .execute_tx (self .__abi_module .wrap_erc20 .build_transaction (
96
- token_contract , token_amount , metadata .supply , uri , self .get_transact_opts ()
96
+ token_contract , token_amount , arg .supply , uri , self .get_transact_opts ()
97
97
))
98
98
99
99
def create_with_erc721 (self , token_contract : str , token_id : int , metadata ):
@@ -102,35 +102,49 @@ def create_with_erc721(self, token_contract: str, token_id: int, metadata):
102
102
token_contract , token_id , uri , self .get_transact_opts ()
103
103
))
104
104
105
- def mint (self , args ):
106
- pass
105
+ def mint (self , args : MintCollectionArg ):
106
+ self . mint_to ( self . get_signer_address (), args )
107
107
108
- def mint_to (self , to_address : str , args ):
109
- pass
108
+ def mint_to (self , to_address : str , arg : MintCollectionArg ):
109
+ self .execute_tx (self .__abi_module .mint .build_transaction (
110
+ to_address , arg .token_id , arg .amount , "" , self .get_transact_opts ()
111
+ ))
110
112
111
- def mint_batch (self , args ):
112
- pass
113
+ def mint_batch (self , args : List [ MintCollectionArg ] ):
114
+ self . mint_batch_to ( self . get_signer_address (), args )
113
115
114
- def mint_batch_to (self , to_address , args ):
115
- pass
116
+ def mint_batch_to (self , to_address , args : List [MintCollectionArg ]):
117
+ ids = [a .id for a in args ]
118
+ amounts = [a .amount for a in args ]
119
+ self .execute_tx (self .__abi_module .mint_batch .build_transaction (
120
+ to_address , ids , amounts , self .get_transact_opts ()
121
+ ))
116
122
117
- def burn (self , args ):
118
- pass
123
+ def burn (self , args : MintCollectionArg ):
124
+ self . burn_from ( self . get_signer_address (), args )
119
125
120
- def burn_batch (self , args ):
121
- pass
126
+ def burn_batch (self , args : List [ MintCollectionArg ] ):
127
+ self . burn_batch_from ( self . get_signer_address (), args )
122
128
123
- def burn_from (self , account : str , args ):
124
- pass
129
+ def burn_from (self , account : str , args : MintCollectionArg ):
130
+ self .execute_tx (self .__abi_module .burn .build_transaction (
131
+ account , args .token_id , args .amount , self .get_transact_opts ()
132
+ ))
125
133
126
- def burn_batch_from (self , account : str , args ):
127
- pass
134
+ def burn_batch_from (self , account : str , args : List [MintCollectionArg ]):
135
+ self .execute_tx (self .__abi_module .burn_batch .build_transaction (
136
+ account , [i .id for i in args ], [i .amount for i in args ], self .get_transact_opts ()
137
+ ))
128
138
129
- def transfer_from (self , from_address : str , to_address : str , args ):
130
- pass
139
+ def transfer_from (self , from_address : str , to_address : str , args : MintCollectionArg ):
140
+ self .execute_tx (self .__abi_module .safe_transfer_from .build_transaction (
141
+ from_address , to_address , args .token_id , args .amount , "" , self .get_transact_opts ()
142
+ ))
131
143
132
144
def transfer_batch_from (self , from_address : str , to_address : str , args ):
133
- pass
145
+ self .execute_tx (self .__abi_module .safe_batch_transfer_from .build_transaction (
146
+ from_address , to_address , args .token_id , args .amount , "" , self .get_transact_opts ()
147
+ ))
134
148
135
149
def set_royalty_bps (self , amount : int ):
136
150
self .execute_tx (self .__abi_module .set_royalty_bps .build_transaction (
0 commit comments