ODCdataobjects

FungibleFractionsDO

DataObject with base funtionality of Fungible Fractions (Can be used for ERC1155-Compatible DataManagers)

_This contract exposes base functionality of Fungible Fraction tokens, including balanceOf, totalSupply, exists, transferFrom, mint, burn and their batch variants. It also implements the IDODataTransfer interface to handle the transfer of DataPoint data between diids (transfering the balances of the tokens to a different diid if target is empty)

 NOTE: This contract is expected to be used by a DataManager contract, which could
 implement a fungible token interface and provide more advanced features like approvals,
 access control, metadata management, etc. As may be an ERC1155 token.

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

InsufficientBalance

error InsufficientBalance(bytes32 diid, uint256 id, uint256 balance, uint256 value)

Error thrown when the balance is insufficient

Parameters

NameTypeDescription
diidbytes32The Data index id of the user
iduint256The id of the token
balanceuint256The current balance
valueuint256The requested amount

InsufficientTotalSupply

error InsufficientTotalSupply(uint256 id, uint256 totalSupply, uint256 value)

Error thrown when the total supply is insufficient

Parameters

NameTypeDescription
iduint256The id of the token
totalSupplyuint256The current total supply
valueuint256The requested amount NOTE: This should never happen because we've already checked "from" balance

ArrayLengthMismatch

error ArrayLengthMismatch()

Error thrown when the params length mismatch

TransferConflict

error TransferConflict()

Error thrown when there is a conflict in the transfer

DpData

Data structure for storing Fungible Fractions data

Parameters

NameTypeDescription
struct DpData {
  uint256 totalSupplyAll;
  mapping(uint256 => uint256) totalSupply;
}

DiidData

Data structure for storing Fungible Fractions data of a user

Parameters

NameTypeDescription
struct DiidData {
  struct EnumerableSet.UintSet ids;
  mapping(uint256 => uint256) balances;
}

onDataPointTransfer

function onDataPointTransfer(DataPoint dp, bytes32 fromDiid, bytes32 toDiid) external virtual

Transfers data from one id to another

Access to this function MUST be protected and allowed only for Data Index Implementation registered for this DataPoint NOTE: Transfers using this function will skip hook functions on the Data Manager, disable it if required

Parameters

NameTypeDescription
dpDataPointIdentifier of the DataPoint
fromDiidbytes32ID to transfer from
toDiidbytes32ID to transfer to

_dispatchRead

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

_dispatchWrite

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

_balanceOf

function _balanceOf(DataPoint dp, address account, uint256 id) internal view returns (uint256)

Function used to get the balance of an account

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
accountaddressThe account address
iduint256The id of the token

Return Values

NameTypeDescription
[0]uint256The balance of the account

_balanceOfBatch

function _balanceOfBatch(DataPoint dp, address account, uint256[] ids) internal view returns (uint256[] balances)

Function used to get the balance of an account

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
accountaddressThe account address
idsuint256[]The ids of the tokens

Return Values

NameTypeDescription
balancesuint256[]The balance of the account

_balanceOfBatchAccounts

function _balanceOfBatchAccounts(DataPoint dp, address[] accounts, uint256[] ids) internal view returns (uint256[] balances)

Function used to get the balance of multiple accounts

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
accountsaddress[]The account addresses
idsuint256[]The ids of the tokens

Return Values

NameTypeDescription
balancesuint256[]The balance of the accounts

_totalSupply

function _totalSupply(DataPoint dp, uint256 id) internal view returns (uint256)

Function used to get the total supply of a token

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
iduint256The id of the token

Return Values

NameTypeDescription
[0]uint256The total supply of the token

_totalSupplyAll

function _totalSupplyAll(DataPoint dp) internal view returns (uint256)

Function used to get the total supply of all ids tokens

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier

Return Values

NameTypeDescription
[0]uint256The total supply of all ids tokens

_exists

function _exists(DataPoint dp, uint256 id) internal view returns (bool)

Function used to check if an id exists

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
iduint256The id of the token

Return Values

NameTypeDescription
[0]boolTrue if the id exists, false otherwise

_transferFrom

function _transferFrom(DataPoint dp, address from, address to, uint256 id, uint256 value) internal virtual

Function used to transfer tokens from one account to another

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
fromaddressThe account to transfer from
toaddressThe account to transfer to
iduint256The id of the token
valueuint256The amount of tokens to transfer

_mint

function _mint(DataPoint dp, address to, uint256 id, uint256 value) internal virtual

Function used to mint tokens

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
toaddressThe account to mint to
iduint256The id of the token
valueuint256The amount of tokens to mint

_burn

function _burn(DataPoint dp, address from, uint256 id, uint256 value) internal virtual

Function used to burn tokens

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
fromaddressThe account to burn from
iduint256The id of the token
valueuint256The amount of tokens to burn

_batchTransferFrom

function _batchTransferFrom(DataPoint dp, address from, address to, uint256[] ids, uint256[] values) internal virtual

Function used to transfer multiple tokens from one account to another at once

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
fromaddressThe account to transfer from
toaddressThe account to transfer to
idsuint256[]The ids of the tokens
valuesuint256[]The amounts of tokens to transfer

_batchMint

function _batchMint(DataPoint dp, address to, uint256[] ids, uint256[] values) internal virtual

Function used to mint multiple tokens at once

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
toaddressThe account to mint to
idsuint256[]The ids of the tokens
valuesuint256[]The amounts of tokens to mint

_batchBurn

function _batchBurn(DataPoint dp, address from, uint256[] ids, uint256[] values) internal virtual

Operation used to burn multiple tokens at once

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
fromaddressThe account to burn from
idsuint256[]The ids of the tokens
valuesuint256[]The amounts of tokens to burn

_increaseBalance

function _increaseBalance(struct FungibleFractionsDO.DiidData diidd, uint256 id, uint256 value, DataPoint, bytes32) internal

_decreaseBalance

function _decreaseBalance(struct FungibleFractionsDO.DiidData diidd, uint256 id, uint256 value, DataPoint, bytes32 diidFrom) internal

_onDataPointTransfer

function _onDataPointTransfer(DataPoint dp, bytes32 fromDiid, bytes32 toDiid) internal

_dpData

function _dpData(DataPoint dp) internal returns (struct FungibleFractionsDO.DpData)

_diidData

function _diidData(DataPoint dp, bytes32 diid) internal returns (struct FungibleFractionsDO.DiidData)

_tryDpData

function _tryDpData(DataPoint dp) internal view returns (bool, struct FungibleFractionsDO.DpData)

_tryDiidData

function _tryDiidData(DataPoint dp, bytes32 diid) internal view returns (bool, struct FungibleFractionsDO.DiidData)