83 lines
3.7 KiB
Solidity
83 lines
3.7 KiB
Solidity
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
|
pragma solidity >=0.8.9;
|
||
|
|
||
|
interface IMessageReceiverApp {
|
||
|
enum ExecutionStatus {
|
||
|
Fail, // execution failed, finalized
|
||
|
Success, // execution succeeded, finalized
|
||
|
Retry // execution rejected, can retry later
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @notice Called by MessageBus (MessageBusReceiver) if the process is originated from MessageBus (MessageBusSender)'s
|
||
|
* sendMessageWithTransfer it is only called when the tokens are checked to be arrived at this contract's address.
|
||
|
* @param _sender The address of the source app contract
|
||
|
* @param _token The address of the token that comes out of the bridge
|
||
|
* @param _amount The amount of tokens received at this contract through the cross-chain bridge.
|
||
|
* the contract that implements this contract can safely assume that the tokens will arrive before this
|
||
|
* function is called.
|
||
|
* @param _srcChainId The source chain ID where the transfer is originated from
|
||
|
* @param _message Arbitrary message bytes originated from and encoded by the source app contract
|
||
|
* @param _executor Address who called the MessageBus execution function
|
||
|
*/
|
||
|
function executeMessageWithTransfer(
|
||
|
address _sender,
|
||
|
address _token,
|
||
|
uint256 _amount,
|
||
|
uint64 _srcChainId,
|
||
|
bytes calldata _message,
|
||
|
address _executor
|
||
|
) external payable returns (ExecutionStatus);
|
||
|
|
||
|
/**
|
||
|
* @notice Only called by MessageBus (MessageBusReceiver) if
|
||
|
* 1. executeMessageWithTransfer reverts, or
|
||
|
* 2. executeMessageWithTransfer returns ExecutionStatus.Fail
|
||
|
* @param _sender The address of the source app contract
|
||
|
* @param _token The address of the token that comes out of the bridge
|
||
|
* @param _amount The amount of tokens received at this contract through the cross-chain bridge.
|
||
|
* the contract that implements this contract can safely assume that the tokens will arrive before this
|
||
|
* function is called.
|
||
|
* @param _srcChainId The source chain ID where the transfer is originated from
|
||
|
* @param _message Arbitrary message bytes originated from and encoded by the source app contract
|
||
|
* @param _executor Address who called the MessageBus execution function
|
||
|
*/
|
||
|
function executeMessageWithTransferFallback(
|
||
|
address _sender,
|
||
|
address _token,
|
||
|
uint256 _amount,
|
||
|
uint64 _srcChainId,
|
||
|
bytes calldata _message,
|
||
|
address _executor
|
||
|
) external payable returns (ExecutionStatus);
|
||
|
|
||
|
/**
|
||
|
* @notice Called by MessageBus (MessageBusReceiver) to process refund of the original transfer from this contract
|
||
|
* @param _token The token address of the original transfer
|
||
|
* @param _amount The amount of the original transfer
|
||
|
* @param _message The same message associated with the original transfer
|
||
|
* @param _executor Address who called the MessageBus execution function
|
||
|
*/
|
||
|
function executeMessageWithTransferRefund(
|
||
|
address _token,
|
||
|
uint256 _amount,
|
||
|
bytes calldata _message,
|
||
|
address _executor
|
||
|
) external payable returns (ExecutionStatus);
|
||
|
|
||
|
/**
|
||
|
* @notice Called by MessageBus (MessageBusReceiver)
|
||
|
* @param _sender The address of the source app contract
|
||
|
* @param _srcChainId The source chain ID where the transfer is originated from
|
||
|
* @param _message Arbitrary message bytes originated from and encoded by the source app contract
|
||
|
* @param _executor Address who called the MessageBus execution function
|
||
|
*/
|
||
|
function executeMessage(
|
||
|
address _sender,
|
||
|
uint64 _srcChainId,
|
||
|
bytes calldata _message,
|
||
|
address _executor
|
||
|
) external payable returns (ExecutionStatus);
|
||
|
}
|