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:274


_innerProvable

static _innerProvable: undefined | ProvableHashable<any>;

Inherited from

MerkleList._innerProvable

Source

lib/provable/merkle-list.ts:277


_nextHash

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

Inherited from

MerkleList._nextHash

Source

lib/provable/merkle-list.ts:273


_provable

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

Inherited from

MerkleList._provable

Source

lib/provable/merkle-list.ts:276


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:222


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:223


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:224


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:225

Accessors

Constructor

get Constructor(): typeof MerkleList

Returns

typeof MerkleList

Source

lib/provable/merkle-list.ts:279


innerProvable

get innerProvable(): ProvableHashable<T>

Returns

ProvableHashable\<T>

Source

lib/provable/merkle-list.ts:296


emptyHash

get static emptyHash(): Field

Returns

Field

Source

lib/provable/merkle-list.ts:291

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


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:283


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:194


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:199


assertConstant()

static assertConstant(forest: AccountUpdateForestBase): void

Parameters

forest: AccountUpdateForestBase

Returns

void

Source

lib/mina/account-update.ts:1296


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:216


fromFlatArray()

static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest

Parameters

updates: AccountUpdate[]

Returns

AccountUpdateForest

Source

lib/mina/account-update.ts:1265


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:1269