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.
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()
andwrite()
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);
Description | Parameters | Returns | Modifiers |
---|---|---|---|
Verifies if Data Manager is allowed to write in a specific Data Point | dp : Identifier of the Data Pointdm : Address of Data Manager | Boolean indicating if write access is allowed | external view |
2. allowDataManager()
function allowDataManager(DataPoint dp, address dm, bool approved) external;
Description | Parameters | Returns | Modifiers |
---|---|---|---|
Defines if Data Manager is allowed to write in specific Data Point | dp : Identifier of the Data Pointdm : Address of Data Managerapproved : If Data Manager should be approved for the Data Point | None | external |
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);
Description | Parameters | Returns | Modifiers |
---|---|---|---|
Reads stored data | dobj : Identifier of Data Objectdp : Identifier of the Data Pointoperation : Read operation to execute on the datadata : Operation-specific data | Operation-specific data | external view |
4. write()
function write(address dobj, DataPoint dp, bytes4 operation, bytes calldata data) external returns (bytes memory);
Description | Parameters | Returns | Modifiers |
---|---|---|---|
Stores data | dobj : Identifier of Data Objectdp : Identifier of the Data Pointoperation : Write operation to execute on the datadata : 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);
Description | Parameters | Returns | Modifiers |
---|---|---|---|
Generates an ID | account : Address to derive the ID | ID as bytes32 | external , pure |
6. ownerOf()
function ownerOf(bytes32 diid_) external view returns (uint32, address);
Description | Parameters | Returns | Modifiers |
---|---|---|---|
Retrieves ownership | diid_ : Identifier of the account | Chain ID and address | external , view |
More details on access control and the Data Index Reference Implementation can be found in the Data Index Reference Implementation.