@aztec/aztec.js 0.78.1 → 0.79.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.
Files changed (157) hide show
  1. package/dest/account_manager/deploy_account_method.d.ts +2 -2
  2. package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
  3. package/dest/account_manager/deploy_account_method.js +14 -21
  4. package/dest/account_manager/index.d.ts +2 -3
  5. package/dest/account_manager/index.d.ts.map +1 -1
  6. package/dest/account_manager/index.js +1 -1
  7. package/dest/api/abi.d.ts +1 -1
  8. package/dest/api/abi.d.ts.map +1 -1
  9. package/dest/api/abi.js +1 -1
  10. package/dest/api/account.d.ts +1 -1
  11. package/dest/api/account.d.ts.map +1 -1
  12. package/dest/{contract/index.d.ts → api/contract.d.ts} +9 -8
  13. package/dest/api/contract.d.ts.map +1 -0
  14. package/dest/{contract/index.js → api/contract.js} +8 -7
  15. package/dest/api/deployment.d.ts +1 -0
  16. package/dest/api/deployment.d.ts.map +1 -1
  17. package/dest/api/deployment.js +1 -0
  18. package/dest/api/ethereum.d.ts +3 -0
  19. package/dest/api/ethereum.d.ts.map +1 -0
  20. package/dest/api/ethereum.js +2 -0
  21. package/dest/api/{interfaces/pxe.d.ts → interfaces.d.ts} +1 -1
  22. package/dest/api/interfaces.d.ts.map +1 -0
  23. package/dest/api/rpc.d.ts +3 -0
  24. package/dest/api/rpc.d.ts.map +1 -0
  25. package/dest/api/rpc.js +2 -0
  26. package/dest/api/testing.d.ts +6 -0
  27. package/dest/api/testing.d.ts.map +1 -0
  28. package/dest/api/testing.js +5 -0
  29. package/dest/api/utils.d.ts +8 -0
  30. package/dest/api/utils.d.ts.map +1 -0
  31. package/dest/api/utils.js +6 -0
  32. package/dest/api/wallet.d.ts +1 -1
  33. package/dest/api/wallet.d.ts.map +1 -1
  34. package/dest/api/wallet.js +1 -1
  35. package/dest/contract/base_contract_interaction.d.ts +41 -3
  36. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  37. package/dest/contract/base_contract_interaction.js +39 -1
  38. package/dest/contract/batch_call.d.ts +25 -6
  39. package/dest/contract/batch_call.d.ts.map +1 -1
  40. package/dest/contract/batch_call.js +62 -25
  41. package/dest/contract/contract.d.ts +1 -1
  42. package/dest/contract/contract.d.ts.map +1 -1
  43. package/dest/contract/contract_base.d.ts +1 -1
  44. package/dest/contract/contract_base.d.ts.map +1 -1
  45. package/dest/contract/contract_function_interaction.d.ts +8 -6
  46. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  47. package/dest/contract/contract_function_interaction.js +33 -25
  48. package/dest/contract/deploy_method.d.ts +6 -5
  49. package/dest/contract/deploy_method.d.ts.map +1 -1
  50. package/dest/contract/deploy_method.js +26 -50
  51. package/dest/contract/deploy_proven_tx.d.ts +1 -1
  52. package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
  53. package/dest/contract/deploy_sent_tx.d.ts +1 -1
  54. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  55. package/dest/contract/protocol_contracts.d.ts +1 -1
  56. package/dest/contract/protocol_contracts.d.ts.map +1 -1
  57. package/dest/contract/proven_tx.d.ts +1 -1
  58. package/dest/contract/proven_tx.d.ts.map +1 -1
  59. package/dest/contract/unsafe_contract.d.ts +1 -1
  60. package/dest/contract/unsafe_contract.d.ts.map +1 -1
  61. package/dest/entrypoint/entrypoint.d.ts +4 -0
  62. package/dest/entrypoint/entrypoint.d.ts.map +1 -1
  63. package/dest/entrypoint/entrypoint.js +16 -0
  64. package/dest/ethereum/l1_contracts.d.ts.map +1 -0
  65. package/dest/{api/ethereum → ethereum}/l1_contracts.js +1 -1
  66. package/dest/{api/ethereum → ethereum}/portal_manager.d.ts +1 -1
  67. package/dest/ethereum/portal_manager.d.ts.map +1 -0
  68. package/dest/{api/ethereum → ethereum}/portal_manager.js +4 -1
  69. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +1 -1
  70. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  71. package/dest/fee/public_fee_payment_method.js +1 -1
  72. package/dest/index.d.ts +7 -13
  73. package/dest/index.d.ts.map +1 -1
  74. package/dest/index.js +8 -14
  75. package/dest/test/anvil_test_watcher.d.ts.map +1 -0
  76. package/dest/{api/ethereum → test}/anvil_test_watcher.js +2 -2
  77. package/dest/{utils/aztec_cheatcodes.d.ts → test/aztec_cheat_codes.d.ts} +1 -1
  78. package/dest/test/aztec_cheat_codes.d.ts.map +1 -0
  79. package/dest/{api → test}/cheat_codes.d.ts +2 -2
  80. package/dest/test/cheat_codes.d.ts.map +1 -0
  81. package/dest/{api → test}/cheat_codes.js +2 -2
  82. package/dest/{api/ethereum/cheat_codes.d.ts → test/rollup_cheat_codes.d.ts} +2 -3
  83. package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
  84. package/dest/{api/ethereum/cheat_codes.js → test/rollup_cheat_codes.js} +2 -4
  85. package/dest/utils/authwit.d.ts.map +1 -1
  86. package/dest/utils/authwit.js +1 -1
  87. package/dest/utils/fee_juice.d.ts +1 -1
  88. package/dest/utils/fee_juice.d.ts.map +1 -1
  89. package/dest/wallet/account_wallet.js +1 -1
  90. package/package.json +14 -13
  91. package/src/account_manager/deploy_account_method.ts +12 -31
  92. package/src/account_manager/index.ts +1 -1
  93. package/src/api/abi.ts +11 -0
  94. package/src/api/account.ts +1 -1
  95. package/src/{contract/index.ts → api/contract.ts} +21 -7
  96. package/src/api/deployment.ts +1 -0
  97. package/src/api/ethereum.ts +11 -0
  98. package/src/api/rpc.ts +2 -0
  99. package/src/api/testing.ts +5 -0
  100. package/src/{utils/index.ts → api/utils.ts} +7 -7
  101. package/src/api/wallet.ts +1 -7
  102. package/src/contract/base_contract_interaction.ts +60 -3
  103. package/src/contract/batch_call.ts +63 -21
  104. package/src/contract/contract.ts +1 -1
  105. package/src/contract/contract_base.ts +1 -1
  106. package/src/contract/contract_function_interaction.ts +35 -25
  107. package/src/contract/deploy_method.ts +22 -36
  108. package/src/contract/deploy_proven_tx.ts +1 -1
  109. package/src/contract/deploy_sent_tx.ts +1 -1
  110. package/src/contract/protocol_contracts.ts +1 -1
  111. package/src/contract/proven_tx.ts +1 -1
  112. package/src/contract/unsafe_contract.ts +1 -1
  113. package/src/entrypoint/entrypoint.ts +21 -0
  114. package/src/{api/ethereum → ethereum}/l1_contracts.ts +1 -1
  115. package/src/{api/ethereum → ethereum}/portal_manager.ts +4 -1
  116. package/src/fee/fee_juice_payment_method_with_claim.ts +1 -1
  117. package/src/fee/public_fee_payment_method.ts +1 -1
  118. package/src/index.ts +7 -27
  119. package/src/{api/ethereum → test}/anvil_test_watcher.ts +2 -2
  120. package/src/{api → test}/cheat_codes.ts +2 -2
  121. package/src/{api/ethereum/cheat_codes.ts → test/rollup_cheat_codes.ts} +2 -4
  122. package/src/utils/authwit.ts +2 -1
  123. package/src/utils/fee_juice.ts +1 -2
  124. package/src/wallet/account_wallet.ts +1 -1
  125. package/dest/api/cheat_codes.d.ts.map +0 -1
  126. package/dest/api/ethereum/anvil_test_watcher.d.ts.map +0 -1
  127. package/dest/api/ethereum/chain_monitor.d.ts +0 -25
  128. package/dest/api/ethereum/chain_monitor.d.ts.map +0 -1
  129. package/dest/api/ethereum/chain_monitor.js +0 -74
  130. package/dest/api/ethereum/cheat_codes.d.ts.map +0 -1
  131. package/dest/api/ethereum/index.d.ts +0 -7
  132. package/dest/api/ethereum/index.d.ts.map +0 -1
  133. package/dest/api/ethereum/index.js +0 -6
  134. package/dest/api/ethereum/l1_contracts.d.ts.map +0 -1
  135. package/dest/api/ethereum/portal_manager.d.ts.map +0 -1
  136. package/dest/api/interfaces/pxe.d.ts.map +0 -1
  137. package/dest/contract/index.d.ts.map +0 -1
  138. package/dest/deployment/index.d.ts +0 -2
  139. package/dest/deployment/index.d.ts.map +0 -1
  140. package/dest/deployment/index.js +0 -1
  141. package/dest/rpc_clients/index.d.ts +0 -3
  142. package/dest/rpc_clients/index.d.ts.map +0 -1
  143. package/dest/rpc_clients/index.js +0 -2
  144. package/dest/utils/aztec_cheatcodes.d.ts.map +0 -1
  145. package/dest/utils/index.d.ts +0 -8
  146. package/dest/utils/index.d.ts.map +0 -1
  147. package/dest/utils/index.js +0 -6
  148. package/src/api/ethereum/chain_monitor.ts +0 -88
  149. package/src/api/ethereum/index.ts +0 -19
  150. package/src/deployment/index.ts +0 -1
  151. package/src/rpc_clients/index.ts +0 -2
  152. /package/dest/api/{interfaces/pxe.js → interfaces.js} +0 -0
  153. /package/dest/{api/ethereum → ethereum}/l1_contracts.d.ts +0 -0
  154. /package/dest/{api/ethereum → test}/anvil_test_watcher.d.ts +0 -0
  155. /package/dest/{utils/aztec_cheatcodes.js → test/aztec_cheat_codes.js} +0 -0
  156. /package/src/api/{interfaces/pxe.ts → interfaces.ts} +0 -0
  157. /package/src/{utils/aztec_cheatcodes.ts → test/aztec_cheat_codes.ts} +0 -0
