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

✨ ERC20Votes #1127

Merged
merged 41 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ auth
tokens
├─ WETH — "Simple Wrapped Ether implementation"
├─ ERC20 — "Simple ERC20 + EIP-2612 implementation"
├─ ERC20Votes — "ERC20 with votes based on ERC5805 and ERC6372"
├─ ERC4626 — "Simple ERC4626 tokenized Vault implementation"
├─ ERC721 — "Simple ERC721 implementation with storage hitchhiking"
├─ ERC2981 — "Simple ERC2981 NFT Royalty Standard implementation"
Expand Down
1 change: 1 addition & 0 deletions src/Milady.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "./auth/OwnableRoles.sol";
import "./auth/EnumerableRoles.sol";
import "./tokens/ERC1155.sol";
import "./tokens/ERC20.sol";
import "./tokens/ERC20Votes.sol";
import "./tokens/ERC2981.sol";
import "./tokens/ERC4626.sol";
import "./tokens/ERC6909.sol";
Expand Down
13 changes: 12 additions & 1 deletion src/tokens/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,17 @@ abstract contract ERC20 {
result = _DEFAULT_VERSION_HASH;
}

/// @dev For inheriting contracts to increment the nonce.
function _incrementNonce(address owner) internal virtual {
/// @solidity memory-safe-assembly
assembly {
mstore(0x0c, _NONCES_SLOT_SEED)
mstore(0x00, owner)
let nonceSlot := keccak256(0x0c, 0x20)
sstore(nonceSlot, add(1, sload(nonceSlot)))
}
}

/// @dev Returns the current nonce for `owner`.
/// This value is used to compute the signature for EIP-2612 permit.
function nonces(address owner) public view virtual returns (uint256 result) {
Expand Down Expand Up @@ -434,7 +445,7 @@ abstract contract ERC20 {
mstore(0x20, and(0xff, v))
mstore(0x40, r)
mstore(0x60, s)
let t := staticcall(gas(), 1, 0, 0x80, 0x20, 0x20)
let t := staticcall(gas(), 1, 0x00, 0x80, 0x20, 0x20)
// If the ecrecover fails, the returndatasize will be 0x00,
// `owner` will be checked if it equals the hash at 0x00,
// which evaluates to false (i.e. 0), and we will revert.
Expand Down
Loading