Skip to content

Commit

Permalink
♻️ Make ERC1155 Module-Friendly (#238)
Browse files Browse the repository at this point in the history
### 🕓 Changelog

This PR refactors the `ERC1155` contract to make it module-friendly and
ready for the breaking `0.4.0` release. Please note that we remove the
zero address check from the function `balanceOf` in the `ERC1155`. In
addition, we consistently use the contract name for all string revert
reasons in all contracts. Eventually, I downgrade Python to version 3.11
in the CI pipelines due to some noisy deprecation warnings.

---------

Signed-off-by: Pascal Marco Caversaccio <[email protected]>
  • Loading branch information
pcaversaccio authored Apr 22, 2024
1 parent 17ccb43 commit 5cf5ad5
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 342 deletions.
286 changes: 142 additions & 144 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
architecture:
- x64
python_version:
- 3.12
- 3.11

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
architecture:
- x64
python_version:
- 3.12
- 3.11

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
architecture:
- x64
python_version:
- 3.12
- 3.11
node_version:
- 20

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- **Tokens**
- [`ERC20`](https://github.com/pcaversaccio/snekmate/blob/v0.1.0/src/snekmate/tokens/ERC20.vy): Make `ERC20` module-friendly. ([#234](https://github.com/pcaversaccio/snekmate/pull/234))
- [`ERC721`](https://github.com/pcaversaccio/snekmate/blob/v0.1.0/src/snekmate/tokens/ERC721.vy): Make `ERC721` module-friendly. ([#237](https://github.com/pcaversaccio/snekmate/pull/237))
- [`ERC1155`](https://github.com/pcaversaccio/snekmate/blob/v0.1.0/src/snekmate/tokens/ERC1155.vy): Make `ERC1155` module-friendly. ([#238](https://github.com/pcaversaccio/snekmate/pull/238))
- **Utility Functions**
- [`Base64`](https://github.com/pcaversaccio/snekmate/blob/v0.1.0/src/snekmate/utils/Base64.vy): Make `Base64` module-friendly. ([#222](https://github.com/pcaversaccio/snekmate/pull/222))
- [`BatchDistributor`](https://github.com/pcaversaccio/snekmate/blob/v0.1.0/src/snekmate/utils/BatchDistributor.vy): Make `BatchDistributor` module-friendly. ([#223](https://github.com/pcaversaccio/snekmate/pull/223))
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ src
│ │ └── IERC4906 — "EIP-4906 Interface Definition"
│ └── mocks
│ ├── ERC20Mock — "ERC20 Module Reference Implementation"
│ └── ERC721Mock — "ERC721 Module Reference Implementation"
│ ├── ERC721Mock — "ERC721 Module Reference Implementation"
│ └── ERC1155Mock — "ERC1155 Module Reference Implementation"
└── utils
├── Base64 — "Base64 Encoding and Decoding Functions"
├── BatchDistributor — "Batch Sending Both Native and ERC-20 Tokens"
Expand Down
4 changes: 2 additions & 2 deletions src/snekmate/extensions/ERC4626.vy
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def permit(owner: address, spender: address, amount: uint256, deadline: uint256,
@notice See {ERC20-permit} for the function
docstring.
"""
assert block.timestamp <= deadline, "ERC20Permit: expired deadline"
assert block.timestamp <= deadline, "ERC20: expired deadline"

current_nonce: uint256 = self.nonces[owner]
self.nonces[owner] = unsafe_add(current_nonce, 1)
Expand All @@ -328,7 +328,7 @@ def permit(owner: address, spender: address, amount: uint256, deadline: uint256,
hash: bytes32 = self._hash_typed_data_v4(struct_hash)

signer: address = self._recover_vrs(hash, convert(v, uint256), convert(r, uint256), convert(s, uint256))
assert signer == owner, "ERC20Permit: invalid signature"
assert signer == owner, "ERC20: invalid signature"

self._approve(owner, spender, amount)

Expand Down
Loading

0 comments on commit 5cf5ad5

Please sign in to comment.