StateLeaf
Notice
A leaf in the state tree, which maps public keys to voice credit balances
Implements
Table of contents
Constructors
Properties
Methods
- asArray
- asCircuitInputs
- asContractParam
- copy
- equals
- hash
- serialize
- toJSON
- deserialize
- fromJSON
- genBlankLeaf
- genRandomLeaf
Constructors
constructor
• new StateLeaf(pubKey
, voiceCreditBalance
, timestamp
): StateLeaf
Create a new instance of a state leaf
Parameters
Name | Type | Description |
---|---|---|
pubKey | PubKey | the public key of the user signin up |
voiceCreditBalance | bigint | the voice credit balance of the user |
timestamp | bigint | the timestamp of when the user signed-up |
Returns
Defined in
Properties
pubKey
• pubKey: PubKey
Implementation of
Defined in
timestamp
• timestamp: bigint
Defined in
voiceCreditBalance
• voiceCreditBalance: bigint
Implementation of
Defined in
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
asCircuitInputs
▸ asCircuitInputs(): bigint
[]
Return this state leaf as an array of bigints
Returns
bigint
[]
the state leaf as an array of bigints
Defined in
asContractParam
▸ asContractParam(): IStateLeafContractParams
Return this state leaf as a contract param
Returns
the state leaf as a contract param (object)
Defined in
copy
▸ copy(): StateLeaf
Crate a deep copy of the object
Returns
a copy of the state leaf
Defined in
equals
▸ equals(s
): boolean
Check if two state leaves are equal
Parameters
Name | Type | Description |
---|---|---|
s | StateLeaf | the state leaf to compare with |
Returns
boolean
whether they are equal or not
Defined in
hash
▸ hash(): bigint
Hash this state leaf (first convert as array)
Returns
bigint
the has of the state leaf elements
Defined in
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
toJSON
▸ toJSON(): IJsonStateLeaf
Serialize to a JSON object
Returns
Defined in
deserialize
▸ deserialize(serialized
): StateLeaf
Deserialize the state leaf
Parameters
Name | Type | Description |
---|---|---|
serialized | string | the serialized state leaf |
Returns
a deserialized state leaf
Defined in
fromJSON
▸ fromJSON(json
): StateLeaf
Deserialize into a StateLeaf instance
Parameters
Name | Type | Description |
---|---|---|
json | IJsonStateLeaf | the json representation |
Returns
the deserialized object as a StateLeaf instance
Defined in
genBlankLeaf
▸ genBlankLeaf(): StateLeaf
Generate a blank state leaf
Returns
a blank state leaf
Defined in
genRandomLeaf
▸ genRandomLeaf(): StateLeaf
Generate a random leaf (random salt and random key pair)
Returns
a random state leaf