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.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@

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)
>
> 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

Expand All @@ -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
Expand Down Expand Up @@ -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 # ...
```
11 changes: 7 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
59 changes: 59 additions & 0 deletions tests/test_bundle.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion tests/test_constants.py
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 4 additions & 3 deletions tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
6 changes: 3 additions & 3 deletions tests/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions thirdweb/abi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .pack import *

from .nft_collection import *
#todo?
3 changes: 2 additions & 1 deletion thirdweb/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
from .currency import *
from .market import *
from .pack import *
from .collection import *
from .collection import CollectionModule
from .bundle import *
4 changes: 2 additions & 2 deletions thirdweb/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
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
from ..options import SdkOptions
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):
Expand Down
Loading