@aztec/aztec.js 0.82.2 → 0.82.3
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/dest/account_manager/account_manager.d.ts +21 -11
- package/dest/account_manager/account_manager.d.ts.map +1 -1
- package/dest/account_manager/account_manager.js +4 -25
- package/dest/api/contract.d.ts +2 -1
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +1 -24
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/batch_call.d.ts +2 -2
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +3 -27
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +1 -1
- package/dest/contract/deploy_method.d.ts +10 -2
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +11 -0
- package/dest/contract/interaction_options.d.ts +49 -0
- package/dest/contract/interaction_options.d.ts.map +1 -0
- package/dest/contract/interaction_options.js +3 -0
- package/dest/contract/proven_tx.d.ts +1 -0
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/proven_tx.js +5 -1
- package/package.json +8 -8
- package/src/account_manager/account_manager.ts +4 -30
- package/src/api/contract.ts +8 -1
- package/src/contract/base_contract_interaction.ts +1 -26
- package/src/contract/batch_call.ts +2 -6
- package/src/contract/contract_function_interaction.ts +9 -41
- package/src/contract/deploy_method.ts +16 -2
- package/src/contract/interaction_options.ts +55 -0
- package/src/contract/proven_tx.ts +6 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { CompleteAddress, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
3
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
5
4
|
import type { AccountContract } from '../account/account_contract.js';
|
|
6
5
|
import type { Salt } from '../account/index.js';
|
|
7
6
|
import type { AccountInterface } from '../account/interface.js';
|
|
8
|
-
import { type DeployOptions } from '../contract/deploy_method.js';
|
|
7
|
+
import { DeployMethod, type DeployOptions } from '../contract/deploy_method.js';
|
|
9
8
|
import { type WaitOpts } from '../contract/sent_tx.js';
|
|
9
|
+
import { AccountEntrypointMetaPaymentMethod } from '../fee/account_entrypoint_meta_payment_method.js';
|
|
10
|
+
import { type FeePaymentMethod } from '../index.js';
|
|
10
11
|
import { AccountWalletWithSecretKey, type Wallet } from '../wallet/index.js';
|
|
11
12
|
import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
12
13
|
/**
|
|
@@ -23,7 +24,6 @@ export type DeployAccountOptions = Pick<DeployOptions, 'fee' | 'skipClassRegistr
|
|
|
23
24
|
* and creating and registering the user wallet in the PXE Service.
|
|
24
25
|
*/
|
|
25
26
|
export declare class AccountManager {
|
|
26
|
-
#private;
|
|
27
27
|
private pxe;
|
|
28
28
|
private secretKey;
|
|
29
29
|
private accountContract;
|
|
@@ -73,6 +73,24 @@ export declare class AccountManager {
|
|
|
73
73
|
* @returns A Wallet instance.
|
|
74
74
|
*/
|
|
75
75
|
register(): Promise<AccountWalletWithSecretKey>;
|
|
76
|
+
/**
|
|
77
|
+
* Returns the pre-populated deployment method to deploy the account contract that backs this account.
|
|
78
|
+
* If no wallet is provided, it uses a signerless wallet with the multi call entrypoint
|
|
79
|
+
* @param deployWallet - Wallet used for deploying the account contract.
|
|
80
|
+
* @returns A DeployMethod instance that deploys this account contract
|
|
81
|
+
*/
|
|
82
|
+
getDeployMethod(deployWallet?: Wallet): Promise<DeployMethod>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns a FeePaymentMethod that routes the original one provided as an argument
|
|
85
|
+
* through the account's entrypoint. This allows an account contract to pay
|
|
86
|
+
* for its own deployment and initialization.
|
|
87
|
+
*
|
|
88
|
+
* For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
|
|
89
|
+
*
|
|
90
|
+
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
91
|
+
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
92
|
+
*/
|
|
93
|
+
getSelfPaymentMethod(originalPaymentMethod?: FeePaymentMethod): Promise<AccountEntrypointMetaPaymentMethod>;
|
|
76
94
|
/**
|
|
77
95
|
* Deploys the account contract that backs this account.
|
|
78
96
|
* Does not register the associated class nor publicly deploy the instance by default.
|
|
@@ -82,14 +100,6 @@ export declare class AccountManager {
|
|
|
82
100
|
* @returns A SentTx object that can be waited to get the associated Wallet.
|
|
83
101
|
*/
|
|
84
102
|
deploy(opts?: DeployAccountOptions): DeployAccountSentTx;
|
|
85
|
-
/**
|
|
86
|
-
* Estimates the gas needed to deploy the account contract that backs this account.
|
|
87
|
-
* This method is here to ensure that the fee payment method is correctly set up in case
|
|
88
|
-
* the account contract needs to pay for its own deployment.
|
|
89
|
-
* @param opts - Fee options to be used for the deployment.
|
|
90
|
-
* @returns The gas estimations for the account contract deployment and initialization.
|
|
91
|
-
*/
|
|
92
|
-
estimateDeploymentGas(opts?: DeployAccountOptions): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>>;
|
|
93
103
|
/**
|
|
94
104
|
* Deploys the account contract that backs this account if needed and awaits the tx to be mined.
|
|
95
105
|
* Uses the salt provided in the constructor or a randomly generated one. If no initialization
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_manager.d.ts","sourceRoot":"","sources":["../../src/account_manager/account_manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE3F,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"account_manager.d.ts","sourceRoot":"","sources":["../../src/account_manager/account_manager.ts"],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C,aAAa;IAIvB,SAAS,CAAC,iBAAiB;IAI3B;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAMpD;;;;OAIG;IACI,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC;IAIrD;;;;OAIG;IACI,UAAU;IAIjB;;;;OAIG;IACI,WAAW,IAAI,2BAA2B;IAIjD;;;;OAIG;IACU,SAAS,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAK7D;;;;;;OAMG;IACU,QAAQ,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAW5D;;;;;OAKG;IACU,eAAe,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA6C1E;;;;;;;;;OASG;IACU,oBAAoB,CAAC,qBAAqB,CAAC,EAAE,gBAAgB;IAa1E;;;;;;;OAOG;IACI,MAAM,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,mBAAmB;IA2B/D;;;;;;OAMG;IACU,SAAS,CAAC,IAAI,GAAE,oBAAoB,GAAG,QAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAKpH;;OAEG;IACU,YAAY;CAG1B"}
|
|
@@ -106,7 +106,7 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
|
106
106
|
* If no wallet is provided, it uses a signerless wallet with the multi call entrypoint
|
|
107
107
|
* @param deployWallet - Wallet used for deploying the account contract.
|
|
108
108
|
* @returns A DeployMethod instance that deploys this account contract
|
|
109
|
-
*/ async
|
|
109
|
+
*/ async getDeployMethod(deployWallet) {
|
|
110
110
|
const artifact = await this.accountContract.getContractArtifact();
|
|
111
111
|
if (!await this.isDeployable()) {
|
|
112
112
|
throw new Error(`Account contract ${artifact.name} does not require deployment.`);
|
|
@@ -138,7 +138,7 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
|
138
138
|
*
|
|
139
139
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
140
140
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
141
|
-
*/ async
|
|
141
|
+
*/ async getSelfPaymentMethod(originalPaymentMethod) {
|
|
142
142
|
const artifact = await this.accountContract.getContractArtifact();
|
|
143
143
|
const wallet = await this.getWallet();
|
|
144
144
|
const address = wallet.getAddress();
|
|
@@ -153,10 +153,10 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
|
153
153
|
* @returns A SentTx object that can be waited to get the associated Wallet.
|
|
154
154
|
*/ deploy(opts) {
|
|
155
155
|
let deployMethod;
|
|
156
|
-
const sentTx = this
|
|
156
|
+
const sentTx = this.getDeployMethod(opts?.deployWallet).then((method)=>{
|
|
157
157
|
deployMethod = method;
|
|
158
158
|
if (!opts?.deployWallet && opts?.fee) {
|
|
159
|
-
return this
|
|
159
|
+
return this.getSelfPaymentMethod(opts?.fee?.paymentMethod);
|
|
160
160
|
}
|
|
161
161
|
}).then((maybeWrappedPaymentMethod)=>{
|
|
162
162
|
let fee = opts?.fee;
|
|
@@ -178,27 +178,6 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
|
178
178
|
return new DeployAccountSentTx(this.pxe, sentTx, this.getWallet());
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
|
-
* Estimates the gas needed to deploy the account contract that backs this account.
|
|
182
|
-
* This method is here to ensure that the fee payment method is correctly set up in case
|
|
183
|
-
* the account contract needs to pay for its own deployment.
|
|
184
|
-
* @param opts - Fee options to be used for the deployment.
|
|
185
|
-
* @returns The gas estimations for the account contract deployment and initialization.
|
|
186
|
-
*/ async estimateDeploymentGas(opts) {
|
|
187
|
-
const deployMethod = await this.#getDeployMethod(opts?.deployWallet);
|
|
188
|
-
const fee = !opts?.deployWallet && opts?.fee ? {
|
|
189
|
-
...opts.fee,
|
|
190
|
-
paymentMethod: await this.#getSelfPaymentMethod(opts.fee.paymentMethod)
|
|
191
|
-
} : opts?.fee;
|
|
192
|
-
return deployMethod.estimateGas({
|
|
193
|
-
contractAddressSalt: new Fr(this.salt),
|
|
194
|
-
skipClassRegistration: opts?.skipClassRegistration ?? true,
|
|
195
|
-
skipPublicDeployment: opts?.skipPublicDeployment ?? true,
|
|
196
|
-
skipInitialization: opts?.skipInitialization ?? false,
|
|
197
|
-
universalDeploy: true,
|
|
198
|
-
fee
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
181
|
* Deploys the account contract that backs this account if needed and awaits the tx to be mined.
|
|
203
182
|
* Uses the salt provided in the constructor or a randomly generated one. If no initialization
|
|
204
183
|
* is required it skips the transaction, and only registers the account in the PXE Service.
|
package/dest/api/contract.d.ts
CHANGED
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
* @packageDocumentation
|
|
37
37
|
*/
|
|
38
38
|
export { Contract } from '../contract/contract.js';
|
|
39
|
-
export { ContractFunctionInteraction
|
|
39
|
+
export { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
40
|
+
export { type RequestMethodOptions, type SendMethodOptions, type ProfileMethodOptions, type SimulateMethodOptions, } from '../contract/interaction_options.js';
|
|
40
41
|
export { TxProfileResult } from '@aztec/stdlib/tx';
|
|
41
42
|
export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
|
|
42
43
|
export { ProvenTx } from '../contract/proven_tx.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/api/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/api/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,qBAAqB,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAEjH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAChC,4BAA4B,EAC5B,mCAAmC,EACnC,KAAK,QAAQ,GACd,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
import type { FeeOptions, TxExecutionOptions, UserFeeOptions } from '@aztec/entrypoints/interfaces';
|
|
2
2
|
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
4
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
6
5
|
import type { Capsule, TxExecutionRequest, TxProvingResult } from '@aztec/stdlib/tx';
|
|
7
6
|
import type { Wallet } from '../wallet/wallet.js';
|
|
7
|
+
import type { RequestMethodOptions, SendMethodOptions } from './interaction_options.js';
|
|
8
8
|
import { ProvenTx } from './proven_tx.js';
|
|
9
9
|
import { SentTx } from './sent_tx.js';
|
|
10
|
-
/**
|
|
11
|
-
* Represents the options to configure a request from a contract interaction.
|
|
12
|
-
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
13
|
-
*/
|
|
14
|
-
export type RequestMethodOptions = {
|
|
15
|
-
/** Extra authwits to use during execution */
|
|
16
|
-
authWitnesses?: AuthWitness[];
|
|
17
|
-
/** Extra capsules to use during execution */
|
|
18
|
-
capsules?: Capsule[];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Represents options for calling a (constrained) function in a contract.
|
|
22
|
-
*/
|
|
23
|
-
export type SendMethodOptions = RequestMethodOptions & {
|
|
24
|
-
/** Wether to skip the simulation of the public part of the transaction. */
|
|
25
|
-
skipPublicSimulation?: boolean;
|
|
26
|
-
/** The fee options for the transaction. */
|
|
27
|
-
fee?: UserFeeOptions;
|
|
28
|
-
/** Custom nonce to inject into the app payload of the transaction. Useful when trying to cancel an ongoing transaction by creating a new one with a higher fee */
|
|
29
|
-
nonce?: Fr;
|
|
30
|
-
/** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
|
|
31
|
-
cancellable?: boolean;
|
|
32
|
-
};
|
|
33
10
|
/**
|
|
34
11
|
* Base class for an interaction with a contract, be it a deployment, a function call, or a batch.
|
|
35
12
|
* Implements the sequence create/simulate/send.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_contract_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/base_contract_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,KAAK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OAAO,CAAC,eAAe,CAAC;IAOxF;;;;OAIG;IACU,KAAK,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOtE;;;;;;;;OAQG;IACI,IAAI,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM;IAUpD;;;;;OAKG;IACU,WAAW,CACtB,IAAI,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,aAAa,GAAG,sBAAsB,CAAC,GACrE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,CAAC;IAiBhE;;;OAGG;cACa,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;IAU1F;;;;;;OAMG;cACa,aAAa,CAC3B,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,4BAAqB,EACxB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,UAAU,CAAC;CA8BvB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
2
2
|
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
3
3
|
import type { Wallet } from '../wallet/wallet.js';
|
|
4
|
-
import { BaseContractInteraction
|
|
5
|
-
import type { SimulateMethodOptions } from './
|
|
4
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
5
|
+
import type { RequestMethodOptions, SendMethodOptions, SimulateMethodOptions } from './interaction_options.js';
|
|
6
6
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
7
7
|
export declare class BatchCall extends BaseContractInteraction {
|
|
8
8
|
protected calls: BaseContractInteraction[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch_call.d.ts","sourceRoot":"","sources":["../../src/contract/batch_call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"batch_call.d.ts","sourceRoot":"","sources":["../../src/contract/batch_call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA0B,MAAM,4BAA4B,CAAC;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE/G,qFAAqF;AACrF,qBAAa,SAAU,SAAQ,uBAAuB;IACxB,SAAS,CAAC,KAAK,EAAE,uBAAuB,EAAE;gBAA1D,MAAM,EAAE,MAAM,EAAY,KAAK,EAAE,uBAAuB,EAAE;IAItE;;;;;OAKG;IACU,MAAM,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IASjF;;;;OAIG;IACU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAWnF;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;YAwE1D,WAAW;CAG1B"}
|
|
@@ -4,32 +4,8 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { Capsule, HashedValues, TxExecutionRequest, TxProfileResult } from '@aztec/stdlib/tx';
|
|
6
6
|
import type { Wallet } from '../wallet/wallet.js';
|
|
7
|
-
import { BaseContractInteraction
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Represents the options for simulating a contract function interaction.
|
|
11
|
-
* Allows specifying the address from which the view method should be called.
|
|
12
|
-
* Disregarded for simulation of public functions
|
|
13
|
-
*/
|
|
14
|
-
export type ProfileMethodOptions = Pick<SendMethodOptions, 'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'> & {
|
|
15
|
-
/** Whether to return gates information or the bytecode/witnesses. */
|
|
16
|
-
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
17
|
-
/** The sender's Aztec address. */
|
|
18
|
-
from?: AztecAddress;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Represents the options for simulating a contract function interaction.
|
|
22
|
-
* Allows specifying the address from which the method should be called.
|
|
23
|
-
* Disregarded for simulation of public functions
|
|
24
|
-
*/
|
|
25
|
-
export type SimulateMethodOptions = Pick<SendMethodOptions, 'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'> & {
|
|
26
|
-
/** The sender's Aztec address. */
|
|
27
|
-
from?: AztecAddress;
|
|
28
|
-
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
29
|
-
skipTxValidation?: boolean;
|
|
30
|
-
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
31
|
-
skipFeeEnforcement?: boolean;
|
|
32
|
-
};
|
|
7
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
8
|
+
import type { ProfileMethodOptions, RequestMethodOptions, SendMethodOptions, SimulateMethodOptions } from './interaction_options.js';
|
|
33
9
|
/**
|
|
34
10
|
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
35
11
|
* It contains available interactions one can call on a method, including view.
|
|
@@ -66,7 +42,7 @@ export declare class ContractFunctionInteraction extends BaseContractInteraction
|
|
|
66
42
|
simulate(options?: SimulateMethodOptions): Promise<any>;
|
|
67
43
|
/**
|
|
68
44
|
* Simulate a transaction and profile the gate count for each function in the transaction.
|
|
69
|
-
* @param options - Same options as `simulate
|
|
45
|
+
* @param options - Same options as `simulate`, plus profiling method
|
|
70
46
|
*
|
|
71
47
|
* @returns An object containing the function return value and profile result.
|
|
72
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_function_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/contract_function_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAkE,MAAM,mBAAmB,CAAC;AACrH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"contract_function_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/contract_function_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAkE,MAAM,mBAAmB,CAAC;AACrH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,qBAAa,2BAA4B,SAAQ,uBAAuB;IAGpE,SAAS,CAAC,eAAe,EAAE,YAAY;IACvC,SAAS,CAAC,WAAW,EAAE,WAAW;IAClC,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;IAGrB,OAAO,CAAC,eAAe;gBANvB,MAAM,EAAE,MAAM,EACJ,eAAe,EAAE,YAAY,EAC7B,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,GAAG,EAAE,EACrB,aAAa,GAAE,WAAW,EAAO,EACjC,QAAQ,GAAE,OAAO,EAAO,EAChB,eAAe,GAAE,YAAY,EAAO;IAS9C;;;;;OAKG;IACmB,MAAM,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAc1F;;;;;OAKG;IACmB,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwB5F;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAuCxE;;;;;OAKG;IACU,OAAO,CAAC,OAAO,GAAE,oBAA+C,GAAG,OAAO,CAAC,eAAe,CAAC;IAUxG;;;;;;OAMG;IACI,IAAI,CAAC,EACV,aAAkB,EAClB,QAAa,EACb,eAAoB,GACrB,EAAE;QACD,kDAAkD;QAClD,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;QAC9B,6CAA6C;QAC7C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB,sDAAsD;QACtD,eAAe,CAAC,EAAE,YAAY,EAAE,CAAC;KAClC,GAAG,2BAA2B;CAWhC"}
|
|
@@ -94,7 +94,7 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* Simulate a transaction and profile the gate count for each function in the transaction.
|
|
97
|
-
* @param options - Same options as `simulate
|
|
97
|
+
* @param options - Same options as `simulate`, plus profiling method
|
|
98
98
|
*
|
|
99
99
|
* @returns An object containing the function return value and profile result.
|
|
100
100
|
*/ async profile(options = {
|
|
@@ -5,13 +5,14 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
5
5
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
6
6
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
7
7
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
8
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
8
|
+
import type { TxExecutionRequest, TxProfileResult } from '@aztec/stdlib/tx';
|
|
9
9
|
import type { Wallet } from '../wallet/wallet.js';
|
|
10
|
-
import { BaseContractInteraction
|
|
10
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
11
11
|
import type { Contract } from './contract.js';
|
|
12
12
|
import type { ContractBase } from './contract_base.js';
|
|
13
13
|
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
14
14
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
15
|
+
import type { ProfileMethodOptions, SendMethodOptions } from './interaction_options.js';
|
|
15
16
|
/**
|
|
16
17
|
* Options for deploying a contract on the Aztec network.
|
|
17
18
|
* Allows specifying a contract address salt, and additional send method options.
|
|
@@ -61,6 +62,13 @@ export declare class DeployMethod<TContract extends ContractBase = Contract> ext
|
|
|
61
62
|
* it returns a promise for an array instead of a function call directly.
|
|
62
63
|
*/
|
|
63
64
|
request(options?: DeployOptions): Promise<ExecutionPayload>;
|
|
65
|
+
/**
|
|
66
|
+
* Simulate a deployment and profile the gate count for each function in the transaction.
|
|
67
|
+
* @param options - Same options as `send`, plus extra profiling options.
|
|
68
|
+
*
|
|
69
|
+
* @returns An object containing the function return value and profile result.
|
|
70
|
+
*/
|
|
71
|
+
profile(options?: DeployOptions & ProfileMethodOptions): Promise<TxProfileResult>;
|
|
64
72
|
/**
|
|
65
73
|
* Register this contract in the PXE and returns the Contract object.
|
|
66
74
|
* @param options - Deployment options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAoB,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAoB,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAI5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAA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QG;IACU,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAU7E;;;;;;;OAOG;IACU,OAAO,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqB5E;;;;;OAKG;IACU,OAAO,CAClB,OAAO,GAAE,aAAa,GAAG,oBAA+C,GACvE,OAAO,CAAC,eAAe,CAAC;IAK3B;;;OAGG;IACU,QAAQ,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;IAMtE;;;;OAIG;cACa,6BAA6B,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuCrG;;;;OAIG;cACa,6BAA6B,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAehG;;;;;;;OAOG;IACa,IAAI,CAAC,OAAO,GAAE,aAAkB,GAAG,YAAY,CAAC,SAAS,CAAC;IAM1E;;;;;OAKG;IACU,WAAW,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAa3F;;;;OAIG;IACmB,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAOvF;;;OAGG;IACa,WAAW,CACzB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,sBAAsB,CAAC,GACpE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,CAAC;IAIhE,sCAAsC;IACtC,IAAW,OAAO,6BAEjB;IAED,uDAAuD;IACvD,IAAW,cAAc,4BAExB;CACF"}
|
|
@@ -77,6 +77,17 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
77
77
|
return mergeExecutionPayloads(exec);
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
+
* Simulate a deployment and profile the gate count for each function in the transaction.
|
|
81
|
+
* @param options - Same options as `send`, plus extra profiling options.
|
|
82
|
+
*
|
|
83
|
+
* @returns An object containing the function return value and profile result.
|
|
84
|
+
*/ async profile(options = {
|
|
85
|
+
profileMode: 'gates'
|
|
86
|
+
}) {
|
|
87
|
+
const txRequest = await this.create(options);
|
|
88
|
+
return await this.wallet.profileTx(txRequest, options.profileMode, options?.from);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
80
91
|
* Register this contract in the PXE and returns the Contract object.
|
|
81
92
|
* @param options - Deployment options.
|
|
82
93
|
*/ async register(options = {}) {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { UserFeeOptions } from '@aztec/entrypoints/interfaces';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { Capsule } from '@aztec/stdlib/tx';
|
|
6
|
+
/**
|
|
7
|
+
* Represents the options to configure a request from a contract interaction.
|
|
8
|
+
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
9
|
+
*/
|
|
10
|
+
export type RequestMethodOptions = {
|
|
11
|
+
/** Extra authwits to use during execution */
|
|
12
|
+
authWitnesses?: AuthWitness[];
|
|
13
|
+
/** Extra capsules to use during execution */
|
|
14
|
+
capsules?: Capsule[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Represents options for calling a (constrained) function in a contract.
|
|
18
|
+
*/
|
|
19
|
+
export type SendMethodOptions = RequestMethodOptions & {
|
|
20
|
+
/** Wether to skip the simulation of the public part of the transaction. */
|
|
21
|
+
skipPublicSimulation?: boolean;
|
|
22
|
+
/** The fee options for the transaction. */
|
|
23
|
+
fee?: UserFeeOptions;
|
|
24
|
+
/** Custom nonce to inject into the app payload of the transaction. Useful when trying to cancel an ongoing transaction by creating a new one with a higher fee */
|
|
25
|
+
nonce?: Fr;
|
|
26
|
+
/** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
|
|
27
|
+
cancellable?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Represents the options for simulating a contract function interaction.
|
|
31
|
+
* Allows specifying the address from which the method should be called.
|
|
32
|
+
* Disregarded for simulation of public functions
|
|
33
|
+
*/
|
|
34
|
+
export type SimulateMethodOptions = Pick<SendMethodOptions, 'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'> & {
|
|
35
|
+
/** The sender's Aztec address. */
|
|
36
|
+
from?: AztecAddress;
|
|
37
|
+
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
38
|
+
skipTxValidation?: boolean;
|
|
39
|
+
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
40
|
+
skipFeeEnforcement?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Represents the options for profiling an interaction.
|
|
44
|
+
*/
|
|
45
|
+
export type ProfileMethodOptions = SimulateMethodOptions & {
|
|
46
|
+
/** Whether to return gates information or the bytecode/witnesses. */
|
|
47
|
+
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=interaction_options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction_options.d.ts","sourceRoot":"","sources":["../../src/contract/interaction_options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;GAGG;AACH,MAAM,MA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AAd,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,qBAAa,QAAS,SAAQ,EAAE;IAClB,SAAS,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE;IAK5C,SAAS,CAAC,cAAc,IAAI,EAAE;IAI9B;;OAEG;IACI,IAAI,IAAI,MAAM;CAOtB"}
|
|
@@ -7,11 +7,15 @@ import { SentTx } from './sent_tx.js';
|
|
|
7
7
|
constructor(wallet, tx){
|
|
8
8
|
super(tx.data, tx.clientIvcProof, tx.contractClassLogs, tx.publicFunctionCalldata), this.wallet = wallet;
|
|
9
9
|
}
|
|
10
|
+
// Clone the TX data to get a serializable object.
|
|
11
|
+
getPlainDataTx() {
|
|
12
|
+
return new Tx(this.data, this.clientIvcProof, this.contractClassLogs, this.publicFunctionCalldata);
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Sends the transaction to the network via the provided wallet.
|
|
12
16
|
*/ send() {
|
|
13
17
|
const promise = (()=>{
|
|
14
|
-
return this.wallet.sendTx(this);
|
|
18
|
+
return this.wallet.sendTx(this.getPlainDataTx());
|
|
15
19
|
})();
|
|
16
20
|
return new SentTx(this.wallet, promise);
|
|
17
21
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "0.82.
|
|
4
|
+
"version": "0.82.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -80,13 +80,13 @@
|
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@aztec/constants": "0.82.
|
|
84
|
-
"@aztec/entrypoints": "0.82.
|
|
85
|
-
"@aztec/ethereum": "0.82.
|
|
86
|
-
"@aztec/foundation": "0.82.
|
|
87
|
-
"@aztec/l1-artifacts": "0.82.
|
|
88
|
-
"@aztec/protocol-contracts": "0.82.
|
|
89
|
-
"@aztec/stdlib": "0.82.
|
|
83
|
+
"@aztec/constants": "0.82.3",
|
|
84
|
+
"@aztec/entrypoints": "0.82.3",
|
|
85
|
+
"@aztec/ethereum": "0.82.3",
|
|
86
|
+
"@aztec/foundation": "0.82.3",
|
|
87
|
+
"@aztec/l1-artifacts": "0.82.3",
|
|
88
|
+
"@aztec/protocol-contracts": "0.82.3",
|
|
89
|
+
"@aztec/stdlib": "0.82.3",
|
|
90
90
|
"axios": "^1.7.2",
|
|
91
91
|
"tslib": "^2.4.0",
|
|
92
92
|
"viem": "2.23.7"
|
|
@@ -2,7 +2,6 @@ import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { CompleteAddress, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
4
|
import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
5
|
-
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
5
|
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
7
6
|
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
8
7
|
|
|
@@ -145,7 +144,7 @@ export class AccountManager {
|
|
|
145
144
|
* @param deployWallet - Wallet used for deploying the account contract.
|
|
146
145
|
* @returns A DeployMethod instance that deploys this account contract
|
|
147
146
|
*/
|
|
148
|
-
async
|
|
147
|
+
public async getDeployMethod(deployWallet?: Wallet): Promise<DeployMethod> {
|
|
149
148
|
const artifact = await this.accountContract.getContractArtifact();
|
|
150
149
|
|
|
151
150
|
if (!(await this.isDeployable())) {
|
|
@@ -200,7 +199,7 @@ export class AccountManager {
|
|
|
200
199
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
201
200
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
202
201
|
*/
|
|
203
|
-
async
|
|
202
|
+
public async getSelfPaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
|
|
204
203
|
const artifact = await this.accountContract.getContractArtifact();
|
|
205
204
|
const wallet = await this.getWallet();
|
|
206
205
|
const address = wallet.getAddress();
|
|
@@ -223,11 +222,11 @@ export class AccountManager {
|
|
|
223
222
|
*/
|
|
224
223
|
public deploy(opts?: DeployAccountOptions): DeployAccountSentTx {
|
|
225
224
|
let deployMethod: DeployMethod;
|
|
226
|
-
const sentTx = this
|
|
225
|
+
const sentTx = this.getDeployMethod(opts?.deployWallet)
|
|
227
226
|
.then(method => {
|
|
228
227
|
deployMethod = method;
|
|
229
228
|
if (!opts?.deployWallet && opts?.fee) {
|
|
230
|
-
return this
|
|
229
|
+
return this.getSelfPaymentMethod(opts?.fee?.paymentMethod);
|
|
231
230
|
}
|
|
232
231
|
})
|
|
233
232
|
.then(maybeWrappedPaymentMethod => {
|
|
@@ -248,31 +247,6 @@ export class AccountManager {
|
|
|
248
247
|
return new DeployAccountSentTx(this.pxe, sentTx, this.getWallet());
|
|
249
248
|
}
|
|
250
249
|
|
|
251
|
-
/**
|
|
252
|
-
* Estimates the gas needed to deploy the account contract that backs this account.
|
|
253
|
-
* This method is here to ensure that the fee payment method is correctly set up in case
|
|
254
|
-
* the account contract needs to pay for its own deployment.
|
|
255
|
-
* @param opts - Fee options to be used for the deployment.
|
|
256
|
-
* @returns The gas estimations for the account contract deployment and initialization.
|
|
257
|
-
*/
|
|
258
|
-
public async estimateDeploymentGas(
|
|
259
|
-
opts?: DeployAccountOptions,
|
|
260
|
-
): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>> {
|
|
261
|
-
const deployMethod = await this.#getDeployMethod(opts?.deployWallet);
|
|
262
|
-
const fee =
|
|
263
|
-
!opts?.deployWallet && opts?.fee
|
|
264
|
-
? { ...opts.fee, paymentMethod: await this.#getSelfPaymentMethod(opts.fee.paymentMethod) }
|
|
265
|
-
: opts?.fee;
|
|
266
|
-
return deployMethod.estimateGas({
|
|
267
|
-
contractAddressSalt: new Fr(this.salt),
|
|
268
|
-
skipClassRegistration: opts?.skipClassRegistration ?? true,
|
|
269
|
-
skipPublicDeployment: opts?.skipPublicDeployment ?? true,
|
|
270
|
-
skipInitialization: opts?.skipInitialization ?? false,
|
|
271
|
-
universalDeploy: true,
|
|
272
|
-
fee,
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
250
|
/**
|
|
277
251
|
* Deploys the account contract that backs this account if needed and awaits the tx to be mined.
|
|
278
252
|
* Uses the salt provided in the constructor or a randomly generated one. If no initialization
|
package/src/api/contract.ts
CHANGED
|
@@ -36,7 +36,14 @@
|
|
|
36
36
|
* @packageDocumentation
|
|
37
37
|
*/
|
|
38
38
|
export { Contract } from '../contract/contract.js';
|
|
39
|
-
export { ContractFunctionInteraction
|
|
39
|
+
export { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
type RequestMethodOptions,
|
|
43
|
+
type SendMethodOptions,
|
|
44
|
+
type ProfileMethodOptions,
|
|
45
|
+
type SimulateMethodOptions,
|
|
46
|
+
} from '../contract/interaction_options.js';
|
|
40
47
|
|
|
41
48
|
export { TxProfileResult } from '@aztec/stdlib/tx';
|
|
42
49
|
export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { FeeOptions, TxExecutionOptions, UserFeeOptions } from '@aztec/entrypoints/interfaces';
|
|
2
2
|
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
3
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
4
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
6
5
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -9,34 +8,10 @@ import type { Capsule, TxExecutionRequest, TxProvingResult } from '@aztec/stdlib
|
|
|
9
8
|
import { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
|
|
10
9
|
import type { Wallet } from '../wallet/wallet.js';
|
|
11
10
|
import { getGasLimits } from './get_gas_limits.js';
|
|
11
|
+
import type { RequestMethodOptions, SendMethodOptions } from './interaction_options.js';
|
|
12
12
|
import { ProvenTx } from './proven_tx.js';
|
|
13
13
|
import { SentTx } from './sent_tx.js';
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Represents the options to configure a request from a contract interaction.
|
|
17
|
-
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
18
|
-
*/
|
|
19
|
-
export type RequestMethodOptions = {
|
|
20
|
-
/** Extra authwits to use during execution */
|
|
21
|
-
authWitnesses?: AuthWitness[];
|
|
22
|
-
/** Extra capsules to use during execution */
|
|
23
|
-
capsules?: Capsule[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Represents options for calling a (constrained) function in a contract.
|
|
28
|
-
*/
|
|
29
|
-
export type SendMethodOptions = RequestMethodOptions & {
|
|
30
|
-
/** Wether to skip the simulation of the public part of the transaction. */
|
|
31
|
-
skipPublicSimulation?: boolean;
|
|
32
|
-
/** The fee options for the transaction. */
|
|
33
|
-
fee?: UserFeeOptions;
|
|
34
|
-
/** Custom nonce to inject into the app payload of the transaction. Useful when trying to cancel an ongoing transaction by creating a new one with a higher fee */
|
|
35
|
-
nonce?: Fr;
|
|
36
|
-
/** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
|
|
37
|
-
cancellable?: boolean;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
15
|
/**
|
|
41
16
|
* Base class for an interaction with a contract, be it a deployment, a function call, or a batch.
|
|
42
17
|
* Implements the sequence create/simulate/send.
|
|
@@ -3,12 +3,8 @@ import { type FunctionCall, FunctionType, decodeFromAbi } from '@aztec/stdlib/ab
|
|
|
3
3
|
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { Wallet } from '../wallet/wallet.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
type RequestMethodOptions,
|
|
9
|
-
type SendMethodOptions,
|
|
10
|
-
} from './base_contract_interaction.js';
|
|
11
|
-
import type { SimulateMethodOptions } from './contract_function_interaction.js';
|
|
6
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
7
|
+
import type { RequestMethodOptions, SendMethodOptions, SimulateMethodOptions } from './interaction_options.js';
|
|
12
8
|
|
|
13
9
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
14
10
|
export class BatchCall extends BaseContractInteraction {
|
|
@@ -5,45 +5,13 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
5
5
|
import type { Capsule, HashedValues, TxExecutionRequest, TxProfileResult } from '@aztec/stdlib/tx';
|
|
6
6
|
|
|
7
7
|
import type { Wallet } from '../wallet/wallet.js';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from './base_contract_interaction.js';
|
|
13
|
-
|
|
14
|
-
export type { SendMethodOptions };
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Represents the options for simulating a contract function interaction.
|
|
18
|
-
* Allows specifying the address from which the view method should be called.
|
|
19
|
-
* Disregarded for simulation of public functions
|
|
20
|
-
*/
|
|
21
|
-
export type ProfileMethodOptions = Pick<
|
|
22
|
-
SendMethodOptions,
|
|
23
|
-
'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'
|
|
24
|
-
> & {
|
|
25
|
-
/** Whether to return gates information or the bytecode/witnesses. */
|
|
26
|
-
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
27
|
-
/** The sender's Aztec address. */
|
|
28
|
-
from?: AztecAddress;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Represents the options for simulating a contract function interaction.
|
|
33
|
-
* Allows specifying the address from which the method should be called.
|
|
34
|
-
* Disregarded for simulation of public functions
|
|
35
|
-
*/
|
|
36
|
-
export type SimulateMethodOptions = Pick<
|
|
8
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
9
|
+
import type {
|
|
10
|
+
ProfileMethodOptions,
|
|
11
|
+
RequestMethodOptions,
|
|
37
12
|
SendMethodOptions,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/** The sender's Aztec address. */
|
|
41
|
-
from?: AztecAddress;
|
|
42
|
-
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
43
|
-
skipTxValidation?: boolean;
|
|
44
|
-
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
45
|
-
skipFeeEnforcement?: boolean;
|
|
46
|
-
};
|
|
13
|
+
SimulateMethodOptions,
|
|
14
|
+
} from './interaction_options.js';
|
|
47
15
|
|
|
48
16
|
/**
|
|
49
17
|
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
@@ -72,7 +40,7 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
72
40
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
73
41
|
* @returns A Promise that resolves to a transaction instance.
|
|
74
42
|
*/
|
|
75
|
-
public async create(options: SendMethodOptions = {}): Promise<TxExecutionRequest> {
|
|
43
|
+
public override async create(options: SendMethodOptions = {}): Promise<TxExecutionRequest> {
|
|
76
44
|
// docs:end:create
|
|
77
45
|
if (this.functionDao.functionType === FunctionType.UNCONSTRAINED) {
|
|
78
46
|
throw new Error("Can't call `create` on an unconstrained function.");
|
|
@@ -92,7 +60,7 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
92
60
|
* @param options - An optional object containing additional configuration for the request generation.
|
|
93
61
|
* @returns An execution payload wrapped in promise.
|
|
94
62
|
*/
|
|
95
|
-
public async request(options: RequestMethodOptions = {}): Promise<ExecutionPayload> {
|
|
63
|
+
public override async request(options: RequestMethodOptions = {}): Promise<ExecutionPayload> {
|
|
96
64
|
// docs:end:request
|
|
97
65
|
const args = encodeArguments(this.functionDao, this.args);
|
|
98
66
|
const calls = [
|
|
@@ -166,7 +134,7 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
166
134
|
|
|
167
135
|
/**
|
|
168
136
|
* Simulate a transaction and profile the gate count for each function in the transaction.
|
|
169
|
-
* @param options - Same options as `simulate
|
|
137
|
+
* @param options - Same options as `simulate`, plus profiling method
|
|
170
138
|
*
|
|
171
139
|
* @returns An object containing the function return value and profile result.
|
|
172
140
|
*/
|
|
@@ -11,17 +11,18 @@ import {
|
|
|
11
11
|
} from '@aztec/stdlib/contract';
|
|
12
12
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
13
13
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
14
|
-
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
14
|
+
import type { TxExecutionRequest, TxProfileResult } from '@aztec/stdlib/tx';
|
|
15
15
|
|
|
16
16
|
import { deployInstance } from '../deployment/deploy_instance.js';
|
|
17
17
|
import { registerContractClass } from '../deployment/register_class.js';
|
|
18
18
|
import type { Wallet } from '../wallet/wallet.js';
|
|
19
|
-
import { BaseContractInteraction
|
|
19
|
+
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
20
20
|
import type { Contract } from './contract.js';
|
|
21
21
|
import type { ContractBase } from './contract_base.js';
|
|
22
22
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
23
23
|
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
24
24
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
25
|
+
import type { ProfileMethodOptions, SendMethodOptions } from './interaction_options.js';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Options for deploying a contract on the Aztec network.
|
|
@@ -114,6 +115,19 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
114
115
|
return mergeExecutionPayloads(exec);
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Simulate a deployment and profile the gate count for each function in the transaction.
|
|
120
|
+
* @param options - Same options as `send`, plus extra profiling options.
|
|
121
|
+
*
|
|
122
|
+
* @returns An object containing the function return value and profile result.
|
|
123
|
+
*/
|
|
124
|
+
public async profile(
|
|
125
|
+
options: DeployOptions & ProfileMethodOptions = { profileMode: 'gates' },
|
|
126
|
+
): Promise<TxProfileResult> {
|
|
127
|
+
const txRequest = await this.create(options);
|
|
128
|
+
return await this.wallet.profileTx(txRequest, options.profileMode, options?.from);
|
|
129
|
+
}
|
|
130
|
+
|
|
117
131
|
/**
|
|
118
132
|
* Register this contract in the PXE and returns the Contract object.
|
|
119
133
|
* @param options - Deployment options.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { UserFeeOptions } from '@aztec/entrypoints/interfaces';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
import type { Capsule } from '@aztec/stdlib/tx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents the options to configure a request from a contract interaction.
|
|
9
|
+
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
10
|
+
*/
|
|
11
|
+
export type RequestMethodOptions = {
|
|
12
|
+
/** Extra authwits to use during execution */
|
|
13
|
+
authWitnesses?: AuthWitness[];
|
|
14
|
+
/** Extra capsules to use during execution */
|
|
15
|
+
capsules?: Capsule[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Represents options for calling a (constrained) function in a contract.
|
|
20
|
+
*/
|
|
21
|
+
export type SendMethodOptions = RequestMethodOptions & {
|
|
22
|
+
/** Wether to skip the simulation of the public part of the transaction. */
|
|
23
|
+
skipPublicSimulation?: boolean;
|
|
24
|
+
/** The fee options for the transaction. */
|
|
25
|
+
fee?: UserFeeOptions;
|
|
26
|
+
/** Custom nonce to inject into the app payload of the transaction. Useful when trying to cancel an ongoing transaction by creating a new one with a higher fee */
|
|
27
|
+
nonce?: Fr;
|
|
28
|
+
/** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
|
|
29
|
+
cancellable?: boolean;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Represents the options for simulating a contract function interaction.
|
|
34
|
+
* Allows specifying the address from which the method should be called.
|
|
35
|
+
* Disregarded for simulation of public functions
|
|
36
|
+
*/
|
|
37
|
+
export type SimulateMethodOptions = Pick<
|
|
38
|
+
SendMethodOptions,
|
|
39
|
+
'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'
|
|
40
|
+
> & {
|
|
41
|
+
/** The sender's Aztec address. */
|
|
42
|
+
from?: AztecAddress;
|
|
43
|
+
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
44
|
+
skipTxValidation?: boolean;
|
|
45
|
+
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
46
|
+
skipFeeEnforcement?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Represents the options for profiling an interaction.
|
|
51
|
+
*/
|
|
52
|
+
export type ProfileMethodOptions = SimulateMethodOptions & {
|
|
53
|
+
/** Whether to return gates information or the bytecode/witnesses. */
|
|
54
|
+
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
55
|
+
};
|
|
@@ -11,12 +11,17 @@ export class ProvenTx extends Tx {
|
|
|
11
11
|
super(tx.data, tx.clientIvcProof, tx.contractClassLogs, tx.publicFunctionCalldata);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Clone the TX data to get a serializable object.
|
|
15
|
+
protected getPlainDataTx(): Tx {
|
|
16
|
+
return new Tx(this.data, this.clientIvcProof, this.contractClassLogs, this.publicFunctionCalldata);
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Sends the transaction to the network via the provided wallet.
|
|
16
21
|
*/
|
|
17
22
|
public send(): SentTx {
|
|
18
23
|
const promise = (() => {
|
|
19
|
-
return this.wallet.sendTx(this);
|
|
24
|
+
return this.wallet.sendTx(this.getPlainDataTx());
|
|
20
25
|
})();
|
|
21
26
|
|
|
22
27
|
return new SentTx(this.wallet, promise);
|