Skip to main content

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

Constructors

constructor

new AccountUpdateForest(«destructured»)

Parameters

NameType
«destructured»MerkleListBase\<{ accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleListBase\<AccountUpdateTreeBase> ; id: number = RandomId }>

Inherited from

MerkleList.constructor

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

MerkleList.data

Defined in

lib/provable-types/merkle-list.ts:80


hash

hash: Field

Inherited from

MerkleList.hash

Defined in

lib/provable-types/merkle-list.ts:79


_emptyHash

Static _emptyHash: undefined | Field

Inherited from

MerkleList._emptyHash

Defined in

lib/provable-types/merkle-list.ts:257


_innerProvable

Static _innerProvable: undefined | ProvableHashable\<any>

Inherited from

MerkleList._innerProvable

Defined in

lib/provable-types/merkle-list.ts:260


_nextHash

Static _nextHash: undefined | (hash: Field, t: any) => Field

Inherited from

MerkleList._nextHash

Defined in

lib/provable-types/merkle-list.ts:256


_provable

Static _provable: undefined | ProvableHashable\<MerkleList\<any>>

Inherited from

MerkleList._provable

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
NameType
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

Field

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

MerkleList.clone

Defined in

lib/provable-types/merkle-list.ts:187


isEmpty

isEmpty(): Bool

Returns

Bool

Inherited from

MerkleList.isEmpty

Defined in

lib/provable-types/merkle-list.ts:87


nextHash

nextHash(hash, value): Field

Parameters

NameTypeDefault value
hashFieldundefined
valueObjectundefined
value.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable
value.childrenMerkleListBase\<AccountUpdateTreeBase>undefined
value.idnumberRandomId

Returns

Field

Inherited from

MerkleList.nextHash

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

NameType
accountUpdateHashed\<AccountUpdate>
childrenMerkleListBase\<AccountUpdateTreeBase>
idnumber

Inherited from

MerkleList.pop

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

NameType
accountUpdateHashed\<AccountUpdate>
childrenMerkleListBase\<AccountUpdateTreeBase>
idnumber

Inherited from

MerkleList.popExn

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

NameType
conditionBool

Returns

Object

NameType
accountUpdateHashed\<AccountUpdate>
childrenMerkleListBase\<AccountUpdateTreeBase>
idnumber

Inherited from

MerkleList.popIf

Defined in

lib/provable-types/merkle-list.ts:171


push

push(element): void

Push a new element to the list.

Parameters

NameTypeDefault value
elementObjectundefined
element.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable
element.childrenMerkleListBase\<AccountUpdateTreeBase>undefined
element.idnumberRandomId

Returns

void

Inherited from

MerkleList.push

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

NameTypeDefault value
conditionBoolundefined
elementObjectundefined
element.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable
element.childrenMerkleListBase\<AccountUpdateTreeBase>undefined
element.idnumberRandomId

Returns

void

Inherited from

MerkleList.pushIf

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

MerkleList.startIterating

Defined in

lib/provable-types/merkle-list.ts:192


assertConstant

Static assertConstant(forest): void

Parameters

NameType
forestAccountUpdateForestBase

Returns

void

Defined in

lib/account-update.ts:1382


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

NameTypeDefault value
typeProvableHashable\<T>undefined
nextHash(hash: Field, value: T) => Fieldundefined
emptyHash_FieldemptyHash

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

MerkleList.create

Defined in

lib/provable-types/merkle-list.ts:209


fromFlatArray

Static fromFlatArray(updates): AccountUpdateForest

Parameters

NameType
updatesAccountUpdate[]

Returns

AccountUpdateForest

Defined in

lib/account-update.ts:1351


fromSimpleForest

Static Private fromSimpleForest(simpleForest): AccountUpdateForest

Parameters

NameType
simpleForestCallForest\<AccountUpdate>

Returns

AccountUpdateForest

Defined in

lib/account-update.ts:1370


toFlatArray

Static toFlatArray(forest, mutate?, depth?): AccountUpdate[]

Parameters

NameTypeDefault value
forestAccountUpdateForestBaseundefined
mutatebooleantrue
depthnumber0

Returns

AccountUpdate[]

Defined in

lib/account-update.ts:1355