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
6 changes: 3 additions & 3 deletions thirdweb/contracts/edition.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from thirdweb.core.classes.contract_royalty import ContractRoyalty
from thirdweb.core.classes.contract_sales import ContractPrimarySale
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_1155 import ERC1155
from thirdweb.core.classes.erc_1155_standard import ERC1155Standard
from thirdweb.core.classes.erc_1155_signature_minting import ERC1155SignatureMinting
from thirdweb.abi import TokenERC1155

Expand All @@ -27,7 +27,7 @@
from thirdweb.types.tx import TxResultWithId


class Edition(ERC1155[TokenERC1155]):
class Edition(ERC1155Standard[TokenERC1155]):
"""
Create a collection of NFTs that lets you mint multiple copies of each NFT.

Expand Down Expand Up @@ -169,7 +169,7 @@ def mint_additional_supply_to(
:returns: receipt, id, and metadata of the mint
"""

metadata = self._get_token_metadata(token_id)
metadata = self._erc1155._get_token_metadata(token_id)
receipt = self._contract_wrapper.send_transaction(
"mint_to", [to, token_id, metadata.uri, additional_supply]
)
Expand Down
6 changes: 3 additions & 3 deletions thirdweb/contracts/edition_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from thirdweb.core.classes.contract_royalty import ContractRoyalty
from thirdweb.core.classes.contract_sales import ContractPrimarySale
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_1155 import ERC1155
from thirdweb.core.classes.erc_1155_standard import ERC1155Standard
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import ContractType
from thirdweb.types.contracts.claim_conditions import ClaimVerification
Expand All @@ -28,7 +28,7 @@
from web3.eth import TxReceipt


class EditionDrop(ERC1155[DropERC1155]):
class EditionDrop(ERC1155Standard[DropERC1155]):
"""
Setup a collection of NFTs with a customizable number of each NFT that are minted as users claim them.

Expand Down Expand Up @@ -153,7 +153,7 @@ def create_batch(
TxResultWithId(
receipt,
id=id,
data=lambda: self._get_token_metadata(id),
data=lambda: self._erc1155._get_token_metadata(id),
)
)

Expand Down
4 changes: 2 additions & 2 deletions thirdweb/contracts/multiwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from thirdweb.core.classes.contract_roles import ContractRoles
from thirdweb.core.classes.contract_royalty import ContractRoyalty
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_721 import ERC721
from thirdweb.core.classes.erc_721_standard import ERC721Standard
from thirdweb.abi import Multiwrap as MultiwrapABI
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import ContractType
Expand All @@ -35,7 +35,7 @@
from thirdweb.types.tx import TxResultWithId


class Multiwrap(ERC721[MultiwrapABI]):
class Multiwrap(ERC721Standard[MultiwrapABI]):
"""
Multiwrap lets you wrap any number of ERC20, ERC721, or ERC1155 tokens into
a single wrapped token bundle.
Expand Down
4 changes: 2 additions & 2 deletions thirdweb/contracts/nft_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from thirdweb.core.classes.contract_sales import ContractPrimarySale
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.common.nft import upload_or_extract_uri, upload_or_extract_uris
from thirdweb.core.classes.erc_721 import ERC721
from thirdweb.core.classes.erc_721_standard import ERC721Standard
from thirdweb.core.classes.erc_721_signature_minting import ERC721SignatureMinting
from thirdweb.abi import TokenERC721

Expand All @@ -26,7 +26,7 @@
from thirdweb.types.tx import TxResultWithId


class NFTCollection(ERC721[TokenERC721]):
class NFTCollection(ERC721Standard[TokenERC721]):
"""
Create a collection of one-of-one NFTs.

Expand Down
4 changes: 2 additions & 2 deletions thirdweb/contracts/nft_drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from thirdweb.core.classes.contract_sales import ContractPrimarySale
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.drop_claim_conditions import DropClaimConditions
from thirdweb.core.classes.erc_721 import ERC721
from thirdweb.core.classes.erc_721_standard import ERC721Standard
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import ContractType
from thirdweb.types.contracts.claim_conditions import ClaimVerification
Expand All @@ -30,7 +30,7 @@
from thirdweb.types.tx import TxResultWithId


class NFTDrop(ERC721[DropERC721]):
class NFTDrop(ERC721Standard[DropERC721]):
"""
Setup a collection of one-of-one NFTs that are minted as users claim them.

Expand Down
6 changes: 3 additions & 3 deletions thirdweb/contracts/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from thirdweb.core.classes.contract_platform_fee import ContractPlatformFee
from thirdweb.core.classes.contract_roles import ContractRoles
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_20 import ERC20
from thirdweb.core.classes.erc_20_standard import ERC20Standard
from thirdweb.core.classes.erc_20_signature_minting import ERC20SignatureMinting
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import ContractType
Expand All @@ -22,7 +22,7 @@
from thirdweb.types.settings.metadata import TokenContractMetadata


class Token(ERC20):
class Token(ERC20Standard):
"""
Create a standard crypto token or cryptocurrency.

Expand Down Expand Up @@ -96,7 +96,7 @@ def get_vote_balance_of(self, account: str) -> CurrencyValue:
:returns: vote balance of the specified wallet
"""