@@ -1,7 +1,8 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
3
4
  import { GasSettings } from '@aztec/stdlib/gas';
4
- import type { Capsule, TxExecutionRequest, TxProvingResult } from '@aztec/stdlib/tx';
5
+ import type { Capsule, HashedValues, TxExecutionRequest, TxProvingResult } from '@aztec/stdlib/tx';
5
6
 
6
7
  import type { Wallet } from '../account/wallet.js';
7
8
  import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
@@ -33,7 +34,9 @@ export type SendMethodOptions = {
33
34
  export abstract class BaseContractInteraction {
34
35
  protected log = createLogger('aztecjs:contract_interaction');
35
36
 
36
- private capsules: Capsule[] = [];
37
+ protected authWitnesses: AuthWitness[] = [];
38
+ protected hashedArguments: HashedValues[] = [];
39
+ protected capsules: Capsule[] = [];
37
40
 
38
41
  constructor(protected wallet: Wallet) {}
39
42
 
@@ -44,6 +47,14 @@ export abstract class BaseContractInteraction {
44
47
  */
45
48
  public abstract create(options?: SendMethodOptions): Promise<TxExecutionRequest>;
46
49
 
50
+ /**
51
+ * Returns an execution request that represents this operation.
52
+ * Can be used as a building block for constructing batch requests.
53
+ * @param options - An optional object containing additional configuration for the transaction.
54
+ * @returns An execution request wrapped in promise.
55
+ */
56
+ public abstract request(options?: SendMethodOptions): Promise<Omit<ExecutionRequestInit, 'fee'>>;
57
+
47
58
  /**
48
59
  * Creates a transaction execution request, simulates and proves it. Differs from .prove in
49
60
  * that its result does not include the wallet nor the composed tx object, but only the proving result.
@@ -167,6 +178,52 @@ export abstract class BaseContractInteraction {
167
178
  return { gasSettings, paymentMethod };
168
179
  }
169
180
 
181
+ /**
182
+ * Add authWitness used in this contract interaction.
183
+ * @param authWitness - authWitness used in the contract interaction.
184
+ */
185
+ public addAuthWitness(authWitness: AuthWitness) {
186
+ this.authWitnesses.push(authWitness);
187
+ }
188
+
189
+ /**
190
+ * Add authWitness used in this contract interaction.
191
+ * @param authWitnesses - authWitnesses used in the contract interaction.
192
+ */
193
+ public addAuthWitnesses(authWitnesses: AuthWitness[]) {
194
+ this.authWitnesses.push(...authWitnesses);
195
+ }
196
+
197
+ /**
198
+ * Return all authWitnesses added for this interaction.
199
+ */
200
+ public getAuthWitnesses() {
201
+ return this.authWitnesses;
202
+ }
203
+
204
+ /**
205
+ * Add hashedArgument used in this contract interaction.
206
+ * @param hashedArgument - hashedArgument used in the contract interaction.
207
+ */
208
+ public addHashedArgument(hashedArgument: HashedValues) {
209
+ this.hashedArguments.push(hashedArgument);
210
+ }
211
+
212
+ /**
213
+ * Add hashedArguments used in this contract interaction.
214
+ * @param hashedArguments - hashedArguments used in the contract interaction.
215
+ */
216
+ public addHashedArguments(hashedArguments: HashedValues[]) {
217
+ this.hashedArguments.push(...hashedArguments);
218
+ }
219
+
220
+ /**
221
+ * Return all hashedArguments added for this interaction.
222
+ */
223
+ public getHashedArguments() {
224
+ return this.hashedArguments;
225
+ }
226
+
170
227
  /**
171
228
  * Add data passed to the oracle calls during this contract interaction.
172
229
  * @param capsule - Data passed to oracle calls.
@@ -184,7 +241,7 @@ export abstract class BaseContractInteraction {
184
241
  }
185
242
 
186
243
  /**
187
- * Return all capsules added for this function interaction.
244
+ * Return all capsules added for this contract interaction.
188
245
  */
189
246
  public getCapsules() {
190
247
  return this.capsules;
@@ -1,27 +1,41 @@
1
1
  import { type FunctionCall, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
2
2
  import type { TxExecutionRequest } from '@aztec/stdlib/tx';
3
3
 
4
- import type { Wallet } from '../account/index.js';
4
+ import type { Wallet } from '../account/wallet.js';
5
+ import { type ExecutionRequestInit, mergeExecutionRequestInits } from '../entrypoint/entrypoint.js';
5
6
  import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
6
7
  import type { SimulateMethodOptions } from './contract_function_interaction.js';
7
8
 
8
9
  /** A batch of function calls to be sent as a single transaction through a wallet. */
9
10
  export class BatchCall extends BaseContractInteraction {
10
- constructor(wallet: Wallet, protected calls: FunctionCall[]) {
11
+ constructor(wallet: Wallet, protected calls: BaseContractInteraction[]) {
11
12
  super(wallet);
12
13
  }
13
14
 
14
15
  /**
15
16
  * Create a transaction execution request that represents this batch, encoded and authenticated by the
16
17
  * user's wallet, ready to be simulated.
17
- * @param opts - An optional object containing additional configuration for the transaction.
18
+ * @param options - An optional object containing additional configuration for the transaction.
18
19
  * @returns A Promise that resolves to a transaction instance.
19
20
  */
20
- public async create(opts?: SendMethodOptions): Promise<TxExecutionRequest> {
21
- const calls = this.calls;
22
- const capsules = this.getCapsules();
23
- const fee = await this.getFeeOptions({ calls, capsules, ...opts });
24
- return await this.wallet.createTxExecutionRequest({ calls, capsules, ...opts, fee });
21
+ public async create(options: SendMethodOptions = {}): Promise<TxExecutionRequest> {
22
+ const requestWithoutFee = await this.request(options);
23
+
24
+ const { fee: userFee } = options;
25
+ const fee = await this.getFeeOptions({ ...requestWithoutFee, fee: userFee });
26
+
27
+ return await this.wallet.createTxExecutionRequest({ ...requestWithoutFee, fee });
28
+ }
29
+
30
+ /**
31
+ * Returns an execution request that represents this operation.
32
+ * @param options - An optional object containing additional configuration for the transaction.
33
+ * @returns An execution request wrapped in promise.
34
+ */
35
+ public async request(options: SendMethodOptions = {}): Promise<Omit<ExecutionRequestInit, 'fee'>> {
36
+ const requests = await this.getRequests();
37
+ const { nonce, cancellable } = options;
38
+ return mergeExecutionRequestInits(requests, { nonce, cancellable });
25
39
  }
26
40
 
27
41
  /**
@@ -34,35 +48,37 @@ export class BatchCall extends BaseContractInteraction {
34
48
  * @returns The result of the transaction as returned by the contract function.
35
49
  */
36
50
  public async simulate(options: SimulateMethodOptions = {}): Promise<any> {
37
- const { indexedCalls, unconstrained } = this.calls.reduce<{
51
+ const { indexedRequests, unconstrained } = (await this.getRequests()).reduce<{
38
52
  /** Keep track of the number of private calls to retrieve the return values */
39
53
  privateIndex: 0;
40
54
  /** Keep track of the number of public calls to retrieve the return values */
41
55
  publicIndex: 0;
42
- /** The public and private function calls in the batch */
43
- indexedCalls: [FunctionCall, number, number][];
56
+ /** The public and private function execution requests in the batch */
57
+ indexedRequests: [Omit<ExecutionRequestInit, 'fee'>, number, number][];
44
58
  /** The unconstrained function calls in the batch. */
45
59
  unconstrained: [FunctionCall, number][];
46
60
  }>(
47
61
  (acc, current, index) => {
48
- if (current.type === FunctionType.UNCONSTRAINED) {
49
- acc.unconstrained.push([current, index]);
62
+ const call = current.calls[0];
63
+ if (call.type === FunctionType.UNCONSTRAINED) {
64
+ acc.unconstrained.push([call, index]);
50
65
  } else {
51
- acc.indexedCalls.push([
66
+ acc.indexedRequests.push([
52
67
  current,
53
68
  index,
54
- current.type === FunctionType.PRIVATE ? acc.privateIndex++ : acc.publicIndex++,
69
+ call.type === FunctionType.PRIVATE ? acc.privateIndex++ : acc.publicIndex++,
55
70
  ]);
56
71
  }
57
72
  return acc;
58
73
  },
59
- { indexedCalls: [], unconstrained: [], publicIndex: 0, privateIndex: 0 },
74
+ { indexedRequests: [], unconstrained: [], publicIndex: 0, privateIndex: 0 },
60
75
  );
61
76
 
62
- const calls = indexedCalls.map(([call]) => call);
63
- const capsules = this.getCapsules();
64
- const fee = await this.getFeeOptions({ calls, capsules, ...options });
65
- const txRequest = await this.wallet.createTxExecutionRequest({ calls, capsules, ...options, fee });
77
+ const requests = indexedRequests.map(([request]) => request);
78
+ const requestWithoutFee = mergeExecutionRequestInits(requests);
79
+ const { fee: userFee } = options;
80
+ const fee = await this.getFeeOptions({ ...requestWithoutFee, fee: userFee });
81
+ const txRequest = await this.wallet.createTxExecutionRequest({ ...requestWithoutFee, fee });
66
82
 
67
83
  const unconstrainedCalls = unconstrained.map(
68
84
  async ([call, index]) =>
@@ -79,7 +95,8 @@ export class BatchCall extends BaseContractInteraction {
79
95
  unconstrainedResults.forEach(([result, index]) => {
80
96
  results[index] = result;
81
97
  });
82
- indexedCalls.forEach(([call, callIndex, resultIndex]) => {
98
+ indexedRequests.forEach(([request, callIndex, resultIndex]) => {
99
+ const call = request.calls[0];
83
100
  // As account entrypoints are private, for private functions we retrieve the return values from the first nested call
84
101
  // since we're interested in the first set of values AFTER the account entrypoint
85
102
  // For public functions we retrieve the first values directly from the public output.
@@ -92,4 +109,29 @@ export class BatchCall extends BaseContractInteraction {
92
109
  });
93
110
  return results;
94
111
  }
112
+
113
+ /**
114
+ * Return all authWitnesses added for this interaction.
115
+ */
116
+ public override getAuthWitnesses() {
117
+ return [this.authWitnesses, ...this.calls.map(c => c.getAuthWitnesses())].flat();
118
+ }
119
+
120
+ /**
121
+ * Return all hashedArguments added for this interaction.
122
+ */
123
+ public override getHashedArguments() {
124
+ return [this.hashedArguments, ...this.calls.map(c => c.getHashedArguments())].flat();
125
+ }
126
+
127
+ /**
128
+ * Return all capsules added for this interaction.
129
+ */
130
+ public override getCapsules() {
131
+ return [this.capsules, ...this.calls.map(c => c.getCapsules())].flat();
132
+ }
133
+
134
+ private async getRequests() {
135
+ return await Promise.all(this.calls.map(c => c.request()));
136
+ }
95
137
  }
@@ -3,7 +3,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
3
  import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
4
4
  import { PublicKeys } from '@aztec/stdlib/keys';
5
5
 
6
- import type { Wallet } from '../account/index.js';
6
+ import type { Wallet } from '../account/wallet.js';
7
7
  import { ContractBase } from './contract_base.js';
8
8
  import { DeployMethod } from './deploy_method.js';
9
9
 
@@ -7,7 +7,7 @@ import {
7
7
  } from '@aztec/stdlib/abi';
8
8
  import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
9
9
 
10
- import type { Wallet } from '../account/index.js';
10
+ import type { Wallet } from '../account/wallet.js';
11
11
  import { ContractFunctionInteraction } from './contract_function_interaction.js';
12
12
 
13
13
  /**
@@ -1,16 +1,10 @@
1
- import {
2
- type FunctionAbi,
3
- FunctionCall,
4
- FunctionSelector,
5
- FunctionType,
6
- decodeFromAbi,
7
- encodeArguments,
8
- } from '@aztec/stdlib/abi';
1
+ import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
9
2
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
10
3
  import type { PrivateKernelProverProfileResult } from '@aztec/stdlib/kernel';
11
4
  import type { TxExecutionRequest } from '@aztec/stdlib/tx';
12
5
 
13
6
  import type { Wallet } from '../account/wallet.js';
7
+ import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
14
8
  import { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
15
9
  import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
16
10
 
@@ -59,38 +53,54 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
59
53
  /**
60
54
  * Create a transaction execution request that represents this call, encoded and authenticated by the
61
55
  * user's wallet, ready to be simulated.
62
- * @param opts - An optional object containing additional configuration for the transaction.
56
+ * @param options - An optional object containing additional configuration for the transaction.
63
57
  * @returns A Promise that resolves to a transaction instance.
64
58
  */
65
- public async create(opts: SendMethodOptions = {}): Promise<TxExecutionRequest> {
59
+ public async create(options: SendMethodOptions = {}): Promise<TxExecutionRequest> {
66
60
  // docs:end:create
67
61
  if (this.functionDao.functionType === FunctionType.UNCONSTRAINED) {
68
62
  throw new Error("Can't call `create` on an unconstrained function.");
69
63
  }
70
- const calls = [await this.request()];
71
- const capsules = this.getCapsules();
72
- const fee = await this.getFeeOptions({ calls, capsules, ...opts });
73
- const { nonce, cancellable } = opts;
74
- return await this.wallet.createTxExecutionRequest({ calls, fee, nonce, cancellable, capsules });
64
+ const requestWithoutFee = await this.request(options);
65
+
66
+ const { fee: userFee } = options;
67
+ const fee = await this.getFeeOptions({ ...requestWithoutFee, fee: userFee });
68
+
69
+ return await this.wallet.createTxExecutionRequest({ ...requestWithoutFee, fee });
75
70
  }
76
71
 
77
72
  // docs:start:request
78
73
  /**
79
- * Returns an execution request that represents this operation. Useful as a building
80
- * block for constructing batch requests.
74
+ * Returns an execution request that represents this operation.
75
+ * Can be used as a building block for constructing batch requests.
76
+ * @param options - An optional object containing additional configuration for the transaction.
81
77
  * @returns An execution request wrapped in promise.
82
78
  */
83
- public async request(): Promise<FunctionCall> {
79
+ public async request(options: SendMethodOptions = {}): Promise<Omit<ExecutionRequestInit, 'fee'>> {
84
80
  // docs:end:request
85
81
  const args = encodeArguments(this.functionDao, this.args);
82
+ const calls = [
83
+ {
84
+ name: this.functionDao.name,
85
+ args,
86
+ selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
87
+ type: this.functionDao.functionType,
88
+ to: this.contractAddress,
89
+ isStatic: this.functionDao.isStatic,
90
+ returnTypes: this.functionDao.returnTypes,
91
+ },
92
+ ];
93
+ const authWitnesses = this.getAuthWitnesses();
94
+ const hashedArguments = this.getHashedArguments();
95
+ const capsules = this.getCapsules();
96
+ const { nonce, cancellable } = options;
86
97
  return {
87
- name: this.functionDao.name,
88
- args,
89
- selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
90
- type: this.functionDao.functionType,
91
- to: this.contractAddress,
92
- isStatic: this.functionDao.isStatic,
93
- returnTypes: this.functionDao.returnTypes,
98
+ calls,
99
+ authWitnesses,
100
+ hashedArguments,
101
+ capsules,
102
+ nonce,
103
+ cancellable,
94
104
  };
95
105
  }
96
106
 
@@ -1,5 +1,5 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
- import { type ContractArtifact, type FunctionArtifact, type FunctionCall, getInitializer } from '@aztec/stdlib/abi';
2
+ import { type ContractArtifact, type FunctionArtifact, getInitializer } from '@aztec/stdlib/abi';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import {
5
5
  type ContractInstanceWithAddress,
@@ -9,12 +9,12 @@ import {
9
9
  } from '@aztec/stdlib/contract';
10
10
  import type { GasSettings } from '@aztec/stdlib/gas';
11
11
  import type { PublicKeys } from '@aztec/stdlib/keys';
12
- import type { Capsule, TxExecutionRequest } from '@aztec/stdlib/tx';
12
+ import type { TxExecutionRequest } from '@aztec/stdlib/tx';
13
13
 
14
- import type { Wallet } from '../account/index.js';
14
+ import type { Wallet } from '../account/wallet.js';
15
15
  import { deployInstance } from '../deployment/deploy_instance.js';
16
16
  import { registerContractClass } from '../deployment/register_class.js';
17
- import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
17
+ import { type ExecutionRequestInit, mergeExecutionRequestInits } from '../entrypoint/entrypoint.js';
18
18
  import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
19
19
  import type { Contract } from './contract.js';
20
20
  import type { ContractBase } from './contract_base.js';
@@ -75,7 +75,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
75
75
  * @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
76
76
  */
77
77
  public async create(options: DeployOptions = {}): Promise<TxExecutionRequest> {
78
- return this.wallet.createTxExecutionRequest(await this.request(options));
78
+ const requestWithoutFee = await this.request(options);
79
+ const fee = await this.getFeeOptions({ ...requestWithoutFee, fee: options.fee });
80
+ return this.wallet.createTxExecutionRequest({ ...requestWithoutFee, fee });
79
81
  }
80
82
 
81
83
  // REFACTOR: Having a `request` method with different semantics than the ones in the other
@@ -89,7 +91,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
89
91
  * @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
90
92
  * it returns a promise for an array instead of a function call directly.
91
93
  */
92
- public async request(options: DeployOptions = {}): Promise<ExecutionRequestInit> {
94
+ public async request(options: DeployOptions = {}): Promise<Omit<ExecutionRequestInit, 'fee'>> {
93
95
  const deployment = await this.getDeploymentFunctionCalls(options);
94
96
 
95
97
  // NOTE: MEGA HACK. Remove with #10007
@@ -105,20 +107,13 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
105
107
 
106
108
  const bootstrap = await this.getInitializeFunctionCalls(options);
107
109
 
108
- if (deployment.calls.length + bootstrap.calls.length === 0) {
110
+ const requests = await Promise.all([...deployment, ...bootstrap].map(c => c.request()));
111
+ if (!requests.length) {
109
112
  throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`);
110
113
  }
111
114
 
112
- const calls = [...deployment.calls, ...bootstrap.calls];
113
- const authWitnesses = [...(deployment.authWitnesses ?? []), ...(bootstrap.authWitnesses ?? [])];
114
- const hashedArguments = [...(deployment.hashedArguments ?? []), ...(bootstrap.hashedArguments ?? [])];
115
- const capsules = [...(deployment.capsules ?? []), ...(bootstrap.capsules ?? [])];
116
- const { cancellable, nonce, fee: userFee } = options;
117
-
118
- const request = { calls, authWitnesses, hashedArguments, capsules, cancellable, fee: userFee, nonce };
119
-
120
- const fee = await this.getFeeOptions(request);
121
- return { ...request, fee };
115
+ const { nonce, cancellable } = options;
116
+ return mergeExecutionRequestInits(requests, { nonce, cancellable });
122
117
  }
123
118
 
124
119
  /**
@@ -136,11 +131,8 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
136
131
  * @param options - Deployment options.
137
132
  * @returns A function call array with potentially requests to the class registerer and instance deployer.
138
133
  */
139
- protected async getDeploymentFunctionCalls(
140
- options: DeployOptions = {},
141
- ): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'hashedArguments' | 'capsules'>> {
142
- const calls: FunctionCall[] = [];
143
- const capsules: Capsule[] = [];
134
+ protected async getDeploymentFunctionCalls(options: DeployOptions = {}): Promise<ContractFunctionInteraction[]> {
135
+ const calls: ContractFunctionInteraction[] = [];
144
136
 
145
137
  // Set contract instance object so it's available for populating the DeploySendTx object
146
138
  const instance = await this.getInstance(options);
@@ -165,19 +157,17 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
165
157
  `Creating request for registering contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
166
158
  );
167
159
  const registerContractClassInteraction = await registerContractClass(this.wallet, this.artifact);
168
- calls.push(await registerContractClassInteraction.request());
169
- capsules.push(...registerContractClassInteraction.getCapsules());
160
+ calls.push(registerContractClassInteraction);
170
161
  }
171
162
  }
172
163
 
173
164
  // Deploy the contract via the instance deployer.
174
165
  if (!options.skipPublicDeployment) {
175
166
  const deploymentInteraction = await deployInstance(this.wallet, instance);
176
- calls.push(await deploymentInteraction.request());
177
- capsules.push(...deploymentInteraction.getCapsules());
167
+ calls.push(deploymentInteraction);
178
168
  }
179
169
 
180
- return { calls, capsules };
170
+ return calls;
181
171
  }
182
172
 
183
173
  /**
@@ -185,23 +175,19 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
185
175
  * @param options - Deployment options.
186
176
  * @returns - An array of function calls.
187
177
  */
188
- protected async getInitializeFunctionCalls(
189
- options: DeployOptions,
190
- ): Promise<Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'hashedArguments' | 'capsules'>> {
191
- const { address } = await this.getInstance(options);
192
- const calls: FunctionCall[] = [];
193
- const capsules: Capsule[] = [];
178
+ protected async getInitializeFunctionCalls(options: DeployOptions): Promise<ContractFunctionInteraction[]> {
179
+ const calls: ContractFunctionInteraction[] = [];
194
180
  if (this.constructorArtifact && !options.skipInitialization) {
181
+ const { address } = await this.getInstance(options);
195
182
  const constructorCall = new ContractFunctionInteraction(
196
183
  this.wallet,
197
184
  address,
198
185
  this.constructorArtifact,
199
186
  this.args,
200
187
  );
201
- calls.push(await constructorCall.request());
202
- capsules.push(...constructorCall.getCapsules());
188
+ calls.push(constructorCall);
203
189
  }
204
- return { calls, capsules };
190
+ return calls;
205
191
  }
206
192
 
207
193
  /**
@@ -3,7 +3,7 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
3
  import type { PXE } from '@aztec/stdlib/interfaces/client';
4
4
  import type { Tx } from '@aztec/stdlib/tx';
5
5
 
6
- import type { Wallet } from '../account/index.js';
6
+ import type { Wallet } from '../account/wallet.js';
7
7
  import type { Contract } from './contract.js';
8
8
  import { DeploySentTx } from './deploy_sent_tx.js';
9
9
  import { ProvenTx } from './proven_tx.js';
@@ -5,7 +5,7 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
5
  import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
6
6
  import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
7
7
 
8
- import type { Wallet } from '../account/index.js';
8
+ import type { Wallet } from '../account/wallet.js';
9
9
  import type { Contract } from './contract.js';
10
10
  import type { ContractBase } from './contract_base.js';
11
11
  import { SentTx, type WaitOpts } from './sent_tx.js';
@@ -1,6 +1,6 @@
1
1
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
2
 
3
- import type { Wallet } from '../wallet/index.js';
3
+ import type { Wallet } from '../account/wallet.js';
4
4
  import { UnsafeContract } from './unsafe_contract.js';
5
5
 
6
6
  /** Returns a Contract wrapper for the class registerer. */
@@ -1,7 +1,7 @@
1
1
  import type { PXE } from '@aztec/stdlib/interfaces/client';
2
2
  import { Tx } from '@aztec/stdlib/tx';
3
3
 
4
- import type { Wallet } from '../account/index.js';
4
+ import type { Wallet } from '../account/wallet.js';
5
5
  import { SentTx } from './sent_tx.js';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import type { ContractArtifact } from '@aztec/stdlib/abi';
2
2
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
3
 
4
- import type { Wallet } from '../wallet/index.js';
4
+ import type { Wallet } from '../account/wallet.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. */
@@ -28,6 +28,27 @@ export type ExecutionRequestInit = {
28
28
  cancellable?: boolean;
29
29
  };
30
30
 
31
+ /**
32
+ * Merges an array of ExecutionRequestInits.
33
+ */
34
+ export function mergeExecutionRequestInits(
35
+ requests: Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'hashedArguments' | 'capsules'>[],
36
+ { nonce, cancellable }: Pick<ExecutionRequestInit, 'nonce' | 'cancellable'> = {},
37
+ ): Omit<ExecutionRequestInit, 'fee'> {
38
+ const calls = requests.map(r => r.calls).flat();
39
+ const authWitnesses = requests.map(r => r.authWitnesses ?? []).flat();
40
+ const hashedArguments = requests.map(r => r.hashedArguments ?? []).flat();
41
+ const capsules = requests.map(r => r.capsules ?? []).flat();
42
+ return {
43
+ calls,
44
+ authWitnesses,
45
+ hashedArguments,
46
+ capsules,
47
+ nonce,
48
+ cancellable,
49
+ };
50
+ }
51
+
31
52
  /** Creates transaction execution requests out of a set of function calls. */
32
53
  export interface EntrypointInterface {
33
54
  /**
@@ -1,7 +1,7 @@
1
1
  import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
 
4
- import { createPXEClient } from '../../rpc_clients/index.js';
4
+ import { createPXEClient } from '../rpc_clients/pxe_client.js';
5
5
 
6
6
  export const getL1ContractAddresses = async (url: string): Promise<L1ContractAddresses> => {
7
7
  const pxeClient = createPXEClient(url, {});
@@ -5,7 +5,10 @@ import { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
  import type { Logger } from '@aztec/foundation/log';
7
7
  import type { SiblingPath } from '@aztec/foundation/trees';
8
- import { FeeJuicePortalAbi, OutboxAbi, TestERC20Abi, TokenPortalAbi } from '@aztec/l1-artifacts';
8
+ import { FeeJuicePortalAbi } from '@aztec/l1-artifacts/FeeJuicePortalAbi';
9
+ import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
10
+ import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
11
+ import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
9
12
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
13
  import { computeSecretHash } from '@aztec/stdlib/hash';
11
14
  import type { PXE } from '@aztec/stdlib/interfaces/client';
@@ -3,8 +3,8 @@ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
3
  import type { FunctionCall } from '@aztec/stdlib/abi';
4
4
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
5
5
 
6
- import type { L2AmountClaim } from '../api/ethereum/portal_manager.js';
7
6
  import { getFeeJuice } from '../contract/protocol_contracts.js';
7
+ import type { L2AmountClaim } from '../ethereum/portal_manager.js';
8
8
  import type { Wallet } from '../wallet/index.js';
9
9
  import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
10
10
 
@@ -99,7 +99,7 @@ export class PublicFeePaymentMethod implements FeePaymentMethod {
99
99
  );
100
100
 
101
101
  return [
102
- await setPublicAuthWitInteraction.request(),
102
+ ...(await setPublicAuthWitInteraction.request()).calls,
103
103
  {
104
104
  name: 'fee_entrypoint_public',
105
105
  to: this.paymentContract,