Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

BaseAdapter

Git Source

Inherits: Adapter

Title: BaseAdapter

Base contract for adapters that connect underlying protocols to the MetaIntentReceiver.

Provides reusable functions for connecting with the MetaIntentReceiver, including token transfer helpers and message decoding patterns. Protocol-specific adapters should inherit from this contract and override the virtual functions to implement their specific requirements.

Constants

RECEIVER

The MetaIntentReceiver that this adapter forwards fulfillments to

Receiver public immutable RECEIVER

Functions

constructor

constructor(address receiverAddr) ;

Parameters

NameTypeDescription
receiverAddraddressThe address of the MetaIntentReceiver contract

onlyProtocol

modifier onlyProtocol() ;

receiver

Returns the MetaIntentReceiver address this adapter forwards to

function receiver() external view returns (address receiverAddr);

Returns

NameTypeDescription
receiverAddraddressThe address of the MetaIntentReceiver contract

_decodeMessage

Decode a protocol-specific message into RelayedOrderOutput

Virtual function that must be overridden by protocol-specific adapters. This internal version allows adapters to use the decoding logic internally.

function _decodeMessage(bytes calldata message) internal virtual returns (RelayedOrderOutput memory output);

Parameters

NameTypeDescription
messagebytesThe protocol-specific encoded message

Returns

NameTypeDescription
outputRelayedOrderOutputThe decoded RelayedOrderOutput struct

_onlyProtocol

Modifier pattern for protocol-specific access control

Override this function to add authorization checks. For example, override to only allow specific protocol bridge contracts to call. Empty by default - implementations should override for production use.

function _onlyProtocol() internal virtual;

_fulfillToReceiver

Transfer tokens to receiver and call fulfill

Handles both native and ERC20 token transfers to the receiver, then calls fulfill() on the MetaIntentReceiver. Follows CEI pattern: checks (balance validation) happen in receiver.

function _fulfillToReceiver(RelayedOrderOutput calldata output) internal returns (bytes32 payloadHash);

Parameters

NameTypeDescription
outputRelayedOrderOutputThe relayed order output to fulfill

Returns

NameTypeDescription
payloadHashbytes32The payload hash returned by the receiver

receive

receive() external payable virtual;

Errors

NativeTransferFailed

Revert when native token transfer to receiver fails

error NativeTransferFailed();

ReceiverIsZeroAddress

Revert when receiver address is zero

error ReceiverIsZeroAddress();