return self._get_value(
return self._erc20._get_value(
self._contract_wrapper._contract_abi.get_votes.call(account)
)

Expand Down
3 changes: 1 addition & 2 deletions thirdweb/core/classes/erc_1155.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any, Generic, List, Optional, Union, cast
from thirdweb.abi import TokenERC1155
from typing import Generic, List, Union
from thirdweb.common.error import NotFoundException
from thirdweb.common.nft import fetch_token_metadata
from thirdweb.constants.currency import ZERO_ADDRESS
Expand Down
29 changes: 29 additions & 0 deletions thirdweb/core/classes/erc_1155_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Generic
from thirdweb.core.classes.base_contract import BaseContract
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_1155 import ERC1155
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import TERC1155


class ERC1155Standard(Generic[TERC1155], BaseContract[TERC1155]):
_storage: IpfsStorage
_erc1155: ERC1155

def __init__(self, contract_wrapper: ContractWrapper, storage: IpfsStorage):
super(contract_wrapper)
self._storage = storage

self._erc1155 = ERC1155(contract_wrapper, storage)
self.get = self._erc1155.get
self.get_all = self._erc1155.get_all
self.get_total_count = self._erc1155.get_total_count
self.get_owned = self._erc1155.get_owned
self.total_supply = self._erc1155.total_supply
self.balance = self._erc1155.balance
self.balance_of = self._erc1155.balance_of
self.is_transfer_restricted = self._erc1155.is_transfer_restricted
self.is_approved = self._erc1155.is_approved
self.transfer = self._erc1155.transfer
self.burn = self._erc1155.burn
self.set_approval_for_all = self._erc1155.set_approval_for_all
29 changes: 29 additions & 0 deletions thirdweb/core/classes/erc_20_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from typing import Generic
from thirdweb.abi.token_erc20 import TokenERC20
from thirdweb.core.classes.base_contract import BaseContract
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_20 import ERC20
from thirdweb.core.classes.ipfs_storage import IpfsStorage

class ERC20Standard(BaseContract[TokenERC20]):
_storage: IpfsStorage
_erc20: ERC20

def __init__(self, contract_wrapper: ContractWrapper, storage: IpfsStorage):
super(contract_wrapper)
self._storage = storage

self._erc20 = ERC20(contract_wrapper, storage)
self.get = self._erc20.get
self.balance = self._erc20.balance
self.balance_of = self._erc20.balance_of
self.total_supply = self._erc20.total_supply
self.allowance = self._erc20.allowance
self.allowance_of = self._erc20.allowance_of
self.is_transfer_restricted = self._erc20.is_transfer_restricted
self.transfer = self._erc20.transfer
self.transfer_from = self._erc20.transfer_from
self.set_allowance = self._erc20.set_allowance
self.transfer_batch = self._erc20.transfer_batch
self.burn = self._erc20.burn
self.burn_from = self._erc20.burn_from
12 changes: 4 additions & 8 deletions thirdweb/core/classes/erc_721.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import List, Generic
from typing import Generic, List
from thirdweb.common.error import NotFoundException
from thirdweb.common.nft import fetch_token_metadata
from thirdweb.constants.currency import ZERO_ADDRESS
from thirdweb.constants.role import Role, get_role_hash
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.base_contract import BaseContract
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import TERC721
from thirdweb.types.nft import NFTMetadata, NFTMetadataOwner, QueryAllParams
Expand All @@ -14,11 +14,7 @@
class ERC721(Generic[TERC721], BaseContract[TERC721]):
_storage: IpfsStorage

def __init__(
self,
contract_wrapper: ContractWrapper,
storage: IpfsStorage,
):
def __init__(self, contract_wrapper: ContractWrapper, storage: IpfsStorage):
super().__init__(contract_wrapper)
self._storage = storage

Expand Down Expand Up @@ -224,4 +220,4 @@ def _get_token_metadata(self, token_id: int) -> NFTMetadata:
if not token_uri:
raise NotFoundException(str(token_id))

return fetch_token_metadata(token_id, token_uri, self._storage)
return fetch_token_metadata(token_id, token_uri, self._storage)
34 changes: 34 additions & 0 deletions thirdweb/core/classes/erc_721_standard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from typing import Generic
from thirdweb.core.classes.base_contract import BaseContract
from thirdweb.core.classes.contract_wrapper import ContractWrapper
from thirdweb.core.classes.erc_721 import ERC721
from thirdweb.core.classes.ipfs_storage import IpfsStorage
from thirdweb.types.contract import TERC721


class ERC721Standard(Generic[TERC721], BaseContract[TERC721]):
_storage: IpfsStorage
_erc721: ERC721

def __init__(
self,
contract_wrapper: ContractWrapper,
storage: IpfsStorage,
):
super(contract_wrapper)
self.storage = storage

self._erc721 = ERC721(contract_wrapper, storage)
self.get = self._erc721.get
self.get_all = self._erc721.get_all
self.get_total_count = self._erc721.get_total_count
self.owner_of = self._erc721.owner_of
self.total_supply = self._erc721.total_supply
self.balance = self._erc721.balance
self.balance_of = self._erc721.balance_of
self.is_transfer_restricted = self._erc721.is_transfer_restricted
self.is_approved = self._erc721.is_approved
self.transfer = self._erc721.transfer
self.burn = self._erc721.burn
self.set_approval_for_all = self._erc721.set_approval_for_all
self.set_approval_for_token = self._erc721.set_approval_for_token