From 8be1ea668afcd8b3af7659e1cf02e9370cb0a3ad Mon Sep 17 00:00:00 2001 From: tushar994 <54453857+tushar994@users.noreply.github.com> Date: Mon, 15 Apr 2024 02:19:04 +0530 Subject: [PATCH] change IOFTV2.sol to IBaseOFTV2.sol and add a new implementation of IOFTV2.sol --- contracts/token/oft/v2/BaseOFTV2.sol | 6 ++--- .../token/oft/v2/interfaces/IBaseOFTV2.sol | 25 +++++++++++++++++++ contracts/token/oft/v2/interfaces/IOFTV2.sol | 20 +++------------ .../token/oft/v2/mocks/OFTStakingMockV2.sol | 6 ++--- 4 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 contracts/token/oft/v2/interfaces/IBaseOFTV2.sol diff --git a/contracts/token/oft/v2/BaseOFTV2.sol b/contracts/token/oft/v2/BaseOFTV2.sol index b4386b3e..b72c22bc 100644 --- a/contracts/token/oft/v2/BaseOFTV2.sol +++ b/contracts/token/oft/v2/BaseOFTV2.sol @@ -3,10 +3,10 @@ pragma solidity ^0.8.0; import "./OFTCoreV2.sol"; -import "./interfaces/IOFTV2.sol"; +import "./interfaces/IBaseOFTV2.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; -abstract contract BaseOFTV2 is OFTCoreV2, ERC165, IOFTV2 { +abstract contract BaseOFTV2 is OFTCoreV2, ERC165, IBaseOFTV2 { constructor(uint8 _sharedDecimals, address _lzEndpoint) OFTCoreV2(_sharedDecimals, _lzEndpoint) {} /************************************************************************ @@ -48,7 +48,7 @@ abstract contract BaseOFTV2 is OFTCoreV2, ERC165, IOFTV2 { * public view functions ************************************************************************/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { - return interfaceId == type(IOFTV2).interfaceId || super.supportsInterface(interfaceId); + return interfaceId == type(IBaseOFTV2).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee( diff --git a/contracts/token/oft/v2/interfaces/IBaseOFTV2.sol b/contracts/token/oft/v2/interfaces/IBaseOFTV2.sol new file mode 100644 index 00000000..05c4af76 --- /dev/null +++ b/contracts/token/oft/v2/interfaces/IBaseOFTV2.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT + +pragma solidity >=0.5.0; + +import "./ICommonOFT.sol"; + +/** + * @dev Interface of the BaseIOFT core standard + */ +interface IBaseOFTV2 is ICommonOFT { + + /** + * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` + * `_from` the owner of token + * `_dstChainId` the destination chain identifier + * `_toAddress` can be any size depending on the `dstChainId`. + * `_amount` the quantity of tokens in wei + * `_refundAddress` the address LayerZero refunds if too much message fee is sent + * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) + * `_adapterParams` is a flexible bytes array to indicate messaging adapter services + */ + function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) external payable; + + function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable; +} diff --git a/contracts/token/oft/v2/interfaces/IOFTV2.sol b/contracts/token/oft/v2/interfaces/IOFTV2.sol index 927621c4..37a5037b 100644 --- a/contracts/token/oft/v2/interfaces/IOFTV2.sol +++ b/contracts/token/oft/v2/interfaces/IOFTV2.sol @@ -2,24 +2,10 @@ pragma solidity >=0.5.0; -import "./ICommonOFT.sol"; +import "./IBaseOFTV2.sol"; +import "@openzeppelin/contracts/interfaces/IERC20.sol"; /** * @dev Interface of the IOFT core standard */ -interface IOFTV2 is ICommonOFT { - - /** - * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` - * `_from` the owner of token - * `_dstChainId` the destination chain identifier - * `_toAddress` can be any size depending on the `dstChainId`. - * `_amount` the quantity of tokens in wei - * `_refundAddress` the address LayerZero refunds if too much message fee is sent - * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) - * `_adapterParams` is a flexible bytes array to indicate messaging adapter services - */ - function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) external payable; - - function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable; -} +interface IOFTV2 is IBaseOFTV2, IERC20 {} diff --git a/contracts/token/oft/v2/mocks/OFTStakingMockV2.sol b/contracts/token/oft/v2/mocks/OFTStakingMockV2.sol index 1a44eb45..a6bc5470 100644 --- a/contracts/token/oft/v2/mocks/OFTStakingMockV2.sol +++ b/contracts/token/oft/v2/mocks/OFTStakingMockV2.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; -import "../interfaces/IOFTV2.sol"; +import "../interfaces/IBaseOFTV2.sol"; import "../interfaces/IOFTReceiverV2.sol"; import "../../../../libraries/BytesLib.sol"; @@ -21,7 +21,7 @@ contract OFTStakingMockV2 is IOFTReceiverV2 { // ... other types // variables - IOFTV2 public oft; + IBaseOFTV2 public oft; mapping(uint16 => bytes32) public remoteStakingContracts; mapping(address => uint) public balances; bool public paused; // for testing try/catch @@ -32,7 +32,7 @@ contract OFTStakingMockV2 is IOFTReceiverV2 { // _oft can be any composable OFT contract, e.g. ComposableOFT, ComposableBasedOFT and ComposableProxyOFT. constructor(address _oft) { - oft = IOFTV2(_oft); + oft = IBaseOFTV2(_oft); IERC20(oft.token()).safeApprove(_oft, type(uint).max); }