Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 304f968

Browse files
adam-majAdam MajmudarAdam Majmudar
authored
Add feature snippets (#127)
* Fix super() * Update * Fix standards with functions * Add erc20, erc721, and erc1155 extensions * Fix duplicate functions * Add docs setup to make init, update docs for erc20, erc721, erc1155 * Add feature snippets generation * Delete scripts --------- Co-authored-by: Adam Majmudar <adam@Adams-MacBook-Pro.local> Co-authored-by: Adam Majmudar <adam@Adams-MBP.localdomain>
1 parent 5e9338e commit 304f968

30 files changed

+4248
-163
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ init:
1313
poetry run pip3 install eth-brownie
1414
npm install -g @0x/abi-gen
1515
yarn
16+
poetry shell
17+
pip3 install pydoc-markdown
18+
pip3 install 0x-order-utils
1619

1720
test:
1821
poetry run brownie test --network hardhat

docs/docs/contract-metadata.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def get() -> TContractSchema
2020

2121
Get the metadata associated with this contract.
2222

23+
```python
24+
metadata = contract.metadata.get()
25+
print(metadata)
26+
```
27+
2328
**Returns**:
2429

2530
metadata associated with this contract
@@ -34,6 +39,18 @@ def set(metadata: TContractSchema) -> TxReceipt
3439

3540
Set the metadata associated with this contract.
3641

42+
```python
43+
from thirdweb.types import ContractMetadataSchema
44+
45+
metadata = ContractMetadataSchema.from_json({
46+
"name": "My Contract",
47+
"description": "This is my contract!",
48+
"image": open("path/to/file.jpg", "rb")
49+
})
50+
51+
receipt = contract.metadata.set(metadata)
52+
```
53+
3754
**Arguments**:
3855

3956
- `metadata`: metadata to set

docs/docs/contract-platform-fee.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def get() -> ContractPlatformFeeSchema
2020

2121
Get the platform fee of this contract.
2222

23+
```python
24+
platform_fees = contract.platform_fee.get()
25+
print(platform_fees.platform_fee_basis_points)
26+
print(platform_fees.platform_fee_recipient)
27+
```
28+
2329
**Returns**:
2430

2531
the platform fee.
@@ -34,6 +40,17 @@ def set(platform_fee_info: ContractPlatformFeeSchema) -> TxReceipt
3440

3541
Set the platform fee of this contract.
3642

43+
```python
44+
from thirdweb.types import ContractPlatformFeeSchema
45+
46+
platform_fee_info = ContractPlatformFeeSchema(
47+
platform_fee_basis_points=100 # 1%
48+
platform_fee_receipient="{{wallet_address}}"
49+
)
50+
51+
receipt = contract.platform_fee.set(platform_fee_info)
52+
```
53+
3754
**Arguments**:
3855

3956
- `platform_fee_info`: the platform fee info to set.

docs/docs/contract-roles.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def get_all() -> Dict[Role, List[str]]
2020

2121
Get all role members on this contract.
2222

23+
```python
24+
all_role_members = contract.roles.get_all()
25+
print(all_role_members)
26+
```
27+
2328
**Returns**:
2429

2530
a dictionary of role members for each role
@@ -34,6 +39,16 @@ def get(role: Role) -> List[str]
3439

3540
Get all members of a role on this contract.
3641

42+
```python
43+
from thirdweb.constants.role import Role
44+
45+
# Select any role to filter by
46+
role = Role.ADMIN
47+
48+
role_members = contract.roles.get(role)
49+
print(role_members)
50+
```
51+
3752
**Arguments**:
3853

3954
- `role`: role to get members of
@@ -52,6 +67,15 @@ def grant(role: Role, address: str) -> TxReceipt
5267

5368
Grant a role to an address.
5469

70+
```python
71+
from thirdweb.constants.role import Role
72+
73+
address = "{{wallet_address}}" # Address to grant a role
74+
role = Role.ADMIN # Select a role to grant
75+
76+
receipt = contract.roles.grant(role, address)
77+
```
78+
5579
**Arguments**:
5680

5781
- `role`: role to grant
@@ -71,6 +95,15 @@ def revoke(role: Role, address: str) -> TxReceipt
7195

7296
Revoke a role from an address.
7397

98+
```python
99+
from thirdweb.constants.role import Role
100+
101+
address = "{{wallet_address}}" # Address to revoke a role from
102+
role = Role.MINTER # The role to revoke
103+
104+
receipt = contract.roles.revoke(role, address)
105+
```
106+
74107
**Arguments**:
75108

76109
- `role`: role to revoke

docs/docs/contract-royalty.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def get_default_royalty_info() -> ContractRoyaltySchema
2020

2121
Get the default royalty information for this contract.
2222

23+
```python
24+
royalty_info = contract.royalties.get_default_royalty_info()
25+
print(royalty_info)
26+
```
27+
2328
**Returns**:
2429

2530
the default royalty information.
@@ -34,6 +39,13 @@ def get_token_royalty_info(token_id: int) -> ContractRoyaltySchema
3439

3540
Get the royalty information for a specific token.
3641

42+
```python
43+
token_id = 0
44+
45+
royalty_info = contract.royalties.get_token_royalty_info(token_id)
46+
print(royalty_info)
47+
```
48+
3749
**Arguments**:
3850

3951
- `token_id`: the id of the token.
@@ -52,6 +64,17 @@ def set_default_royalty_info(royalty_data: ContractRoyaltySchema) -> TxReceipt
5264

5365
Set the default royalty information for this contract.
5466

67+
```python
68+
from thirdweb.types import ContractRoyaltySchema
69+
70+
royalty_data = ContractRoyaltySchema(
71+
seller_fee_basis_points=100,
72+
fee_recipient="{{wallet_address}}"
73+
)
74+
75+
receipt = contract.royalties.set_default_royalty_info()
76+
```
77+
5578
**Arguments**:
5679

5780
- `royalty_data`: the default royalty information.
@@ -71,6 +94,18 @@ def set_token_royalty_info(token_id: int,
7194

7295
Set the royalty information for a specific token.
7396

97+
```python
98+
from thirdweb.types import ContractRoyaltySchema
99+
100+
token_id = 0
101+
royalty_data = ContractRoyaltySchema(
102+
seller_fee_basis_points=100,
103+
fee_recipient="{{wallet_address}}"
104+
)
105+
106+
receipt = contract.royalties.set_token_royalty_info(token_id, royalty_data)
107+
```
108+
74109
**Arguments**:
75110

76111
- `token_id`: the id of the token.

docs/docs/contract-sales.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def get_recipient() -> str
2020

2121
Get the primary sale recipient of this contract.
2222

23+
```python
24+
primary_sale_recipient = contract.sales.get_recipient()
25+
print(primary_sale_recipient)
26+
```
27+
2328
**Returns**:
2429

2530
the address of the primary sale recipient.
@@ -34,6 +39,12 @@ def set_recipient(recipient: str) -> TxReceipt
3439

3540
Set the primary sale recipient of this contract
3641

42+
```python
43+
primary_sale_recipient = "{{wallet_address}}"
44+
45+
receipt = contract.sales.set_recipient(primary_sale_recipient)
46+
```
47+
3748
**Arguments**:
3849

3950
- `recipient`: the address of the primary sale recipient.

docs/docs/edition-drop.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
## EditionDrop Objects
88

99
```python
10-
class EditionDrop(ERC1155[DropERC1155])
10+
class EditionDrop(ERC1155Standard[DropERC1155])
1111
```
1212

1313
Setup a collection of NFTs with a customizable number of each NFT that are minted as users claim them.
@@ -80,10 +80,8 @@ List of tx results with ids for created NFTs.
8080
#### claim\_to
8181

8282
```python
83-
def claim_to(destination_address: str,
84-
token_id: int,
85-
quantity: int,
86-
proofs: List[str] = [DEFAULT_MERKLE_ROOT]) -> TxReceipt
83+
def claim_to(destination_address: str, token_id: int,
84+
quantity: int) -> TxReceipt
8785
```
8886

8987
Claim NFTs to a destination address.
@@ -115,9 +113,7 @@ tx receipt of the claim
115113
#### claim
116114

117115
```python
118-
def claim(token_id: int,
119-
quantity: int,
120-
proofs: List[str] = [DEFAULT_MERKLE_ROOT]) -> TxReceipt
116+
def claim(token_id: int, quantity: int) -> TxReceipt
121117
```
122118

123119
Claim NFTs.

docs/docs/edition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Interface for interacting with an edition contract
99
## Edition Objects
1010

1111
```python
12-
class Edition(ERC1155[TokenERC1155])
12+
class Edition(ERC1155Standard[TokenERC1155])
1313
```
1414

1515
Create a collection of NFTs that lets you mint multiple copies of each NFT.

0 commit comments

Comments
 (0)