diff --git a/README.md b/README.md index 75932498..245eceee 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,10 @@ PyPi package found [here](https://pypi.org/project/thirdweb-sdk). -## Deprecation Notice +## Deprecation Notices +> 1 of 2 +> > The `nftlabs-sdk` pypi package will be deprecated on November 30th, 2021 > > Please make sure you install the new `thirdweb-sdk` package found [here](https://pypi.org/project/thirdweb-sdk) @@ -11,6 +13,21 @@ PyPi package found [here](https://pypi.org/project/thirdweb-sdk). > In your code, update all imports to use the `thirdweb` package and switch to using the `ThirdwebSdk` package (instead of the `NftlabsSdk` package) +--- + +> 2 of 2 +> +> The `collection` module has been renamed to `bundle` and will be deprecated on November 30th, 2021 +> +> All references to `collection` module and its associated classes should be updated to `bundle` and its newely created classes. +> +> You can find the detailed documentation for the `bundle` module [here](https://python-docs.nftlabs.co/modules.bundle.html) + + + + + + ### Docs https://docs.nftlabs.co @@ -33,7 +50,7 @@ $ pip install thirdweb-sdk nftlabs ├── abi // contains autogenerated ABI contract wrappers ├── errors // commonly thrown errors -├── modules // NFT, Currency, Marketplace, Pack, Collection, etc modules +├── modules // NFT, Currency, Marketplace, Pack, Bundle, etc modules ├── options // Options classes used throughout the SDK ├── sdk.py // NftlabsSdk class, wrapper for the entire package ├── storage // Distributed file storage helper classes @@ -76,3 +93,39 @@ $ abi-gen --language Python -o nftlabs/abi --abis ../nftlabs-protocols/abi/NFT.j ``` Anytime there are ABI contract changes, you should regenerate the abi wrappers. + + +### Writing Documentation + +This package uses [`PyDoctor`](https://github.com/twisted/pydoctor) to auto-generate docs. Each method, class and variable should have a detailed description of what it is meant for as a comment enclosed in triple quoation marks (`""" """`) just below the line they are defined. + +Example: + +Do: +```python +def my_method(self, arg1, arg2): + """ + This part goes into the documentation. + """ + return arg1 + arg2 +``` + +Don't: +```python +""" +This part will not go into the documentation. +""" + +def my_method(self, arg1, arg2): + return arg1 + arg2 +``` + + +Addtionally, each module should also have a docstring at the top of the file. This will be used as a breif descroption of the module on the [homepage of the documentation](https://python-docs.nftlabs.co/). + +Example: +```python +1 """Interact with the NFT module of the app""" # docstring +2 # Module code starts from here +3 # ... +``` \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 48bd1e7d..4d8a5469 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,15 @@ -thirdweb-web3==5.24.8 -thirdweb-contract-wrappers==2.0.3 0x-contract-addresses==3.0.0 0x-contract-artifacts==3.0.0 -0x-contract-wrappers==2.0.0 0x-json-schemas==2.1.0 0x-order-utils==4.0.1 +aiohttp==3.7.4.post0 async-timeout==3.0.1 attrs==21.2.0 +autopep8==1.6.0 base58==2.1.0 bitarray==1.2.2 certifi==2021.10.8 +chardet==4.0.0 charset-normalizer==2.0.6 cytoolz==0.11.0 dataclasses-json==0.5.6 @@ -35,19 +35,22 @@ mypy-extensions==0.4.3 netaddr==0.8.0 parsimonious==0.8.1 protobuf==3.18.1 +pycodestyle==2.8.0 pycryptodome==3.11.0 pyrsistent==0.18.0 requests==2.26.0 rlp==2.0.1 six==1.16.0 stringcase==1.2.0 +thirdweb-contract-wrappers==2.0.3 +thirdweb-web3==5.24.8 +toml==0.10.2 toolz==0.11.1 typing-extensions==3.10.0.2 typing-inspect==0.7.1 urllib3==1.26.7 varint==1.0.2 web3==5.24.0 -thirdweb-web3==5.24.8 websockets==9.1 wrapt==1.13.1 yarl==1.7.0 diff --git a/tests/test_bundle.py b/tests/test_bundle.py new file mode 100644 index 00000000..9f068925 --- /dev/null +++ b/tests/test_bundle.py @@ -0,0 +1,59 @@ +import unittest +from os import environ + +from dataclasses_json.api import A + +from thirdweb import SdkOptions, ThirdwebSdk +from thirdweb.modules.bundle import BundleModule +from thirdweb.modules.collection import CollectionModule +from thirdweb.types.collection import CreateCollectionArg + + +class TestRoles(unittest.TestCase): + sdk: ThirdwebSdk + module: BundleModule + old_module: CollectionModule + + @classmethod + def setUpClass(self): + self.sdk = ThirdwebSdk(SdkOptions( + private_key=environ['PKEY'] + ), "https://rpc-mumbai.maticvigil.com") + self.module = self.sdk.get_bundle_module( + "0x5CF412451f4Cef34293604048238bd18D2BD1e71") + self.old_module = self.sdk.get_collection_module( + "0x5CF412451f4Cef34293604048238bd18D2BD1e71") + + def test_bundle_get_all(self): + """ + Test that tries to instantiate the NFT module + """ + result = self.module.get_all() + self.assertGreater( + len(result), 0, "There should be at least 1 token in the contract") + + def test_collection_get_all(self): + """ + Test that tries to instantiate the Collection module + """ + result = self.old_module.get_all() + self.assertGreater( + len(result), 0, "There should be at least 1 token in the contract") + + # def test_collection_mint(self): + # """ + # Test that tries to instantiate the Collection module + # """ + # result = self.old_module.create_and_mint(meta_with_supply=CreateCollectionArg( + # metadata={"name": "Test"}, + # supply=10, + # )) + # print("Minted", result) + # result = self.module.create_and_mint(meta_with_supply=CreateCollectionArg( + # metadata={"name": "Test"}, + # supply=10, + # )) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_constants.py b/tests/test_constants.py index c499b8e7..545c1ce7 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -1,7 +1,7 @@ TEST_NFT_CONTRACT_ADDRESS = "0xEeD541b524Ae738c48211Be91EB81E97739A0A29" TEST_PACK_CONTRACT_ADDRESS = "0x54ec360704b2e9E4e6499a732b78094D6d78e37B" TEST_MARKET_CONTRACT_ADDRESS = "0x325a98B6081ef88C6356d63c56f48Fa1d0d2DD0D" -TEST_COLLECTION_CONTRACT_ADDRESS = "0x6Da734b14e4CE604f1e18efb7E7f7ef022e96616" +TEST_BUNDLE_CONTRACT_ADDRESS = "0x6Da734b14e4CE604f1e18efb7E7f7ef022e96616" TEST_CURRENCY_CONTRACT_ADDRESS = "0xF18FEb8b2F58691d67C98dB98B360840df340e74" TEST_COMPANION_WALLET_ADDRESS = "0x4d36d531D9cB40b8694763123D52170FAE5e1195" diff --git a/tests/test_import.py b/tests/test_import.py index 00d9844b..e6803d35 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -24,12 +24,13 @@ def test_init_currency_module(self): sdk = NftlabsSdk(SdkOptions(), "https://rpc-mumbai.maticvigil.com") currency_module = sdk.get_currency_module("0xF18FEb8b2F58691d67C98dB98B360840df340e74") - def test_init_collection_module(self): + + def test_init_bundle_module(self): """ - Test that tries to instantiate the Currency module + Test that tries to instantiate the Bundle module """ sdk = NftlabsSdk(SdkOptions(), "https://rpc-mumbai.maticvigil.com") - collection_module = sdk.get_collection_module("0x6Da734b14e4CE604f1e18efb7E7f7ef022e96616") + bundle_module = sdk.get_bundle_module("0x6Da734b14e4CE604f1e18efb7E7f7ef022e96616") def test_init_pack_module(self): """ diff --git a/tests/test_market.py b/tests/test_market.py index c1432809..4a5936d9 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -2,7 +2,7 @@ from nftlabs import NftlabsSdk, SdkOptions -from test_constants import (TEST_COLLECTION_CONTRACT_ADDRESS, +from test_constants import (TEST_BUNDLE_CONTRACT_ADDRESS, TEST_MARKET_CONTRACT_ADDRESS, TEST_NFT_CONTRACT_ADDRESS) @@ -16,11 +16,11 @@ def test_init_marketplace_module(self): market_module = sdk.get_market_module(TEST_MARKET_CONTRACT_ADDRESS) self.assertFalse(market_module.is_erc721( - TEST_COLLECTION_CONTRACT_ADDRESS), "A collection is not a 721 contract") + TEST_BUNDLE_CONTRACT_ADDRESS), "A bundle is not a 721 contract") self.assertTrue(market_module.is_erc721( TEST_NFT_CONTRACT_ADDRESS), "A nft contract is a 721 contract") self.assertTrue(market_module.is_erc1155( - TEST_COLLECTION_CONTRACT_ADDRESS), "A collection is a 1155 contract") + TEST_BUNDLE_CONTRACT_ADDRESS), "A bundle is a 1155 contract") self.assertFalse(market_module.is_erc1155( TEST_NFT_CONTRACT_ADDRESS), "A nft contract is not a 1155 contract") diff --git a/tests/test_roles.py b/tests/test_roles.py index d03a08c5..5a5b3893 100644 --- a/tests/test_roles.py +++ b/tests/test_roles.py @@ -3,7 +3,7 @@ from nftlabs import NftlabsSdk, SdkOptions from nftlabs.types.role import Role from os import environ -from test_constants import TEST_COLLECTION_CONTRACT_ADDRESS, TEST_CURRENCY_CONTRACT_ADDRESS, TEST_MARKET_CONTRACT_ADDRESS, TEST_NFT_CONTRACT_ADDRESS, TEST_COMPANION_WALLET_ADDRESS, TEST_PACK_CONTRACT_ADDRESS +from test_constants import TEST_BUNDLE_CONTRACT_ADDRESS, TEST_CURRENCY_CONTRACT_ADDRESS, TEST_MARKET_CONTRACT_ADDRESS, TEST_NFT_CONTRACT_ADDRESS, TEST_COMPANION_WALLET_ADDRESS, TEST_PACK_CONTRACT_ADDRESS class TestRoles(unittest.TestCase): @@ -20,8 +20,8 @@ def test_grant_and_revoke_role(self): TEST_NFT_CONTRACT_ADDRESS), sdk.get_market_module( TEST_MARKET_CONTRACT_ADDRESS), - sdk.get_collection_module( - TEST_COLLECTION_CONTRACT_ADDRESS), + sdk.get_bundle_module( + TEST_BUNDLE_CONTRACT_ADDRESS), sdk.get_pack_module( TEST_PACK_CONTRACT_ADDRESS), sdk.get_currency_module( diff --git a/thirdweb/abi/__init__.py b/thirdweb/abi/__init__.py index f0606a2a..685bda45 100644 --- a/thirdweb/abi/__init__.py +++ b/thirdweb/abi/__init__.py @@ -4,3 +4,4 @@ from .pack import * from .nft_collection import * +#todo? diff --git a/thirdweb/modules/__init__.py b/thirdweb/modules/__init__.py index 128a8b66..034658d8 100644 --- a/thirdweb/modules/__init__.py +++ b/thirdweb/modules/__init__.py @@ -5,4 +5,5 @@ from .currency import * from .market import * from .pack import * -from .collection import * +from .collection import CollectionModule +from .bundle import * diff --git a/thirdweb/modules/base.py b/thirdweb/modules/base.py index 4207dc38..0ec00367 100644 --- a/thirdweb/modules/base.py +++ b/thirdweb/modules/base.py @@ -12,7 +12,7 @@ from ..abi.erc165 import ERC165 from ..abi.market import Market from ..abi.nft import NFT -from ..abi.nft_collection import NFTCollection +from ..abi.nft_collection import NFTCollection as NFTBundle from ..abi.pack import Pack from ..constants.erc_interfaces import InterfaceIdErc721, InterfaceIdErc1155 from ..errors import NoSignerException @@ -20,7 +20,7 @@ from ..storage import IpfsStorage from ..types.role import Role -ModuleTypes = Union[NFT, Market, Pack, NFTCollection, Coin] +ModuleTypes = Union[NFT, Market, Pack, NFTBundle, Coin] class BaseModule(ABC): diff --git a/thirdweb/modules/collection.py b/thirdweb/modules/bundle.py similarity index 79% rename from thirdweb/modules/collection.py rename to thirdweb/modules/bundle.py index 806f2bac..eccb62a7 100644 --- a/thirdweb/modules/collection.py +++ b/thirdweb/modules/bundle.py @@ -2,36 +2,37 @@ from thirdweb_web3 import Web3 -from ..abi.nft_collection import NFTCollection -from ..types.collection import (CollectionMetadata, CreateCollectionArg, - MintCollectionArg) +from ..abi.nft_collection import NFTCollection as NFTBundle +# from ..types.collection import (BundleMetadata, CreateBundleArg, +# MintBundleArg) +from ..types.bundle import (BundleMetadata, CreateBundleArg, MintBundleArg) from ..types.metadata import Metadata from ..types.nft import NftMetadata from .base import BaseModule -class CollectionModule(BaseModule): +class BundleModule(BaseModule): address: str - __abi_module: NFTCollection + __abi_module: NFTBundle def __init__(self, address: str, client: Web3): super().__init__() self.address = address - self.__abi_module = NFTCollection(client, address) + self.__abi_module = NFTBundle(client, address) - def get(self, token_id: int) -> CollectionMetadata: + def get(self, token_id: int) -> BundleMetadata: uri = self.__abi_module.uri.call(token_id) meta_str = self.get_storage().get(uri) meta: NftMetadata = NftMetadata.from_json(meta_str) meta.id = token_id - return CollectionMetadata( + return BundleMetadata( metadata=meta, supply=self.__abi_module.total_supply.call(token_id), creator=self.__abi_module.creator.call(token_id), id=token_id ) - def get_all(self) -> List[CollectionMetadata]: + def get_all(self) -> List[BundleMetadata]: return [self.get(i) for i in range(self.__abi_module.next_token_id.call())] ''' @@ -67,18 +68,18 @@ def transfer(self, to_address: str, token_id: int, amount: int): self.get_signer_address(), to_address, token_id, amount, "", self.get_transact_opts() )) - def create(self, metadata: Metadata) -> CollectionMetadata: + def create(self, metadata: Metadata) -> BundleMetadata: return self.create_batch([metadata])[0] - def create_batch(self, metas: List[Metadata]) -> List[CollectionMetadata]: - meta_with_supply = [CreateCollectionArg( + def create_batch(self, metas: List[Metadata]) -> List[BundleMetadata]: + meta_with_supply = [CreateBundleArg( metadata=m, supply=0) for m in metas] return self.create_and_mint_batch(meta_with_supply) - def create_and_mint(self, meta_with_supply: CreateCollectionArg) -> CollectionMetadata: + def create_and_mint(self, meta_with_supply: CreateBundleArg) -> BundleMetadata: return self.create_and_mint_batch([meta_with_supply])[0] - def create_and_mint_batch(self, meta_with_supply: List[CreateCollectionArg]) -> List[CollectionMetadata]: + def create_and_mint_batch(self, meta_with_supply: List[CreateBundleArg]) -> List[BundleMetadata]: uris = [self.get_storage().upload(meta.to_json(), self.address, self.get_signer_address()) for meta in meta_with_supply] supplies = [a.supply for a in meta_with_supply] @@ -90,7 +91,7 @@ def create_and_mint_batch(self, meta_with_supply: List[CreateCollectionArg]) -> token_ids = result[0]['args']['tokenIds'] return [self.get(i) for i in token_ids] - def create_with_erc20(self, token_contract: str, token_amount: int, arg: CreateCollectionArg): + def create_with_erc20(self, token_contract: str, token_amount: int, arg: CreateBundleArg): uri = self.get_storage().upload( arg.metadata, self.address, self.get_signer_address()) self.execute_tx(self.__abi_module.wrap_erc20.build_transaction( @@ -104,42 +105,42 @@ def create_with_erc721(self, token_contract: str, token_id: int, metadata): token_contract, token_id, uri, self.get_transact_opts() )) - def mint(self, args: MintCollectionArg): + def mint(self, args: MintBundleArg): self.mint_to(self.get_signer_address(), args) - def mint_to(self, to_address: str, arg: MintCollectionArg): + def mint_to(self, to_address: str, arg: MintBundleArg): self.execute_tx(self.__abi_module.mint.build_transaction( to_address, arg.token_id, arg.amount, "", self.get_transact_opts() )) - def mint_batch(self, args: List[MintCollectionArg]): + def mint_batch(self, args: List[MintBundleArg]): self.mint_batch_to(self.get_signer_address(), args) - def mint_batch_to(self, to_address, args: List[MintCollectionArg]): + def mint_batch_to(self, to_address, args: List[MintBundleArg]): ids = [a.token_id for a in args] amounts = [a.amount for a in args] tx = self.__abi_module.mint_batch.build_transaction( to_address, ids, amounts, self.get_transact_opts()) self.execute_tx(tx) - def burn(self, args: MintCollectionArg): + def burn(self, args: MintBundleArg): self.burn_from(self.get_signer_address(), args) - def burn_batch(self, args: List[MintCollectionArg]): + def burn_batch(self, args: List[MintBundleArg]): self.burn_batch_from(self.get_signer_address(), args) - def burn_from(self, account: str, args: MintCollectionArg): + def burn_from(self, account: str, args: MintBundleArg): self.execute_tx(self.__abi_module.burn.build_transaction( account, args.token_id, args.amount, self.get_transact_opts() )) - def burn_batch_from(self, account: str, args: List[MintCollectionArg]): + def burn_batch_from(self, account: str, args: List[MintBundleArg]): self.execute_tx(self.__abi_module.burn_batch.build_transaction( account, [i.id for i in args], [ i.amount for i in args], self.get_transact_opts() )) - def transfer_from(self, from_address: str, to_address: str, args: MintCollectionArg): + def transfer_from(self, from_address: str, to_address: str, args: MintBundleArg): self.execute_tx(self.__abi_module.safe_transfer_from.build_transaction( from_address, to_address, args.token_id, args.amount, "", self.get_transact_opts() )) @@ -154,5 +155,5 @@ def set_royalty_bps(self, amount: int): amount, self.get_transact_opts() )) - def get_abi_module(self) -> NFTCollection: + def get_abi_module(self) -> NFTBundle: return self.__abi_module diff --git a/thirdweb/modules/collection/__init__.py b/thirdweb/modules/collection/__init__.py new file mode 100644 index 00000000..b74b5d85 --- /dev/null +++ b/thirdweb/modules/collection/__init__.py @@ -0,0 +1,3 @@ +from ..bundle import BundleModule + +CollectionModule = BundleModule diff --git a/thirdweb/options/sdk_options.py b/thirdweb/options/sdk_options.py index 4846023c..734768cb 100644 --- a/thirdweb/options/sdk_options.py +++ b/thirdweb/options/sdk_options.py @@ -3,7 +3,7 @@ @dataclasses.dataclass class SdkOptions: - ipfs_gateway_url: str = "https://cloudflare-ipfs.com/ipfs/" + ipfs_gateway_url: str = "https://ipfs.io/ipfs/" registry_contract_address: str = "" max_gas_price_in_gwei: int = 100 gas_speed: str = "fastest" diff --git a/thirdweb/sdk.py b/thirdweb/sdk.py index 4e25015f..3296c00f 100644 --- a/thirdweb/sdk.py +++ b/thirdweb/sdk.py @@ -7,6 +7,7 @@ from .modules.nft import NftModule from .modules.pack import PackModule from .modules.collection import CollectionModule +from .modules.bundle import BundleModule from .modules.currency import CurrencyModule from .modules.market import MarketModule from .options import SdkOptions @@ -36,6 +37,7 @@ class ThirdwebSdk(object): __nft_module: Optional[NftModule] __pack_module: Optional[PackModule] __collection_module: Optional[CollectionModule] + __bundle_module = Optional[BundleModule] __market_module: Optional[MarketModule] """ @@ -47,6 +49,7 @@ def __init__(self, options: SdkOptions, url: str): self.__nft_module = None self.__pack_module = None self.__collection_module = None + self.__bundle_module = None self.__current_account = None self.__market_module = None @@ -56,7 +59,7 @@ def __init__(self, options: SdkOptions, url: str): self.storage = IpfsStorage( options.ipfs_gateway_url if options.ipfs_gateway_url - else "https://cloudflare-ipfs.com/ipfs/") + else "https://ipfs.io/ipfs/") self.client = Web3(HTTPProvider(url)) if not self.client.isConnected(): @@ -129,17 +132,24 @@ def get_market_module(self, address: str) -> MarketModule: return self.__market_module """ - Returns an instance of the collection module + Returns an instance of the bundle module """ @set_default_account def get_collection_module(self, address: str) -> CollectionModule: - if self.__collection_module is not None: - return self.__collection_module + """ + COLLECTION MODULE AND ALL ITS CLASSES WILL BE DEPRECATED SOON. USE BUNDLE MODULE INSTEAD. + """ + return self.get_bundle_module(address) - module = CollectionModule(address, self.__get_client()) + def get_bundle_module(self, address: str) -> BundleModule: + + if self.__bundle_module is not None: + return self.__bundle_module + + module = BundleModule(address, self.__get_client()) self.__init_module(module) - self.__collection_module = module - return self.__collection_module + self.__bundle_module = module + return self.__bundle_module """ Internal function used to return the current web3 provider used by downstream modules diff --git a/thirdweb/storage/ipfs_storage.py b/thirdweb/storage/ipfs_storage.py index c16cc25e..1ec1812f 100644 --- a/thirdweb/storage/ipfs_storage.py +++ b/thirdweb/storage/ipfs_storage.py @@ -3,6 +3,7 @@ from requests import get, post import json + class IpfsStorage: __nftlabsApiUrl = "https://upload.nftlabs.co" @@ -14,7 +15,7 @@ def __init__(self, gateway_uri: str): def get(self, uri: str) -> str: ipfs_uri = replace_ipfs_prefix_with_gateway(uri, self.gateway_uri) - response = get(ipfs_uri) + response = get(ipfs_uri, timeout=10) if response.status_code != 200: raise Exception("Failed to download metadata") @@ -24,6 +25,7 @@ def get(self, uri: str) -> str: """ Upload data to IPFS, data parameter """ + def upload(self, data, contract_address: str, signer_address: str) -> str: if isinstance(data, str) and data.startswith("ipfs://"): return data @@ -40,7 +42,7 @@ def upload(self, data, contract_address: str, signer_address: str) -> str: response = result.json() return response['IpfsUri'] - + def upload_metadata(self, metadata: str, contract_address: str, signer_address: str) -> str: if type(metadata) == str: return self.upload(metadata, contract_address, signer_address) diff --git a/thirdweb/types/bundle/__init__.py b/thirdweb/types/bundle/__init__.py new file mode 100644 index 00000000..650174e2 --- /dev/null +++ b/thirdweb/types/bundle/__init__.py @@ -0,0 +1,31 @@ +from dataclasses import dataclass +from typing import Optional + +from dataclasses_json import dataclass_json + +from ..nft import NftMetadata +from ..metadata import Metadata + + +@dataclass_json +@dataclass +class BundleMetadata: + id: Optional[int] = None + creator: Optional[str] = None + supply: Optional[int] = None + metadata: Optional[NftMetadata] = None + + +@dataclass_json +@dataclass +class CreateBundleArg: + metadata: Optional[Metadata] = None + supply: Optional[int] = None + + +@dataclass_json +@dataclass +class MintBundleArg: + token_id: Optional[int] = None + amount: Optional[int] = None + diff --git a/thirdweb/types/collection/__init__.py b/thirdweb/types/collection/__init__.py index 6d7cfb88..c26e3d74 100644 --- a/thirdweb/types/collection/__init__.py +++ b/thirdweb/types/collection/__init__.py @@ -1,31 +1 @@ -from dataclasses import dataclass -from typing import Optional - -from dataclasses_json import dataclass_json - -from ..nft import NftMetadata -from ..metadata import Metadata - - -@dataclass_json -@dataclass -class CollectionMetadata: - id: Optional[int] = None - creator: Optional[str] = None - supply: Optional[int] = None - metadata: Optional[NftMetadata] = None - - -@dataclass_json -@dataclass -class CreateCollectionArg: - metadata: Optional[Metadata] = None - supply: Optional[int] = None - - -@dataclass_json -@dataclass -class MintCollectionArg: - token_id: Optional[int] = None - amount: Optional[int] = None - +from .types import CreateCollectionArg, CollectionMetadata, MintCollectionArg diff --git a/thirdweb/types/collection/types.py b/thirdweb/types/collection/types.py new file mode 100644 index 00000000..e93abc42 --- /dev/null +++ b/thirdweb/types/collection/types.py @@ -0,0 +1,5 @@ +from ..bundle import BundleMetadata, CreateBundleArg, MintBundleArg + +CollectionMetadata = BundleMetadata +CreateCollectionArg = CreateBundleArg +MintCollectionArg = MintBundleArg diff --git a/thirdweb/types/listing.py b/thirdweb/types/listing.py index 49fae6b5..2c9268e3 100644 --- a/thirdweb/types/listing.py +++ b/thirdweb/types/listing.py @@ -11,13 +11,13 @@ @dataclass_json @dataclass class Listing: - """A listing of an some asset (e.g. a NFT, Collection, Pack, etc.) + """A listing of an some asset (e.g. a NFT, Bundle, Pack, etc.) Attributes: id (str): The id of the listing seller (str): The wallet address of the seller token_contract (str): The address of the token contract - token_id (str): The id of the token (e.g. id of NFT, Pack, or Collection) + token_id (str): The id of the token (e.g. id of NFT, Pack, or Bundle) quantity (int): The quantity of token being listed (a single listing could sell >= 1 token) currency_contract (str): The address of the currency contract. This property is set to 0x0 if the listing is free. price_per_token (int): The price per token. E.g. if the currency_contract is pointing to a contract with token symbol $DAI, then this listing costs (price_per_token * $DAI).