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
Name | Type | Default value |
---|---|---|
value | Object | undefined |
value.accountUpdate | Hashed \<AccountUpdate > | HashedAccountUpdate.provable |
value.children | MerkleList \<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> | AccountUpdateForest.provable |
value.id | number | RandomId |
Inherited from
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).constructor
Defined in
Properties
accountUpdate
• accountUpdate: Hashed
\<AccountUpdate
> = HashedAccountUpdate.provable
Inherited from
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).accountUpdate
Defined in
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
id
• id: number
= RandomId
Inherited from
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).id
Defined in
_isStruct
▪ Static
_isStruct: true
Inherited from
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, })._isStruct
Defined in
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
Name | Type | Default value | Description |
---|---|---|---|
value | Object | undefined | the element of type T to put assertions on. |
value.accountUpdate | Hashed \<AccountUpdate > | HashedAccountUpdate.provable | - |
value.children | MerkleList \<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> | AccountUpdateForest.provable | - |
value.id | number | RandomId | - |
Returns
void
Inherited from
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).check
Defined in
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
Name | Type | Default value | Description |
---|---|---|---|
value? | Object | undefined | the element of type T to generate the auxiliary data array from, optional. If not provided, a default value for auxiliary data is returned. |
value.accountUpdate | Hashed \<AccountUpdate > | HashedAccountUpdate.provable | - |
value.children | MerkleList \<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> | AccountUpdateForest.provable | - |
value.id | number | RandomId | - |
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
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
Name | Type | Default value | Description |
---|---|---|---|
value | Object | undefined | the element of type T to generate the Field array from. |
value.accountUpdate | Hashed \<AccountUpdate > | HashedAccountUpdate.provable | - |
value.children | MerkleList \<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> | AccountUpdateForest.provable | - |
value.id | number | RandomId | - |
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
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
Name | Type | Default value |
---|---|---|
x | Object | undefined |
x.accountUpdate | Hashed \<AccountUpdate > | HashedAccountUpdate.provable |
x.children | MerkleList \<{ id: number; accountUpdate: Hashed\<AccountUpdate>; children: MerkleListBase\<AccountUpdateTreeBase>; }> | AccountUpdateForest.provable |
x.id | number | RandomId |
Returns
Object
Name | Type |
---|---|
fields? | Field [] |
packed? | [Field , number ][] |
Inherited from
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).toInput
Defined in
Methods
approve
▸ approve(update
, hash?
): void
Add an AccountUpdate or AccountUpdateTree to the children of this tree's root.
See approve.
Parameters
Name | Type |
---|---|
update | AccountUpdate | AccountUpdateTree |
hash? | Field |
Returns
void
Defined in
empty
▸ Static
empty(): AccountUpdateTree
Returns
Overrides
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).empty
Defined in
from
▸ Static
from(update
, hash?
): AccountUpdateTree
Create a tree of account updates which only consists of a root.
Parameters
Name | Type |
---|---|
update | AccountUpdate | AccountUpdateTree |
hash? | Field |
Returns
Defined in
fromFields
▸ Static
fromFields(fields
, aux
): AccountUpdateTree
Parameters
Name | Type |
---|---|
fields | Field [] |
aux | any |
Returns
Overrides
StructNoJson({ id: RandomId, accountUpdate: HashedAccountUpdate.provable, children: AccountUpdateForest.provable, }).fromFields
Defined in
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