ODCdataobjectsomnichain

OmnichainFungibleFractionsDO

DataObject with base funtionality of a fungible cross-chain fractions

_This contract exposes base functionality of a omnichain fungible fractions, allowing to mint, burn, transfer (locally and cross-chain), check balances and supply.

 NOTE: This contract does not emit token events, it is expected that the DataManager contract will
 emit events for the token operations_

ExpectedAndActualRequestIdDoNotMatch

error ExpectedAndActualRequestIdDoNotMatch(bytes32 expectedRequestId, bytes32 actualRequestId)

Error thrown when the expected and actual request IDs do not match

Parameters

NameTypeDescription
expectedRequestIdbytes32The expected request ID (GUID)
actualRequestIdbytes32The actual request ID (GUID)

InvalidRequestId

error InvalidRequestId(bytes32 rid)

Error thrown when a call to retry omnichain increase balance is provided with wrong or already deleted request id

Parameters

NameTypeDescription
ridbytes32The request ID (GUID) to retry

IncreaseBalanceCallbackHandlerFailed

error IncreaseBalanceCallbackHandlerFailed(address handler, address receiver, uint256 id, uint256 value)

Error thrown when call to handler failed

Parameters

NameTypeDescription
handleraddressAddress of the handler
receiveraddressAddress of the receiver of the tokens
iduint256Id of the token
valueuint256Amount of tokens NOTE: id and value are set to 0 in case of batch transfer

NotEnoughGasForBalanceHandlers

error NotEnoughGasForBalanceHandlers()

Error thrown when we do not have enough gas left to call Balance Handler Callbacks

ZeroAddressHandler

error ZeroAddressHandler()

Error thrown when the handler is the zero address

HandlerAlreadyRegistered

error HandlerAlreadyRegistered()

Error thrown when handler couldn't be added.

HandlerNotRemoved

error HandlerNotRemoved()

Error thrown when handler couldn't be removed.

OmnichainTransferRefund

event OmnichainTransferRefund(bytes32 rid, DataPoint dp, OmnichainAddress from, address to, uint256[] ids, uint256[] values)

Event emitted when an omnichain transfer is refunded

Parameters

NameTypeDescription
ridbytes32The request ID (GUID)
dpDataPointDataPoint identifier
fromOmnichainAddressAddress where tokens were taken from
toaddressAddress which received refund (refund address provided with original transaction)
idsuint256[]Ids of the tokens refunded
valuesuint256[]The amounts of tokens refunded

OmnichainTransferFailedRefund

event OmnichainTransferFailedRefund(bytes32 rid, DataPoint dp, OmnichainAddress from, address to, uint256[] ids, uint256[] values, address actualRefundTarget, bool refundAccepted)

Event emitted when an omnichain transfer refunded is required but was not accepted by provided refundAddress

if refundAccepted is false, that means ERC-1155 was formally violated, some actions by DM (actualRefundTarget) are probably required to handle this correctly

Parameters

NameTypeDescription
ridbytes32The request ID (GUID)
dpDataPointDataPoint identifier
fromOmnichainAddressAddress where tokens were taken from
toaddressAddress which should have received refund (refund address provided with original transaction)
idsuint256[]Ids of the tokens refunded
valuesuint256[]The amounts of tokens refunded
actualRefundTargetaddressAddress finally used for refund (its balance was actually increased)
refundAcceptedboolIf actualRefundTarget accepted refund, if false - it means balance was increased but no Transfer event emitted and onERC1155Received call was reverted

OmnichainTransferSent

event OmnichainTransferSent(bytes32 rid, uint32 chainid, address target, uint256[] ids, uint256[] values)

Event emitted when an omnichain transfer is sent

Data (rid) from this event can be used for retry

Parameters

NameTypeDescription
ridbytes32The request ID (GUID)
chainiduint32The target chain ID
targetaddressThe target address
idsuint256[]Ids of the tokens sent
valuesuint256[]The amounts of tokens sent

OmnichainRetryIncompleteOmnichainIncreaseBalanceSent

event OmnichainRetryIncompleteOmnichainIncreaseBalanceSent(bytes32 originalRid, bytes32 retryRequestRid)

Event emitted when an incomplete omnichain increase balance request is retried

Parameters

NameTypeDescription
originalRidbytes32The original request ID (GUID)
retryRequestRidbytes32The retry request ID (GUID)

OmnichainIncreaseBalanceHandlerRegistered

event OmnichainIncreaseBalanceHandlerRegistered(address handler, bool added)

Event emitted when an omnichain increase balance handler is registered

Parameters

NameTypeDescription
handleraddressThe handler address
addedboolTrue if the handler was added, false if removed

CallResult

Enum for call result

Parameters

NameTypeDescription
enum CallResult {
  NONE,
  SUCCESS,
  FAILURE
}

DpData2

Data structure for storing omnichain increase balance handlers

Parameters

NameTypeDescription
struct DpData2 {
  struct EnumerableSet.AddressSet omnichainIncreaseBalanceHandlers;
}

PendingOmnichainTransfer

Data structure for storing pending omnichain transfers for retry or refund

Parameters

NameTypeDescription
struct PendingOmnichainTransfer {
  DataPoint dp;
  OmnichainAddress from;
  OmnichainAddress to;
  uint256[] ids;
  uint256[] values;
  address refundAddress;
}

IncreaseBalanceQueryParams

Data structure for storing parameters for increase balance query

Parameters

