EternalStorage¶
Description¶
This is an implementation of the well-known eternal storage smart contract pattern, described in more detail here and here.
In short, it is a key-value store for variables which are retrieved by a byte string, typically a hash of their name and an index.
The contract is architected this way so that the access pattern is uniform and the memory layout is not dependent on implementation or compilation details. In this way, smart contracts can retain state between updates while minimising the difficulty and expense of migrating this information.
Each type of variable has its own mapping, along with getters and setters. As this entails some replication, this document will express functions and variables generically with the type variable 𝕋, where 𝕋 \in {uint
, string
, address
, bytes
, bytes32
, bool
, int
}. This notation is used slightly abusively, standing in for both names and types; in the former case, substitution is in camelCase. More complex types, such as structs and nested mappings, are not supported.
Source: contracts/EternalStorage.sol
Constructor¶
constructor
¶
Initialises the inherited State
instance.
Details
Signature
constructor(address _owner, address _associatedContract)
Visibility
public
State Mutability
``
Views¶
getAddressValue
¶
Details
Signature
getAddressValue(bytes32 record) view returns (address)
Visibility
external
State Mutability
view
getBooleanValue
¶
Details
Signature
getBooleanValue(bytes32 record) view returns (bool)
Visibility
external
State Mutability
view
getBytes32Value
¶
Details
Signature
getBytes32Value(bytes32 record) view returns (bytes32)
Visibility
external
State Mutability
view
getBytesValue
¶
Details
Signature
getBytesValue(bytes32 record) view returns (bytes)
Visibility
external
State Mutability
view
getIntValue
¶
Details
Signature
getIntValue(bytes32 record) view returns (int256)
Visibility
external
State Mutability
view
getStringValue
¶
Details
Signature
getStringValue(bytes32 record) view returns (string)
Visibility
external
State Mutability
view
getUIntValue
¶
Details
Signature
getUIntValue(bytes32 record) view returns (uint256)
Visibility
external
State Mutability
view
Restricted Functions¶
deleteAddressValue
¶
Details
Signature
deleteAddressValue(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
deleteBooleanValue
¶
Details
Signature
deleteBooleanValue(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
deleteBytes32Value
¶
Details
Signature
deleteBytes32Value(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
deleteBytesValue
¶
Details
Signature
deleteBytesValue(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
deleteIntValue
¶
Details
Signature
deleteIntValue(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
deleteStringValue
¶
Details
Signature
deleteStringValue(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
deleteUIntValue
¶
Details
Signature
deleteUIntValue(bytes32 record)
Visibility
external
State Mutability
``
Modifiers
setAddressValue
¶
Details
Signature
setAddressValue(bytes32 record, address value)
Visibility
external
State Mutability
``
Modifiers
setBooleanValue
¶
Details
Signature
setBooleanValue(bytes32 record, bool value)
Visibility
external
State Mutability
``
Modifiers
setBytes32Value
¶
Details
Signature
setBytes32Value(bytes32 record, bytes32 value)
Visibility
external
State Mutability
``
Modifiers
setBytesValue
¶
Details
Signature
setBytesValue(bytes32 record, bytes value)
Visibility
external
State Mutability
``
Modifiers
setIntValue
¶
Details
Signature
setIntValue(bytes32 record, int256 value)
Visibility
external
State Mutability
``
Modifiers
setStringValue
¶
Details
Signature
setStringValue(bytes32 record, string value)
Visibility
external
State Mutability
``
Modifiers
setUIntValue
¶
Details
Signature
setUIntValue(bytes32 record, uint256 value)
Visibility
external
State Mutability
``
Modifiers