Methods
These are the operations that can be performed on the StateManager contract.
Read Functions
Retrieves the size (length) of the State Manager database.
Returns an array that contains a StateEntry struct for each variable saved in the State Manager.
Pass a range position (start
and offset
) in this function for it to return an array that contains a StateEntry struct for each variable of the range.
Pass an array of keys in this function for it to return an array that contains a StateEntry struct for each variable that corresponds to a key.
Pass an array of indices in this function for it to return an array that contains a StateEntry struct for each variable that corresponds to a key.
An index is a uint256 representing a specific key. This information is saved in the _index
mapping in the StateManager.
Pass a key in this function for it to retrieve:
If that key exists in the StateManager (true) or not (false).
The key's index.
Pass a key in this function for it to return the StateEntry struct that corresponds to the key.
Pass an index in this function for it to returns the StateEntry struct that corresponds to that index.
Write Functions
Pass a StateEntry struct in this function for it to add a new variable to the StateManager.
If the key passed in the struct corresponds to a variable that already exists in the StateManager, it is replaced with the new value. In this case, the function returns the replaced value.
Pass multiple StateEntry structs in this function for it to add new variables to the StateManager.
If the keys passed in the structs correspond to variables that already exist in the StateManager, they are replaced with the new values. In this case, the function returns the replaced values.
Pass a key in this function for it to remove the corresponding variable from the StateManager.
The function returns the removed variable's type (bool, int, uint, string, etc..) and its value.
Pass multiple keys in this function to remove the corresponding variables from the StateManager.
The function returns the removed variables' types (bool, int, uint, string, etc..) and values.
Pass multiple indices in this function to remove the corresponding variables from the StateManager
The output function returns the removed variables' types (bool, int, uint, string etc...) and values.
Note
To avoid side effects or undesired transaction reverts, the array of indices must be passed by force in descending order. For example: If you want to delete the variables at indexes 9, 18 and 13, pass the array ordered as [18, 13, 9]. This will ensure the function behavior is respected correctly.
Last updated