Skip to content

Commit

Permalink
fix(protocol): add access control to BridgedERC20Base.burn (TKO-08 ) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Jan 25, 2024
1 parent 5902e38 commit 9004b04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit 9004b04

Please sign in to comment.