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 e3fb3ea

Browse files
committed
Completed pack.create function
1 parent b843d46 commit e3fb3ea

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nftlabs/modules/pack.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Dict, List
33
from json import dumps
44

5-
from web3 import Web3
5+
from thirdweb_web3 import Web3
66
from eth_abi import encode_abi
77

88

@@ -26,19 +26,19 @@ def __init__(self, address: str, client: Web3):
2626
self.__abi_module = Pack(client, address)
2727

2828
def get(self, pack_id: int) -> PackMetadata:
29-
uri = self._BaseModule__get_token_uri(pack_id)
29+
uri = self.__abi_module.uri.call(pack_id)
3030
if uri == "":
3131
raise AssetNotFoundException(pack_id)
3232
metadata = self.get_storage().get(uri)
3333
state = self.__abi_module.get_pack.call(pack_id)
3434
total_supply = self.__abi_module.total_supply.call(pack_id)
3535
return PackMetadata(
3636
id=pack_id,
37-
creator_address=state.creator,
37+
creator_address=state['creator'],
3838
current_supply=total_supply,
3939
metadata=metadata,
40-
open_start=None if state.openStart <= 0 else datetime.fromtimestamp(
41-
state.openStart),
40+
open_start=None if state['openStart'] <= 0 else datetime.fromtimestamp(
41+
state['openStart']),
4242
)
4343

4444
def open(self, pack_id: int) -> List[NftMetadata]:
@@ -98,6 +98,8 @@ def create(self, arg: CreatePackArg) -> PackMetadata:
9898
))
9999
result = self.__abi_module.get_pack_created_event(
100100
receipt.transactionHash)
101+
new_pack_id = result[0]['args']['packId']
102+
return self.get(new_pack_id)
101103

102104
def transfer_from(self, from_address: str, to_address: str, args: AssetAmountPair):
103105
return self.execute_tx(self.__abi_module.safe_transfer_from.build_transaction(

0 commit comments

Comments
 (0)