Skip to content

Some changes to the compiler / ERC20 without inheritance using ERC7201 - #575

Open
rodrigogribeiro wants to merge 5 commits into
mainfrom
erc20-no-inheritance
Open

Some changes to the compiler / ERC20 without inheritance using ERC7201#575
rodrigogribeiro wants to merge 5 commits into
mainfrom
erc20-no-inheritance

Conversation

@rodrigogribeiro

Copy link
Copy Markdown
Collaborator

No description provided.

@rodrigogribeiro
rodrigogribeiro marked this pull request as ready for review September 8, 2026 16:35

@czepluch czepluch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be named "vault" instead of "valt"? The directory for the vaulttoken

Comment thread test/examples/erc20/mytoken.sol Outdated
Comment on lines +14 to +34
function caller() returns (address) {
let r : word;
assembly { r := caller() }
return address(r);
}
function selfAddress() returns (address) {
let a : word;
assembly { a := address() }
return address(a);
}
function chainId() returns (uint256) {
let c : word;
assembly { c := chainid() }
return uint256(c);
}
function nowTime() returns (uint256) {
let t : word;
assembly { t := timestamp() }
return uint256(t);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use std.opcodes and get rid of assembly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

require(bf >= value, Error(0xe450d38c)); // ERC20InsufficientBalance
HasLedger.setBalance(s, from, Num.sub(bf, value));
}
if (to == address(0)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transfer(to = address(0)) reaches this burn branch: nothing on the public transfer/transferFrom path rejects a zero recipient, so a typo'd recipient burns the tokens and reduces supply. OZ reverts here with ERC20InvalidReceiver. Guard the entry points, or make burn explicit in the seam (Option<address>) so it cannot happen by accident. Same issue in valt/erc20base.sol:47.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

import {sload, sstore, log3, mstore} from std.opcodes;
import * from store;

export { HasLedger, HasSupply, HasAllowance, coreUpdate, spendAllowance, approveVal };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These exported setters plus a freely constructible AppStore let any code bypass tokenUpdate (pause check, votes, Transfer event). Consider exporting a single mutator that takes the hook evidence as a parameter. same enforcement OZ gets from private _balances.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants