ODCdataobjects

BaseDataObject

Base contract for DataObject implementations

This contract provides the basic storage of DataPoint data as identifiers and associated Data Index implementation. It also provides internal functions for DataObjects to manage the DataPoint data and the read and write functionality for Data Index implementations to interact with the DataObject

IncorrectDataIndexImplementationAddress

error IncorrectDataIndexImplementationAddress(address dataIndexImpl)

Error thrown when the proposed address is not the Data Index implementation

Parameters

NameTypeDescription
dataIndexImpladdressThe Data Index implementation

DataIndexImplementationNotSet

error DataIndexImplementationNotSet(DataPoint dp)

Error thrown when there is no DataIndex implementation for a DataPoint

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier

InvalidCaller

error InvalidCaller(DataPoint dp, address sender)

Error thrown when the msg.sender is not the expected caller

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
senderaddressThe msg.sender address

DiidDataUnavailable

error DiidDataUnavailable(DataPoint dp, bytes32 diid)

Error thrown when the DiidData is not found

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
diidbytes32The user Data Index id

NativePaymentNotSupported

error NativePaymentNotSupported()

Error thrown when the native payment is not supported

WrongOperationArguments

error WrongOperationArguments()

Error thrown when the operation arguments are wrong

UnknownReadOperation

error UnknownReadOperation(bytes4 selector)

Error thrown when the read operation is unknown

Parameters

NameTypeDescription
selectorbytes4The operation selector

UnknownWriteOperation

error UnknownWriteOperation(bytes4 selector)

Error thrown when the write operation is unknown

Parameters

NameTypeDescription
selectorbytes4The operation selector

DefaultDataIndexImplementationSet

event DefaultDataIndexImplementationSet(address dataIndexImplementation)

Event emitted when default Data Index implementation is set

Parameters

NameTypeDescription
dataIndexImplementationaddressThe Data Index implementation address

DataIndexImplementationSet

event DataIndexImplementationSet(DataPoint dp, address dataIndexImplementation)

Event emitted when the Data Index implementation is set

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier
dataIndexImplementationaddressThe Data Index implementation address

DataPointStorage

Data structure to store DataPoint data

Parameters

NameTypeDescription
struct DataPointStorage {
  contract IDataIndex dataIndexImplementation;
  uint256 dpDataIndex;
  mapping(bytes32 => uint256) diidDataIndexes;
}

defaultDataIndex

contract IDataIndex defaultDataIndex

DataIndex implementation to be used if none is set for DataPoint. Zero address is valid and prevents usage of such DataPoints

onlyDataIndex

modifier onlyDataIndex(DataPoint dp)

Modifier to check if the caller is the Data Index implementation which is set for the DataPoint, or the default one.

Parameters

NameTypeDescription
dpDataPointThe DataPoint identifier

constructor

constructor() internal

setDefaultDataIndexImplementation

function setDefaultDataIndexImplementation(address newImpl) external

Set default DataIndex implementation, which should be used if none is set for a DataPoint

NOTE: zero address is valid and can be used to dissalow usage of such DataPoints

Parameters

NameTypeDescription
newImpladdressAddress DataIndex implementations

setDataIndexImplementation

function setDataIndexImplementation(DataPoint dp, address newImpl) external

This function SHOULD be called by the Data Index Implementation OR DataPoint Admin

Initializes DataPoint with provided Data Index implementation or changes current implementation to another one

Parameters

NameTypeDescription
dpDataPointDataPoint to work with
newImpladdressNew Data Index Implementation

read

function read(DataPoint dp, bytes4 operation, bytes data) external view returns (bytes)

Reads stored data

Parameters

NameTypeDescription
dpDataPointIdentifier of the DataPoint
operationbytes4Read operation to execute on the data
databytesOperation-specific data

Return Values

NameTypeDescription
[0]bytesOperation-specific data

write

function write(DataPoint dp, bytes4 operation, bytes data) external payable returns (bytes)

Stores data

Access to this function MUST be protected and allowed only for Data Index Implementation registered for this DataPoint

Parameters

NameTypeDescription
dpDataPointIdentifier of the DataPoint
operationbytes4Write operation to execute on the data
databytesOperation-specific data

Return Values

NameTypeDescription
[0]bytesOperation-specific data (can be empty)

withdrawNativeBalance

function withdrawNativeBalance() external

Function to withdraw locked native balance

_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)

_setDataIndexImplementation

function _setDataIndexImplementation(DataPoint dp, address newImpl, struct BaseDataObject.DataPointStorage dps) internal

_dataIndex

function _dataIndex(DataPoint dp) internal view returns (contract IDataIndex)

_tryDataIndex

function _tryDataIndex(DataPoint dp) internal view returns (bool success, contract IDataIndex)

_diid

function _diid(DataPoint dp, address account) internal view returns (bytes32)

_tryDiid

function _tryDiid(DataPoint dp, address account) internal view returns (bytes32)

_dpDataIndex

function _dpDataIndex(DataPoint dp) internal returns (uint256 dpDataIdx)

_tryDpDataIndex

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

Returns 0 if index is not created

_diidDataIndex

function _diidDataIndex(DataPoint dp, bytes32 diid) internal returns (uint256 diidDataIdx)

_diidHasData

function _diidHasData(DataPoint dp, bytes32 diid) internal view returns (bool)

_moveDataIndexIfTargetEmpty

function _moveDataIndexIfTargetEmpty(DataPoint dp, bytes32 diidFrom, bytes32 diidTo, bool allowEmptyFrom) internal returns (bool)

_tryDiidDataIndex

function _tryDiidDataIndex(DataPoint dp, bytes32 diid) internal view returns (uint256)

Returns 0 if index is not created

_requireDataIndexImplIsValid

function _requireDataIndexImplIsValid(address dataIndexImpl) internal view virtual

_isDataPointAdmin

function _isDataPointAdmin(DataPoint dp, address account) internal view returns (bool)

_handleNativePaymentInWrite

function _handleNativePaymentInWrite() internal virtual

Override this function to support native coin payment for write() call

_dataPointStorage

function _dataPointStorage(DataPoint dp) internal view returns (struct BaseDataObject.DataPointStorage)