Skip to content

Commit

Permalink
Refactor and cleanup adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
ermyas committed Sep 19, 2023
1 parent 032c11a commit 705b583
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 350 deletions.
16 changes: 14 additions & 2 deletions src/adapters/axelar/AxelarReceiverAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ contract AxelarReceiverAdapter is IAxelarExecutable, IMessageReceiverAdapter {
using StringAddressConversion for string;

string public constant name = "axelar";
string public constant senderChain = "ethereum";

IAxelarGateway public immutable gateway;
IGAC public immutable gac;

/*/////////////////////////////////////////////////////////////////
STATE VARIABLES
////////////////////////////////////////////////////////////////*/
string public senderChain;
address public senderAdapter;

mapping(bytes32 => bool) public isMessageExecuted;
Expand All @@ -46,9 +46,21 @@ contract AxelarReceiverAdapter is IAxelarExecutable, IMessageReceiverAdapter {
/*/////////////////////////////////////////////////////////////////
CONSTRUCTOR
////////////////////////////////////////////////////////////////*/
constructor(address _gateway, address _gac) {
/// @param _gateway is axelar gateway contract address.
/// @param _gac is global access controller.
/// @param _senderChain is the chain id of the sender chain.
constructor(address _gateway, address _gac, string memory _senderChain) {
if (_gateway == address(0) || _gac == address(0)) {
revert Error.ZERO_ADDRESS_INPUT();
}

if (bytes(_senderChain).length == 0) {
revert Error.INVALID_SENDER_CHAIN_ID();
}

gateway = IAxelarGateway(_gateway);
gac = IGAC(_gac);
senderChain = _senderChain;
}

/*/////////////////////////////////////////////////////////////////
Expand Down
164 changes: 0 additions & 164 deletions src/adapters/axelar/interfaces/IAxelarGasService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,114 +3,6 @@ pragma solidity >=0.8.9;

// This should be owned by the microservice that is paying for gas.
interface IAxelarGasService {
error NothingReceived();
error InvalidAddress();
error NotCollector();
error InvalidAmounts();

event GasPaidForContractCall(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);

event GasPaidForContractCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);

event NativeGasPaidForContractCall(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
uint256 gasFeeAmount,
address refundAddress
);

event NativeGasPaidForContractCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
uint256 gasFeeAmount,
address refundAddress
);

event GasPaidForExpressCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
);

event NativeGasPaidForExpressCallWithToken(
address indexed sourceAddress,
string destinationChain,
string destinationAddress,
bytes32 indexed payloadHash,
string symbol,
uint256 amount,
uint256 gasFeeAmount,
address refundAddress
);

event GasAdded(
bytes32 indexed txHash, uint256 indexed logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress
);

event NativeGasAdded(bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress);

event ExpressGasAdded(
bytes32 indexed txHash, uint256 indexed logIndex, address gasToken, uint256 gasFeeAmount, address refundAddress
);

event NativeExpressGasAdded(
bytes32 indexed txHash, uint256 indexed logIndex, uint256 gasFeeAmount, address refundAddress
);

// This is called on the source chain before calling the gateway to execute a remote contract.
function payGasForContractCall(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;

// This is called on the source chain before calling the gateway to execute a remote contract.
function payGasForContractCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;

// This is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForContractCall(
address sender,
Expand All @@ -119,60 +11,4 @@ interface IAxelarGasService {
bytes calldata payload,
address refundAddress
) external payable;

// This is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForContractCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address refundAddress
) external payable;

// This is called on the source chain before calling the gateway to execute a remote contract.
function payGasForExpressCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;

// This is called on the source chain before calling the gateway to execute a remote contract.
function payNativeGasForExpressCallWithToken(
address sender,
string calldata destinationChain,
string calldata destinationAddress,
bytes calldata payload,
string calldata symbol,
uint256 amount,
address refundAddress
) external payable;

function addGas(bytes32 txHash, uint256 txIndex, address gasToken, uint256 gasFeeAmount, address refundAddress)
external;

function addNativeGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable;

function addExpressGas(
bytes32 txHash,
uint256 txIndex,
address gasToken,
uint256 gasFeeAmount,
address refundAddress
) external;

function addNativeExpressGas(bytes32 txHash, uint256 logIndex, address refundAddress) external payable;

function collectFees(address payable receiver, address[] calldata tokens, uint256[] calldata amounts) external;

function refund(address payable receiver, address token, uint256 amount) external;

function gasCollector() external returns (address);
}
Loading

0 comments on commit 705b583

Please sign in to comment.