diff --git a/src/child/ChildAxelarBridgeAdaptor.sol b/src/child/ChildAxelarBridgeAdaptor.sol index 9fa9dd13..00f7515b 100644 --- a/src/child/ChildAxelarBridgeAdaptor.sol +++ b/src/child/ChildAxelarBridgeAdaptor.sol @@ -52,8 +52,8 @@ contract ChildAxelarBridgeAdaptor is /// @notice Address of the authorized initializer. address public immutable initializerAddress; - constructor(address _gateway) AxelarExecutable(_gateway) { - initializerAddress = msg.sender; + constructor(address _gateway, address _initializerAddress) AxelarExecutable(_gateway) { + initializerAddress = _initializerAddress; } /** diff --git a/src/child/ChildERC20Bridge.sol b/src/child/ChildERC20Bridge.sol index b5948576..5cb96ce5 100644 --- a/src/child/ChildERC20Bridge.sol +++ b/src/child/ChildERC20Bridge.sol @@ -83,8 +83,8 @@ contract ChildERC20Bridge is _; } - constructor() { - initializerAddress = msg.sender; + constructor(address _initializerAddress) { + initializerAddress = _initializerAddress; } /** diff --git a/src/root/RootAxelarBridgeAdaptor.sol b/src/root/RootAxelarBridgeAdaptor.sol index 99b56bdb..d01633b0 100644 --- a/src/root/RootAxelarBridgeAdaptor.sol +++ b/src/root/RootAxelarBridgeAdaptor.sol @@ -53,8 +53,8 @@ contract RootAxelarBridgeAdaptor is /// @notice Address of the authorized initializer. address public immutable initializerAddress; - constructor(address _gateway) AxelarExecutable(_gateway) { - initializerAddress = msg.sender; + constructor(address _gateway, address _initializerAddress) AxelarExecutable(_gateway) { + initializerAddress = _initializerAddress; } /** diff --git a/src/root/RootERC20Bridge.sol b/src/root/RootERC20Bridge.sol index bb723879..e8eb6660 100644 --- a/src/root/RootERC20Bridge.sol +++ b/src/root/RootERC20Bridge.sol @@ -95,8 +95,8 @@ contract RootERC20Bridge is _; } - constructor() { - initializerAddress = msg.sender; + constructor(address _initializerAddress) { + initializerAddress = _initializerAddress; } /** diff --git a/src/root/flowrate/RootERC20BridgeFlowRate.sol b/src/root/flowrate/RootERC20BridgeFlowRate.sol index f439dd29..1f05a872 100644 --- a/src/root/flowrate/RootERC20BridgeFlowRate.sol +++ b/src/root/flowrate/RootERC20BridgeFlowRate.sol @@ -80,7 +80,7 @@ contract RootERC20BridgeFlowRate is // Map ERC 20 token address to threshold mapping(address => uint256) public largeTransferThresholds; - constructor() RootERC20Bridge() {} + constructor(address _initializerAddress) RootERC20Bridge(_initializerAddress) {} function initialize( InitializationRoles memory newRoles, diff --git a/test/integration/child/ChildAxelarBridge.t.sol b/test/integration/child/ChildAxelarBridge.t.sol index c142e21b..2b5e538c 100644 --- a/test/integration/child/ChildAxelarBridge.t.sol +++ b/test/integration/child/ChildAxelarBridge.t.sol @@ -39,10 +39,10 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil childERC20 = new ChildERC20(); childERC20.initialize(address(123), "Test", "TST", 18); - childERC20Bridge = new ChildERC20Bridge(); + childERC20Bridge = new ChildERC20Bridge(address(this)); mockChildAxelarGateway = new MockChildAxelarGateway(); mockChildAxelarGasService = new MockChildAxelarGasService(); - childAxelarBridgeAdaptor = new ChildAxelarBridgeAdaptor(address(mockChildAxelarGateway)); + childAxelarBridgeAdaptor = new ChildAxelarBridgeAdaptor(address(mockChildAxelarGateway), address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), diff --git a/test/unit/child/ChildAxelarBridgeAdaptor.t.sol b/test/unit/child/ChildAxelarBridgeAdaptor.t.sol index c358ebff..7934e048 100644 --- a/test/unit/child/ChildAxelarBridgeAdaptor.t.sol +++ b/test/unit/child/ChildAxelarBridgeAdaptor.t.sol @@ -43,7 +43,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro mockChildERC20Bridge = new MockChildERC20Bridge(); mockChildAxelarGateway = new MockChildAxelarGateway(); mockChildAxelarGasService = new MockChildAxelarGasService(); - axelarAdaptor = new ChildAxelarBridgeAdaptor(address(mockChildAxelarGateway)); + axelarAdaptor = new ChildAxelarBridgeAdaptor(address(mockChildAxelarGateway), address(this)); axelarAdaptor.initialize( roles, address(mockChildERC20Bridge), @@ -77,7 +77,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeWithUnauthorizedInitializer() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.prank(address(0x1234)); vm.expectRevert(UnauthorizedInitializer.selector); newAdaptor.initialize( @@ -90,7 +90,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeWithZeroAdmin() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(ZeroAddress.selector); roles.defaultAdmin = address(0); newAdaptor.initialize( @@ -103,7 +103,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeWithZeroBridgeManager() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(ZeroAddress.selector); roles.bridgeManager = address(0); newAdaptor.initialize( @@ -116,7 +116,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeWithZeroGasServiceManager() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(ZeroAddress.selector); roles.gasServiceManager = address(0); newAdaptor.initialize( @@ -129,7 +129,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeWithZeroTargetManager() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(ZeroAddress.selector); roles.targetManager = address(0); newAdaptor.initialize( @@ -142,7 +142,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeGivenZeroAddress() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(ZeroAddress.selector); newAdaptor.initialize( roles, address(0), ROOT_CHAIN_NAME, ROOT_BRIDGE_ADAPTOR, address(mockChildAxelarGasService) @@ -150,7 +150,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeGivenEmptyRootChain() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(InvalidRootChain.selector); newAdaptor.initialize( roles, address(mockChildERC20Bridge), "", ROOT_BRIDGE_ADAPTOR, address(mockChildAxelarGasService) @@ -158,7 +158,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeGivenAnEmptyBridgeAdaptorString() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(InvalidRootBridgeAdaptor.selector); newAdaptor.initialize( roles, address(mockChildERC20Bridge), ROOT_CHAIN_NAME, "", address(mockChildAxelarGasService) @@ -166,7 +166,7 @@ contract ChildAxelarBridgeAdaptorUnitTest is Test, IChildAxelarBridgeAdaptorErro } function test_RevertIf_InitializeGivenZeroGasService() public { - ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS); + ChildAxelarBridgeAdaptor newAdaptor = new ChildAxelarBridgeAdaptor(GATEWAY_ADDRESS, address(this)); vm.expectRevert(ZeroAddress.selector); newAdaptor.initialize(roles, address(mockChildERC20Bridge), ROOT_CHAIN_NAME, ROOT_BRIDGE_ADAPTOR, address(0)); } diff --git a/test/unit/child/ChildERC20Bridge.t.sol b/test/unit/child/ChildERC20Bridge.t.sol index aa7cffbb..b0a5bd2a 100644 --- a/test/unit/child/ChildERC20Bridge.t.sol +++ b/test/unit/child/ChildERC20Bridge.t.sol @@ -59,7 +59,7 @@ contract ChildERC20BridgeUnitTest is Test, IChildERC20BridgeEvents, IChildERC20B childTokenTemplate = new ChildERC20(); childTokenTemplate.initialize(address(123), "Test", "TST", 18); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); childBridge.initialize(roles, address(this), address(childTokenTemplate), ROOT_IMX_TOKEN, CHILD_WIMX_TOKEN); } @@ -165,7 +165,7 @@ contract ChildERC20BridgeUnitTest is Test, IChildERC20BridgeEvents, IChildERC20B } function test_RevertIf_InitializeWithUnauthorizedInitializer() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); vm.prank(address(0x1234)); vm.expectRevert(UnauthorizedInitializer.selector); bridge.initialize(roles, address(1), address(1), address(1), address(1)); @@ -177,54 +177,54 @@ contract ChildERC20BridgeUnitTest is Test, IChildERC20BridgeEvents, IChildERC20B } function test_RevertIf_InitializeWithAZeroAddressDefaultAdmin() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); roles.defaultAdmin = address(0); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(1), address(1), address(1)); } function test_RevertIf_InitializeWithAZeroAddressPauser() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); roles.pauser = address(0); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(1), address(1), address(1)); } function test_RevertIf_InitializeWithAZeroAddressUnpauser() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); roles.unpauser = address(0); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(1), address(1), address(1)); } function test_RevertIf_InitializeWithAZeroAddressAdapter() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); roles.adaptorManager = address(0); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(0), address(1), address(1), address(1)); } function test_RevertIf_InitializeWithAZeroAddressTreasuryManager() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); roles.treasuryManager = address(0); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(1), address(1), address(1)); } function test_RevertIf_InitializeWithAZeroAddressChildTemplate() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(0), address(1), address(1)); } function test_RevertIf_InitializeWithAZeroAddressIMXToken() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(1), address(0), address(1)); } function test_RevertIf_InitializeWithAZeroAddressAll() public { - ChildERC20Bridge bridge = new ChildERC20Bridge(); + ChildERC20Bridge bridge = new ChildERC20Bridge(address(this)); vm.expectRevert(ZeroAddress.selector); roles.defaultAdmin = address(0); roles.pauser = address(0); diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol index 2af7e3fa..dd3dea5e 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol @@ -42,7 +42,7 @@ contract ChildERC20BridgeWithdrawUnitTest is Test, IChildERC20BridgeEvents, IChi initialDepositor: address(this), treasuryManager: address(this) }); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); childBridge.initialize( roles, address(mockAdaptor), address(childTokenTemplate), ROOT_IMX_TOKEN, WIMX_TOKEN_ADDRESS ); diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol index 92680ec5..223d70dc 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETH.t.sol @@ -28,7 +28,7 @@ contract ChildERC20BridgeWithdrawETHUnitTest is Test, IChildERC20BridgeEvents, I mockAdaptor = new MockAdaptor(); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: pauser, diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol index 7c474695..79260e46 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawETHTo.t.sol @@ -37,7 +37,7 @@ contract ChildERC20BridgeWithdrawETHToUnitTest is Test, IChildERC20BridgeEvents, mockAdaptor = new MockAdaptor(); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: pauser, diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol index 914665a9..c48c08d8 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMX.t.sol @@ -27,7 +27,7 @@ contract ChildERC20BridgeWithdrawIMXUnitTest is Test, IChildERC20BridgeEvents, I mockAdaptor = new MockAdaptor(); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: pauser, diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol index 218a35b7..b2fa6b72 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawIMXTo.t.sol @@ -31,7 +31,7 @@ contract ChildERC20BridgeWithdrawIMXToUnitTest is Test, IChildERC20BridgeEvents, mockAdaptor = new MockAdaptor(); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: pauser, diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol index cecc7bb0..88cc2b63 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawTo.t.sol @@ -42,7 +42,7 @@ contract ChildERC20BridgeWithdrawToUnitTest is Test, IChildERC20BridgeEvents, IC initialDepositor: address(this), treasuryManager: address(this) }); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); childBridge.initialize( roles, address(mockAdaptor), address(childTokenTemplate), ROOT_IMX_TOKEN, WIMX_TOKEN_ADDRESS ); diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol index a14fb6a1..a9a40c8e 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMX.t.sol @@ -31,7 +31,7 @@ contract ChildERC20BridgeWithdrawWIMXUnitTest is Test, IChildERC20BridgeEvents, wIMXToken = new WIMX(); Address.sendValue(payable(wIMXToken), 100 ether); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: pauser, diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol index 0ffe48c7..94d2a3db 100644 --- a/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdrawWIMXTo.t.sol @@ -33,7 +33,7 @@ contract ChildERC20BridgeWithdrawWIMXToUnitTest is Test, IChildERC20BridgeEvents wIMXToken = new WIMX(); Address.sendValue(payable(wIMXToken), 100 ether); - childBridge = new ChildERC20Bridge(); + childBridge = new ChildERC20Bridge(address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: pauser, diff --git a/test/unit/root/RootAxelarBridgeAdaptor.t.sol b/test/unit/root/RootAxelarBridgeAdaptor.t.sol index 87923bc5..302fb75d 100644 --- a/test/unit/root/RootAxelarBridgeAdaptor.t.sol +++ b/test/unit/root/RootAxelarBridgeAdaptor.t.sol @@ -44,7 +44,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR token = new ERC20PresetMinterPauser("Test", "TST"); mockAxelarGateway = new MockAxelarGateway(); axelarGasService = new MockAxelarGasService(); - axelarAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + axelarAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); stubRootBridge = new StubRootBridge(); axelarAdaptor.initialize( roles, address(stubRootBridge), CHILD_CHAIN_NAME, CHILD_BRIDGE_ADAPTOR_STRING, address(axelarGasService) @@ -77,7 +77,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeWithUnauthorizedInitializer() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.prank(address(0x1234)); vm.expectRevert(UnauthorizedInitializer.selector); newAdaptor.initialize( @@ -86,7 +86,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeWithZeroAdmin() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(ZeroAddresses.selector); roles.defaultAdmin = address(0); newAdaptor.initialize( @@ -95,7 +95,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeWithZeroBridgeManager() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(ZeroAddresses.selector); roles.bridgeManager = address(0); newAdaptor.initialize( @@ -104,7 +104,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeWithZeroGasServiceManager() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(ZeroAddresses.selector); roles.gasServiceManager = address(0); newAdaptor.initialize( @@ -113,7 +113,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeWithZeroTargetManager() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(ZeroAddresses.selector); roles.targetManager = address(0); newAdaptor.initialize( @@ -122,7 +122,7 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeGivenZeroAddress() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(ZeroAddresses.selector); newAdaptor.initialize( roles, address(0), CHILD_CHAIN_NAME, CHILD_BRIDGE_ADAPTOR_STRING, address(axelarGasService) @@ -130,13 +130,13 @@ contract RootAxelarBridgeAdaptorTest is Test, IRootAxelarBridgeAdaptorEvents, IR } function test_RevertIf_InitializeGivenEmptyChildChainName() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(InvalidChildChain.selector); newAdaptor.initialize(roles, address(this), "", CHILD_BRIDGE_ADAPTOR_STRING, address(axelarGasService)); } function test_RevertIf_InitializeGivenEmptyChildAdapter() public { - RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway)); + RootAxelarBridgeAdaptor newAdaptor = new RootAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); vm.expectRevert(InvalidChildBridgeAdaptor.selector); newAdaptor.initialize(roles, address(this), CHILD_CHAIN_NAME, "", address(axelarGasService)); } diff --git a/test/unit/root/RootERC20Bridge.t.sol b/test/unit/root/RootERC20Bridge.t.sol index 9d59f961..999bc330 100644 --- a/test/unit/root/RootERC20Bridge.t.sol +++ b/test/unit/root/RootERC20Bridge.t.sol @@ -55,7 +55,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid deployCodeTo("WETH.sol", abi.encode("Wrapped ETH", "WETH"), WRAPPED_ETH); - rootBridge = new RootERC20Bridge(); + rootBridge = new RootERC20Bridge(address(this)); mockAxelarGateway = new MockAxelarGateway(); axelarGasService = new MockAxelarGasService(); @@ -134,7 +134,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithUnauthorizedInitializer() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -170,7 +170,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressDefaultAdmin() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(0), pauser: address(this), @@ -184,7 +184,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressPauser() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(0), @@ -198,7 +198,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressUnpauser() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -211,7 +211,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressVariableManager() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -224,7 +224,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressAdaptorManager() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -237,7 +237,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressRootAdapter() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -250,7 +250,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressChildBridge() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -263,7 +263,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressTokenTemplate() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -276,7 +276,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid } function test_RevertIf_InitializeWithAZeroAddressIMXToken() public { - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -296,7 +296,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid variableManager: address(this), adaptorManager: address(this) }); - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(1), address(1), address(1), address(1), address(0), UNLIMITED_IMX_DEPOSITS); } @@ -309,7 +309,7 @@ contract RootERC20BridgeUnitTest is Test, IRootERC20BridgeEvents, IRootERC20Brid variableManager: address(0), adaptorManager: address(0) }); - RootERC20Bridge bridge = new RootERC20Bridge(); + RootERC20Bridge bridge = new RootERC20Bridge(address(this)); vm.expectRevert(ZeroAddress.selector); bridge.initialize(roles, address(0), address(0), address(0), address(0), address(0), UNLIMITED_IMX_DEPOSITS); } diff --git a/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol b/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol index 9f76f984..1f435afb 100644 --- a/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol +++ b/test/unit/root/flowrate/RootERC20BridgeFlowRate.t.sol @@ -136,7 +136,7 @@ contract RootERC20BridgeFlowRateUnitTest is bob = makeAddr("bob"); charlie = makeAddr("charlie"); - rootBridgeFlowRate = new RootERC20BridgeFlowRate(); + rootBridgeFlowRate = new RootERC20BridgeFlowRate(address(this)); mockAxelarGateway = new MockAxelarGateway(); axelarGasService = new MockAxelarGasService(); @@ -257,7 +257,7 @@ contract RootERC20BridgeFlowRateUnitTest is } function test_RevertIf_InitializeWithAZeroAddressRateAdmin() public { - RootERC20BridgeFlowRate newRootBridgeFlowRate = new RootERC20BridgeFlowRate(); + RootERC20BridgeFlowRate newRootBridgeFlowRate = new RootERC20BridgeFlowRate(address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), diff --git a/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol b/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol index 274b7871..7a8ae5b8 100644 --- a/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol +++ b/test/unit/root/withdrawals/RootERC20BridgeWithdraw.t.sol @@ -45,7 +45,7 @@ contract RootERC20BridgeWithdrawUnitTest is Test, IRootERC20BridgeEvents, IRootE deployCodeTo("WETH.sol", abi.encode("Wrapped ETH", "WETH"), WRAPPED_ETH); - rootBridge = new RootERC20Bridge(); + rootBridge = new RootERC20Bridge(address(this)); mockAxelarGateway = new MockAxelarGateway(); axelarGasService = new MockAxelarGasService(); diff --git a/test/utils.t.sol b/test/utils.t.sol index 77c117db..e557600e 100644 --- a/test/utils.t.sol +++ b/test/utils.t.sol @@ -66,8 +66,8 @@ contract Utils is Test { mockAxelarGateway = new MockAxelarGateway(); childTokenTemplate = new ChildERC20(); childTokenTemplate.initialize(address(1), "Test", "TST", 18); - childBridge = new ChildERC20Bridge(); - childBridgeAdaptor = new ChildAxelarBridgeAdaptor(address(mockAxelarGateway)); + childBridge = new ChildERC20Bridge(address(this)); + childBridgeAdaptor = new ChildAxelarBridgeAdaptor(address(mockAxelarGateway), address(this)); IChildERC20Bridge.InitializationRoles memory roles = IChildERC20Bridge.InitializationRoles({ defaultAdmin: address(this), pauser: address(this), @@ -124,11 +124,12 @@ contract Utils is Test { integrationTest.imxToken = ERC20PresetMinterPauser(imxTokenAddress); integrationTest.imxToken.mint(address(this), 1000000 ether); - integrationTest.rootBridgeFlowRate = new RootERC20BridgeFlowRate(); + integrationTest.rootBridgeFlowRate = new RootERC20BridgeFlowRate(address(this)); integrationTest.mockAxelarGateway = new MockAxelarGateway(); integrationTest.axelarGasService = new MockAxelarGasService(); - integrationTest.axelarAdaptor = new RootAxelarBridgeAdaptor(address(integrationTest.mockAxelarGateway)); + integrationTest.axelarAdaptor = + new RootAxelarBridgeAdaptor(address(integrationTest.mockAxelarGateway), address(this)); IRootERC20Bridge.InitializationRoles memory roles = IRootERC20Bridge.InitializationRoles({ defaultAdmin: address(this),