BaseAdapter
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
| Name | Type | Description |
|---|---|---|
receiverAddr | address | The 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
| Name | Type | Description |
|---|---|---|
receiverAddr | address | The 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
| Name | Type | Description |
|---|---|---|
message | bytes | The protocol-specific encoded message |
Returns
| Name | Type | Description |
|---|---|---|
output | RelayedOrderOutput | The 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
| Name | Type | Description |
|---|---|---|
output | RelayedOrderOutput | The relayed order output to fulfill |
Returns
| Name | Type | Description |
|---|---|---|
payloadHash | bytes32 | The 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();