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 0162aa7

Browse files
committed
Implemented nft.getall
1 parent 0206aed commit 0162aa7

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
nft_module = sdk.get_nft_module("0xbDfF8fb43688fB4D2184DF8029A7238ac1413A24")
1919
print(nft_module.total_supply())
2020

21-
minted_nft = nft_module.mint(arg=MintArg(name="Test 123", description="Some description"))
22-
print(minted_nft)
23-
# print(nft_module.get(27))
24-
#
21+
# minted_nft = nft_module.mint(arg=MintArg(name="Test 123", description="Some description"))
22+
# print(minted_nft)
23+
24+
for nft in nft_module.get_all():
25+
print(nft)

nftlabs/modules/nft.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from web3.types import TxReceipt
88

99
from . import BaseModule
10-
from typing import Callable, Dict, NamedTuple
10+
from typing import Callable, Dict, NamedTuple, List
1111
from ..abi.nft import NFT
1212
from ..storage.ipfs_storage import IpfsStorage
1313

@@ -100,3 +100,6 @@ def set_royalty_bps(self, amount: int):
100100
tx = self.__abi_module.set_royalty_bps.build_transaction(amount, self.get_transact_opts())
101101
self.execute_tx(tx)
102102

103+
def get_all(self) -> List[NftType]:
104+
max_id = self.__abi_module.next_token_id.call()
105+
return [self.get(i) for i in range(max_id)]

nftlabs/types/nft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import Optional
2+
from typing import Optional, Union
33

44
from dataclasses_json import dataclass_json
55

@@ -10,6 +10,6 @@ class NFT:
1010
name: str
1111
description: str
1212
image: str
13-
properties: Optional[dict] = None
13+
properties: Optional[Union[str, dict]] = None
1414
id: Optional[int] = None
1515
uri: Optional[str] = None

0 commit comments

Comments
 (0)