AccountUpdateForest
o1js / Modules / AccountUpdateForest
Class: AccountUpdateForest
Class which represents a forest (list of trees) of account updates, in a compressed way which allows iterating and selectively witnessing the account updates.
The (recursive) type signature is:
type AccountUpdateForest = MerkleList<AccountUpdateTree>;
type AccountUpdateTree = {
accountUpdate: Hashed<AccountUpdate>;
children: AccountUpdateForest;
};
Hierarchy
MerkleList\<{accountUpdate:Hashed\<AccountUpdate> = HashedAccountUpdate.provable;children:MerkleListBase\<AccountUpdateTreeBase> ;id:number= RandomId },this>↳
AccountUpdateForest
Table of contents
Constructors
Properties
Accessors
Methods
- clone
- isEmpty
- nextHash
- pop
- popExn
- popIf
- push
- pushIf
- startIterating
- assertConstant
- create
- fromFlatArray
- fromSimpleForest
- toFlatArray
Constructors
constructor
• new AccountUpdateForest(«destructured»)
Parameters
| Name | Type |
|---|---|
«destructured» | MerkleListBase\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }> |
Inherited from
Defined in
lib/provable-types/merkle-list.ts:82
Properties
data
• data: Unconstrained\<WithHash\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>[]>
Inherited from
Defined in
lib/provable-types/merkle-list.ts:80
hash
• hash: Field
Inherited from
Defined in
lib/provable-types/merkle-list.ts:79
_emptyHash
▪ Static _emptyHash: undefined | Field
Inherited from
Defined in
lib/provable-types/merkle-list.ts:257
_innerProvable
▪ Static _innerProvable: undefined | ProvableHashable\<any>
Inherited from
Defined in
lib/provable-types/merkle-list.ts:260
_nextHash
▪ Static _nextHash: undefined | (hash: Field, t: any) => Field
Inherited from
Defined in
lib/provable-types/merkle-list.ts:256
_provable
▪ Static _provable: undefined | ProvableHashable\<MerkleList\<any>>
Inherited from
Defined in
lib/provable-types/merkle-list.ts:259
empty
▪ Static empty: () => MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Type declaration
▸ (): MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Returns
MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Inherited from
MerkleList.create( AccountUpdateTreeBase, merkleListHash ).empty
Defined in
lib/provable-types/merkle-list.ts:215
from
▪ Static from: (array: { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }[]) => MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Type declaration
▸ (array): MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Parameters
| Name | Type |
|---|---|
array | { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }[] |
Returns
MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Inherited from
MerkleList.create( AccountUpdateTreeBase, merkleListHash ).from
Defined in
lib/provable-types/merkle-list.ts:216
provable
▪ Static provable: ProvableHashable\<MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>>
Inherited from
MerkleList.create( AccountUpdateTreeBase, merkleListHash ).provable
Defined in
lib/provable-types/merkle-list.ts:217
Accessors
Constructor
• get Constructor(): typeof MerkleList
Returns
typeof MerkleList
Inherited from
MerkleList.create( AccountUpdateTreeBase, merkleListHash ).Constructor
Defined in
lib/provable-types/merkle-list.ts:262
innerProvable
• get innerProvable(): ProvableHashable\<T>
Returns
ProvableHashable\<T>
Inherited from
MerkleList.create( AccountUpdateTreeBase, merkleListHash ).innerProvable
Defined in
lib/provable-types/merkle-list.ts:279
emptyHash
• Static get emptyHash(): Field
Returns
Inherited from
MerkleList.create( AccountUpdateTreeBase, merkleListHash ).emptyHash
Defined in
lib/provable-types/merkle-list.ts:274
Methods
clone
▸ clone(): MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Returns
MerkleList\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Inherited from
Defined in
lib/provable-types/merkle-list.ts:187
isEmpty
▸ isEmpty(): Bool
Returns
Inherited from
Defined in
lib/provable-types/merkle-list.ts:87
nextHash
▸ nextHash(hash, value): Field
Parameters
| Name | Type | Default value |
|---|---|---|
hash | Field | undefined |
value | Object | undefined |
value.accountUpdate | Hashed\<AccountUpdate> | HashedAccountUpdate.provable |
value.children | MerkleListBase\<AccountUpdateTreeBase> | undefined |
value.id | number | RandomId |
Returns
Inherited from
Defined in
lib/provable-types/merkle-list.ts:266
pop
▸ pop(): Object
Remove the last element from the list and return it.
If the list is empty, returns a dummy element.
Returns
Object
| Name | Type |
|---|---|
accountUpdate | Hashed\<AccountUpdate> |
children | MerkleListBase\<AccountUpdateTreeBase> |
id | number |
Inherited from
Defined in
lib/provable-types/merkle-list.ts:152
popExn
▸ popExn(): Object
Remove the last element from the list and return it.
This proves that the list is non-empty, and fails otherwise.
Returns
Object
| Name | Type |
|---|---|
accountUpdate | Hashed\<AccountUpdate> |
children | MerkleListBase\<AccountUpdateTreeBase> |
id | number |
Inherited from
Defined in
lib/provable-types/merkle-list.ts:137
popIf
▸ popIf(condition): Object
Return the last element, but only remove it if condition is true.
If the list is empty, returns a dummy element.
Parameters
| Name | Type |
|---|---|
condition | Bool |
Returns
Object
| Name | Type |
|---|---|
accountUpdate | Hashed\<AccountUpdate> |
children | MerkleListBase\<AccountUpdateTreeBase> |
id | number |
Inherited from
Defined in
lib/provable-types/merkle-list.ts:171
push
▸ push(element): void
Push a new element to the list.
Parameters
| Name | Type | Default value |
|---|---|---|
element | Object | undefined |
element.accountUpdate | Hashed\<AccountUpdate> | HashedAccountUpdate.provable |
element.children | MerkleListBase\<AccountUpdateTreeBase> | undefined |
element.id | number | RandomId |
Returns
void
Inherited from
Defined in
lib/provable-types/merkle-list.ts:94
pushIf
▸ pushIf(condition, element): void
Push a new element to the list, if the condition is true.
Parameters
| Name | Type | Default value |
|---|---|---|
condition | Bool | undefined |
element | Object | undefined |
element.accountUpdate | Hashed\<AccountUpdate> | HashedAccountUpdate.provable |
element.children | MerkleListBase\<AccountUpdateTreeBase> | undefined |
element.id | number | RandomId |
Returns
void
Inherited from
Defined in
lib/provable-types/merkle-list.ts:106
startIterating
▸ startIterating(): MerkleListIterator\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Returns
MerkleListIterator\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>
Inherited from
Defined in
lib/provable-types/merkle-list.ts:192
assertConstant
▸ Static assertConstant(forest): void
Parameters
| Name | Type |
|---|---|
forest | AccountUpdateForestBase |
Returns
void
Defined in
create
▸ Static create\<T>(type, nextHash?, emptyHash_?): typeof MerkleList & { empty: () => MerkleList\<T> ; from: (array: T[]) => MerkleList\<T> ; provable: ProvableHashable\<MerkleList\<T>> }
Create a Merkle list type
Optionally, you can tell create() how to do the hash that pushes a new list element, by passing a nextHash function.
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type | Default value |
|---|---|---|
type | ProvableHashable\<T> | undefined |
nextHash | (hash: Field, value: T) => Field | undefined |
emptyHash_ | Field | emptyHash |
Returns
typeof MerkleList & { empty: () => MerkleList\<T> ; from: (array: T[]) => MerkleList\<T> ; provable: ProvableHashable\<MerkleList\<T>> }
Example
class MyList extends MerkleList.create(Field, (hash, x) =>
Poseidon.hashWithPrefix('custom', [hash, x])
) {}
Inherited from
Defined in
lib/provable-types/merkle-list.ts:209
fromFlatArray
▸ Static fromFlatArray(updates): AccountUpdateForest
Parameters
| Name | Type |
|---|---|
updates | AccountUpdate[] |
Returns
Defined in
fromSimpleForest
▸ Static Private fromSimpleForest(simpleForest): AccountUpdateForest
Parameters
| Name | Type |
|---|---|
simpleForest | CallForest\<AccountUpdate> |
Returns
Defined in
toFlatArray
▸ Static toFlatArray(forest, mutate?, depth?): AccountUpdate[]
Parameters
| Name | Type | Default value |
|---|---|---|
forest | AccountUpdateForestBase | undefined |
mutate | boolean | true |
depth | number | 0 |