@aztec/aztec.js 0.65.1 → 0.66.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/dest/account_manager/deploy_account_method.d.ts +1 -1
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +3 -2
- package/dest/account_manager/index.d.ts +1 -1
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +1 -2
- package/dest/contract/base_contract_interaction.d.ts +12 -11
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +27 -13
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +11 -17
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +5 -12
- package/dest/contract/deploy_method.d.ts +2 -2
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +14 -18
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/proven_tx.js +3 -3
- package/dest/deployment/register_class.d.ts +1 -1
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +8 -3
- package/dest/entrypoint/default_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_entrypoint.js +4 -5
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +4 -5
- package/dest/entrypoint/entrypoint.d.ts +1 -1
- package/dest/entrypoint/entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/payload.d.ts +12 -0
- package/dest/entrypoint/payload.d.ts.map +1 -1
- package/dest/entrypoint/payload.js +1 -1
- package/dest/index.d.ts +5 -5
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -5
- package/dest/main.js +1 -1
- package/dest/main.js.LICENSE.txt +2 -0
- package/dest/utils/cheat_codes.d.ts +2 -125
- package/dest/utils/cheat_codes.d.ts.map +1 -1
- package/dest/utils/cheat_codes.js +9 -233
- package/dest/wallet/account_wallet.d.ts +1 -0
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +4 -1
- package/dest/wallet/base_wallet.d.ts +1 -0
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +1 -1
- package/dest/wallet/signerless_wallet.d.ts +1 -0
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +4 -1
- package/package.json +8 -8
- package/src/account_manager/deploy_account_method.ts +5 -2
- package/src/account_manager/index.ts +1 -2
- package/src/contract/base_contract_interaction.ts +37 -18
- package/src/contract/batch_call.ts +18 -29
- package/src/contract/contract_function_interaction.ts +4 -11
- package/src/contract/deploy_method.ts +20 -19
- package/src/contract/proven_tx.ts +0 -4
- package/src/deployment/register_class.ts +8 -1
- package/src/entrypoint/default_entrypoint.ts +3 -4
- package/src/entrypoint/default_multi_call_entrypoint.ts +3 -4
- package/src/entrypoint/entrypoint.ts +1 -1
- package/src/entrypoint/payload.ts +13 -0
- package/src/index.ts +6 -9
- package/src/utils/cheat_codes.ts +14 -251
- package/src/wallet/account_wallet.ts +4 -0
- package/src/wallet/base_wallet.ts +2 -0
- package/src/wallet/signerless_wallet.ts +4 -0
|
@@ -31,5 +31,8 @@ export class SignerlessWallet extends BaseWallet {
|
|
|
31
31
|
createAuthWit(_intent) {
|
|
32
32
|
throw new Error('SignerlessWallet: Method createAuthWit not implemented.');
|
|
33
33
|
}
|
|
34
|
+
isL1ToL2MessageSynced(l1ToL2Message) {
|
|
35
|
+
return this.pxe.isL1ToL2MessageSynced(l1ToL2Message);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmVybGVzc193YWxsZXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L3NpZ25lcmxlc3Nfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBR3hFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUU5Qzs7R0FFRztBQUNILE1BQU0sT0FBTyxnQkFBaUIsU0FBUSxVQUFVO0lBQzlDLFlBQVksR0FBUSxFQUFVLFVBQWdDO1FBQzVELEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQztRQURpQixlQUFVLEdBQVYsVUFBVSxDQUFzQjtJQUU5RCxDQUFDO0lBQ0QsS0FBSyxDQUFDLHdCQUF3QixDQUFDLFNBQStCO1FBQzVELElBQUksVUFBVSxHQUFHLElBQUksQ0FBQyxVQUFVLENBQUM7UUFDakMsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDO1lBQ2hCLE1BQU0sRUFBRSxTQUFTLEVBQUUsT0FBTyxFQUFFLGVBQWUsRUFBRSxHQUFHLE1BQU0sSUFBSSxDQUFDLEdBQUcsQ0FBQyxXQUFXLEVBQUUsQ0FBQztZQUM3RSxVQUFVLEdBQUcsSUFBSSxpQkFBaUIsQ0FBQyxPQUFPLEVBQUUsZUFBZSxDQUFDLENBQUM7UUFDL0QsQ0FBQztRQUVELE9BQU8sVUFBVSxDQUFDLHdCQUF3QixDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQ3hELENBQUM7SUFFRCxVQUFVO1FBQ1IsTUFBTSxJQUFJLEtBQUssQ0FBQyxzREFBc0QsQ0FBQyxDQUFDO0lBQzFFLENBQUM7SUFFRCxVQUFVO1FBQ1IsTUFBTSxJQUFJLEtBQUssQ0FBQyxzREFBc0QsQ0FBQyxDQUFDO0lBQzFFLENBQUM7SUFFRCxpQkFBaUI7UUFDZixNQUFNLElBQUksS0FBSyxDQUFDLDZEQUE2RCxDQUFDLENBQUM7SUFDakYsQ0FBQztJQUVELGtCQUFrQjtRQUNoQixNQUFNLElBQUksS0FBSyxDQUFDLDhEQUE4RCxDQUFDLENBQUM7SUFDbEYsQ0FBQztJQUVELGFBQWEsQ0FBQyxPQUFxRDtRQUNqRSxNQUFNLElBQUksS0FBSyxDQUFDLHlEQUF5RCxDQUFDLENBQUM7SUFDN0UsQ0FBQztJQUVRLHFCQUFxQixDQUFDLGFBQWlCO1FBQzlDLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxxQkFBcUIsQ0FBQyxhQUFhLENBQUMsQ0FBQztJQUN2RCxDQUFDO0NBQ0YifQ==
|
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.
|
|
4
|
+
"version": "0.66.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
]
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@aztec/circuit-types": "0.
|
|
80
|
-
"@aztec/circuits.js": "0.
|
|
81
|
-
"@aztec/ethereum": "0.
|
|
82
|
-
"@aztec/foundation": "0.
|
|
83
|
-
"@aztec/l1-artifacts": "0.
|
|
84
|
-
"@aztec/protocol-contracts": "0.
|
|
85
|
-
"@aztec/types": "0.
|
|
79
|
+
"@aztec/circuit-types": "0.66.0",
|
|
80
|
+
"@aztec/circuits.js": "0.66.0",
|
|
81
|
+
"@aztec/ethereum": "0.66.0",
|
|
82
|
+
"@aztec/foundation": "0.66.0",
|
|
83
|
+
"@aztec/l1-artifacts": "0.66.0",
|
|
84
|
+
"@aztec/protocol-contracts": "0.66.0",
|
|
85
|
+
"@aztec/types": "0.66.0",
|
|
86
86
|
"axios": "^1.7.2",
|
|
87
87
|
"tslib": "^2.4.0",
|
|
88
88
|
"viem": "^2.7.15"
|
|
@@ -46,13 +46,16 @@ export class DeployAccountMethod extends DeployMethod {
|
|
|
46
46
|
: feePaymentNameOrArtifact;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
protected override async getInitializeFunctionCalls(
|
|
49
|
+
protected override async getInitializeFunctionCalls(
|
|
50
|
+
options: DeployOptions,
|
|
51
|
+
): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'packedArguments'>> {
|
|
50
52
|
const exec = await super.getInitializeFunctionCalls(options);
|
|
51
53
|
|
|
52
54
|
if (options.fee && this.#feePaymentArtifact) {
|
|
53
55
|
const { address } = this.getInstance();
|
|
54
56
|
const emptyAppPayload = EntrypointPayload.fromAppExecution([]);
|
|
55
|
-
const
|
|
57
|
+
const fee = await this.getDefaultFeeOptions(options.fee);
|
|
58
|
+
const feePayload = await EntrypointPayload.fromFeeOptions(address, fee);
|
|
56
59
|
|
|
57
60
|
exec.calls.push({
|
|
58
61
|
name: this.#feePaymentArtifact.name,
|
|
@@ -17,7 +17,7 @@ import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
|
17
17
|
*/
|
|
18
18
|
export type DeployAccountOptions = Pick<
|
|
19
19
|
DeployOptions,
|
|
20
|
-
'fee' | 'skipClassRegistration' | 'skipPublicDeployment' | '
|
|
20
|
+
'fee' | 'skipClassRegistration' | 'skipPublicDeployment' | 'skipInitialization'
|
|
21
21
|
>;
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -166,7 +166,6 @@ export class AccountManager {
|
|
|
166
166
|
skipInitialization: opts?.skipInitialization ?? false,
|
|
167
167
|
universalDeploy: true,
|
|
168
168
|
fee: opts?.fee,
|
|
169
|
-
estimateGas: opts?.estimateGas,
|
|
170
169
|
}),
|
|
171
170
|
)
|
|
172
171
|
.then(tx => tx.getTxHash());
|
|
@@ -3,7 +3,9 @@ import { type Fr, GasSettings } from '@aztec/circuits.js';
|
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
4
|
|
|
5
5
|
import { type Wallet } from '../account/wallet.js';
|
|
6
|
-
import { type ExecutionRequestInit
|
|
6
|
+
import { type ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
7
|
+
import { type FeeOptions, type UserFeeOptions } from '../entrypoint/payload.js';
|
|
8
|
+
import { NoFeePaymentMethod } from '../fee/no_fee_payment_method.js';
|
|
7
9
|
import { getGasLimits } from './get_gas_limits.js';
|
|
8
10
|
import { ProvenTx } from './proven_tx.js';
|
|
9
11
|
import { SentTx } from './sent_tx.js';
|
|
@@ -16,11 +18,7 @@ export type SendMethodOptions = {
|
|
|
16
18
|
/** Wether to skip the simulation of the public part of the transaction. */
|
|
17
19
|
skipPublicSimulation?: boolean;
|
|
18
20
|
/** The fee options for the transaction. */
|
|
19
|
-
fee?:
|
|
20
|
-
/** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings (will default to true later down the road). */
|
|
21
|
-
estimateGas?: boolean;
|
|
22
|
-
/** Percentage to pad the suggested gas limits by, if empty, defaults to 10%. */
|
|
23
|
-
estimatedGasPad?: number;
|
|
21
|
+
fee?: UserFeeOptions;
|
|
24
22
|
/** 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
23
|
nonce?: Fr;
|
|
26
24
|
/** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
|
|
@@ -92,33 +90,54 @@ export abstract class BaseContractInteraction {
|
|
|
92
90
|
public async estimateGas(
|
|
93
91
|
opts?: Omit<SendMethodOptions, 'estimateGas' | 'skipPublicSimulation'>,
|
|
94
92
|
): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>> {
|
|
95
|
-
const txRequest = await this.create({ ...opts, estimateGas: false });
|
|
93
|
+
const txRequest = await this.create({ ...opts, fee: { ...opts?.fee, estimateGas: false } });
|
|
96
94
|
const simulationResult = await this.wallet.simulateTx(txRequest, true);
|
|
97
95
|
const { totalGas: gasLimits, teardownGas: teardownGasLimits } = getGasLimits(
|
|
98
96
|
simulationResult,
|
|
99
|
-
opts?.
|
|
97
|
+
opts?.fee?.estimatedGasPadding,
|
|
100
98
|
);
|
|
101
99
|
return { gasLimits, teardownGasLimits };
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
/**
|
|
105
|
-
*
|
|
103
|
+
* Returns default fee options based on the user opts without running a simulation for gas estimation.
|
|
104
|
+
* @param fee - User-provided fee options.
|
|
105
|
+
*/
|
|
106
|
+
protected async getDefaultFeeOptions(fee: UserFeeOptions | undefined): Promise<FeeOptions> {
|
|
107
|
+
const maxFeesPerGas = fee?.gasSettings?.maxFeesPerGas ?? (await this.wallet.getCurrentBaseFees());
|
|
108
|
+
const paymentMethod = fee?.paymentMethod ?? new NoFeePaymentMethod();
|
|
109
|
+
const gasSettings: GasSettings = GasSettings.default({ ...fee?.gasSettings, maxFeesPerGas });
|
|
110
|
+
return { gasSettings, paymentMethod };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Return fee options based on the user opts, estimating tx gas if needed.
|
|
106
115
|
* @param request - Request to execute for this interaction.
|
|
107
116
|
* @param pad - Percentage to pad the suggested gas limits by, as decimal (e.g., 0.10 for 10%).
|
|
108
117
|
* @returns Fee options for the actual transaction.
|
|
109
118
|
*/
|
|
110
|
-
protected async
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
protected async getFeeOptions(
|
|
120
|
+
request: Omit<ExecutionRequestInit, 'fee'> & { /** User-provided fee options */ fee?: UserFeeOptions },
|
|
121
|
+
): Promise<FeeOptions> {
|
|
122
|
+
const defaultFeeOptions = await this.getDefaultFeeOptions(request.fee);
|
|
123
|
+
const paymentMethod = defaultFeeOptions.paymentMethod;
|
|
124
|
+
const maxFeesPerGas = defaultFeeOptions.gasSettings.maxFeesPerGas;
|
|
125
|
+
|
|
126
|
+
let gasSettings = defaultFeeOptions.gasSettings;
|
|
127
|
+
if (request.fee?.estimateGas) {
|
|
128
|
+
const feeForEstimation: FeeOptions = { paymentMethod, gasSettings };
|
|
129
|
+
const txRequest = await this.wallet.createTxExecutionRequest({ ...request, fee: feeForEstimation });
|
|
114
130
|
const simulationResult = await this.wallet.simulateTx(txRequest, true);
|
|
115
|
-
const { totalGas: gasLimits, teardownGas: teardownGasLimits } = getGasLimits(
|
|
116
|
-
|
|
131
|
+
const { totalGas: gasLimits, teardownGas: teardownGasLimits } = getGasLimits(
|
|
132
|
+
simulationResult,
|
|
133
|
+
request.fee?.estimatedGasPadding,
|
|
134
|
+
);
|
|
135
|
+
gasSettings = GasSettings.from({ maxFeesPerGas, gasLimits, teardownGasLimits });
|
|
136
|
+
this.log.verbose(
|
|
117
137
|
`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`,
|
|
118
138
|
);
|
|
119
|
-
const gasSettings = GasSettings.default({ ...fee.gasSettings, gasLimits, teardownGasLimits });
|
|
120
|
-
return { ...fee, gasSettings };
|
|
121
139
|
}
|
|
122
|
-
|
|
140
|
+
|
|
141
|
+
return { gasSettings, paymentMethod };
|
|
123
142
|
}
|
|
124
143
|
}
|
|
@@ -19,10 +19,8 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
19
19
|
*/
|
|
20
20
|
public async create(opts?: SendMethodOptions): Promise<TxExecutionRequest> {
|
|
21
21
|
const calls = this.calls;
|
|
22
|
-
const fee = opts
|
|
23
|
-
|
|
24
|
-
: opts?.fee;
|
|
25
|
-
return await this.wallet.createTxExecutionRequest({ calls, fee });
|
|
22
|
+
const fee = await this.getFeeOptions({ calls, ...opts });
|
|
23
|
+
return await this.wallet.createTxExecutionRequest({ calls, ...opts, fee });
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
/**
|
|
@@ -35,29 +33,21 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
35
33
|
* @returns The result of the transaction as returned by the contract function.
|
|
36
34
|
*/
|
|
37
35
|
public async simulate(options: SimulateMethodOptions = {}): Promise<any> {
|
|
38
|
-
const {
|
|
39
|
-
/**
|
|
40
|
-
* Keep track of the number of private calls to retrieve the return values
|
|
41
|
-
*/
|
|
36
|
+
const { indexedCalls, unconstrained } = this.calls.reduce<{
|
|
37
|
+
/** Keep track of the number of private calls to retrieve the return values */
|
|
42
38
|
privateIndex: 0;
|
|
43
|
-
/**
|
|
44
|
-
* Keep track of the number of private calls to retrieve the return values
|
|
45
|
-
*/
|
|
39
|
+
/** Keep track of the number of public calls to retrieve the return values */
|
|
46
40
|
publicIndex: 0;
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
calls: [FunctionCall, number, number][];
|
|
51
|
-
/**
|
|
52
|
-
* The unconstrained function calls in the batch.
|
|
53
|
-
*/
|
|
41
|
+
/** The public and private function calls in the batch */
|
|
42
|
+
indexedCalls: [FunctionCall, number, number][];
|
|
43
|
+
/** The unconstrained function calls in the batch. */
|
|
54
44
|
unconstrained: [FunctionCall, number][];
|
|
55
45
|
}>(
|
|
56
46
|
(acc, current, index) => {
|
|
57
47
|
if (current.type === FunctionType.UNCONSTRAINED) {
|
|
58
48
|
acc.unconstrained.push([current, index]);
|
|
59
49
|
} else {
|
|
60
|
-
acc.
|
|
50
|
+
acc.indexedCalls.push([
|
|
61
51
|
current,
|
|
62
52
|
index,
|
|
63
53
|
current.type === FunctionType.PRIVATE ? acc.privateIndex++ : acc.publicIndex++,
|
|
@@ -65,18 +55,17 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
65
55
|
}
|
|
66
56
|
return acc;
|
|
67
57
|
},
|
|
68
|
-
{
|
|
58
|
+
{ indexedCalls: [], unconstrained: [], publicIndex: 0, privateIndex: 0 },
|
|
69
59
|
);
|
|
70
60
|
|
|
71
|
-
const
|
|
61
|
+
const calls = indexedCalls.map(([call]) => call);
|
|
62
|
+
const fee = await this.getFeeOptions({ calls, ...options });
|
|
63
|
+
const txRequest = await this.wallet.createTxExecutionRequest({ calls, ...options, fee });
|
|
72
64
|
|
|
73
|
-
const unconstrainedCalls = unconstrained.map(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
indexedCall[1],
|
|
78
|
-
] as const;
|
|
79
|
-
});
|
|
65
|
+
const unconstrainedCalls = unconstrained.map(
|
|
66
|
+
async ([call, index]) =>
|
|
67
|
+
[await this.wallet.simulateUnconstrained(call.name, call.args, call.to, options?.from), index] as const,
|
|
68
|
+
);
|
|
80
69
|
|
|
81
70
|
const [unconstrainedResults, simulatedTx] = await Promise.all([
|
|
82
71
|
Promise.all(unconstrainedCalls),
|
|
@@ -88,7 +77,7 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
88
77
|
unconstrainedResults.forEach(([result, index]) => {
|
|
89
78
|
results[index] = result;
|
|
90
79
|
});
|
|
91
|
-
|
|
80
|
+
indexedCalls.forEach(([call, callIndex, resultIndex]) => {
|
|
92
81
|
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
93
82
|
// since we're interested in the first set of values AFTER the account entrypoint
|
|
94
83
|
// For public functions we retrieve the first values directly from the public output.
|
|
@@ -58,21 +58,14 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
58
58
|
* @param opts - An optional object containing additional configuration for the transaction.
|
|
59
59
|
* @returns A Promise that resolves to a transaction instance.
|
|
60
60
|
*/
|
|
61
|
-
public async create(opts
|
|
61
|
+
public async create(opts: SendMethodOptions = {}): Promise<TxExecutionRequest> {
|
|
62
62
|
if (this.functionDao.functionType === FunctionType.UNCONSTRAINED) {
|
|
63
63
|
throw new Error("Can't call `create` on an unconstrained function.");
|
|
64
64
|
}
|
|
65
65
|
const calls = [this.request()];
|
|
66
|
-
const fee = opts
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const txRequest = await this.wallet.createTxExecutionRequest({
|
|
70
|
-
calls,
|
|
71
|
-
fee,
|
|
72
|
-
nonce: opts?.nonce,
|
|
73
|
-
cancellable: opts?.cancellable,
|
|
74
|
-
});
|
|
75
|
-
return txRequest;
|
|
66
|
+
const fee = await this.getFeeOptions({ calls, ...opts });
|
|
67
|
+
const { nonce, cancellable } = opts;
|
|
68
|
+
return await this.wallet.createTxExecutionRequest({ calls, fee, nonce, cancellable });
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
/**
|
|
@@ -89,6 +89,11 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
89
89
|
* it returns a promise for an array instead of a function call directly.
|
|
90
90
|
*/
|
|
91
91
|
public async request(options: DeployOptions = {}): Promise<ExecutionRequestInit> {
|
|
92
|
+
const deployment = await this.getDeploymentFunctionCalls(options);
|
|
93
|
+
|
|
94
|
+
// NOTE: MEGA HACK. Remove with #10007
|
|
95
|
+
// register the contract after generating deployment function calls in order to publicly register the class and (optioanlly) emit its bytecode
|
|
96
|
+
//
|
|
92
97
|
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
|
|
93
98
|
// Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
|
|
94
99
|
// runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
|
|
@@ -97,25 +102,21 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
97
102
|
// once this tx has gone through.
|
|
98
103
|
await this.wallet.registerContract({ artifact: this.artifact, instance: this.getInstance(options) });
|
|
99
104
|
|
|
100
|
-
const deployment = await this.getDeploymentFunctionCalls(options);
|
|
101
105
|
const bootstrap = await this.getInitializeFunctionCalls(options);
|
|
102
106
|
|
|
103
107
|
if (deployment.calls.length + bootstrap.calls.length === 0) {
|
|
104
108
|
throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`);
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
fee: options.fee,
|
|
112
|
-
};
|
|
111
|
+
const calls = [...deployment.calls, ...bootstrap.calls];
|
|
112
|
+
const authWitnesses = [...(deployment.authWitnesses ?? []), ...(bootstrap.authWitnesses ?? [])];
|
|
113
|
+
const packedArguments = [...(deployment.packedArguments ?? []), ...(bootstrap.packedArguments ?? [])];
|
|
114
|
+
const { cancellable, nonce, fee: userFee } = options;
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
request.fee = await this.getFeeOptionsFromEstimatedGas(request, options.estimatedGasPad);
|
|
116
|
-
}
|
|
116
|
+
const request = { calls, authWitnesses, packedArguments, cancellable, fee: userFee, nonce };
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
const fee = await this.getFeeOptions(request);
|
|
119
|
+
return { ...request, fee };
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
/**
|
|
@@ -133,7 +134,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
133
134
|
* @param options - Deployment options.
|
|
134
135
|
* @returns A function call array with potentially requests to the class registerer and instance deployer.
|
|
135
136
|
*/
|
|
136
|
-
protected async getDeploymentFunctionCalls(
|
|
137
|
+
protected async getDeploymentFunctionCalls(
|
|
138
|
+
options: DeployOptions = {},
|
|
139
|
+
): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'packedArguments'>> {
|
|
137
140
|
const calls: FunctionCall[] = [];
|
|
138
141
|
|
|
139
142
|
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
@@ -167,9 +170,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
167
170
|
calls.push(deployInstance(this.wallet, instance).request());
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
return {
|
|
171
|
-
calls,
|
|
172
|
-
};
|
|
173
|
+
return { calls };
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
/**
|
|
@@ -177,7 +178,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
177
178
|
* @param options - Deployment options.
|
|
178
179
|
* @returns - An array of function calls.
|
|
179
180
|
*/
|
|
180
|
-
protected getInitializeFunctionCalls(
|
|
181
|
+
protected getInitializeFunctionCalls(
|
|
182
|
+
options: DeployOptions,
|
|
183
|
+
): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'packedArguments'>> {
|
|
181
184
|
const { address } = this.getInstance(options);
|
|
182
185
|
const calls: FunctionCall[] = [];
|
|
183
186
|
if (this.constructorArtifact && !options.skipInitialization) {
|
|
@@ -189,9 +192,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
189
192
|
);
|
|
190
193
|
calls.push(constructorCall.request());
|
|
191
194
|
}
|
|
192
|
-
return Promise.resolve({
|
|
193
|
-
calls,
|
|
194
|
-
});
|
|
195
|
+
return Promise.resolve({ calls });
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
/**
|
|
@@ -11,8 +11,6 @@ export class ProvenTx extends Tx {
|
|
|
11
11
|
super(
|
|
12
12
|
tx.data,
|
|
13
13
|
tx.clientIvcProof,
|
|
14
|
-
tx.noteEncryptedLogs,
|
|
15
|
-
tx.encryptedLogs,
|
|
16
14
|
tx.unencryptedLogs,
|
|
17
15
|
tx.contractClassLogs,
|
|
18
16
|
tx.enqueuedPublicFunctionCalls,
|
|
@@ -25,8 +23,6 @@ export class ProvenTx extends Tx {
|
|
|
25
23
|
return new Tx(
|
|
26
24
|
this.data,
|
|
27
25
|
this.clientIvcProof,
|
|
28
|
-
this.noteEncryptedLogs,
|
|
29
|
-
this.encryptedLogs,
|
|
30
26
|
this.unencryptedLogs,
|
|
31
27
|
this.contractClassLogs,
|
|
32
28
|
this.enqueuedPublicFunctionCalls,
|
|
@@ -5,15 +5,22 @@ import { type ContractFunctionInteraction } from '../contract/contract_function_
|
|
|
5
5
|
import { type Wallet } from '../wallet/index.js';
|
|
6
6
|
import { getRegistererContract } from './protocol_contracts.js';
|
|
7
7
|
|
|
8
|
+
const defaultEmitPublicBytecode =
|
|
9
|
+
// guard against `process` not being defined (e.g. in the browser)
|
|
10
|
+
typeof process === 'object' && typeof process.env === 'object'
|
|
11
|
+
? ['1', 'true', 'yes', ''].includes(process.env.AZTEC_EMIT_PUBLIC_BYTECODE ?? '')
|
|
12
|
+
: true;
|
|
13
|
+
|
|
8
14
|
/** Sets up a call to register a contract class given its artifact. */
|
|
9
15
|
export async function registerContractClass(
|
|
10
16
|
wallet: Wallet,
|
|
11
17
|
artifact: ContractArtifact,
|
|
18
|
+
emitPublicBytecode = defaultEmitPublicBytecode,
|
|
12
19
|
): Promise<ContractFunctionInteraction> {
|
|
13
20
|
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
|
|
14
21
|
getContractClassFromArtifact(artifact);
|
|
15
22
|
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
|
|
16
23
|
const registerer = getRegistererContract(wallet);
|
|
17
24
|
await wallet.addCapsule(encodedBytecode);
|
|
18
|
-
return registerer.methods.register(artifactHash, privateFunctionsRoot, publicBytecodeCommitment);
|
|
25
|
+
return registerer.methods.register(artifactHash, privateFunctionsRoot, publicBytecodeCommitment, emitPublicBytecode);
|
|
19
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PackedValues, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
2
|
+
import { TxContext } from '@aztec/circuits.js';
|
|
3
3
|
import { FunctionType } from '@aztec/foundation/abi';
|
|
4
4
|
|
|
5
5
|
import { type EntrypointInterface, type ExecutionRequestInit } from './entrypoint.js';
|
|
@@ -11,7 +11,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
|
|
|
11
11
|
constructor(private chainId: number, private protocolVersion: number) {}
|
|
12
12
|
|
|
13
13
|
createTxExecutionRequest(exec: ExecutionRequestInit): Promise<TxExecutionRequest> {
|
|
14
|
-
const { calls, authWitnesses = [], packedArguments = [] } = exec;
|
|
14
|
+
const { fee, calls, authWitnesses = [], packedArguments = [] } = exec;
|
|
15
15
|
|
|
16
16
|
if (calls.length > 1) {
|
|
17
17
|
throw new Error(`Expected a single call, got ${calls.length}`);
|
|
@@ -24,8 +24,7 @@ export class DefaultEntrypoint implements EntrypointInterface {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const entrypointPackedValues = PackedValues.fromValues(call.args);
|
|
27
|
-
const
|
|
28
|
-
const txContext = new TxContext(this.chainId, this.protocolVersion, gasSettings);
|
|
27
|
+
const txContext = new TxContext(this.chainId, this.protocolVersion, fee.gasSettings);
|
|
29
28
|
return Promise.resolve(
|
|
30
29
|
new TxExecutionRequest(
|
|
31
30
|
call.to,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EntrypointInterface, EntrypointPayload, type ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
|
|
2
2
|
import { PackedValues, TxExecutionRequest } from '@aztec/circuit-types';
|
|
3
|
-
import { type AztecAddress,
|
|
3
|
+
import { type AztecAddress, TxContext } from '@aztec/circuits.js';
|
|
4
4
|
import { type FunctionAbi, FunctionSelector, encodeArguments } from '@aztec/foundation/abi';
|
|
5
5
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
6
6
|
|
|
@@ -15,17 +15,16 @@ export class DefaultMultiCallEntrypoint implements EntrypointInterface {
|
|
|
15
15
|
) {}
|
|
16
16
|
|
|
17
17
|
createTxExecutionRequest(executions: ExecutionRequestInit): Promise<TxExecutionRequest> {
|
|
18
|
-
const { calls, authWitnesses = [], packedArguments = [] } = executions;
|
|
18
|
+
const { fee, calls, authWitnesses = [], packedArguments = [] } = executions;
|
|
19
19
|
const payload = EntrypointPayload.fromAppExecution(calls);
|
|
20
20
|
const abi = this.getEntrypointAbi();
|
|
21
21
|
const entrypointPackedArgs = PackedValues.fromValues(encodeArguments(abi, [payload]));
|
|
22
|
-
const gasSettings = executions.fee?.gasSettings ?? GasSettings.default();
|
|
23
22
|
|
|
24
23
|
const txRequest = TxExecutionRequest.from({
|
|
25
24
|
firstCallArgsHash: entrypointPackedArgs.hash,
|
|
26
25
|
origin: this.address,
|
|
27
26
|
functionSelector: FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
|
|
28
|
-
txContext: new TxContext(this.chainId, this.version, gasSettings),
|
|
27
|
+
txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
|
|
29
28
|
argsOfCalls: [...payload.packedArguments, ...packedArguments, entrypointPackedArgs],
|
|
30
29
|
authWitnesses,
|
|
31
30
|
});
|
|
@@ -17,7 +17,7 @@ export type ExecutionRequestInit = {
|
|
|
17
17
|
/** Any transient packed arguments for this execution */
|
|
18
18
|
packedArguments?: PackedValues[];
|
|
19
19
|
/** How the fee is going to be payed */
|
|
20
|
-
fee
|
|
20
|
+
fee: FeeOptions;
|
|
21
21
|
/** An optional nonce. Used to repeat a previous tx with a higher fee so that the first one is cancelled */
|
|
22
22
|
nonce?: Fr;
|
|
23
23
|
/** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
|
|
@@ -4,6 +4,7 @@ import { FunctionType } from '@aztec/foundation/abi';
|
|
|
4
4
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
5
5
|
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
6
6
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
7
|
+
import { type FieldsOf } from '@aztec/foundation/types';
|
|
7
8
|
|
|
8
9
|
import { type FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
9
10
|
|
|
@@ -17,6 +18,18 @@ export type FeeOptions = {
|
|
|
17
18
|
gasSettings: GasSettings;
|
|
18
19
|
};
|
|
19
20
|
|
|
21
|
+
/** Fee options as set by a user. */
|
|
22
|
+
export type UserFeeOptions = {
|
|
23
|
+
/** The fee payment method to use */
|
|
24
|
+
paymentMethod?: FeePaymentMethod;
|
|
25
|
+
/** The gas settings */
|
|
26
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
27
|
+
/** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
|
|
28
|
+
estimateGas?: boolean;
|
|
29
|
+
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
30
|
+
estimatedGasPadding?: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
20
33
|
// These must match the values defined in:
|
|
21
34
|
// - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
|
|
22
35
|
const APP_MAX_CALLS = 4;
|
package/src/index.ts
CHANGED
|
@@ -32,9 +32,9 @@ export {
|
|
|
32
32
|
type ContractNotes,
|
|
33
33
|
type ContractStorageLayout,
|
|
34
34
|
type DeployOptions,
|
|
35
|
+
type ProfileResult,
|
|
35
36
|
type SendMethodOptions,
|
|
36
37
|
type WaitOpts,
|
|
37
|
-
type ProfileResult,
|
|
38
38
|
} from './contract/index.js';
|
|
39
39
|
|
|
40
40
|
export { ContractDeployer } from './deployment/index.js';
|
|
@@ -42,7 +42,6 @@ export { ContractDeployer } from './deployment/index.js';
|
|
|
42
42
|
export {
|
|
43
43
|
AnvilTestWatcher,
|
|
44
44
|
CheatCodes,
|
|
45
|
-
EthCheatCodes,
|
|
46
45
|
L1FeeJuicePortalManager,
|
|
47
46
|
L1ToL2TokenPortalManager,
|
|
48
47
|
L1TokenManager,
|
|
@@ -60,8 +59,8 @@ export {
|
|
|
60
59
|
type FieldLike,
|
|
61
60
|
type FunctionSelectorLike,
|
|
62
61
|
type L2AmountClaim,
|
|
63
|
-
type L2Claim,
|
|
64
62
|
type L2AmountClaimWithRecipient,
|
|
63
|
+
type L2Claim,
|
|
65
64
|
type WrappedFieldLike,
|
|
66
65
|
} from './utils/index.js';
|
|
67
66
|
|
|
@@ -112,9 +111,7 @@ export {
|
|
|
112
111
|
Comparator,
|
|
113
112
|
CompleteAddress,
|
|
114
113
|
ContractClass2BlockL2Logs,
|
|
115
|
-
EncryptedL2BlockL2Logs,
|
|
116
114
|
EncryptedLogPayload,
|
|
117
|
-
EncryptedNoteL2BlockL2Logs,
|
|
118
115
|
EpochProofQuote,
|
|
119
116
|
EpochProofQuotePayload,
|
|
120
117
|
EventMetadata,
|
|
@@ -127,9 +124,7 @@ export {
|
|
|
127
124
|
L1ToL2Message,
|
|
128
125
|
L2Actor,
|
|
129
126
|
L2Block,
|
|
130
|
-
L2BlockL2Logs,
|
|
131
127
|
LogId,
|
|
132
|
-
LogType,
|
|
133
128
|
MerkleTreeId,
|
|
134
129
|
Note,
|
|
135
130
|
PackedValues,
|
|
@@ -143,10 +138,12 @@ export {
|
|
|
143
138
|
UnencryptedL2Log,
|
|
144
139
|
UniqueNote,
|
|
145
140
|
createAztecNodeClient,
|
|
141
|
+
getTimestampRangeForEpoch,
|
|
146
142
|
merkleTreeIds,
|
|
147
143
|
mockEpochProofQuote,
|
|
148
144
|
mockTx,
|
|
149
145
|
type AztecNode,
|
|
146
|
+
type EpochConstants,
|
|
150
147
|
type LogFilter,
|
|
151
148
|
type PXE,
|
|
152
149
|
type PartialAddress,
|
|
@@ -161,7 +158,7 @@ export { decodeFromAbi, encodeArguments, type AbiType } from '@aztec/foundation/
|
|
|
161
158
|
export { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
162
159
|
export { sha256 } from '@aztec/foundation/crypto';
|
|
163
160
|
export { makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
164
|
-
export { createDebugLogger,
|
|
161
|
+
export { createDebugLogger, type DebugLogger } from '@aztec/foundation/log';
|
|
165
162
|
export { retry, retryUntil } from '@aztec/foundation/retry';
|
|
166
163
|
export { to2Fields, toBigInt } from '@aztec/foundation/serialize';
|
|
167
164
|
export { sleep } from '@aztec/foundation/sleep';
|
|
@@ -169,7 +166,7 @@ export { elapsed } from '@aztec/foundation/timer';
|
|
|
169
166
|
export { type FieldsOf } from '@aztec/foundation/types';
|
|
170
167
|
export { fileURLToPath } from '@aztec/foundation/url';
|
|
171
168
|
|
|
172
|
-
export { deployL1Contract, deployL1Contracts, type DeployL1Contracts } from '@aztec/ethereum';
|
|
169
|
+
export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contracts } from '@aztec/ethereum';
|
|
173
170
|
|
|
174
171
|
// Start of section that exports public api via granular api.
|
|
175
172
|
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
|