@proto-kit/protocol β€’ Docs


Documentation / @proto-kit/protocol / State

Class: State<Value>

Utilities for runtime module state, such as get/set

Extends

Type Parameters

β€’ Value

Constructors

new State()

new State<Value>(valueType): State<Value>

Parameters

β€’ valueType: FlexibleProvablePure<Value>

Returns

State<Value>

Overrides

Mixin(WithPath, WithStateServiceProvider).constructor

Defined in

packages/protocol/src/state/State.ts:54

Properties

path?

optional path: Field

Inherited from

Mixin(WithPath, WithStateServiceProvider).path

Defined in

packages/protocol/src/state/State.ts:15


stateServiceProvider?

optional stateServiceProvider: StateServiceProvider

Inherited from

Mixin(WithPath, WithStateServiceProvider).stateServiceProvider

Defined in

packages/protocol/src/state/State.ts:27


valueType

valueType: FlexibleProvablePure<Value>

Defined in

packages/protocol/src/state/State.ts:54

Methods

get()

get(): Promise<Option<Value>>

Retrieves the current state and creates a state transition anchoring the use of the current state value in the circuit.

Returns

Promise<Option<Value>>

Option representation of the current state.

Defined in

packages/protocol/src/state/State.ts:136


hasPathOrFail()

hasPathOrFail(): asserts this is Object

Returns

asserts this is Object

Inherited from

Mixin(WithPath, WithStateServiceProvider).hasPathOrFail

Defined in

packages/protocol/src/state/State.ts:17


hasStateServiceOrFail()

hasStateServiceOrFail(): asserts this is Object

Returns

asserts this is Object

Inherited from

Mixin(WithPath, WithStateServiceProvider).hasStateServiceOrFail

Defined in

packages/protocol/src/state/State.ts:29


set()

set(value): Promise<void>

Sets a new state value by creating a state transition from the current value to the newly set value.

The newly set value isn’t available via state.get(), since the state transitions are not applied within the same circuit. You can however store and access your new value in a separate circuit variable.

Parameters

β€’ value: Value

Value to be set as the current state

Returns

Promise<void>

Defined in

packages/protocol/src/state/State.ts:167


from()

static from<Value>(valueType): State<Value>

Creates a new state wrapper for the provided value type.

Type Parameters

β€’ Value

Parameters

β€’ valueType: FlexibleProvablePure<Value>

Type of value to be stored (e.g. UInt64, Struct, …)

Returns

State<Value>

New state for the given value type.

Defined in

packages/protocol/src/state/State.ts:50