Skip to main content

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;
};

Extends

  • MerkleList\<{"accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }, this>

Constructors

new AccountUpdateForest()

new AccountUpdateForest(__namedParameters: MerkleListBase<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>): AccountUpdateForest

Parameters

__namedParameters: MerkleListBase\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

Returns

AccountUpdateForest

Inherited from

MerkleList.constructor

Source

lib/provable/merkle-list.ts:83

Properties

data

data: Unconstrained<WithHash<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>[]>;

Inherited from

MerkleList.data

Source

lib/provable/merkle-list.ts:81


hash

hash: Field;

Inherited from

MerkleList.hash

Source

lib/provable/merkle-list.ts:80


_emptyHash

static _emptyHash: undefined | Field;

Inherited from

MerkleList._emptyHash

Source

lib/provable/merkle-list.ts:297


_innerProvable

static _innerProvable: undefined | ProvableHashable<any>;

Inherited from

MerkleList._innerProvable

Source

lib/provable/merkle-list.ts:300


_nextHash

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

Inherited from

MerkleList._nextHash

Source

lib/provable/merkle-list.ts:296


_provable

static _provable: undefined | ProvableHashable<MerkleList<any>>;

Inherited from

MerkleList._provable

Source

lib/provable/merkle-list.ts:299


empty()

static empty: () => MerkleList<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>;

Returns

MerkleList\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.create( AccountUpdateTreeBase, merkleListHash ).empty

Source

lib/provable/merkle-list.ts:245


from()

static from: (array: {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}[]) => MerkleList<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>;

Parameters

array: { "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }[]

Returns

MerkleList\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.create( AccountUpdateTreeBase, merkleListHash ).from

Source

lib/provable/merkle-list.ts:246


fromReverse()

static fromReverse: (array: {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}[]) => MerkleList<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>;

Parameters

array: { "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }[]

Returns

MerkleList\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.create( AccountUpdateTreeBase, merkleListHash ).fromReverse

Source

lib/provable/merkle-list.ts:247


provable

static provable: ProvableHashable<MerkleList<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>>;

Inherited from

MerkleList.create( AccountUpdateTreeBase, merkleListHash ).provable

Source

lib/provable/merkle-list.ts:248

Accessors

Constructor

get Constructor(): typeof MerkleList

Returns

typeof MerkleList

Source

lib/provable/merkle-list.ts:302


innerProvable

get innerProvable(): ProvableHashable<T>

Returns

ProvableHashable\<T>

Source

lib/provable/merkle-list.ts:319


emptyHash

get static emptyHash(): Field

Returns

Field

Source

lib/provable/merkle-list.ts:314

Methods

clone()

clone(): MerkleList<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>

Returns

MerkleList\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.clone

Source

lib/provable/merkle-list.ts:189


forEach()

forEach(length: number, callback: (element: {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}, isDummy: Bool, i: number) => void): void

Iterate through the list in a fixed number of steps any apply a given callback on each element.

Proves that the iteration traverses the entire list. Once past the last element, dummy elements will be passed to the callback.

Note: There are no guarantees about the contents of dummy elements, so the callback is expected to handle the isDummy flag separately.

Parameters

length: number

callback

Returns

void

Inherited from

MerkleList.forEach

Source

lib/provable/merkle-list.ts:203


isEmpty()

isEmpty(): Bool

Returns

Bool

Inherited from

MerkleList.isEmpty

Source

lib/provable/merkle-list.ts:88


nextHash()

nextHash(hash: Field, value: {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}): Field

Parameters

hash: Field

value

value.accountUpdate: Hashed\<AccountUpdate>= HashedAccountUpdate.provable

value.children: MerkleListBase\<AccountUpdateTreeBase>= undefined

value.id: number= RandomId

Returns

Field

Inherited from

MerkleList.nextHash

Source

lib/provable/merkle-list.ts:306


pop()

pop(): {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}

Remove the last element from the list and return it.

If the list is empty, returns a dummy element.

Returns

{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.pop

Source

lib/provable/merkle-list.ts:154


popExn()

popExn(): {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}

Remove the last element from the list and return it.

This proves that the list is non-empty, and fails otherwise.

Returns

{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.popExn

Source

lib/provable/merkle-list.ts:139


popIf()

popIf(condition: Bool): {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}

Return the last element, but only remove it if condition is true.

If the list is empty, returns a dummy element.

Parameters

condition: Bool

Returns

{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.popIf

Source

lib/provable/merkle-list.ts:173


push()

push(element: {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}): void

Push a new element to the list.

Parameters

element

element.accountUpdate: Hashed\<AccountUpdate>= HashedAccountUpdate.provable

element.children: MerkleListBase\<AccountUpdateTreeBase>= undefined

element.id: number= RandomId

Returns

void

Inherited from

MerkleList.push

Source

lib/provable/merkle-list.ts:95


pushIf()

pushIf(condition: Bool, element: {
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}): void

Push a new element to the list, if the condition is true.

Parameters

condition: Bool

element

element.accountUpdate: Hashed\<AccountUpdate>= HashedAccountUpdate.provable

element.children: MerkleListBase\<AccountUpdateTreeBase>= undefined

element.id: number= RandomId

Returns

void

Inherited from

MerkleList.pushIf

Source

lib/provable/merkle-list.ts:107


startIterating()

startIterating(): MerkleListIterator<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>

Returns

MerkleListIterator\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.startIterating

Source

lib/provable/merkle-list.ts:217


startIteratingFromLast()

startIteratingFromLast(): MerkleListIterator<{
"accountUpdate": HashedAccountUpdate.provable;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>

Returns

MerkleListIterator\<{ "accountUpdate": HashedAccountUpdate.provable; "children": MerkleListBase\<AccountUpdateTreeBase>; "id": RandomId; }>

accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate.provable;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.startIteratingFromLast

Source

lib/provable/merkle-list.ts:222


assertConstant()

static assertConstant(forest: AccountUpdateForestBase): void

Parameters

forest: AccountUpdateForestBase

Returns

void

Source

lib/mina/account-update.ts:1352


create()

static create<T>(
type: ProvableHashable<T>,
nextHash: (hash: Field, value: T) => Field,
emptyHash_: Field): typeof MerkleList & {
"empty": () => MerkleList<T>;
"from": (array: T[]) => MerkleList<T>;
"fromReverse": (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

T

Parameters

type: ProvableHashable\<T>

nextHash= undefined

emptyHash_: Field= emptyHash

Returns

typeof MerkleList & { "empty": () => MerkleList\<T>; "from": (array: T[]) => MerkleList\<T>; "fromReverse": (array: T[]) => MerkleList\<T>; "provable": ProvableHashable\<MerkleList\<T>>; }

Inherited from

MerkleList.create

Example

class MyList extends MerkleList.create(Field, (hash, x) =>
Poseidon.hashWithPrefix('custom', [hash, x])
) {}

Source

lib/provable/merkle-list.ts:239


fromFlatArray()

static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest

Parameters

updates: AccountUpdate[]

Returns

AccountUpdateForest

Source

lib/mina/account-update.ts:1321


toFlatArray()

static toFlatArray(
forest: AccountUpdateForestBase,
mutate: boolean,
depth: number): AccountUpdate[]

Parameters

forest: AccountUpdateForestBase

mutate: boolean= true

depth: number= 0

Returns

AccountUpdate[]

Source

lib/mina/account-update.ts:1325