OAppAuthReceiver

Git Source

Inherits: IOAppReceiver, OAppAuthCore

Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers.

This Auth version of OAppCore uses solmate's Auth instead of OZ's Ownable for compatibility purposes

State Variables

RECEIVER_VERSION

uint64 internal constant RECEIVER_VERSION = 2;

Functions

oAppVersion

Retrieves the OApp version information.

Providing 0 as the default for OAppSender version. Indicates that the OAppSender is not implemented. ie. this is a RECEIVE only OApp.

If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions.

function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion);

Returns

isComposeMsgSender

Indicates whether an address is an approved composeMsg sender to the Endpoint.

*_origin The origin information containing the source endpoint and sender address.

  • srcEid: The source chain endpoint ID.

  • sender: The sender address on the src chain.

  • nonce: The nonce of the message.*

_message The lzReceive payload.

Applications can optionally choose to implement separate composeMsg senders that are NOT the bridging layer.

The default sender IS the OAppReceiver implementer.

function isComposeMsgSender(Origin calldata, bytes calldata, address _sender) public view virtual returns (bool);

Parameters

Returns

allowInitializePath

Checks if the path initialization is allowed based on the provided origin.

This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received.

This defaults to assuming if a peer has been set, its initialized. Can be overridden by the OApp if there is other logic to determine this.

function allowInitializePath(Origin calldata origin) public view virtual returns (bool);

Parameters

Returns

nextNonce

Retrieves the next nonce for a given source endpoint and sender address.

_srcEid The source endpoint ID.

_sender The sender address.

The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement.

Is required by the off-chain executor to determine the OApp expects msg execution is ordered.

This is also enforced by the OApp.

By default this is NOT enabled. ie. nextNonce is hardcoded to return 0.

function nextNonce(uint32, bytes32) public view virtual returns (uint64 nonce);

Returns

lzReceive

Entry point for receiving messages or packets from the endpoint.

Entry point for receiving msg/packet from the LayerZero endpoint.

function lzReceive(
    Origin calldata _origin,
    bytes32 _guid,
    bytes calldata _message,
    address _executor,
    bytes calldata _extraData
)
    public
    payable
    virtual;

Parameters

_lzReceive

Internal function to implement lzReceive logic without needing to copy the basic parameter validation.

function _lzReceive(
    Origin calldata _origin,
    bytes32 _guid,
    bytes calldata _message,
    address _executor,
    bytes calldata _extraData
)
    internal
    virtual;

Errors

OnlyEndpoint

error OnlyEndpoint(address addr);