Skip to main content

AccountUpdateTree

o1js / Modules / AccountUpdateTree

Class: AccountUpdateTree

Class which represents a tree of account updates, in a compressed way which allows iterating and selectively witnessing the account updates.

The (recursive) type signature is:

type AccountUpdateTree = {
accountUpdate: Hashed<AccountUpdate>;
children: AccountUpdateForest;
};
type AccountUpdateForest = MerkleList<AccountUpdateTree>;

Hierarchy

  • { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> = AccountUpdateForest.provable; id: number = RandomId }

    AccountUpdateTree

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new AccountUpdateTree(value)

Parameters

NameTypeDefault value
valueObjectundefined
value.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable
value.childrenMerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }>AccountUpdateForest.provable
value.idnumberRandomId

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).constructor

Defined in

lib/circuit-value.ts:487

Properties

accountUpdate

accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).accountUpdate

Defined in

lib/account-update.ts:1410


children

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

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).children

Defined in

lib/account-update.ts:1411


id

id: number = RandomId

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).id

Defined in

lib/account-update.ts:1409


_isStruct

Static _isStruct: true

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, })._isStruct

Defined in

lib/circuit-value.ts:487


check

Static check: (value: { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> = AccountUpdateForest.provable; id: number = RandomId }) => void

Type declaration

▸ (value): void

Add assertions to the proof to check if value is a valid member of type T. This function does not return anything, instead it creates any number of assertions to prove that value is a valid member of the type T.

For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.

Parameters
NameTypeDefault valueDescription
valueObjectundefinedthe element of type T to put assertions on.
value.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable-
value.childrenMerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }>AccountUpdateForest.provable-
value.idnumberRandomId-
Returns

void

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).check

Defined in

snarky.d.ts:98


toAuxiliary

Static toAuxiliary: (value?: { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> = AccountUpdateForest.provable; id: number = RandomId }) => any[]

Type declaration

▸ (value?): any[]

A function that takes value (optional), an element of type T, as argument and returns an array of any type that make up the "auxiliary" (non-provable) data of value.

Parameters
NameTypeDefault valueDescription
value?Objectundefinedthe element of type T to generate the auxiliary data array from, optional. If not provided, a default value for auxiliary data is returned.
value.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable-
value.childrenMerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }>AccountUpdateForest.provable-
value.idnumberRandomId-
Returns

any[]

An array of any type describing how this T element is made up of "auxiliary" (non-provable) data.

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).toAuxiliary

Defined in

snarky.d.ts:67


toFields

Static toFields: (value: { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> = AccountUpdateForest.provable; id: number = RandomId }) => Field[]

Type declaration

▸ (value): Field[]

A function that takes value, an element of type T, as argument and returns an array of Field elements that make up the provable data of value.

Parameters
NameTypeDefault valueDescription
valueObjectundefinedthe element of type T to generate the Field array from.
value.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable-
value.childrenMerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }>AccountUpdateForest.provable-
value.idnumberRandomId-
Returns

Field[]

A Field array describing how this T element is made up of Field elements.

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).toFields

Defined in

snarky.d.ts:58


toInput

Static toInput: (x: { accountUpdate: Hashed\<AccountUpdate> = HashedAccountUpdate.provable; children: MerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> = AccountUpdateForest.provable; id: number = RandomId }) => { fields?: Field[] ; packed?: [Field, number][] }

Type declaration

▸ (x): Object

Parameters
NameTypeDefault value
xObjectundefined
x.accountUpdateHashed\<AccountUpdate>HashedAccountUpdate.provable
x.childrenMerkleList\<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }>AccountUpdateForest.provable
x.idnumberRandomId
Returns

Object

NameType
fields?Field[]
packed?[Field, number][]

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).toInput

Defined in

lib/circuit-value.ts:490

Methods

approve

approve(update, hash?): void

Add an AccountUpdate or AccountUpdateTree to the children of this tree's root.

See approve.

Parameters

NameType
updateAccountUpdate | AccountUpdateTree
hash?Field

Returns

void

Defined in

lib/account-update.ts:1430


empty

Static empty(): AccountUpdateTree

Returns

AccountUpdateTree

Overrides

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).empty

Defined in

lib/account-update.ts:1446


from

Static from(update, hash?): AccountUpdateTree

Create a tree of account updates which only consists of a root.

Parameters

NameType
updateAccountUpdate | AccountUpdateTree
hash?Field

Returns

AccountUpdateTree

Defined in

lib/account-update.ts:1416


fromFields

Static fromFields(fields, aux): AccountUpdateTree

Parameters

NameType
fieldsField[]
auxany

Returns

AccountUpdateTree

Overrides

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).fromFields

Defined in

lib/account-update.ts:1443


sizeInFields

Static sizeInFields(): number

Return the size of the T type in terms of Field type, as Field is the primitive type.

Warning: This function returns a number, so you cannot use it to prove something on chain. You can use it during debugging or to understand the memory complexity of some type.

Returns

number

A number representing the size of the T type in terms of Field type.

Inherited from

StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).sizeInFields

Defined in

snarky.d.ts:88