@midnight-ntwrk/compact-runtime v0.7.0 • Readme | API
@midnight-ntwrk/compact-runtime v0.7.0 / StateValue
Class: StateValue
Represents the core of a contract's state, and recursively represents each of its components.
There are different classes of state values:
null
- Cells of AlignedValues
- Maps from AlignedValues to state values
- Bounded Merkle trees containing AlignedValue leaves
- Short (<= 15 element) arrays of state values
State values are immutable, any operations that mutate states will return a new state instead.
Constructors
new StateValue()
private new StateValue(): StateValue
Returns
Methods
arrayPush()
arrayPush(value): StateValue
Parameters
• value: StateValue
Returns
asArray()
asArray(): undefined | StateValue[]
Returns
undefined
| StateValue
[]
asBoundedMerkleTree()
asBoundedMerkleTree(): undefined | StateBoundedMerkleTree
Returns
undefined
| StateBoundedMerkleTree
asCell()
asCell(): AlignedValue
Returns
asMap()
asMap(): undefined | StateMap
Returns
undefined
| StateMap
encode()
Internal
encode(): EncodedStateValue
Returns
EncodedStateValue
logSize()
logSize(): number
Returns
number
toString()
toString(compact?): string
Parameters
• compact?: boolean
Returns
string
type()
type():
| "map"
| "null"
| "cell"
| "array"
| "boundedMerkleTree"
Returns
| "map"
| "null"
| "cell"
| "array"
| "boundedMerkleTree"
decode()
Internal
static decode(value): StateValue
Parameters
• value: EncodedStateValue
Returns
newArray()
static newArray(): StateValue
Returns
newBoundedMerkleTree()
static newBoundedMerkleTree(tree): StateValue
Parameters
• tree: StateBoundedMerkleTree
Returns
newCell()
static newCell(value): StateValue
Parameters
• value: AlignedValue
Returns
newMap()
static newMap(map): StateValue
Parameters
• map: StateMap
Returns
newNull()
static newNull(): StateValue