From ec43e7d639ff92b7a9b01c3b9695abdc15aa64af Mon Sep 17 00:00:00 2001 From: Benjamin Patch Date: Wed, 1 Nov 2023 11:58:32 +1100 Subject: [PATCH] lint --- src/child/ChildAxelarBridgeAdaptor.sol | 14 +++++++++++--- src/child/ChildERC20Bridge.sol | 3 +-- src/interfaces/child/IChildAxelarBridgeAdaptor.sol | 2 +- src/interfaces/child/IChildERC20Bridge.sol | 8 +++++++- src/test/child/MockChildAxelarGasService.sol | 12 ++++++++++++ test/integration/child/ChildAxelarBridge.t.sol | 4 +++- .../withdrawals/ChildERC20BridgeWithdraw.t.sol | 1 + 7 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 src/test/child/MockChildAxelarGasService.sol create mode 100644 test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol diff --git a/src/child/ChildAxelarBridgeAdaptor.sol b/src/child/ChildAxelarBridgeAdaptor.sol index 3c6d2a64b..8cfa753af 100644 --- a/src/child/ChildAxelarBridgeAdaptor.sol +++ b/src/child/ChildAxelarBridgeAdaptor.sol @@ -6,11 +6,19 @@ import {IAxelarGasService} from "@axelar-cgp-solidity/contracts/interfaces/IAxel import {IAxelarGateway} from "@axelar-cgp-solidity/contracts/interfaces/IAxelarGateway.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import {IChildERC20Bridge} from "../interfaces/child/IChildERC20Bridge.sol"; -import {IChildAxelarBridgeAdaptorErrors, IChildAxelarBridgeAdaptorEvents} from "../interfaces/child/IChildAxelarBridgeAdaptor.sol"; +import { + IChildAxelarBridgeAdaptorErrors, + IChildAxelarBridgeAdaptorEvents +} from "../interfaces/child/IChildAxelarBridgeAdaptor.sol"; import {IChildERC20BridgeAdaptor} from "../interfaces/child/IChildERC20BridgeAdaptor.sol"; -contract ChildAxelarBridgeAdaptor is AxelarExecutable, IChildERC20BridgeAdaptor, Initializable, IChildAxelarBridgeAdaptorErrors, - IChildAxelarBridgeAdaptorEvents { +contract ChildAxelarBridgeAdaptor is + AxelarExecutable, + IChildERC20BridgeAdaptor, + Initializable, + IChildAxelarBridgeAdaptorErrors, + IChildAxelarBridgeAdaptorEvents +{ /// @notice Address of bridge to relay messages to. IChildERC20Bridge public childBridge; IAxelarGasService public gasService; diff --git a/src/child/ChildERC20Bridge.sol b/src/child/ChildERC20Bridge.sol index 7e8304c4a..ecf25fbd7 100644 --- a/src/child/ChildERC20Bridge.sol +++ b/src/child/ChildERC20Bridge.sol @@ -126,7 +126,6 @@ contract ChildERC20Bridge is } } - function withdraw(IChildERC20 childToken, uint256 amount) external { _withdraw(childToken, msg.sender, amount); } @@ -165,7 +164,7 @@ contract ChildERC20Bridge is // Send the message to the bridge adaptor and up to root chain bridgeAdaptor.sendMessage{value: msg.value}(payload, msg.sender); - + // TODO emit event emit ChildChainERC20Withdraw(rootToken, address(childToken), msg.sender, receiver, amount); } diff --git a/src/interfaces/child/IChildAxelarBridgeAdaptor.sol b/src/interfaces/child/IChildAxelarBridgeAdaptor.sol index 0e13f2ae1..8dbb6309c 100644 --- a/src/interfaces/child/IChildAxelarBridgeAdaptor.sol +++ b/src/interfaces/child/IChildAxelarBridgeAdaptor.sol @@ -13,4 +13,4 @@ interface IChildAxelarBridgeAdaptorErrors { interface IChildAxelarBridgeAdaptorEvents { /// @notice Emitted when an Axelar message is sent to the root chain. event MapTokenAxelarMessage(string indexed rootChain, string indexed rootBridgeAdaptor, bytes indexed payload); -} \ No newline at end of file +} diff --git a/src/interfaces/child/IChildERC20Bridge.sol b/src/interfaces/child/IChildERC20Bridge.sol index 532e56efd..c24252e16 100644 --- a/src/interfaces/child/IChildERC20Bridge.sol +++ b/src/interfaces/child/IChildERC20Bridge.sol @@ -25,7 +25,13 @@ interface IChildERC20BridgeEvents { /// @notice Emitted when a map token message is received from the root chain and executed successfully. event L2TokenMapped(address rootToken, address childToken); - event ChildChainERC20Withdraw(address indexed rootToken, address indexed childToken, address depositor, address indexed receiver, uint256 amount); + event ChildChainERC20Withdraw( + address indexed rootToken, + address indexed childToken, + address depositor, + address indexed receiver, + uint256 amount + ); event ChildChainERC20Deposit( address indexed rootToken, diff --git a/src/test/child/MockChildAxelarGasService.sol b/src/test/child/MockChildAxelarGasService.sol new file mode 100644 index 000000000..1b0fc31eb --- /dev/null +++ b/src/test/child/MockChildAxelarGasService.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: Apache 2.0 +pragma solidity ^0.8.21; + +contract MockChildAxelarGasService { + function payNativeGasForContractCall( + address sender, + string calldata destinationChain, + string calldata destinationAddress, + bytes calldata payload, + address refundAddress + ) external payable {} +} diff --git a/test/integration/child/ChildAxelarBridge.t.sol b/test/integration/child/ChildAxelarBridge.t.sol index 980477a2a..724c676cf 100644 --- a/test/integration/child/ChildAxelarBridge.t.sol +++ b/test/integration/child/ChildAxelarBridge.t.sol @@ -45,7 +45,9 @@ contract ChildERC20BridgeIntegrationTest is Test, IChildERC20BridgeEvents, IChil IMX_TOKEN_ADDRESS ); - childAxelarBridgeAdaptor.initialize(ROOT_CHAIN_NAME, address(childERC20Bridge), address(mockChildAxelarGasService)); + childAxelarBridgeAdaptor.initialize( + ROOT_CHAIN_NAME, address(childERC20Bridge), address(mockChildAxelarGasService) + ); } function test_ChildTokenMap() public { diff --git a/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/test/unit/child/withdrawals/ChildERC20BridgeWithdraw.t.sol @@ -0,0 +1 @@ +