@aztec/aztec.js 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dest/account/contract.d.ts +4 -4
- package/dest/account/contract.d.ts.map +1 -1
- package/dest/account/index.d.ts +1 -1
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/interface.d.ts +5 -5
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/wallet.d.ts +2 -2
- package/dest/account/wallet.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_sent_tx.d.ts +4 -4
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_sent_tx.js +1 -1
- package/dest/account_manager/index.d.ts +7 -7
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +1 -1
- package/dest/contract/base_contract_interaction.d.ts +4 -4
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -5
- package/dest/contract/batch_call.d.ts +3 -3
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +1 -1
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/checker.d.ts.map +1 -1
- package/dest/contract/checker.js +2 -2
- package/dest/contract/contract.d.ts +4 -4
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract_base.d.ts +44 -4
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +1 -1
- package/dest/contract/contract_function_interaction.d.ts +21 -12
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +41 -11
- package/dest/contract/deploy_method.d.ts +11 -11
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +8 -6
- package/dest/contract/deploy_sent_tx.d.ts +8 -7
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +4 -1
- package/dest/contract/index.d.ts +3 -3
- package/dest/contract/index.js +3 -3
- package/dest/contract/sent_tx.d.ts +2 -2
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +6 -6
- package/dest/contract/unsafe_contract.d.ts +3 -3
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.d.ts +3 -3
- package/dest/deployment/broadcast_function.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.js +1 -1
- package/dest/deployment/contract_deployer.d.ts +2 -2
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/deploy_instance.d.ts +3 -3
- package/dest/deployment/deploy_instance.d.ts.map +1 -1
- package/dest/deployment/protocol_contracts.d.ts +1 -1
- package/dest/deployment/protocol_contracts.d.ts.map +1 -1
- package/dest/deployment/register_class.d.ts +3 -3
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +1 -1
- package/dest/entrypoint/default_entrypoint.d.ts +2 -2
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_entrypoint.js +1 -1
- package/dest/entrypoint/entrypoint.d.ts +3 -3
- package/dest/entrypoint/entrypoint.d.ts.map +1 -1
- package/dest/fee/fee_payment_method.d.ts +3 -3
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.d.ts +5 -5
- package/dest/fee/native_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.js +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +4 -4
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.d.ts +4 -4
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/rpc_clients/pxe_client.d.ts +1 -1
- package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
- package/dest/rpc_clients/pxe_client.js +3 -3
- package/dest/utils/abi_types.d.ts +1 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/account.d.ts +2 -2
- package/dest/utils/account.d.ts.map +1 -1
- package/dest/utils/account.js +1 -1
- package/dest/utils/authwit.d.ts +2 -2
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +1 -1
- package/dest/utils/cheat_codes.d.ts +2 -2
- package/dest/utils/cheat_codes.d.ts.map +1 -1
- package/dest/utils/cheat_codes.js +1 -1
- package/dest/utils/l1_contracts.d.ts +1 -1
- package/dest/utils/l1_contracts.d.ts.map +1 -1
- package/dest/utils/pub_key.d.ts +1 -1
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pxe.d.ts +2 -2
- package/dest/utils/pxe.d.ts.map +1 -1
- package/dest/wallet/account_wallet.d.ts +4 -4
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +2 -2
- package/dest/wallet/account_wallet_with_private_key.d.ts +4 -4
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +1 -1
- package/dest/wallet/base_wallet.d.ts +10 -9
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +6 -3
- package/dest/wallet/create_recipient.d.ts +1 -1
- package/dest/wallet/create_recipient.d.ts.map +1 -1
- package/dest/wallet/index.d.ts +3 -3
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.d.ts +3 -3
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/package.json +17 -11
- package/src/account/contract.ts +4 -4
- package/src/account/index.ts +1 -1
- package/src/account/interface.ts +5 -5
- package/src/account/wallet.ts +2 -2
- package/src/account_manager/deploy_account_sent_tx.ts +4 -4
- package/src/account_manager/index.ts +8 -8
- package/src/contract/base_contract_interaction.ts +6 -6
- package/src/contract/batch_call.ts +3 -3
- package/src/contract/checker.ts +4 -4
- package/src/contract/contract.ts +4 -4
- package/src/contract/contract_base.ts +46 -4
- package/src/contract/contract_function_interaction.ts +47 -16
- package/src/contract/deploy_method.ts +17 -13
- package/src/contract/deploy_sent_tx.ts +11 -7
- package/src/contract/index.ts +3 -3
- package/src/contract/sent_tx.ts +13 -6
- package/src/contract/unsafe_contract.ts +3 -3
- package/src/deployment/broadcast_function.ts +3 -3
- package/src/deployment/contract_deployer.ts +4 -4
- package/src/deployment/deploy_instance.ts +3 -3
- package/src/deployment/protocol_contracts.ts +1 -1
- package/src/deployment/register_class.ts +3 -3
- package/src/entrypoint/default_entrypoint.ts +2 -2
- package/src/entrypoint/entrypoint.ts +3 -3
- package/src/fee/fee_payment_method.ts +3 -3
- package/src/fee/native_fee_payment_method.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +4 -4
- package/src/fee/public_fee_payment_method.ts +4 -4
- package/src/index.ts +2 -0
- package/src/rpc_clients/pxe_client.ts +3 -2
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/account.ts +2 -2
- package/src/utils/authwit.ts +2 -2
- package/src/utils/cheat_codes.ts +2 -2
- package/src/utils/l1_contracts.ts +1 -1
- package/src/utils/pub_key.ts +1 -1
- package/src/utils/pxe.ts +2 -2
- package/src/wallet/account_wallet.ts +6 -6
- package/src/wallet/account_wallet_with_private_key.ts +4 -4
- package/src/wallet/base_wallet.ts +33 -23
- package/src/wallet/create_recipient.ts +1 -1
- package/src/wallet/index.ts +3 -3
- package/src/wallet/signerless_wallet.ts +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PXE, Tx, TxExecutionRequest } from '@aztec/circuit-types';
|
|
1
|
+
import { type PXE, type Tx, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
|
|
3
|
-
import { FeeOptions } from '../entrypoint/entrypoint.js';
|
|
3
|
+
import { type FeeOptions } from '../entrypoint/entrypoint.js';
|
|
4
4
|
import { SentTx } from './sent_tx.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -37,13 +37,13 @@ export abstract class BaseContractInteraction {
|
|
|
37
37
|
public abstract create(options?: SendMethodOptions): Promise<TxExecutionRequest>;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Proves a transaction execution request and returns a tx object ready to be sent.
|
|
41
41
|
* @param options - optional arguments to be used in the creation of the transaction
|
|
42
42
|
* @returns The resulting transaction
|
|
43
43
|
*/
|
|
44
|
-
public async
|
|
44
|
+
public async prove(options: SendMethodOptions = {}): Promise<Tx> {
|
|
45
45
|
const txRequest = this.txRequest ?? (await this.create(options));
|
|
46
|
-
this.tx = await this.pxe.
|
|
46
|
+
this.tx = await this.pxe.proveTx(txRequest, !options.skipPublicSimulation);
|
|
47
47
|
return this.tx;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -58,7 +58,7 @@ export abstract class BaseContractInteraction {
|
|
|
58
58
|
*/
|
|
59
59
|
public send(options: SendMethodOptions = {}) {
|
|
60
60
|
const promise = (async () => {
|
|
61
|
-
const tx = this.tx ?? (await this.
|
|
61
|
+
const tx = this.tx ?? (await this.prove(options));
|
|
62
62
|
return this.pxe.sendTx(tx);
|
|
63
63
|
})();
|
|
64
64
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionCall, TxExecutionRequest } from '@aztec/circuit-types';
|
|
1
|
+
import { type FunctionCall, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
|
|
3
|
-
import { Wallet } from '../account/index.js';
|
|
4
|
-
import { BaseContractInteraction, SendMethodOptions } from './base_contract_interaction.js';
|
|
3
|
+
import { type Wallet } from '../account/index.js';
|
|
4
|
+
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
5
5
|
|
|
6
6
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
7
7
|
export class BatchCall extends BaseContractInteraction {
|
package/src/contract/checker.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type AbiType, type BasicType, type ContractArtifact, type StructType } from '@aztec/foundation/abi';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Represents a type derived from input type T with the 'kind' property removed.
|
|
@@ -51,10 +51,10 @@ export function abiChecker(artifact: ContractArtifact) {
|
|
|
51
51
|
* Throws an error if the type has an unrecognized kind or incorrectly formed attributes.
|
|
52
52
|
* Additionally, checks nested types for array and struct kinds.
|
|
53
53
|
*
|
|
54
|
-
* @param type - The
|
|
54
|
+
* @param type - The AbiType object representing the type of the ABI function parameter.
|
|
55
55
|
* @returns A boolean value indicating whether the type is valid or not.
|
|
56
56
|
*/
|
|
57
|
-
function abiParameterTypeChecker(type:
|
|
57
|
+
function abiParameterTypeChecker(type: AbiType): boolean {
|
|
58
58
|
switch (type.kind) {
|
|
59
59
|
case 'field':
|
|
60
60
|
case 'boolean':
|
|
@@ -73,7 +73,7 @@ function abiParameterTypeChecker(type: ABIType): boolean {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* Check if the structure of the
|
|
76
|
+
* Check if the structure of the AbiType 'struct' is valid by ensuring field names are strings
|
|
77
77
|
* and their type attribute passes the abiParameterTypeChecker. Returns true on successful validation,
|
|
78
78
|
* otherwise throws an error providing insight into the incorrect formation in the struct.
|
|
79
79
|
*
|
package/src/contract/contract.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PublicKey } from '@aztec/circuit-types';
|
|
2
|
-
import { ContractArtifact } from '@aztec/foundation/abi';
|
|
3
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
1
|
+
import { type PublicKey } from '@aztec/circuit-types';
|
|
2
|
+
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
3
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
4
4
|
import { Point } from '@aztec/foundation/fields';
|
|
5
5
|
|
|
6
|
-
import { Wallet } from '../account/index.js';
|
|
6
|
+
import { type Wallet } from '../account/index.js';
|
|
7
7
|
import { ContractBase } from './contract_base.js';
|
|
8
8
|
import { DeployMethod } from './deploy_method.js';
|
|
9
9
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { computePartialAddress } from '@aztec/circuits.js';
|
|
2
|
-
import { ContractArtifact, FunctionArtifact, FunctionSelector } from '@aztec/foundation/abi';
|
|
3
|
-
import { ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
1
|
+
import { type Fr, computePartialAddress } from '@aztec/circuits.js';
|
|
2
|
+
import { type ContractArtifact, type FunctionArtifact, FunctionSelector } from '@aztec/foundation/abi';
|
|
3
|
+
import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
4
4
|
|
|
5
|
-
import { Wallet } from '../account/index.js';
|
|
5
|
+
import { type Wallet } from '../account/index.js';
|
|
6
6
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -16,6 +16,48 @@ export type ContractMethod = ((...args: any[]) => ContractFunctionInteraction) &
|
|
|
16
16
|
readonly selector: FunctionSelector;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Type representing a field layout in the storage of a contract.
|
|
21
|
+
*/
|
|
22
|
+
type FieldLayout = {
|
|
23
|
+
/**
|
|
24
|
+
* Slot in which the field is stored.
|
|
25
|
+
*/
|
|
26
|
+
slot: Fr;
|
|
27
|
+
/**
|
|
28
|
+
* Type being stored at the slot
|
|
29
|
+
*/
|
|
30
|
+
typ: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Type representing a note in use in the contract.
|
|
35
|
+
*/
|
|
36
|
+
type ContractNote = {
|
|
37
|
+
/**
|
|
38
|
+
* Note identifier
|
|
39
|
+
*/
|
|
40
|
+
id: Fr;
|
|
41
|
+
/**
|
|
42
|
+
* Type of the note
|
|
43
|
+
*/
|
|
44
|
+
typ: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Type representing the storage layout of a contract.
|
|
49
|
+
*/
|
|
50
|
+
export type ContractStorageLayout<T extends string> = {
|
|
51
|
+
[K in T]: FieldLayout;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Type representing the notes used in a contract.
|
|
56
|
+
*/
|
|
57
|
+
export type ContractNotes<T extends string> = {
|
|
58
|
+
[K in T]: ContractNote;
|
|
59
|
+
};
|
|
60
|
+
|
|
19
61
|
/**
|
|
20
62
|
* Abstract implementation of a contract extended by the Contract class and generated contract types.
|
|
21
63
|
*/
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { FunctionCall, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress, FunctionData } from '@aztec/circuits.js';
|
|
3
|
-
import { FunctionAbi, FunctionType, encodeArguments } from '@aztec/foundation/abi';
|
|
1
|
+
import { type FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, FunctionData, TxContext } from '@aztec/circuits.js';
|
|
3
|
+
import { type FunctionAbi, FunctionType, encodeArguments } from '@aztec/foundation/abi';
|
|
4
4
|
|
|
5
|
-
import { Wallet } from '../account/wallet.js';
|
|
6
|
-
import { BaseContractInteraction, SendMethodOptions } from './base_contract_interaction.js';
|
|
5
|
+
import { type Wallet } from '../account/wallet.js';
|
|
6
|
+
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
7
7
|
|
|
8
8
|
export { SendMethodOptions };
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Represents the options for
|
|
11
|
+
* Represents the options for simulating a contract function interaction.
|
|
12
12
|
* Allows specifying the address from which the view method should be called.
|
|
13
|
+
* Disregarded for simulation of public functions
|
|
13
14
|
*/
|
|
14
|
-
export type
|
|
15
|
+
export type SimulateMethodOptions = {
|
|
15
16
|
/**
|
|
16
17
|
* The sender's Aztec address.
|
|
17
18
|
*/
|
|
@@ -63,18 +64,48 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* Simulate a transaction and get its return values
|
|
68
|
+
* Differs from prove in a few important ways:
|
|
69
|
+
* 1. It returns the values of the function execution
|
|
70
|
+
* 2. It supports `unconstrained`, `private` and `public` functions
|
|
71
|
+
* 3. For `private` execution it:
|
|
72
|
+
* 3.a SKIPS the entrypoint and starts directly at the function
|
|
73
|
+
* 3.b SKIPS public execution entirely
|
|
74
|
+
* 4. For `public` execution it:
|
|
75
|
+
* 4.a Removes the `txRequest` value after ended simulation
|
|
76
|
+
* 4.b Ignores the `from` in the options
|
|
77
|
+
*
|
|
69
78
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
70
|
-
* @returns The result of the
|
|
79
|
+
* @returns The result of the transaction as returned by the contract function.
|
|
71
80
|
*/
|
|
72
|
-
public
|
|
73
|
-
if (this.functionDao.functionType
|
|
74
|
-
|
|
81
|
+
public async simulate(options: SimulateMethodOptions = {}): Promise<any> {
|
|
82
|
+
if (this.functionDao.functionType == FunctionType.UNCONSTRAINED) {
|
|
83
|
+
return this.wallet.viewTx(this.functionDao.name, this.args, this.contractAddress, options.from);
|
|
75
84
|
}
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
return
|
|
86
|
+
// TODO: If not unconstrained, we return a size 4 array of fields.
|
|
87
|
+
// TODO: It should instead return the correctly decoded value
|
|
88
|
+
// TODO: The return type here needs to be fixed! @LHerskind
|
|
89
|
+
|
|
90
|
+
if (this.functionDao.functionType == FunctionType.SECRET) {
|
|
91
|
+
const nodeInfo = await this.wallet.getNodeInfo();
|
|
92
|
+
const packedArgs = PackedArguments.fromArgs(encodeArguments(this.functionDao, this.args));
|
|
93
|
+
|
|
94
|
+
const txRequest = TxExecutionRequest.from({
|
|
95
|
+
argsHash: packedArgs.hash,
|
|
96
|
+
origin: this.contractAddress,
|
|
97
|
+
functionData: FunctionData.fromAbi(this.functionDao),
|
|
98
|
+
txContext: TxContext.empty(nodeInfo.chainId, nodeInfo.protocolVersion),
|
|
99
|
+
packedArguments: [packedArgs],
|
|
100
|
+
authWitnesses: [],
|
|
101
|
+
});
|
|
102
|
+
const simulatedTx = await this.pxe.simulateTx(txRequest, false, options.from ?? this.wallet.getAddress());
|
|
103
|
+
return simulatedTx.privateReturnValues?.[0];
|
|
104
|
+
} else {
|
|
105
|
+
const txRequest = await this.create();
|
|
106
|
+
const simulatedTx = await this.pxe.simulateTx(txRequest, true);
|
|
107
|
+
this.txRequest = undefined;
|
|
108
|
+
return simulatedTx.publicReturnValues?.[0];
|
|
109
|
+
}
|
|
79
110
|
}
|
|
80
111
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { FunctionCall, PublicKey, Tx, TxExecutionRequest } from '@aztec/circuit-types';
|
|
1
|
+
import { type FunctionCall, type PublicKey, type Tx, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
AztecAddress,
|
|
4
4
|
computePartialAddress,
|
|
5
5
|
getContractClassFromArtifact,
|
|
6
6
|
getContractInstanceFromDeployParams,
|
|
7
7
|
} from '@aztec/circuits.js';
|
|
8
|
-
import { ContractArtifact, FunctionArtifact, getInitializer } from '@aztec/foundation/abi';
|
|
9
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
8
|
+
import { type ContractArtifact, type FunctionArtifact, getInitializer } from '@aztec/foundation/abi';
|
|
9
|
+
import { type EthAddress } from '@aztec/foundation/eth-address';
|
|
10
|
+
import { type Fr } from '@aztec/foundation/fields';
|
|
11
11
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
12
|
-
import { ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
12
|
+
import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
13
13
|
|
|
14
|
-
import { Wallet } from '../account/index.js';
|
|
14
|
+
import { type Wallet } from '../account/index.js';
|
|
15
15
|
import { deployInstance } from '../deployment/deploy_instance.js';
|
|
16
16
|
import { registerContractClass } from '../deployment/register_class.js';
|
|
17
|
-
import { BaseContractInteraction, SendMethodOptions } from './base_contract_interaction.js';
|
|
17
|
+
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
18
18
|
import { type Contract } from './contract.js';
|
|
19
|
-
import { ContractBase } from './contract_base.js';
|
|
19
|
+
import { type ContractBase } from './contract_base.js';
|
|
20
20
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
21
21
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
22
22
|
|
|
@@ -169,7 +169,11 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
169
169
|
*/
|
|
170
170
|
public send(options: DeployOptions = {}): DeploySentTx<TContract> {
|
|
171
171
|
const txHashPromise = super.send(options).getTxHash();
|
|
172
|
-
|
|
172
|
+
const instance = this.getInstance(options);
|
|
173
|
+
this.log(
|
|
174
|
+
`Sent deployment tx of ${this.artifact.name} contract with deployment address ${instance.address.toString()}`,
|
|
175
|
+
);
|
|
176
|
+
return new DeploySentTx(this.pxe, txHashPromise, this.postDeployCtor, instance);
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
/**
|
|
@@ -193,12 +197,12 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
/**
|
|
196
|
-
*
|
|
200
|
+
* Prove the request.
|
|
197
201
|
* @param options - Deployment options.
|
|
198
|
-
* @returns The
|
|
202
|
+
* @returns The proven tx.
|
|
199
203
|
*/
|
|
200
|
-
public
|
|
201
|
-
return super.
|
|
204
|
+
public prove(options: DeployOptions): Promise<Tx> {
|
|
205
|
+
return super.prove(options);
|
|
202
206
|
}
|
|
203
207
|
|
|
204
208
|
/** Return this deployment address. */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { PXE, TxHash, TxReceipt } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress } from '@aztec/circuits.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { type PXE, type TxHash, type TxReceipt } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress } from '@aztec/circuits.js';
|
|
3
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { type FieldsOf } from '@aztec/foundation/types';
|
|
5
|
+
import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
5
6
|
|
|
6
|
-
import { Wallet } from '../account/index.js';
|
|
7
|
+
import { type Wallet } from '../account/index.js';
|
|
7
8
|
import { type Contract } from './contract.js';
|
|
8
|
-
import { ContractBase } from './contract_base.js';
|
|
9
|
-
import { SentTx, WaitOpts } from './sent_tx.js';
|
|
9
|
+
import { type ContractBase } from './contract_base.js';
|
|
10
|
+
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
10
11
|
|
|
11
12
|
/** Options related to waiting for a deployment tx. */
|
|
12
13
|
export type DeployedWaitOpts = WaitOpts & {
|
|
@@ -24,6 +25,8 @@ export type DeployTxReceipt<TContract extends ContractBase = Contract> = FieldsO
|
|
|
24
25
|
* A contract deployment transaction sent to the network, extending SentTx with methods to create a contract instance.
|
|
25
26
|
*/
|
|
26
27
|
export class DeploySentTx<TContract extends Contract = Contract> extends SentTx {
|
|
28
|
+
private log = createDebugLogger('aztec:js:deploy_sent_tx');
|
|
29
|
+
|
|
27
30
|
constructor(
|
|
28
31
|
wallet: PXE | Wallet,
|
|
29
32
|
txHashPromise: Promise<TxHash>,
|
|
@@ -41,6 +44,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
41
44
|
*/
|
|
42
45
|
public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
|
|
43
46
|
const receipt = await this.wait(opts);
|
|
47
|
+
this.log(`Contract ${this.instance.address.toString()} successfully deployed.`);
|
|
44
48
|
return receipt.contract;
|
|
45
49
|
}
|
|
46
50
|
|
package/src/contract/index.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* The {@link Contract} class is the main class in this module, and provides static methods for deploying
|
|
8
8
|
* a contract or interacting with an already deployed one. The `methods` property of the contract instance
|
|
9
|
-
* provides access to private, public, and
|
|
10
|
-
* or can be queried via `
|
|
9
|
+
* provides access to private, public, and simulate methods, that can be invoked in a transaction via `send()`,
|
|
10
|
+
* or can be queried via `simulate()`.
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
13
|
* const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send().deployed();
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* ```ts
|
|
18
18
|
* const contract = await Contract.at(address, MyContractArtifact, wallet);
|
|
19
19
|
* await contract.methods.mint(1000, owner).send().wait();
|
|
20
|
-
* console.log(`Total supply is now ${await contract.methods.totalSupply().
|
|
20
|
+
* console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
23
|
* The result of calling a method in a contract instance, such as `contract.methods.mint(1000, owner)`
|
package/src/contract/sent_tx.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ExtendedNote,
|
|
3
|
+
type GetUnencryptedLogsResponse,
|
|
4
|
+
type PXE,
|
|
5
|
+
type TxHash,
|
|
6
|
+
type TxReceipt,
|
|
7
|
+
TxStatus,
|
|
8
|
+
} from '@aztec/circuit-types';
|
|
2
9
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
-
import { FieldsOf } from '@aztec/foundation/types';
|
|
10
|
+
import { type FieldsOf } from '@aztec/foundation/types';
|
|
4
11
|
|
|
5
12
|
/** Options related to waiting for a tx. */
|
|
6
13
|
export type WaitOpts = {
|
|
@@ -75,10 +82,10 @@ export class SentTx {
|
|
|
75
82
|
const tx = (await this.pxe.getTxEffect(txHash))!;
|
|
76
83
|
const visibleNotes = await this.pxe.getNotes({ txHash });
|
|
77
84
|
receipt.debugInfo = {
|
|
78
|
-
noteHashes: tx.noteHashes
|
|
79
|
-
nullifiers: tx.nullifiers
|
|
80
|
-
publicDataWrites: tx.publicDataWrites
|
|
81
|
-
l2ToL1Msgs: tx.l2ToL1Msgs
|
|
85
|
+
noteHashes: tx.noteHashes,
|
|
86
|
+
nullifiers: tx.nullifiers,
|
|
87
|
+
publicDataWrites: tx.publicDataWrites,
|
|
88
|
+
l2ToL1Msgs: tx.l2ToL1Msgs,
|
|
82
89
|
visibleNotes,
|
|
83
90
|
};
|
|
84
91
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ContractArtifact } from '@aztec/foundation/abi';
|
|
2
|
-
import { ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
1
|
+
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
2
|
+
import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
3
3
|
|
|
4
|
-
import { Wallet } from '../wallet/index.js';
|
|
4
|
+
import { type Wallet } from '../wallet/index.js';
|
|
5
5
|
import { ContractBase } from './contract_base.js';
|
|
6
6
|
|
|
7
7
|
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
createUnconstrainedFunctionMembershipProof,
|
|
7
7
|
getContractClassFromArtifact,
|
|
8
8
|
} from '@aztec/circuits.js';
|
|
9
|
-
import { ContractArtifact, FunctionSelector, FunctionType, bufferAsFields } from '@aztec/foundation/abi';
|
|
9
|
+
import { type ContractArtifact, type FunctionSelector, FunctionType, bufferAsFields } from '@aztec/foundation/abi';
|
|
10
10
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
11
11
|
import { Fr } from '@aztec/foundation/fields';
|
|
12
12
|
|
|
13
|
-
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
14
|
-
import { Wallet } from '../wallet/index.js';
|
|
13
|
+
import { type ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
14
|
+
import { type Wallet } from '../wallet/index.js';
|
|
15
15
|
import { getRegistererContract } from './protocol_contracts.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PublicKey } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress } from '@aztec/circuits.js';
|
|
3
|
-
import { ContractArtifact } from '@aztec/foundation/abi';
|
|
1
|
+
import { type PublicKey } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress } from '@aztec/circuits.js';
|
|
3
|
+
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
4
4
|
import { Point } from '@aztec/foundation/fields';
|
|
5
5
|
|
|
6
|
-
import { Wallet } from '../account/wallet.js';
|
|
6
|
+
import { type Wallet } from '../account/wallet.js';
|
|
7
7
|
import { DeployMethod } from '../contract/deploy_method.js';
|
|
8
8
|
import { Contract } from '../contract/index.js';
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
1
|
+
import { type ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
2
2
|
|
|
3
|
-
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
4
|
-
import { Wallet } from '../wallet/index.js';
|
|
3
|
+
import { type ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
4
|
+
import { type Wallet } from '../wallet/index.js';
|
|
5
5
|
import { getDeployerContract } from './protocol_contracts.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -2,7 +2,7 @@ import { getCanonicalClassRegisterer } from '@aztec/protocol-contracts/class-reg
|
|
|
2
2
|
import { getCanonicalInstanceDeployer } from '@aztec/protocol-contracts/instance-deployer';
|
|
3
3
|
|
|
4
4
|
import { UnsafeContract } from '../contract/unsafe_contract.js';
|
|
5
|
-
import { Wallet } from '../wallet/index.js';
|
|
5
|
+
import { type Wallet } from '../wallet/index.js';
|
|
6
6
|
|
|
7
7
|
/** Returns a Contract wrapper for the class registerer. */
|
|
8
8
|
export function getRegistererContract(wallet: Wallet) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS, getContractClassFromArtifact } from '@aztec/circuits.js';
|
|
2
|
-
import { ContractArtifact, bufferAsFields } from '@aztec/foundation/abi';
|
|
2
|
+
import { type ContractArtifact, bufferAsFields } from '@aztec/foundation/abi';
|
|
3
3
|
|
|
4
|
-
import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
5
|
-
import { Wallet } from '../wallet/index.js';
|
|
4
|
+
import { type ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
5
|
+
import { type Wallet } from '../wallet/index.js';
|
|
6
6
|
import { getRegistererContract } from './protocol_contracts.js';
|
|
7
7
|
|
|
8
8
|
/** Sets up a call to register a contract class given its artifact. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types';
|
|
1
|
+
import { type FunctionCall, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
import { TxContext } from '@aztec/circuits.js';
|
|
3
3
|
|
|
4
|
-
import { EntrypointInterface } from './entrypoint.js';
|
|
4
|
+
import { type EntrypointInterface } from './entrypoint.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Default implementation of the entrypoint interface. It calls a function on a contract directly
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FunctionCall, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { type FunctionCall, type TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
+
import { type Fr } from '@aztec/foundation/fields';
|
|
3
3
|
|
|
4
|
-
import { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
4
|
+
import { type FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Fee payment options for a transaction.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
3
|
+
import { type Fr } from '@aztec/foundation/fields';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Holds information about how the fee for a transaction is to be paid.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FunctionCall } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress, FunctionData } from '@aztec/circuits.js';
|
|
1
|
+
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, FunctionData } from '@aztec/circuits.js';
|
|
3
3
|
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { type Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { getCanonicalGasTokenAddress } from '@aztec/protocol-contracts/gas-token';
|
|
6
6
|
|
|
7
|
-
import { Wallet } from '../account/wallet.js';
|
|
8
|
-
import { FeePaymentMethod } from './fee_payment_method.js';
|
|
7
|
+
import { type Wallet } from '../account/wallet.js';
|
|
8
|
+
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Pay fee directly in the native gas token.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { FunctionCall } from '@aztec/circuit-types';
|
|
1
|
+
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
2
|
import { FunctionData } from '@aztec/circuits.js';
|
|
3
3
|
import { computeMessageSecretHash } from '@aztec/circuits.js/hash';
|
|
4
4
|
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
5
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
6
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
7
7
|
|
|
8
|
-
import { Wallet } from '../account/wallet.js';
|
|
8
|
+
import { type Wallet } from '../account/wallet.js';
|
|
9
9
|
import { computeAuthWitMessageHash } from '../utils/authwit.js';
|
|
10
|
-
import { FeePaymentMethod } from './fee_payment_method.js';
|
|
10
|
+
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Holds information about how the fee for a transaction is to be paid.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { FunctionCall } from '@aztec/circuit-types';
|
|
1
|
+
import { type FunctionCall } from '@aztec/circuit-types';
|
|
2
2
|
import { FunctionData } from '@aztec/circuits.js';
|
|
3
3
|
import { FunctionSelector } from '@aztec/foundation/abi';
|
|
4
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
4
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
7
7
|
import { computeAuthWitMessageHash } from '../utils/authwit.js';
|
|
8
|
-
import { AccountWallet } from '../wallet/account_wallet.js';
|
|
9
|
-
import { FeePaymentMethod } from './fee_payment_method.js';
|
|
8
|
+
import { type AccountWallet } from '../wallet/account_wallet.js';
|
|
9
|
+
import { type FeePaymentMethod } from './fee_payment_method.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Holds information about how the fee for a transaction is to be paid.
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
LogId,
|
|
8
8
|
Note,
|
|
9
9
|
NullifierMembershipWitness,
|
|
10
|
-
PXE,
|
|
10
|
+
type PXE,
|
|
11
|
+
SimulatedTx,
|
|
11
12
|
Tx,
|
|
12
13
|
TxEffect,
|
|
13
14
|
TxExecutionRequest,
|
|
@@ -53,7 +54,7 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false)
|
|
|
53
54
|
TxExecutionRequest,
|
|
54
55
|
TxHash,
|
|
55
56
|
},
|
|
56
|
-
{ Tx, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness },
|
|
57
|
+
{ Tx, SimulatedTx, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness },
|
|
57
58
|
false,
|
|
58
59
|
'pxe',
|
|
59
60
|
fetch,
|
package/src/utils/abi_types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AztecAddress, EthAddress, Fr, FunctionSelector } from '@aztec/circuits.js';
|
|
1
|
+
import { type AztecAddress, type EthAddress, type Fr, type FunctionSelector } from '@aztec/circuits.js';
|
|
2
2
|
|
|
3
3
|
/** Any type that can be converted into a field for a contract call. */
|
|
4
4
|
export type FieldLike = Fr | Buffer | bigint | number | { /** Converts to field */ toField: () => Fr };
|
package/src/utils/account.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CompleteAddress, PXE } from '@aztec/circuit-types';
|
|
1
|
+
import { type CompleteAddress, type PXE } from '@aztec/circuit-types';
|
|
2
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
3
|
|
|
4
|
-
import { DefaultWaitOpts, WaitOpts } from '../contract/index.js';
|
|
4
|
+
import { DefaultWaitOpts, type WaitOpts } from '../contract/index.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Waits for the account to finish synchronizing with the PXE Service.
|
package/src/utils/authwit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FunctionCall, PackedArguments } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress, Fr, GeneratorIndex } from '@aztec/circuits.js';
|
|
1
|
+
import { type FunctionCall, PackedArguments } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, type Fr, GeneratorIndex } from '@aztec/circuits.js';
|
|
3
3
|
import { pedersenHash } from '@aztec/foundation/crypto';
|
|
4
4
|
|
|
5
5
|
// docs:start:authwit_computeAuthWitMessageHash
|
package/src/utils/cheat_codes.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Note, PXE } from '@aztec/circuit-types';
|
|
2
|
-
import { AztecAddress, EthAddress, Fr } from '@aztec/circuits.js';
|
|
1
|
+
import { type Note, type PXE } from '@aztec/circuit-types';
|
|
2
|
+
import { type AztecAddress, type EthAddress, Fr } from '@aztec/circuits.js';
|
|
3
3
|
import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
|
|
4
4
|
import { keccak, pedersenHash } from '@aztec/foundation/crypto';
|
|
5
5
|
import { createDebugLogger } from '@aztec/foundation/log';
|