TransshipmentWorker
Abstract contract representing a worker in the Transshipment system. It includes functionality from CCIPReceiver, OwnerIsCreator, and ITransshipmentStructures.

Solidity API
allowlistedDestinationChains
mapping(uint64 => bool) allowlistedDestinationChains
allowlistedSourceChains
mapping(uint64 => bool) allowlistedSourceChains
allowlistedSenders
mapping(address => bool) allowlistedSenders
s_messageContents
mapping(bytes32 => struct Client.Any2EVMMessage) s_messageContents
s_failedMessages
struct EnumerableMap.Bytes32ToUintMap s_failedMessages
s_linkToken
contract IERC20 s_linkToken
constructor
constructor(address _router, address _link) internal
@notice Constructor initializes the contract with the router address. @param _router The address of the router contract. @param _link The address of the link contract.
onlySelf
modifier onlySelf()
@dev Modifier to allow only the contract itself to execute a function. Throws an exception if called by any account other than the contract itself.
onlyAllowlistedDestinationChain
modifier onlyAllowlistedDestinationChain(uint64 _destinationChainSelector)
@dev Modifier that checks if the chain with the given destinationChainSelector is allowlisted. @param _destinationChainSelector The selector of the destination chain.
onlyAllowlisted
modifier onlyAllowlisted(uint64 _sourceChainSelector, address _sender)
@dev Modifier that checks if the chain with the given sourceChainSelector is allowlisted and if the sender is allowlisted. @param _sourceChainSelector The selector of the destination chain. @param _sender The address of the sender.
allowlistDestinationChain
function allowlistDestinationChain(uint64 _destinationChainSelector, bool allowed) external
@dev Updates the allowlist status of a destination chain for transactions. @notice This function can only be called by the owner. @param _destinationChainSelector The selector of the destination chain to be updated. @param allowed The allowlist status to be set for the destination chain.
allowlistSourceChain
function allowlistSourceChain(uint64 _sourceChainSelector, bool allowed) external
@dev Updates the allowlist status of a source chain @notice This function can only be called by the owner. @param _sourceChainSelector The selector of the source chain to be updated. @param allowed The allowlist status to be set for the source chain.
allowlistSender
function allowlistSender(address _sender, bool allowed) external
@dev Updates the allowlist status of a sender for transactions. @notice This function can only be called by the owner. @param _sender The address of the sender to be updated. @param allowed The allowlist status to be set for the sender.
_sendMessage
function _sendMessage(struct ITransshipmentStructures.MassageParam massageParam, address senderAddress) internal virtual returns (bytes32 messageId)
@notice Sends data and transfer tokens to receiver on the destination chain. @notice Pay for fees in LINK. @dev Assumes your contract has sufficient LINK to pay for CCIP fees. @return messageId The ID of the CCIP message that was sent.
ccipReceive
function ccipReceive(struct Client.Any2EVMMessage any2EvmMessage) external
@notice The entrypoint for the CCIP router to call. This function should never revert, all errors should be handled internally in this contract. @param any2EvmMessage The message to process. @dev Extremely important to ensure only router calls this.
getFailedMessagesIds
function getFailedMessagesIds() external view returns (bytes32[] ids)
Retrieves the IDs of failed messages from the s_failedMessages
map.
Iterates over the s_failedMessages
map, collecting all keys.
Return Values
ids
bytes32[]
An array of bytes32 containing the IDs of failed messages from the s_failedMessages
map.
processMessage
function processMessage(struct Client.Any2EVMMessage any2EvmMessage) external
@notice Serves as the entry point for this contract to process incoming messages. @param any2EvmMessage Received CCIP message. @dev Transfers specified token amounts to the owner of this contract. This function must be external because of the try/catch for error handling. It uses the onlySelf
: can only be called from the contract.
retryFailedMessage
function retryFailedMessage(bytes32 messageId, address tokenReceiver) external
Allows the owner to retry a failed message in order to unblock the associated tokens.
This function is only callable by the contract owner. It changes the status of the message from 'failed' to 'resolved' to prevent reentry and multiple retries of the same message.
Parameters
messageId
bytes32
The unique identifier of the failed message.
tokenReceiver
address
The address to which the tokens will be sent.
_ccipReceive
function _ccipReceive(struct Client.Any2EVMMessage any2EvmMessage) internal virtual
Internal function to handle the reception of CCIP (Cross-Chain Interoperability Protocol) messages. This function is marked as virtual and must be implemented by the inheriting contract.
Parameters
any2EvmMessage
struct Client.Any2EVMMessage
The CCIP message structure containing information about the message. Specifically, the sender's chain, sender's address, message data, etc. Refer to the Client.Any2EVMMessage struct for details. Requirements: - The function must be implemented by the inheriting contract to handle the logic for processing CCIP messages. - Only addresses allowed by the onlyAllowlisted
modifier are permitted to call this function. - The function should process the CCIP message and execute any necessary actions based on the message content.
_buildCCIPMessage
function _buildCCIPMessage(address _receiver, bytes _data, address _token, uint256 _amount, address _feeTokenAddress, uint256 _gasLimit) internal pure returns (struct Client.EVM2AnyMessage)
Construct a CCIP message.
This function will create an EVM2AnyMessage struct with all the necessary information for programmable tokens transfer.
Parameters
_receiver
address
The address of the receiver.
_data
bytes
The string data to be sent.
_token
address
The token to be transferred.
_amount
uint256
The amount of the token to be transferred.
_feeTokenAddress
address
The address of the token used for fees. Set address(0) for native gas.
_gasLimit
uint256
Gas limit for destination chain.
Return Values
[0]
struct Client.EVM2AnyMessage
Client.EVM2AnyMessage Returns an EVM2AnyMessage struct which contains information for sending a CCIP message.
receive
receive() external payable
Fallback function to allow the contract to receive Ether.
This function has no function body, making it a default function for receiving Ether. It is automatically called when Ether is sent to the contract without any data.
withdraw
function withdraw(address _beneficiary) public
@notice Allows the contract owner to withdraw the entire balance of Ether from the contract. @dev This function reverts if there are no funds to withdraw or if the transfer fails. It should only be callable by the owner of the contract. @param _beneficiary The address to which the Ether should be sent.
withdrawToken
function withdrawToken(address _beneficiary, address _token) public
Allows the owner of the contract to withdraw all tokens of a specific ERC20 token.
This function reverts with a 'NothingToWithdraw' error if there are no tokens to withdraw.
Parameters
_beneficiary
address
The address to which the tokens will be sent.
_token
address
The contract address of the ERC20 token to be withdrawn.
multicall
function multicall(struct ITransshipmentStructures.CallData[] calldataStructArray) internal returns (bool)
Executes multiple calls in a batch.
Parameters
calldataStructArray
struct ITransshipmentStructures.CallData[]
Array of CallData structures to execute.
Return Values
[0]
bool
success True if all calls succeed, false otherwise.
execute
function execute(struct ITransshipmentStructures.CallData calldataStruct) internal returns (bytes result)
Executes a single call.
Parameters
calldataStruct
struct ITransshipmentStructures.CallData
The CallData structure containing target, value, and data.
Return Values
result
bytes
The result of the call.
isBytesEmpty
function isBytesEmpty(bytes data) internal pure returns (bool)
Checks if a bytes array is empty.
Parameters
data
bytes
The bytes array to check.
Return Values
[0]
bool
True if the bytes array is empty, false otherwise.
appendAddressToData
function appendAddressToData(address _addr, bytes _data) internal pure returns (bytes)
Appends an address to a bytes array.
Parameters
_addr
address
The address to append.
_data
bytes
The bytes array to which the address is appended.
Return Values
[0]
bytes
result The new bytes array with the address appended.
extractAddressFromData
function extractAddressFromData(bytes _combinedData) internal pure returns (address, bytes)
Extracts an address and data from a combined bytes array.
Parameters
_combinedData
bytes
The combined bytes array containing an address and data.
Return Values
[0]
address
addr The extracted address.
[1]
bytes
data The extracted data.
Last updated