# OAppAuthCore

[Git Source](https://github.com/Ion-Protocol/nucleus-boring-vault/blob/cc0b494b83e17b9b169a73b96050d2810b690477/src/base/Roles/CrossChain/OAppAuth/OAppAuthCore.sol)

**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

```solidity
ILayerZeroEndpointV2 public immutable endpoint;
```

### peers

```solidity
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.*

```solidity
constructor(address _endpoint, address _delegate);
```

**Parameters**

| Name        | Type      | Description                                                                |
| ----------- | --------- | -------------------------------------------------------------------------- |
| `_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.*

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

**Parameters**

| Name    | Type      | Description                                                               |
| ------- | --------- | ------------------------------------------------------------------------- |
| `_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.*

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

**Parameters**

| Name    | Type      | Description                                                               |
| ------- | --------- | ------------------------------------------------------------------------- |
| `_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).

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

**Parameters**

| Name   | Type     | Description      |
| ------ | -------- | ---------------- |
| `_eid` | `uint32` | The endpoint ID. |

**Returns**

| Name     | Type      | Description                                                          |
| -------- | --------- | -------------------------------------------------------------------- |
| `<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.*

```solidity
function setDelegate(address _delegate) public requiresAuth;
```

**Parameters**

| Name        | Type      | Description                            |
| ----------- | --------- | -------------------------------------- |
| `_delegate` | `address` | The address of the delegate to be set. |
