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(protocol): add access control to BridgedERC20Base.burn (TKO-08 ) #15566

Merged
merged 3 commits into from
Jan 25, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ abstract contract BridgedERC20Base is EssentialContract, IBridgedERC20 {

function burn(address account, uint256 amount) public nonReentrant whenNotPaused {
if (migratingAddress != address(0) && !migratingInbound) {
if (msg.sender != account) revert BB_PERMISSION_DENIED();
// Outbond migration
emit MigratedTo(migratingAddress, account, amount);
// Ask the new bridged token to mint token for the user.
Expand Down
16 changes: 15 additions & 1 deletion packages/protocol/test/tokenvault/BridgedERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,22 @@ contract TestBridgedERC20 is TaikoTest {
vm.expectRevert();
oldToken.mint(Bob, 10);

// 2. burning can be done by anyone
// 2. burning can NOT be done by anyone
vm.prank(randAddress());
vm.expectRevert();
oldToken.burn(Bob, 10);

// including the owners
vm.prank(oldToken.owner());
vm.expectRevert();
oldToken.burn(Bob, 10);

vm.prank(newToken.owner());
vm.expectRevert();
oldToken.burn(Bob, 10);

// but can be done by the token owner
vm.prank(Bob);
oldToken.burn(Bob, 10);
assertEq(oldToken.balanceOf(Bob), 90);
assertEq(newToken.balanceOf(Bob), 210);
Expand Down
Loading