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
stateLeaf.ts:25
Properties
pubKey
• pubKey: PubKey
Implementation of
Defined in
stateLeaf.ts:13
timestamp
• timestamp: bigint
Defined in
stateLeaf.ts:17
voiceCreditBalance
• voiceCreditBalance: bigint
Implementation of
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
the state leaf as a contract param (object)
Defined in
stateLeaf.ts:97
copy
▸ copy(): StateLeaf
Crate a deep copy of the object
Returns
a copy of the state leaf
Defined in
stateLeaf.ts:35
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
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
Defined in
stateLeaf.ts:143
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
stateLeaf.ts:133
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
stateLeaf.ts:156
genBlankLeaf
▸ genBlankLeaf(): StateLeaf
Generate a blank state leaf
Returns
a blank state leaf
Defined in
stateLeaf.ts:47
genRandomLeaf
▸ genRandomLeaf(): StateLeaf
Generate a random leaf (random salt and random key pair)
Returns
a random state leaf
Defined in
stateLeaf.ts:70