From ef30f6c883e75b05d533d440f4a5243bc212aa40 Mon Sep 17 00:00:00 2001 From: Benjamin Patch Date: Thu, 2 Nov 2023 09:21:48 +1100 Subject: [PATCH] Remove other adaptor stored in adaptor --- script/DeployChildContracts.s.sol | 1 - src/child/ChildAxelarBridgeAdaptor.sol | 13 ------------- src/root/RootAxelarBridgeAdaptor.sol | 19 ++++++------------- test/unit/root/RootAxelarBridgeAdaptor.t.sol | 2 -- 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/script/DeployChildContracts.s.sol b/script/DeployChildContracts.s.sol index a8d1f7c0a..530eadb4e 100644 --- a/script/DeployChildContracts.s.sol +++ b/script/DeployChildContracts.s.sol @@ -17,7 +17,6 @@ contract DeployChildContracts is Script { function run() public { uint256 deployerPrivateKey = vm.envUint("CHILD_PRIVATE_KEY"); address childGateway = vm.envAddress("CHILD_GATEWAY_ADDRESS"); - address childGasService = vm.envAddress("CHILD_GAS_SERVICE_ADDRESS"); // Not yet used. string memory childRpcUrl = vm.envString("CHILD_RPC_URL"); vm.createSelectFork(childRpcUrl); diff --git a/src/child/ChildAxelarBridgeAdaptor.sol b/src/child/ChildAxelarBridgeAdaptor.sol index 4408bb77d..daa50d741 100644 --- a/src/child/ChildAxelarBridgeAdaptor.sol +++ b/src/child/ChildAxelarBridgeAdaptor.sol @@ -9,14 +9,12 @@ import {IChildAxelarBridgeAdaptorErrors} from "../interfaces/child/IChildAxelarB contract ChildAxelarBridgeAdaptor is AxelarExecutable, Initializable, IChildAxelarBridgeAdaptorErrors { /// @notice Address of bridge to relay messages to. IChildERC20Bridge public childBridge; - string public rootBridgeAdaptor; constructor(address _gateway) AxelarExecutable(_gateway) {} /** * @notice Initializes the contract. * @param _childBridge Address of the child bridge contract. - * @dev Always sets the rootBridgeAdaptor to whatever the rootERC20BridgeAdaptor of the bridge contract is. */ function initialize(address _childBridge) external initializer { if (_childBridge == address(0)) { @@ -24,17 +22,6 @@ contract ChildAxelarBridgeAdaptor is AxelarExecutable, Initializable, IChildAxel } childBridge = IChildERC20Bridge(_childBridge); - rootBridgeAdaptor = childBridge.rootERC20BridgeAdaptor(); - } - - // TODO tests for this - // TODO does this need to be permissioned? - /** - * @notice Sets the root bridge adaptor address. - * @dev Always sets it to whatever the rootERC20BridgeAdaptor of the bridge contract is. - */ - function setRootBridgeAdaptor() external { - rootBridgeAdaptor = childBridge.rootERC20BridgeAdaptor(); } /** diff --git a/src/root/RootAxelarBridgeAdaptor.sol b/src/root/RootAxelarBridgeAdaptor.sol index 0f8816438..e13e461ac 100644 --- a/src/root/RootAxelarBridgeAdaptor.sol +++ b/src/root/RootAxelarBridgeAdaptor.sol @@ -18,7 +18,6 @@ import {IRootERC20Bridge} from "../interfaces/root/IRootERC20Bridge.sol"; /** * @notice RootAxelarBridgeAdaptor is a bridge adaptor that allows the RootERC20Bridge to communicate with the Axelar Gateway. - * @dev This is not an upgradeable contract, because it is trivial to deploy a new one if needed. */ contract RootAxelarBridgeAdaptor is Initializable, @@ -29,7 +28,6 @@ contract RootAxelarBridgeAdaptor is using SafeERC20 for IERC20Metadata; address public rootBridge; - string public childBridgeAdaptor; /// @dev childChain could be immutable, but as of writing this Solidity does not support immutable strings. /// see: https://ethereum.stackexchange.com/questions/127622/typeerror-immutable-variables-cannot-have-a-non-value-type string public childChain; @@ -38,7 +36,11 @@ contract RootAxelarBridgeAdaptor is mapping(uint256 => string) public chainIdToChainName; /** - * @dev Always sets it to whatever the childBridgeAdaptor of the bridge contract is. + * @notice Initilization function for RootAxelarBridgeAdaptor. + * @param _rootBridge Address of root bridge contract. + * @param _childChain Name of child chain. + * @param _axelarGateway Address of Axelar Gateway contract. + * @param _gasService Address of Axelar Gas Service contract. */ function initialize(address _rootBridge, string memory _childChain, address _axelarGateway, address _gasService) public @@ -55,15 +57,6 @@ contract RootAxelarBridgeAdaptor is childChain = _childChain; axelarGateway = IAxelarGateway(_axelarGateway); gasService = IAxelarGasService(_gasService); - childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor(); - } - - /** - * @notice Sets the child bridge adaptor address. - * @dev Always sets it to whatever the childBridgeAdaptor of the bridge contract is. - */ - function setChildBridgeAdaptor() external { - childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor(); } /** @@ -79,7 +72,7 @@ contract RootAxelarBridgeAdaptor is } // Load from storage. - string memory _childBridgeAdaptor = childBridgeAdaptor; + string memory _childBridgeAdaptor = IRootERC20Bridge(rootBridge).childBridgeAdaptor(); string memory _childChain = childChain; // TODO For `sender` (first param), should likely be refundRecipient (and in which case refundRecipient should be renamed to sender and used as refund recipient) diff --git a/test/unit/root/RootAxelarBridgeAdaptor.t.sol b/test/unit/root/RootAxelarBridgeAdaptor.t.sol index c93c70d0c..bc0cda17f 100644 --- a/test/unit/root/RootAxelarBridgeAdaptor.t.sol +++ b/test/unit/root/RootAxelarBridgeAdaptor.t.sol @@ -37,13 +37,11 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR axelarAdaptor.initialize( address(stubRootBridge), CHILD_CHAIN_NAME, address(mockAxelarGateway), address(axelarGasService) ); - axelarAdaptor.setChildBridgeAdaptor(); vm.deal(address(stubRootBridge), 99999999999); } function test_Constructor() public { assertEq(axelarAdaptor.rootBridge(), address(stubRootBridge), "rootBridge not set"); - assertEq(axelarAdaptor.childBridgeAdaptor(), childBridgeAdaptor, "childBridgeAdaptor not set"); assertEq(axelarAdaptor.childChain(), CHILD_CHAIN_NAME, "childChain not set"); assertEq(address(axelarAdaptor.axelarGateway()), address(mockAxelarGateway), "axelarGateway not set"); assertEq(address(axelarAdaptor.gasService()), address(axelarGasService), "axelarGasService not set");