ODCdataobjects

NonFungibleTokenDO

DataObject to interact with non-fungible tokens

This contract is used to manage non-fungible tokens where a Data Object contract is used to store the token data

InsufficientBalance

error InsufficientBalance(bytes32 diid, uint256 currentBalance, uint256 balance, uint256 tokenId)

Error thrown when the balance is insufficient

Parameters

NameTypeDescription
diidbytes32The owner identifier
currentBalanceuint256The current balance of the owner
balanceuint256The balance to decrease
tokenIduint256The token id

ArrayLengthMismatch

error ArrayLengthMismatch()

Error thrown when the params length mismatch

InvalidBatchOrder

error InvalidBatchOrder()

Error thrown when tokens are sent out of order

TokenAlreadyExists

error TokenAlreadyExists(uint256 tokenId)

Error thrown when the token to mint already exists

Parameters

NameTypeDescription
tokenIduint256The token id

TokenNotOwned

error TokenNotOwned(uint256 tokenId)

Error thrown when the token to burn is not owned by the account

Parameters

NameTypeDescription
tokenIduint256The token id

DpData

Data structure for Non Fungible Token data

Parameters

NameTypeDescription
struct DpData {
  mapping(uint256 => address) owners;
}

DiidData

Data structure for Non Fungible Token owner data

Parameters

NameTypeDescription
struct DiidData {
  uint256 balance;
}

constructor

constructor() public

onDataPointTransfer

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

Transfers data from one id to another

onDataPointTransfer in this implementation does nothing

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

_balanceOf

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

Operation used to get the balance of an account

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
accountaddressThe account address

Return Values

NameTypeDescription
[0]uint256The balance of the account

_ownerOf

function _ownerOf(DataPoint dp, uint256 tokenId) internal view returns (address)

Operation used to get the owner of a token

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
tokenIduint256The token id

Return Values

NameTypeDescription
[0]addressThe owner of the token

_mint

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

Operation used to mint new token

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
toaddressThe account address to mint the token to
tokenIduint256The tokenId of token to mint

_burn

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

Operation used to burn a token

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to burn the token from
tokenIduint256The tokenId of token to burn

_transferFrom

function _transferFrom(DataPoint dp, address from, address to, uint256 tokenId) internal

Operation used to transfer token

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to transfer the token from
toaddressThe account address to transfer the token to
tokenIduint256The tokenId of token to transfer

_batchTransferFrom

function _batchTransferFrom(DataPoint dp, address from, address to, uint256[] tokenIds) internal

Operation used to transfer batch of tokens

If the balance is insufficient, the operation will revert with tokenId 0 and not the actual tokenId that caused the error, to save gas

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to transfer the tokens from
toaddressThe account address to transfer the tokens to
tokenIdsuint256[]The tokenIds of tokens to transfer

_batchTransferFrom

function _batchTransferFrom(DataPoint dp, address from, address[] to, uint256[] tokenIds) internal

Operation used to transfer batch of tokens

If the balance is insufficient, the operation will revert with tokenId 0 and not the actual tokenId that caused the error, to save gas NOTE: The token ids array MUST have at least 2 elements and all elements MUST be in ASCENDING order

Parameters

NameTypeDescription
dpDataPointDataPoint identifier
fromaddressThe account address to transfer the tokens from
toaddress[]The accounts addresses to transfer the tokens to
tokenIdsuint256[]The tokenIds of tokens to transfer

_increaseBalance

function _increaseBalance(struct NonFungibleTokenDO.DiidData diidd, DataPoint, bytes32, uint256 balance) internal

_decreaseBalance

function _decreaseBalance(struct NonFungibleTokenDO.DiidData diidd, DataPoint, bytes32 diidFrom, uint256 balance, uint256 tokenId) internal

_dpData

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

_diidData

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

_tryDpData

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

_tryDiidData

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