Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 72209fa

Browse files
committed
Filled in some pack methods:
1 parent fe53ec2 commit 72209fa

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

nftlabs/modules/pack.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,37 @@ def get_nfts(self, pack_id: int) -> List[PackNftMetadata]:
3232
pass
3333

3434
def balance_of(self, address: str, token_id: int) -> int:
35-
pass
35+
return self.__abi_module.balance_of.call(address, token_id)
3636

37-
def balance(self, token_id) -> int:
38-
pass
37+
def balance(self, token_id: int) -> int:
38+
return self.__abi_module.balance_of.call(self.get_signer_address(), token_id)
3939

4040
def is_approved(self, address: str, operator: str) -> bool:
41-
pass
41+
return self.__abi_module.is_approved_for_all.call(address, operator)
4242

4343
def set_approval(self, operator: str, approved: bool):
44-
pass
44+
return self.execute_tx(self.__abi_module.set_approval_for_all.build_transaction(
45+
operator, approved, self.get_transact_opts()
46+
))
4547

4648
def transfer(self, to_address: str, token_id: int, amount: int):
47-
pass
49+
return self.execute_tx(self.__abi_module.safe_transfer_from.build_transaction(
50+
self.get_signer_address(), to_address, token_id, amount, "", self.get_transact_opts(),
51+
))
4852

4953
def create(self, arg: CreatePackArg) -> PackMetadata:
5054
pass
5155

5256
def transfer_from(self, from_address: str, to_address: str, args: AssetAmountPair):
53-
pass
57+
return self.execute_tx(self.__abi_module.safe_transfer_from.build_transaction(
58+
from_address, to_address, args.token_id, args.amount, "", self.get_transact_opts(),
59+
))
5460

5561
def transfer_batch_from(self, from_address: str, to_address: str, args: List[AssetAmountPair]):
56-
pass
62+
ids, amounts = [i.token_id for i in args], [i.amount for i in args]
63+
return self.execute_tx(self.__abi_module.safe_batch_transfer_from.build_transaction(
64+
from_address, to_address, ids, amounts, "", self.get_transact_opts(),
65+
))
5766

5867
def get_link_balance(self) -> CurrencyValue:
5968
pass
@@ -65,10 +74,14 @@ def withdraw_link(self, to_address: str, amount: int):
6574
pass
6675

6776
def set_royalty_bps(self, amount: int):
68-
pass
77+
return self.execute_tx(self.__abi_module.set_royalty_bps.build_transaction(
78+
amount, self.get_transact_opts()
79+
))
6980

70-
def set_restricted_transfer(self, restricted: bool = False):
71-
pass
81+
def set_restricted_transfer(self, restricted: bool = True):
82+
return self.execute_tx(self.__abi_module.set_restricted_transfer.build_transaction(
83+
restricted, self.get_transact_opts()
84+
))
7285

7386
def grant_role(self, role: Role, address: str):
7487
role_hash = role.get_hash()

0 commit comments

Comments
 (0)