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

fix(ERC6909): fail when from is msg.sender with no approval on transferFrom #411

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions src/test/ERC6909.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ contract ERC6909Test is DSTestPlus {
token.transferFrom(sender, receiver, 1337, 100);
}

function testFailTransferFromNotAuthorizedMsgSender() public {
address sender = address(0xABCD);
address receiver = address(0xBEEF);

token.mint(sender, 1337, 100);

hevm.prank(sender);
token.transferFrom(sender, receiver, 1337, 100);
}

function testMint(
address receiver,
uint256 id,
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/ERC6909.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ abstract contract ERC6909 {
uint256 id,
uint256 amount
) public virtual returns (bool) {
if (msg.sender != sender && !isOperator[sender][msg.sender]) {
if (!isOperator[sender][msg.sender]) {
uint256 allowed = allowance[sender][msg.sender][id];
if (allowed != type(uint256).max) allowance[sender][msg.sender][id] = allowed - amount;
}
Expand Down