Skip to content

Commit

Permalink
Add admin permission to add custom base tokens (#776)
Browse files Browse the repository at this point in the history
Co-authored-by: Stanislav Breadless <[email protected]>
  • Loading branch information
vladbochok and StanislavBreadless authored Sep 6, 2024
1 parent d368769 commit 6892ccc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion l1-contracts/contracts/bridgehub/Bridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus
}

/// @notice token can be any contract with the appropriate interface/functionality
function addToken(address _token) external onlyOwner {
function addToken(address _token) external onlyOwnerOrAdmin {
require(!tokenIsRegistered[_token], "Bridgehub: token already registered");
tokenIsRegistered[_token] = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ contract ExperimentalBridgeTest is Test {
}

function test_addToken_cannotBeCalledByRandomAddress(address randomAddress, address randomCaller) public {
if (randomCaller != bridgeOwner) {
vm.prank(randomCaller);
vm.expectRevert(bytes("Ownable: caller is not the owner"));
bridgeHub.addToken(randomAddress);
}
vm.assume(randomAddress != bridgeOwner);
vm.assume(randomAddress != bridgeHub.admin());

vm.prank(randomCaller);
vm.expectRevert(bytes("Bridgehub: not owner or admin"));
bridgeHub.addToken(randomAddress);

assertTrue(!bridgeHub.tokenIsRegistered(randomAddress), "This random address is not registered as a token");

Expand Down

0 comments on commit 6892ccc

Please sign in to comment.