ODCdataManagersomnichainERC1155

OmnichainERC1155DataManager

Contract for managing an Omnichain ERC1155 token using a Omnichain Fungible Fractions Data Object

_This contract is used to manage an Omnichain ERC1155 token where a Data Object contract is used to store the token data on that chain.

 NOTE: This contract and the Data Object contract MUST be approved in the Data Index contract to interact with the given
 Data Point.
 For the correct functioning of this contract, it must be registered as a handler in the Omnichain Fungible
 Fractions Data Object through the registerOmnichainIncreaseBalanceHandler function._

OmnichainMintBurnNotSupported

error OmnichainMintBurnNotSupported()

Error thrown when the from or to address is the zero address in a transfer

UnauthorizedCaller

error UnauthorizedCaller()

Error thrown when the caller is not the Fungible Fractions Data Object

NotRegisteredAsOmnichainIncreaseBalanceHandler

error NotRegisteredAsOmnichainIncreaseBalanceHandler()

Error thrown when the contract is not registered as an Omnichain Increase Balance handler

_isRegisteredAsOmnichainIncreaseBalanceHandler

bool _isRegisteredAsOmnichainIncreaseBalanceHandler

Variable to know if the contract is registered as an Omnichain Increase Balance handler

constructor

constructor(bytes32 datapoint_, address _dataIndex, address _fungibleFractionsDO, string name_, string symbol_) public

registerOmnichainIncreaseBalanceHandler

function registerOmnichainIncreaseBalanceHandler() external

Function to register this contract as an omnichain increase balance handler NOTE: This function must be called after the contract is deployed

afterOmnichainFungibleFractionsIncreaseBalanceOnTargetChain

function afterOmnichainFungibleFractionsIncreaseBalanceOnTargetChain(OmnichainAddress from, address to, uint256 id, uint256 value) public virtual returns (bool)

Function called after a token transfer on target chain

Verifies success of transfer (if to is a contract, additional calls verifying it can accept tokens can be made)

Parameters

NameTypeDescription
fromOmnichainAddressThe address from which the token was transferred
toaddressThe address to which the token was transferred
iduint256Id of the token
valueuint256The amount of the token transferred

Return Values

NameTypeDescription
[0]boolIf transfer verification successfull

afterOmnichainFungibleFractionsIncreaseBalanceOnTargetChain

function afterOmnichainFungibleFractionsIncreaseBalanceOnTargetChain(OmnichainAddress from, address to, uint256[] ids, uint256[] values) public virtual returns (bool)

Function called after a batch token transfer on target chain

Verifies success of transfer (if to is a contract, additional calls verifying it can accept tokens can be made)

Parameters

NameTypeDescription
fromOmnichainAddressThe address from which the token was transferred
toaddressThe address to which the token was transferred
idsuint256[]Ids of the tokens
valuesuint256[]The amounts of the tokens transferred

Return Values

NameTypeDescription
[0]boolIf transfer verification successfull

afterOmnichainFungibleFractionsFailedRefund

function afterOmnichainFungibleFractionsFailedRefund(OmnichainAddress, OmnichainAddress to, address, uint256[] ids, uint256[] values) public virtual

Function called if normal token refund procedure failed and balance of this contract (the one which is called) is increased

Parameters

NameTypeDescription
OmnichainAddress
toOmnichainAddressThe address to which the token was originally transferred
address
idsuint256[]Ids of the tokens
valuesuint256[]The amounts of the tokens transferred

recoverTokens

function recoverTokens(address to, uint256[] ids, uint256[] values) external virtual

Allows contract owner to transfer tokens which was sent to this contract Can be used to recover failed refunds

If onERC1155Received will be added in an overriding contract, it should also override this function and maybe afterOmnichainFungibleFractionsFailedRefund to implement more sophisticated refund mechanics.

Parameters

NameTypeDescription
toaddressDestination address
idsuint256[]Array of token IDs
valuesuint256[]Array of amounts of tokens to transfer

_writeTransfer

function _writeTransfer(address from, OmnichainAddress to, uint256 id, uint256 value, address payable refundAddress) internal virtual

_writeTransferBatch

function _writeTransferBatch(address from, OmnichainAddress to, uint256[] ids, uint256[] values, address payable refundAddress) internal virtual