ODC

OmnichainProxy

Contract for sending messages between chains and executing operations on other chains

_This contract is an OApp that can send messages to other chains and execute operations on them The supported operations are the read and write operations to DataObjects and the check if an account is admin of a DataPoint. With the respective callback support for they responses.

 NOTE: this contract can be used directly or as a intermediary contract for Data Index implementation
 to perform cross-chain operations_

UnknownOperation

error UnknownOperation(enum OmnichainProxy.Operation op)

Error thrown when the operation is unknown

Operation

Operations supported by the contract

Parameters

NameTypeDescription
enum Operation {
  CALLBACK,
  IS_DATAPOINT_ADMIN,
  APPROVE_DATA_MANAGER,
  DATAOBJECT_READ,
  DATAOBJECT_WRITE
}

CallbackData

Callback data for sent messages

Parameters

NameTypeDescription
struct CallbackData {
  address target;
  address payable refund;
}

_dataIndex

contract IDataIndex _dataIndex

Data Index Diamond implementation

_callbackData

mapping(bytes32 => struct OmnichainProxy.CallbackData) _callbackData

Mapping of GUID to CallbackData

constructor

constructor(address _endpoint, address _initialOwner) public

Parameters

NameTypeDescription
_endpointaddressThe address of the LOCAL Layer Zero endpoint
_initialOwneraddressOwner of the contract, also capable of making OApp configurations inside of the endpoint

setDataIndexImplementation

function setDataIndexImplementation(address dataIndex) external

Set new Data Index implementation

implementation should support IERC165, IOmnichainData and IOmnichainGovernance interfaces

Parameters

NameTypeDescription
dataIndexaddressAddress of new Data Index implementation

queryIsDataPointAdmin

function queryIsDataPointAdmin(DataPoint dp, address account, uint128 destinationGasLimit, uint128 callbackGasLimit, address payable refundAddress) external payable returns (bytes32)

Query DataPoint Registry on the chain where DataPoint was generated and check if requested address is admin

Sender should implement IOmnichainCallbackReceiver to receive callback with query result

Parameters

NameTypeDescription
dpDataPointDataPoint to check
accountaddressAddress to check
destinationGasLimituint128Gas limit for the call on destination chain
callbackGasLimituint128Gas limit for result callback (on current chain)
refundAddressaddress payableAddress to send refund to

Return Values

NameTypeDescription
[0]bytes32ID of request (used for callback)

queryApproveDataManager

function queryApproveDataManager(DataPoint dp, OmnichainAddress dm, bool approve, OmnichainAddress sender, uint128 destinationGasLimit, address payable refundAddress) external payable returns (bytes32)

estimateApproveDataManager

function estimateApproveDataManager(DataPoint dp, OmnichainAddress dm, bool approve, OmnichainAddress sender, uint128 destinationGasLimit) external view returns (uint256)

queryDataObjectRead

function queryDataObjectRead(uint32 chainId, address dobj, DataPoint dp, bytes4 operation, bytes data, uint128 destinationGasLimit, uint128 callbackGasLimit, address payable refundAddress) external payable returns (bytes32)

Query DataObject.read() on another chain

Sender should implement IOmnichainCallbackReceiver to receive callback with query result

Parameters

NameTypeDescription
chainIduint32Chain to read from
dobjaddressAddress of DataObject
dpDataPointDataPoint to work with
operationbytes4Operation to execute
databytesData for the operation
destinationGasLimituint128Gas limit for the call on destination chain
callbackGasLimituint128Gas limit for result callback (on current chain)
refundAddressaddress payableAddress to send refund to

queryDataObjectWrite

function queryDataObjectWrite(uint32 chainId, address dobj, DataPoint dp, bytes4 operation, bytes data, uint128 destinationGasLimit, uint128 callbackGasLimit, address payable refundAddress) external payable returns (bytes32)

Query DataObject.write() on another chain

Sender should implement IOmnichainCallbackReceiver to receive callback with query result

Parameters

