Repository navigation
Conversation
cburgdorf
force-pushed
the
std-erc20
branch
3 times, most recently
from
October 4, 2026 22:00
a9dc20c to
4b9633c
Compare
Port Solady's ERC20 as a storage component instead of a base contract. A contract keeps an Erc20 in a field and answers the standard messages IErc20 and IErc20Permit by delegating to it; customization happens in the contract's own handlers around the component's methods, so there are no virtual hooks. The effects on each method show what it touches, and mint and burn perform no access control so the contract decides who reaches them. Semantics follow Solady: its custom errors, true on success, a u256::max() allowance is never spent, transfers to the zero address are allowed. The storage layout is Fe's own. The permit is split into verify_permit, which checks the deadline and the signature against the current nonce and returns a VerifiedPermit that only std can construct, and permit, which consumes the nonce and sets the allowance and accepts nothing else. The split also sidesteps a borrow checker false positive: a precompile STATICCALL (ecrecover, sha256, modexp) inside a mut self method on a contract field struct with a scalar field is rejected as a conflicting borrow. Malleable signatures are rejected through std's canonical ecrecover. The fixture covers a permit signed with cast.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
THIS IS JUST FOOD FOR THOUGHT!
Port Solady's ERC20 as a storage component instead of a base contract. A contract keeps an Erc20 in a field and answers the standard messages IErc20 and IErc20Permit by delegating to it; customization happens in the contract's own handlers around the component's methods, so there are no virtual hooks. The effects on each method show what it touches, and mint and burn perform no access control so the contract decides who reaches them.
Semantics follow Solady: its custom errors, true on success, a u256::max() allowance is never spent, transfers to the zero address are allowed. The storage layout is Fe's own.
The permit is split into verify_permit, which checks the deadline and the signature against the current nonce and returns a VerifiedPermit that only std can construct, and permit, which consumes the nonce and sets the allowance and accepts nothing else. The split also sidesteps a borrow checker false positive: a precompile STATICCALL (ecrecover, sha256, modexp) inside a mut self method on a contract field struct with a scalar field is rejected as a conflicting borrow. Malleable signatures are rejected through std's canonical ecrecover.
The component's mut self methods write StorageMap fields of a struct with a scalar field, which needs #1659; with #1659 merged the fixture passes, including a permit signed with cast.