OAppAuthCore

Git Source

Inherits: IOAppCore, Auth

Abstract contract implementing the IOAppCore interface with basic OApp configurations.

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

State Variables

endpoint

ILayerZeroEndpointV2 public immutable endpoint;

peers

mapping(uint32 eid => bytes32 peer) public peers;

Functions

constructor

Constructor to initialize the OAppCore with the provided endpoint and delegate.

The delegate typically should be set as the owner of the contract.

constructor(address _endpoint, address _delegate);

Parameters

NameTypeDescription

_endpoint

address

The address of the LOCAL Layer Zero endpoint.

_delegate

address

The delegate capable of making OApp configurations inside of the endpoint.

setPeer

Sets the peer address (OApp instance) for a corresponding endpoint.

this contract replaces the OZ Ownable onlyOwner with Solmate requiresAuth

Only the owner/admin of the OApp can call this function.

Indicates that the peer is trusted to send LayerZero messages to this OApp.

Set this to bytes32(0) to remove the peer address.

Peer is a bytes32 to accommodate non-evm chains.

function setPeer(uint32 _eid, bytes32 _peer) public virtual requiresAuth;

Parameters

NameTypeDescription

_eid

uint32

The endpoint ID.

_peer

bytes32

The address of the peer to be associated with the corresponding endpoint.

_setPeer

Sets the peer address (OApp instance) for a corresponding endpoint.

Indicates that the peer is trusted to send LayerZero messages to this OApp.

Set this to bytes32(0) to remove the peer address.

Peer is a bytes32 to accommodate non-evm chains.

function _setPeer(uint32 _eid, bytes32 _peer) internal virtual;

Parameters

NameTypeDescription

_eid

uint32

The endpoint ID.

_peer

bytes32

The address of the peer to be associated with the corresponding endpoint.

_getPeerOrRevert

Internal function to get the peer address associated with a specific endpoint; reverts if NOT set. ie. the peer is set to bytes32(0).

function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32);

Parameters

NameTypeDescription

_eid

uint32

The endpoint ID.

Returns

NameTypeDescription

<none>

bytes32

peer The address of the peer associated with the specified endpoint.

setDelegate

Sets the delegate address for the OApp.

this contract replaces the OZ Ownable onlyOwner with Solmate requiresAuth

Only the owner/admin of the OApp can call this function.

Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.

function setDelegate(address _delegate) public requiresAuth;

Parameters

NameTypeDescription

_delegate

address

The address of the delegate to be set.