Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ’₯ Implement ERC-1155 Standard Token #31

Merged
merged 76 commits into from
Jan 15, 2023
Merged
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
689a9f3
πŸ“ EIP-1155 interfaces
pcaversaccio Dec 19, 2022
779a2d6
πŸ‘» basic EIP-1155 implementation
pcaversaccio Dec 19, 2022
ded156a
πŸ”— add reference links to EIPs in interfaces
pcaversaccio Dec 19, 2022
19deb3c
add contract & update interface
jtriley-eth Dec 21, 2022
c23fa29
add set_uri function
jtriley-eth Dec 21, 2022
cccfd22
add set minter function
jtriley-eth Dec 21, 2022
1a0bce6
add constructor stuffs
jtriley-eth Dec 21, 2022
12ddd56
add test boilerplate
jtriley-eth Dec 22, 2022
4d6577a
Merge branch 'main' into erc1155
pcaversaccio Dec 22, 2022
d2aa5a0
Merge branch 'main' into erc1155
pcaversaccio Dec 22, 2022
66d828a
Merge branch 'erc1155' into erc1155
jtriley-eth Dec 22, 2022
b778f46
Update src/tokens/interfaces/IERC1155Receiver.vy
jtriley-eth Dec 24, 2022
4a49f81
Update test/tokens/interfaces/IERC1155Extended.sol
jtriley-eth Dec 24, 2022
3100695
Update src/tokens/ERC1155.vy
jtriley-eth Dec 24, 2022
43a45a1
Update src/tokens/ERC1155.vy
jtriley-eth Dec 24, 2022
712b4de
Update src/tokens/ERC1155.vy
jtriley-eth Dec 24, 2022
c5996ae
Update test/tokens/interfaces/IERC1155Extended.sol
jtriley-eth Dec 24, 2022
dde010f
Update test/tokens/ERC1155.t.sol
jtriley-eth Dec 24, 2022
b9ff7da
Update src/tokens/ERC1155.vy
jtriley-eth Dec 24, 2022
ba47a3b
Apply suggestions from code review
jtriley-eth Dec 24, 2022
656c63e
add tests, mocks, minor edits to dynarray sizes
jtriley-eth Dec 24, 2022
391326c
add proper indent to natspec
jtriley-eth Dec 24, 2022
092abd4
update contract based on code review
jtriley-eth Dec 26, 2022
098d5b9
rm tests to decouple pr
jtriley-eth Dec 27, 2022
0c1b641
break out auth checks to external transfers and mints
jtriley-eth Dec 27, 2022
da61332
rm outdated todo
jtriley-eth Dec 27, 2022
d6fd1fc
πŸ”‚ Merge pull request #34 from jtriley-eth/erc1155
pcaversaccio Dec 28, 2022
1a7cddf
♻️ bump submodules
pcaversaccio Dec 28, 2022
1a8951b
πŸ“ docs: add note on return value bounds in interfaces
pcaversaccio Dec 28, 2022
ac9fc00
♻️formatting
pcaversaccio Dec 28, 2022
3f6d3db
πŸ”¨ add RoleMinterChanged event in erc20 & erc721 as well as improve docs
pcaversaccio Dec 28, 2022
89e21e2
πŸ”¨ first round of chore & refactor erc1155
pcaversaccio Dec 28, 2022
3e20a3e
πŸͺ› fixing missing hooks & event issuance in erc20 constructor
pcaversaccio Dec 28, 2022
c89dd59
♻️formatting
pcaversaccio Dec 28, 2022
92cccd8
πŸ”¨ second round of chore & refactor erc1155
pcaversaccio Dec 29, 2022
69ca5c0
πŸ”¨ core erc1155 logic should be ready
pcaversaccio Dec 29, 2022
a5f2ce1
πŸ”¨ we're getting there soon
pcaversaccio Dec 29, 2022
29c0dca
πŸ”₯ burnable functions
pcaversaccio Dec 29, 2022
2246b43
⚑️ minting
pcaversaccio Dec 29, 2022
71e6b19
Merge branch 'main' into erc1155
pcaversaccio Dec 30, 2022
738aeb1
♻️ bump submodules
pcaversaccio Dec 30, 2022
6d7aa78
Merge branch 'main' into erc1155
pcaversaccio Dec 30, 2022
bc98e9b
βš’ refactor \ o\ to \owner\ wording in internal mint functions of ERC721
pcaversaccio Dec 30, 2022
2592d6d
πŸ“ comments are important
pcaversaccio Dec 30, 2022
205accd
πŸ“ comments & safe consistency
pcaversaccio Dec 30, 2022
038eea8
Merge branch 'main' into erc1155
pcaversaccio Jan 1, 2023
632aced
Merge branch 'main' into erc1155
pcaversaccio Jan 2, 2023
fedd65f
♻️ cache base uri length
pcaversaccio Jan 2, 2023
a6a2031
Merge branch 'main' into erc1155
pcaversaccio Jan 3, 2023
f17430f
Merge branch 'main' into erc1155
pcaversaccio Jan 5, 2023
a0e7bee
♻️ change readme sequence
pcaversaccio Jan 5, 2023
f3e1743
Merge branch 'main' into erc1155
pcaversaccio Jan 8, 2023
c4befea
Merge branch 'main' into erc1155
pcaversaccio Jan 9, 2023
080754f
add tests, mocks
jtriley-eth Jan 10, 2023
1d03715
♻️ prettier and fix typo
pcaversaccio Jan 12, 2023
28099a0
♻️ change logic sequence in test interfaces
pcaversaccio Jan 12, 2023
3075e62
πŸ›  refactor receiver mock & ix broken link
pcaversaccio Jan 12, 2023
a980213
♻️ remove unused imports & refactor first part of test suite
pcaversaccio Jan 12, 2023
e9ec14a
♻️ add IERC165 to IERC1155Receiver interface and change visibility t…
pcaversaccio Jan 12, 2023
2ca5d34
♻️ add missing IERC165 functions to interfaces
pcaversaccio Jan 12, 2023
305b8ce
♻️ enhance balanceOf and balanceOfBatch tests
pcaversaccio Jan 12, 2023
d35f4bd
♻️ enhance setApprovalForAll tests
pcaversaccio Jan 12, 2023
ff33c77
πŸ›  small refactor
pcaversaccio Jan 12, 2023
03087ad
♻️ enhance safeTransferFrom tests
pcaversaccio Jan 12, 2023
5b6d41d
♻️ enhance ownership function tests
pcaversaccio Jan 13, 2023
7d0100f
πŸ”¨ refactor transfer_ownership and renounce_ownership functions
pcaversaccio Jan 13, 2023
66fc991
♻️ enhance safBatchTransferFrom tests
pcaversaccio Jan 13, 2023
e764ac6
♻️ enhance uri and set_uri functions
pcaversaccio Jan 13, 2023
34f5535
♻️ add total_supply and exists tests
pcaversaccio Jan 13, 2023
c181885
♻️ enhance burn tests
pcaversaccio Jan 13, 2023
f94a872
♻️ enhance set_minter tests
pcaversaccio Jan 13, 2023
f6b7820
♻️ enhance safe_mint and safe_mint_batch tests
pcaversaccio Jan 13, 2023
ecc0844
♻️ add gas snapshot
pcaversaccio Jan 13, 2023
f031a87
♻️ format constructor args
pcaversaccio Jan 15, 2023
19f2e88
πŸ”¨ refactor ERC1155 tests
pcaversaccio Jan 15, 2023
35381ff
♻️ gas snapshot
pcaversaccio Jan 15, 2023
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
Prev Previous commit
Next Next commit
πŸ”₯ burnable functions
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
  • Loading branch information