NameTypeDescription
struct IncreaseBalanceQueryParams {
  DataPoint dp;
  OmnichainAddress from;
  OmnichainAddress to;
  uint256[] ids;
  uint256[] values;
  address payable refundAddress;
  bytes32 nextRequestId;
  uint32 toChainId;
  bool batch;
}

retryIncompleteOmnichainIncreaseBalance

function retryIncompleteOmnichainIncreaseBalance(bytes32 rid, address payable refundAddress) external payable

Retry sending incomplete omnichain increase balance request

Parameters

NameTypeDescription
ridbytes32Request ID of failed message (GUID)
refundAddressaddress payableWhere to send refund

callIncreaseBalanceHandlersAndRevertOnFail

function callIncreaseBalanceHandlersAndRevertOnFail(DataPoint dp, OmnichainAddress from, address toAddress, uint256 id, uint256 value) external

Function only callable by the same contract to call increase balance handlers and revert on fail

callIncreaseBalanceHandlersAndRevertOnFail

function callIncreaseBalanceHandlersAndRevertOnFail(DataPoint dp, OmnichainAddress from, address toAddress, uint256[] ids, uint256[] values) external

Function only callable by the same contract to call increase balance handlers and revert on fail

_dispatchWrite

function _dispatchWrite(DataPoint dp, bytes4 operation, bytes data) internal virtual returns (bytes)

_registerOmnichainIncreaseBalanceHandler

function _registerOmnichainIncreaseBalanceHandler(DataPoint dp, address handler) internal

Function to register an omnichain increase balance handler

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
handleraddressAddress of the handler to register NOTE: The handler MUST implement the IOmnichainFungibleFractionsIncreaseBalanceCallback interface

_unregisterOmnichainIncreaseBalanceHandler

function _unregisterOmnichainIncreaseBalanceHandler(DataPoint dp, address handler) internal

Function to unregister an omnichain increase balance handler

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
handleraddressAddress of the handler to unregister

_omnichainTransfer

function _omnichainTransfer(DataPoint dp, OmnichainAddress from, OmnichainAddress to, uint256 id, uint256 value, address payable refundAddress) internal returns (bytes32)

Operation used to transfer tokens to another chain

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromOmnichainAddressAddress where to take tokens from (on current chain)
toOmnichainAddressAddress to send tokens to
iduint256Id of the token
valueuint256How much to send
refundAddressaddress payableWhere to send refund NOTE: Native Coin payment for sending omnichain tx should be sent with the call

_omnichainIncreaseBalance

function _omnichainIncreaseBalance(DataPoint dp, bytes32 rid, OmnichainAddress from, OmnichainAddress to, uint256 id, uint256 value) internal returns (bytes)

Internal operation used to increase the balance of a target account

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
ridbytes32Request ID (GUID)
fromOmnichainAddressOmnichain Address tokens transferred from (used to emit correct event)
toOmnichainAddressOmnichain Address to send tokens to
iduint256Id of the token
valueuint256Amount of tokens to send NOTE: This function SHOULD be called only by the other-chain DataObject to transfer tokens to someone on this chain which MUST decrease the balance of the user in the origin chain and increase the balance of the target account in the current chain

_omnichainBatchTransfer

function _omnichainBatchTransfer(DataPoint dp, OmnichainAddress from, OmnichainAddress to, uint256[] ids, uint256[] values, address payable refundAddress) internal returns (bytes32)

Function used to transfer a batch of tokens to another chain

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromOmnichainAddressAddress where to take tokens from (on current chain)
toOmnichainAddressAddress to send tokens to
idsuint256[]The ids of the tokens
valuesuint256[]The amounts of tokens to transfer
refundAddressaddress payableWhere to send refund NOTE: Native Coin payment for sending omnichain tx should be sent with the call

_omnichainBatchIncreaseBalance

function _omnichainBatchIncreaseBalance(DataPoint dp, bytes32 rid, OmnichainAddress from, OmnichainAddress to, uint256[] ids, uint256[] values) internal returns (bytes)

Internal operation used to increase the balance of a target account with a batch of tokens

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
ridbytes32Request ID (GUID)
fromOmnichainAddressOmnichain Address tokens transferred from (used to emit correct event)
toOmnichainAddressOmnichain Address to send tokens to
idsuint256[]The id of the token
valuesuint256[]Amount of tokens to send NOTE: This function SHOULD be called only by the other-chain DataObject to transfer tokens to someone on this chain which MUST decrease the balance of the user in the origin chain and increase the balance of the target account in the current chain

_omnichainCallback

function _omnichainCallback(bytes32 rid, bytes data) internal

Callback function for omnichain operations

Parameters

NameTypeDescription
ridbytes32Request ID of the message (GUID)
databytesData received in the callback

_increaseOmnichainBalance

function _increaseOmnichainBalance(DataPoint dp, OmnichainAddress from, OmnichainAddress to, uint256 id, uint256 value, address payable refundAddress) internal returns (bytes32)

Function used to increase balance on another chain

_increaseOmnichainBatchBalance

function _increaseOmnichainBatchBalance(DataPoint dp, OmnichainAddress from, OmnichainAddress to, uint256[] ids, uint256[] values, address payable refundAddress) internal returns (bytes32)

Function used to increase batch balance on another chain

_retryIncreaseOmnichainBalance

function _retryIncreaseOmnichainBalance(bytes32 rid, address payable refundAddress) internal

_handleNativePaymentInWrite

function _handleNativePaymentInWrite() internal

Empty to allow native coin payment in write()

_dpData2

function _dpData2(DataPoint dp) internal returns (struct OmnichainFungibleFractionsDO.DpData2)