NameTypeDescription
chainIduint32Chain to write
dobjaddressAddress of DataObject
dpDataPointDataPoint to work with
operationbytes4Operation to execute
databytesData for the operation
destinationGasLimituint128Gas limit for the call on destination chain
callbackGasLimituint128Gas limit for result callback (on current chain)
refundAddressaddress payableAddress to send refund to

nextRequestId

function nextRequestId(uint32 chainId) public view returns (bytes32)

pause

function pause() external

Pause the contract

Only the owner can call this function

unpause

function unpause() external

Unpause the contract

Only the owner can call this function

_executeOperation

function _executeOperation(enum OmnichainProxy.Operation op, bytes opData) internal returns (bytes)

_executeIsDataPointAdmin

function _executeIsDataPointAdmin(DataPoint dp, address account) internal view returns (bool)

_executeApproveDataManager

function _executeApproveDataManager(DataPoint dp, OmnichainAddress dm, bool approved, OmnichainAddress sender) internal

_executeDataObjectRead

function _executeDataObjectRead(address dobj, DataPoint dp, bytes4 operation, bytes data) internal view returns (bytes)

_executeDataObjectWrite

function _executeDataObjectWrite(address dobj, DataPoint dp, bytes4 operation, bytes data, OmnichainAddress originalSender) internal returns (bytes)

_requireDataIndexImplIsValid

function _requireDataIndexImplIsValid(address dataIndexImpl) internal view virtual

_sendMessage

function _sendMessage(uint32 eid, enum OmnichainProxy.Operation op, bytes opData, uint128 destinationGasLimit, uint128 callbackGasLimit, address refundAddress) internal returns (bytes32)

Send a message to target chain

Parameters

NameTypeDescription
eiduint32EID of destination chain
openum OmnichainProxy.OperationOperation to execute
opDatabytesEncoded data for the operation
destinationGasLimituint128Gas limit to use for the call on destination chain
callbackGasLimituint128Gas limit to use for callback
refundAddressaddressAddress to send refund to

Return Values

NameTypeDescription
[0]bytes32GUID of the sent message

_sendMessageWithoutCallback

function _sendMessageWithoutCallback(uint32 eid, enum OmnichainProxy.Operation op, bytes opData, uint128 destinationGasLimit, address refundAddress) internal returns (bytes32)

Send a message to target chain and NOT expect callback with result

Parameters

NameTypeDescription
eiduint32EID of destination chain
openum OmnichainProxy.OperationOperation to execute
opDatabytesEncoded data for the operation
destinationGasLimituint128Gas limit to use for the call on destination chain
refundAddressaddressAddress to send refund to

Return Values

NameTypeDescription
[0]bytes32GUID of the sent message

_estimateMessageWithoutCallback

function _estimateMessageWithoutCallback(uint32 eid, enum OmnichainProxy.Operation op, bytes opData, uint128 destinationGasLimit) internal view returns (uint256)

_convertSourceValueToDestinationValue

function _convertSourceValueToDestinationValue(uint32 eid, uint256 value) internal view returns (uint256)

_executeCallback

function _executeCallback(bytes32 guid, bytes cbData) internal virtual

_lzReceive

function _lzReceive(struct Origin _origin, bytes32 _guid, bytes payload, address, bytes) internal

Internal function override to handle incoming messages from another chain

Parameters

NameTypeDescription
_originstruct OriginA struct containing information about the message sender
_guidbytes32A unique global packet identifier for the message
payloadbytesThe encoded message payload being received NOTE: The following params are unused in the current implementation of the OApp _executor The address of the Executor responsible for processing the message _extraData Arbitrary data appended by the Executor to the message Decodes the received payload and processes it as per the business logic defined in the function
address
bytes

_sendMessageAndRecordCallback

function _sendMessageAndRecordCallback(uint32 eid, enum OmnichainProxy.Operation operation, bytes opData, uint128 destinationGasLimit, uint128 callbackGasLimit, address payable refundAddress) internal virtual returns (bytes32)

_targetChainEid

function _targetChainEid(uint32 chainId) internal view returns (uint32)