From 068c5c043b3ea4bd4c0c76f351cd837ca0b679a5 Mon Sep 17 00:00:00 2001 From: vladbochok Date: Fri, 6 Sep 2024 00:12:31 +0200 Subject: [PATCH 1/3] Add admin permission to add custom base tokens --- l1-contracts/contracts/bridgehub/Bridgehub.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/contracts/bridgehub/Bridgehub.sol b/l1-contracts/contracts/bridgehub/Bridgehub.sol index 539af6a0c..7b9ecf43b 100644 --- a/l1-contracts/contracts/bridgehub/Bridgehub.sol +++ b/l1-contracts/contracts/bridgehub/Bridgehub.sol @@ -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; } From acd428b3bea552797a8300d02cb5204d23829299 Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Fri, 6 Sep 2024 12:15:04 +0200 Subject: [PATCH 2/3] fix foundry test --- .../unit/concrete/Bridgehub/experimental_bridge.t.sol | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol index 9ef3ae0fb..c92820209 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol @@ -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"); From 007aff1950b651304cb2626070a7a10e3bf9899d Mon Sep 17 00:00:00 2001 From: Stanislav Breadless Date: Fri, 6 Sep 2024 12:18:01 +0200 Subject: [PATCH 3/3] fix lint --- .../foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol index c92820209..ff747ddac 100644 --- a/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol +++ b/l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol @@ -251,7 +251,7 @@ contract ExperimentalBridgeTest is Test { function test_addToken_cannotBeCalledByRandomAddress(address randomAddress, address randomCaller) public { vm.assume(randomAddress != bridgeOwner); vm.assume(randomAddress != bridgeHub.admin()); - + vm.prank(randomCaller); vm.expectRevert(bytes("Bridgehub: not owner or admin")); bridgeHub.addToken(randomAddress);