RainterpreterStoreNPE2
Inherits: IInterpreterStoreV2, ERC165
Simplest possible IInterpreterStoreV2
that could work.
Takes key/value pairings from the input array and stores each in an internal
mapping. StateNamespace
is fully qualified only by msg.sender
on set and
doesn't attempt to do any deduping etc. if the same key appears twice it will
be set twice.
State Variables
sStore
Store is several tiers of sandbox.
0. Address hashed into FullyQualifiedNamespace
is msg.sender
so that
callers cannot attack each other
- StateNamespace is caller-provided namespace so that expressions cannot attack each other
uint256
is expression-provided keyuint256
is expression-provided value tiers 0 and 1 are both embodied in theFullyQualifiedNamespace
.
mapping(FullyQualifiedNamespace fullyQualifiedNamespace => mapping(uint256 key => uint256 value)) internal sStore;
Functions
supportsInterface
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool);
set
Mutates the interpreter store in bulk. The bulk values are provided in
the form of a uint256[]
which can be treated e.g. as pairwise keys and
values to be stored in a Solidity mapping. The IInterpreterStoreV2
defines the meaning of the uint256[]
for its own storage logic.
function set(StateNamespace namespace, uint256[] calldata kvs) external virtual;
Parameters
Name | Type | Description |
---|---|---|
namespace | StateNamespace | The unqualified namespace for the set that MUST be fully qualified by the IInterpreterStoreV2 to prevent key collisions between callers. The fully qualified namespace forms a compound key with the keys for each value to set. |
kvs | uint256[] | The list of changes to apply to the store's internal state. |
get
This would be picked up by an out of bounds index below, but it's nice to have a more specific error message.
function get(FullyQualifiedNamespace namespace, uint256 key) external view virtual returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
namespace | FullyQualifiedNamespace | The fully qualified namespace to get a single value for. |
key | uint256 | The key to get the value for within the namespace. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The value OR ZERO IF NOT SET. |