pcaversaccio committed Dec 29, 2022
commit 29c0dcac49a2f84a150567c4086146e427eeb72f
40 changes: 36 additions & 4 deletions src/tokens/ERC1155.vy
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,14 @@ def exists(id: uint256) -> bool:
@external
def burn(owner: address, id: uint256, amount: uint256):
"""
TBD
@dev Destroys `amount` tokens of token type `id`
from `owner`.
@notice Note that `owner` cannot be the zero
address. Also, `owner` must have at least
`amount` tokens of token type `id`.
@param owner The 20-byte owner address.
@param id The 32-byte identifier of the token.
@param amount The 32-byte token amount to be destroyed.
"""
assert owner == msg.sender or self.isApprovedForAll[owner][msg.sender], "ERC1155: caller is not token owner or approved"
self._burn(owner, id, amount)
Expand All @@ -371,7 +378,16 @@ def burn(owner: address, id: uint256, amount: uint256):
@external
def burn_batch(owner: address, ids: DynArray[uint256, _BATCH_SIZE], amounts: DynArray[uint256, _BATCH_SIZE]):
"""
TBD
@dev Batched version of `burn`.
@notice Note that `ids` and `amounts` must have the
same length.
@param owner The 20-byte owner address.
@param ids The 32-byte array of token identifiers. Note
that the order and length must match the 32-byte
`amounts` array.
@param amounts The 32-byte array of token amounts that are
being destroyed. Note that the order and length must
match the 32-byte `ids` array.
"""
assert owner == msg.sender or self.isApprovedForAll[owner][msg.sender], "ERC1155: caller is not token owner or approved"
self._burn_batch(owner, ids, amounts)
Expand Down Expand Up @@ -631,7 +647,14 @@ def _set_uri(id: uint256, token_uri: String[432]):
@internal
def _burn(owner: address, id: uint256, amount: uint256):
"""
TBD
@dev Destroys `amount` tokens of token type `id`
from `owner`.
@notice Note that `owner` cannot be the zero
address. Also, `owner` must have at least
`amount` tokens of token type `id`.
@param owner The 20-byte owner address.
@param id The 32-byte identifier of the token.
@param amount The 32-byte token amount to be destroyed.
"""
assert owner != empty(address), "ERC1155: burn from the zero address"

Expand All @@ -648,7 +671,16 @@ def _burn(owner: address, id: uint256, amount: uint256):
@internal
def _burn_batch(owner: address, ids: DynArray[uint256, _BATCH_SIZE], amounts: DynArray[uint256, _BATCH_SIZE]):
"""
TBD
@dev Batched version of `burn`.
@notice Note that `ids` and `amounts` must have the
same length.
@param owner The 20-byte owner address.
@param ids The 32-byte array of token identifiers. Note
that the order and length must match the 32-byte
`amounts` array.
@param amounts The 32-byte array of token amounts that are
being destroyed. Note that the order and length must
match the 32-byte `ids` array.
"""
assert len(ids) == len(amounts), "ERC1155: ids and amounts length mismatch"
assert owner != empty(address), "ERC1155: burn from the zero address"
Expand Down