Skip to main content

IDataIndex

What is a Data Index?

Data Index serves as the access control layer for interactions between Data Managers and Data Points. It defines and manages the permissions that determine which Data Managers are authorized to read or write data for specific Data Points within the Data Objects.

When a Data Manager attempts to perform operations (read or write) on a Data Point, the Data Index verifies whether the Data Manager has the necessary permissions. This validation prevents unauthorized changes, preserving the integrity of the asset data. Additionally, the Data Index can execute specific read or write operations on the data stored in the Data Objects associated with the Data Points.

Data Index

Fig 1. DataIndex mediating between DataManager and DataObject

Data Managers request permission from the Data Index to write asset data. The Data Index verifies whether each Data Manager is authorized to interact with specific Data Points. If approved, it grants access, allowing the Data Managers to proceed with their operations.

Note that the read function is provided to have unified interface to access data, but in gas-usage-sensitive applixations it's advised to read directly from the DataObject.

Interface

The interface of the Data Index can be divided into two main parts:

  • Methods for managing permissions: These methods allow for granting and checking approved Data Managers for a Data Point or adding admin roles to other Data Managers for a Data Point. They might look like this:
    /**
* @notice Defines if DataManager is allowed to write in specific DataPoint
* @param dp Identifier of the DataPoint
* @param dm Address of DataManager
* @param approved if DataManager should be approved for the DataPoint
* @dev Function SHOULD be restricted to DataPoint maintainer only
*/
function allowDataManager(DataPoint dp, address dm, bool approved) external;
  • Methods for forwarding read() and write() operations:
    /**
* @notice Reads stored data
* @param dobj Identifier of DataObject
* @param dp Identifier of the DataPoint
* @param operation Read operation to execute on the data
* @param data Operation-specific data
* @return Operation-specific data
*/
function read(address dobj, DataPoint dp, bytes4 operation, bytes calldata data) external view returns (bytes memory);

Methods

1. isApprovedDataManager()

function isApprovedDataManager(DataPoint dp, address dm) external view returns (bool);
DescriptionParametersReturnsModifiers
Verifies if Data Manager is allowed to write in a specific Data Pointdp: Identifier of the Data Point
dm: Address of Data Manager
Boolean indicating if write access is allowedexternal
view

2. allowDataManager()

function allowDataManager(DataPoint dp, address dm, bool approved) external;
DescriptionParametersReturnsModifiers
Defines if Data Manager is allowed to write in specific Data Pointdp: Identifier of the Data Point
dm: Address of Data Manager
approved: If Data Manager should be approved for the Data Point
Noneexternal

Note: This function SHOULD be restricted to Data Point maintainer only.

3. read()

function read(address dobj, DataPoint dp, bytes4 operation, bytes calldata data) external view returns (bytes memory);
DescriptionParametersReturnsModifiers
Reads stored datadobj: Identifier of Data Object
dp: Identifier of the Data Point
operation: Read operation to execute on the data
data: Operation-specific data
Operation-specific dataexternal
view

4. write()

function write(address dobj, DataPoint dp, bytes4 operation, bytes calldata data) external returns (bytes memory);
DescriptionParametersReturnsModifiers
Stores datadobj: Identifier of Data Object
dp: Identifier of the Data Point
operation: Write operation to execute on the data
data: Operation-specific data
Operation-specific data (can be empty)external

Note: This function SHOULD be restricted to allowed Data Managers only.

5. diid()

function diid(address account, DataPoint) external pure returns (bytes32);
DescriptionParametersReturnsModifiers
Generates an IDaccount: Address to derive the IDID as bytes32external, pure

6. ownerOf()

function ownerOf(bytes32 diid_) external view returns (uint32, address);
DescriptionParametersReturnsModifiers
Retrieves ownershipdiid_: Identifier of the accountChain ID and addressexternal, view
note

More details on access control and the Data Index Reference Implementation can be found in the Data Index Reference Implementation.