Skip to main content
Version: v1.3_alpha

StateLeaf

Notice

A leaf in the state tree, which maps public keys to voice credit balances

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new StateLeaf(pubKey, voiceCreditBalance, timestamp): StateLeaf

Create a new instance of a state leaf

Parameters

NameTypeDescription
pubKeyPubKeythe public key of the user signin up
voiceCreditBalancebigintthe voice credit balance of the user
timestampbigintthe timestamp of when the user signed-up

Returns

StateLeaf

Defined in

stateLeaf.ts:25

Properties

pubKey

pubKey: PubKey

Implementation of

IStateLeaf.pubKey

Defined in

stateLeaf.ts:13


timestamp

timestamp: bigint

Defined in

stateLeaf.ts:17


voiceCreditBalance

voiceCreditBalance: bigint

Implementation of

IStateLeaf.voiceCreditBalance

Defined in

stateLeaf.ts:15

Methods

asArray

asArray(): bigint[]

Return this state leaf as an array of bigints

Returns

bigint[]

the state leaf as an array of bigints

Defined in

stateLeaf.ts:79


asCircuitInputs

asCircuitInputs(): bigint[]

Return this state leaf as an array of bigints

Returns

bigint[]

the state leaf as an array of bigints

Defined in

stateLeaf.ts:85


asContractParam

asContractParam(): IStateLeafContractParams

Return this state leaf as a contract param

Returns

IStateLeafContractParams

the state leaf as a contract param (object)

Defined in

stateLeaf.ts:97


copy

copy(): StateLeaf

Crate a deep copy of the object

Returns

StateLeaf

a copy of the state leaf

Defined in

stateLeaf.ts:35


equals

equals(s): boolean

Check if two state leaves are equal

Parameters

NameTypeDescription
sStateLeafthe state leaf to compare with

Returns

boolean

whether they are equal or not

Defined in

stateLeaf.ts:110


hash

hash(): bigint

Hash this state leaf (first convert as array)

Returns

bigint

the has of the state leaf elements

Defined in

stateLeaf.ts:91


serialize

serialize(): string

Serialize the state leaf

Returns

string

Notice

serialize the public key

Notice

convert the voice credit balance and timestamp to a hex string

Defined in

stateLeaf.ts:122


toJSON

toJSON(): IJsonStateLeaf

Serialize to a JSON object

Returns

IJsonStateLeaf

Defined in

stateLeaf.ts:143


deserialize

deserialize(serialized): StateLeaf

Deserialize the state leaf

Parameters

NameTypeDescription
serializedstringthe serialized state leaf

Returns

StateLeaf

a deserialized state leaf

Defined in

stateLeaf.ts:133


fromJSON

fromJSON(json): StateLeaf

Deserialize into a StateLeaf instance

Parameters

NameTypeDescription
jsonIJsonStateLeafthe json representation

Returns

StateLeaf

the deserialized object as a StateLeaf instance

Defined in

stateLeaf.ts:156


genBlankLeaf

genBlankLeaf(): StateLeaf

Generate a blank state leaf

Returns

StateLeaf

a blank state leaf

Defined in

stateLeaf.ts:47


genRandomLeaf

genRandomLeaf(): StateLeaf

Generate a random leaf (random salt and random key pair)

Returns

StateLeaf

a random state leaf

Defined in

stateLeaf.ts:70