ODCdataobjects

FungibleTokenDO

DataObject with base functionality of a fungible token

_This contract exposes base functionality of a fungible token, allowing to mint, burn, transfer (single and batch), check balances and total supply It also implements the IDODataTransfer interface to handle the transfer of DataPoint data between diids (Transfering the balance of an diid to another diid)

 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 ERC20 or ERC777 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 balance, uint256 amount)

Error thrown when the balance is insufficient

Parameters

NameTypeDescription
diidbytes32The owner identifier
balanceuint256The current balance
amountuint256The requested amount

InsufficientTotalSupply

error InsufficientTotalSupply(uint256 totalSupply, uint256 amount)

Error thrown when the total supply is insufficient

Parameters

NameTypeDescription
totalSupplyuint256The current total supply
amountuint256The requested amount NOTE: This should never happen because we've already checked "from" balance

ArrayLengthMismatch

error ArrayLengthMismatch()

Error thrown when the params length mismatch

DpData

Data structure for Fungible Token data

Parameters

NameTypeDescription
struct DpData {
  uint256 totalSupply;
}

DiidData

Data structure for Data Index id data

Parameters

NameTypeDescription
struct DiidData {
  uint256 balance;
}

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 returns (bytes)

_dispatchWrite

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

_balanceOf

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

Function used to get the balance of an account

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
accountaddressThe account address

Return Values

NameTypeDescription
[0]uint256The balance of the account

_totalSupply

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

Function used to get the total supply of the token

Parameters

NameTypeDescription
dpDataPointDataPoint identifier

Return Values

NameTypeDescription
[0]uint256The total supply of the token

_mint

function _mint(DataPoint dp, address to, uint256 amount) internal

Function used to mint new tokens

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
toaddressThe account address to mint the tokens to
amountuint256The amount of tokens to mint

_burn

function _burn(DataPoint dp, address from, uint256 amount) internal

Function used to burn tokens

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to burn the tokens from
amountuint256The amount of tokens to burn

_transfer

function _transfer(DataPoint dp, address from, address to, uint256 amount) internal

Function used to transfer tokens

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to transfer the tokens from
toaddressThe account address to transfer the tokens to
amountuint256The amount of tokens to transfer

_transferBatch

function _transferBatch(DataPoint dp, address from, address[] to, uint256 amount) internal

Function used to transfer tokens to multiple targets

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to transfer the tokens from
toaddress[]The account addresses to transfer the tokens to
amountuint256The amount of tokens to transfer to each target

_transferBatch

function _transferBatch(DataPoint dp, address from, address[] to, uint256[] amount) internal

Function used to transfer tokens to multiple targets with different amounts

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to transfer the tokens from
toaddress[]The account addresses to transfer the tokens to
amountuint256[]The amounts of tokens to transfer

_transferBatch

function _transferBatch(DataPoint dp, address[] from, address[] to, uint256[] amount) internal

Function used to transfer tokens to multiple targets independently

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddress[]The account addresses to transfer the tokens from
toaddress[]The account addresses to transfer the tokens to
amountuint256[]The amounts of tokens to transfer

_onDataPointTransfer

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

This function transfers the token balance of the fromDiid to the toDiid

_dpData

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

_diidData

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

_tryDpData

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

_tryDiidData

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