ODCdataManagersERC1155linked-with-erc20-dm-with-callback

ERC1155WithERC20FractionsWithCallbackDataManager

Contract for managing ERC1155 token with ERC20 fractions with Callback

This contract extends ERC1155DataManager and adds integration for ERC20 fractions with Callback, setting this contract as the callback handler for all the ids. The deployed ERC20FractionWithCallbackDataManagers are set as the callback handlers for they respective token IDs

IncorrectId

error IncorrectId(uint256 id)

Error thrown when the ID is zero

WrongCaller

error WrongCaller()

Error thrown when the caller is not the fungible fractions data object

BatchOperationNotSupported

error BatchOperationNotSupported()

Error thrown when the Batch mint is called

ERC20FractionDataManagerDeployed

event ERC20FractionDataManagerDeployed(uint256 id, address dm)

Event emitted when an ERC20 Fraction Data Manager is deployed

AllIdFungibleFractionTransferCallbackRegistered

event AllIdFungibleFractionTransferCallbackRegistered()

Event emitted when all ID fungible fraction transfer callback is registered

AllIdFungibleFractionTransferCallbackUnregistered

event AllIdFungibleFractionTransferCallbackUnregistered()

Event emitted when all ID fungible fraction transfer callback is unregistered

fractionManagersById

mapping(uint256 => address) fractionManagersById

Mapping of ERC20 Fraction Data Managers by ID

onlyFFDO

modifier onlyFFDO()

Modifier to check if the caller is the fungible fractions data object

constructor

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

registerAllIdFungibleFractionTransferCallback

function registerAllIdFungibleFractionTransferCallback() external

Register transfer callback for all IDs

This function must be called right after the constructor. Otherwise, afterFungibleFractionTransfer will not be called for any transfer. NOTE: If data manager is not approved, this function will revert

mint

function mint(address to, uint256 id, uint256 value, bytes data) public

Mint new tokens

Parameters

NameTypeDescription
toaddressThe address to mint tokens to
iduint256The token ID
valueuint256The amount of tokens to mint
databytesAdditional data with no specified format

batchMint

function batchMint(address, uint256[], uint256[], bytes) public pure

Batch mint not supported

afterFungibleFractionTransfer

function afterFungibleFractionTransfer(address from, address to, uint256 id, uint256 value) external

Function to be called after a fungible fraction transfer

afterFungibleFractionTransfer

function afterFungibleFractionTransfer(address from, address to, uint256[] ids, uint256[] values) external

Function to be called after a fungible fraction transfer batch

_update

function _update(address from, address to, uint256 id, uint256 value) internal virtual

_Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from (or to) is the zero address.

Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.

Requirements:

  • If to refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
  • ids and values must have the same length.

NOTE: The ERC-1155 acceptance check is not performed in this function. See {updateWithAcceptanceCheck} instead.

_update

function _update(address from, address to, uint256[] ids, uint256[] values) internal virtual

_Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from (or to) is the zero address.

Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.

Requirements:

  • If to refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
  • ids and values must have the same length.

NOTE: The ERC-1155 acceptance check is not performed in this function. See {updateWithAcceptanceCheck} instead. NOTE: Array length check is not performed in this function and must be performed in the caller

_deployERC20DMIfNotDeployed

function _deployERC20DMIfNotDeployed(uint256 id) internal