@aztec/aztec.js 0.0.1-commit.b655e406 → 0.0.1-commit.c31f2472

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 (246) hide show
  1. package/dest/account/account.d.ts +26 -42
  2. package/dest/account/account.d.ts.map +1 -1
  3. package/dest/account/account.js +19 -47
  4. package/dest/account/account_contract.d.ts +9 -10
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +20 -9
  7. package/dest/account/account_with_secret_key.d.ts.map +1 -1
  8. package/dest/account/account_with_secret_key.js +21 -4
  9. package/dest/account/index.d.ts +4 -3
  10. package/dest/account/index.d.ts.map +1 -1
  11. package/dest/account/index.js +2 -0
  12. package/dest/account/signerless_account.d.ts +7 -9
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/account/signerless_account.js +8 -11
  15. package/dest/api/abi.d.ts +1 -1
  16. package/dest/api/account.d.ts +3 -4
  17. package/dest/api/account.d.ts.map +1 -1
  18. package/dest/api/account.js +2 -3
  19. package/dest/api/addresses.d.ts +1 -1
  20. package/dest/api/authorization.d.ts +2 -2
  21. package/dest/api/authorization.d.ts.map +1 -1
  22. package/dest/api/authorization.js +1 -1
  23. package/dest/api/block.d.ts +1 -1
  24. package/dest/api/contract.d.ts +17 -11
  25. package/dest/api/contract.d.ts.map +1 -1
  26. package/dest/api/contract.js +15 -9
  27. package/dest/api/crypto.d.ts +1 -1
  28. package/dest/api/deployment.d.ts +1 -1
  29. package/dest/api/eth_address.d.ts +1 -1
  30. package/dest/api/ethereum.d.ts +1 -1
  31. package/dest/api/events.d.ts +1 -1
  32. package/dest/api/fee.d.ts +1 -1
  33. package/dest/api/fee_testing.d.ts +1 -1
  34. package/dest/api/fields.d.ts +3 -2
  35. package/dest/api/fields.d.ts.map +1 -1
  36. package/dest/api/fields.js +2 -1
  37. package/dest/api/keys.d.ts +1 -1
  38. package/dest/api/log.d.ts +1 -1
  39. package/dest/api/messaging.d.ts +1 -1
  40. package/dest/api/node.d.ts +8 -4
  41. package/dest/api/node.d.ts.map +1 -1
  42. package/dest/api/node.js +7 -3
  43. package/dest/api/note.d.ts +2 -2
  44. package/dest/api/note.d.ts.map +1 -1
  45. package/dest/api/note.js +1 -1
  46. package/dest/api/protocol.d.ts +7 -1
  47. package/dest/api/protocol.d.ts.map +1 -1
  48. package/dest/api/protocol.js +6 -0
  49. package/dest/api/trees.d.ts +1 -1
  50. package/dest/api/tx.d.ts +2 -2
  51. package/dest/api/tx.d.ts.map +1 -1
  52. package/dest/api/tx.js +1 -1
  53. package/dest/api/utils.d.ts +1 -1
  54. package/dest/api/wallet.d.ts +2 -3
  55. package/dest/api/wallet.d.ts.map +1 -1
  56. package/dest/api/wallet.js +1 -2
  57. package/dest/authorization/call_authorization_request.d.ts +2 -2
  58. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  59. package/dest/contract/base_contract_interaction.d.ts +8 -11
  60. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  61. package/dest/contract/base_contract_interaction.js +5 -17
  62. package/dest/contract/batch_call.d.ts +8 -9
  63. package/dest/contract/batch_call.d.ts.map +1 -1
  64. package/dest/contract/batch_call.js +54 -34
  65. package/dest/contract/checker.d.ts +1 -1
  66. package/dest/contract/contract.d.ts +2 -2
  67. package/dest/contract/contract.d.ts.map +1 -1
  68. package/dest/contract/contract.js +4 -5
  69. package/dest/contract/contract_base.d.ts +6 -10
  70. package/dest/contract/contract_base.d.ts.map +1 -1
  71. package/dest/contract/contract_base.js +5 -12
  72. package/dest/contract/contract_function_interaction.d.ts +3 -3
  73. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  74. package/dest/contract/contract_function_interaction.js +9 -6
  75. package/dest/contract/deploy_method.d.ts +71 -23
  76. package/dest/contract/deploy_method.d.ts.map +1 -1
  77. package/dest/contract/deploy_method.js +49 -29
  78. package/dest/contract/get_gas_limits.d.ts +1 -1
  79. package/dest/contract/interaction_options.d.ts +44 -7
  80. package/dest/contract/interaction_options.d.ts.map +1 -1
  81. package/dest/contract/interaction_options.js +12 -11
  82. package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
  83. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  84. package/dest/contract/protocol_contracts/auth-registry.js +963 -0
  85. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
  86. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  87. package/dest/contract/protocol_contracts/contract-class-registry.js +784 -0
  88. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
  89. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  90. package/dest/contract/protocol_contracts/contract-instance-registry.js +866 -0
  91. package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
  92. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  93. package/dest/contract/protocol_contracts/fee-juice.js +827 -0
  94. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  95. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  96. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +563 -0
  97. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  98. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  99. package/dest/contract/protocol_contracts/public-checks.js +579 -0
  100. package/dest/contract/wait_for_proven.d.ts +2 -2
  101. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  102. package/dest/contract/wait_for_proven.js +1 -1
  103. package/dest/contract/wait_opts.d.ts +16 -0
  104. package/dest/contract/wait_opts.d.ts.map +1 -0
  105. package/dest/contract/wait_opts.js +5 -0
  106. package/dest/deployment/broadcast_function.d.ts +1 -1
  107. package/dest/deployment/broadcast_function.js +4 -4
  108. package/dest/deployment/contract_deployer.d.ts +1 -1
  109. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  110. package/dest/deployment/contract_deployer.js +1 -1
  111. package/dest/deployment/publish_class.d.ts +1 -1
  112. package/dest/deployment/publish_class.js +3 -3
  113. package/dest/deployment/publish_instance.d.ts +2 -2
  114. package/dest/deployment/publish_instance.d.ts.map +1 -1
  115. package/dest/deployment/publish_instance.js +3 -3
  116. package/dest/ethereum/portal_manager.d.ts +7 -6
  117. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  118. package/dest/ethereum/portal_manager.js +48 -22
  119. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
  120. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  121. package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
  122. package/dest/fee/fee_payment_method.d.ts +2 -2
  123. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  124. package/dest/fee/private_fee_payment_method.d.ts +2 -2
  125. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  126. package/dest/fee/private_fee_payment_method.js +4 -4
  127. package/dest/fee/public_fee_payment_method.d.ts +2 -2
  128. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  129. package/dest/fee/public_fee_payment_method.js +4 -4
  130. package/dest/fee/sponsored_fee_payment.d.ts +2 -2
  131. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  132. package/dest/fee/sponsored_fee_payment.js +2 -2
  133. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  134. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  135. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  136. package/dest/utils/abi_types.d.ts +2 -2
  137. package/dest/utils/abi_types.d.ts.map +1 -1
  138. package/dest/utils/authwit.d.ts +14 -12
  139. package/dest/utils/authwit.d.ts.map +1 -1
  140. package/dest/utils/authwit.js +27 -20
  141. package/dest/utils/cross_chain.d.ts +2 -2
  142. package/dest/utils/cross_chain.d.ts.map +1 -1
  143. package/dest/utils/fee_juice.d.ts +2 -2
  144. package/dest/utils/fee_juice.js +2 -2
  145. package/dest/utils/field_compressed_string.d.ts +1 -1
  146. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  147. package/dest/utils/field_compressed_string.js +1 -1
  148. package/dest/utils/node.d.ts +13 -2
  149. package/dest/utils/node.d.ts.map +1 -1
  150. package/dest/utils/node.js +46 -0
  151. package/dest/utils/pub_key.d.ts +2 -2
  152. package/dest/utils/pub_key.d.ts.map +1 -1
  153. package/dest/utils/pub_key.js +1 -1
  154. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +6 -9
  155. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  156. package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
  157. package/dest/wallet/account_manager.d.ts +3 -9
  158. package/dest/wallet/account_manager.d.ts.map +1 -1
  159. package/dest/wallet/account_manager.js +6 -12
  160. package/dest/wallet/deploy_account_method.d.ts +37 -9
  161. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  162. package/dest/wallet/deploy_account_method.js +9 -7
  163. package/dest/wallet/index.d.ts +1 -2
  164. package/dest/wallet/index.d.ts.map +1 -1
  165. package/dest/wallet/index.js +0 -1
  166. package/dest/wallet/wallet.d.ts +323 -1504
  167. package/dest/wallet/wallet.d.ts.map +1 -1
  168. package/dest/wallet/wallet.js +85 -115
  169. package/package.json +16 -13
  170. package/src/account/account.ts +35 -60
  171. package/src/account/account_contract.ts +7 -8
  172. package/src/account/account_with_secret_key.ts +34 -9
  173. package/src/account/index.ts +3 -2
  174. package/src/account/signerless_account.ts +15 -15
  175. package/src/api/account.ts +10 -3
  176. package/src/api/authorization.ts +1 -0
  177. package/src/api/contract.ts +24 -8
  178. package/src/api/fields.ts +2 -1
  179. package/src/api/node.ts +7 -3
  180. package/src/api/note.ts +1 -1
  181. package/src/api/protocol.ts +7 -0
  182. package/src/api/tx.ts +4 -0
  183. package/src/api/wallet.ts +10 -9
  184. package/src/authorization/call_authorization_request.ts +1 -1
  185. package/src/contract/base_contract_interaction.ts +27 -16
  186. package/src/contract/batch_call.ts +67 -48
  187. package/src/contract/contract.ts +7 -5
  188. package/src/contract/contract_base.ts +5 -15
  189. package/src/contract/contract_function_interaction.ts +10 -11
  190. package/src/contract/deploy_method.ts +134 -40
  191. package/src/contract/interaction_options.ts +52 -13
  192. package/src/contract/protocol_contracts/auth-registry.ts +545 -0
  193. package/src/contract/protocol_contracts/contract-class-registry.ts +433 -0
  194. package/src/contract/protocol_contracts/contract-instance-registry.ts +495 -0
  195. package/src/contract/protocol_contracts/fee-juice.ts +457 -0
  196. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +329 -0
  197. package/src/contract/protocol_contracts/public-checks.ts +315 -0
  198. package/src/contract/wait_for_proven.ts +1 -1
  199. package/src/contract/wait_opts.ts +21 -0
  200. package/src/deployment/broadcast_function.ts +4 -4
  201. package/src/deployment/contract_deployer.ts +3 -2
  202. package/src/deployment/publish_class.ts +3 -3
  203. package/src/deployment/publish_instance.ts +3 -6
  204. package/src/ethereum/portal_manager.ts +65 -34
  205. package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
  206. package/src/fee/fee_payment_method.ts +1 -1
  207. package/src/fee/private_fee_payment_method.ts +5 -3
  208. package/src/fee/public_fee_payment_method.ts +5 -3
  209. package/src/fee/sponsored_fee_payment.ts +3 -1
  210. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  211. package/src/utils/abi_types.ts +1 -1
  212. package/src/utils/authwit.ts +40 -22
  213. package/src/utils/cross_chain.ts +1 -1
  214. package/src/utils/fee_juice.ts +2 -2
  215. package/src/utils/field_compressed_string.ts +1 -1
  216. package/src/utils/node.ts +62 -0
  217. package/src/utils/pub_key.ts +2 -2
  218. package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
  219. package/src/wallet/account_manager.ts +7 -15
  220. package/src/wallet/deploy_account_method.ts +41 -16
  221. package/src/wallet/index.ts +0 -1
  222. package/src/wallet/wallet.ts +207 -152
  223. package/dest/account/interface.d.ts +0 -19
  224. package/dest/account/interface.d.ts.map +0 -1
  225. package/dest/account/interface.js +0 -5
  226. package/dest/contract/deploy_sent_tx.d.ts +0 -43
  227. package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
  228. package/dest/contract/deploy_sent_tx.js +0 -40
  229. package/dest/contract/protocol_contracts.d.ts +0 -9
  230. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  231. package/dest/contract/protocol_contracts.js +0 -26
  232. package/dest/contract/sent_tx.d.ts +0 -51
  233. package/dest/contract/sent_tx.d.ts.map +0 -1
  234. package/dest/contract/sent_tx.js +0 -90
  235. package/dest/contract/unsafe_contract.d.ts +0 -15
  236. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  237. package/dest/contract/unsafe_contract.js +0 -6
  238. package/dest/wallet/base_wallet.d.ts +0 -91
  239. package/dest/wallet/base_wallet.d.ts.map +0 -1
  240. package/dest/wallet/base_wallet.js +0 -238
  241. package/src/account/interface.ts +0 -25
  242. package/src/contract/deploy_sent_tx.ts +0 -68
  243. package/src/contract/protocol_contracts.ts +0 -35
  244. package/src/contract/sent_tx.ts +0 -130
  245. package/src/contract/unsafe_contract.ts +0 -19
  246. package/src/wallet/base_wallet.ts +0 -350
@@ -1,20 +1,22 @@
1
1
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
4
  import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
5
5
  import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
6
6
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { computeVarArgsHash } from '@aztec/stdlib/hash';
8
- import type { TxProfileResult } from '@aztec/stdlib/tx';
8
+ import type { TxHash, TxProfileResult, TxReceipt } from '@aztec/stdlib/tx';
9
9
 
10
10
  import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
11
11
  import type {
12
+ InteractionWaitOptions,
12
13
  ProfileInteractionOptions,
13
14
  SendInteractionOptions,
15
+ SendInteractionOptionsWithoutWait,
16
+ SendReturn,
14
17
  SimulateInteractionOptions,
15
18
  SimulationReturn,
16
19
  } from '../contract/interaction_options.js';
17
- import type { SentTx } from '../contract/sent_tx.js';
18
20
  import type { Wallet } from '../wallet/index.js';
19
21
 
20
22
  /** Intent with an inner hash */
@@ -22,7 +24,7 @@ export type IntentInnerHash = {
22
24
  /** The consumer */
23
25
  consumer: AztecAddress;
24
26
  /** The action to approve */
25
- innerHash: Buffer<ArrayBuffer> | Fr;
27
+ innerHash: Fr;
26
28
  };
27
29
 
28
30
  /** Intent with a call */
@@ -42,8 +44,8 @@ export type ContractFunctionInteractionCallIntent = {
42
44
  };
43
45
 
44
46
  /** Identifies ContractFunctionInteractionCallIntents */
45
- function isContractFunctionIntractionCallIntent(
46
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
47
+ export function isContractFunctionInteractionCallIntent(
48
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
47
49
  ): messageHashOrIntent is ContractFunctionInteractionCallIntent {
48
50
  return (
49
51
  'caller' in messageHashOrIntent &&
@@ -81,7 +83,7 @@ export const computeAuthWitMessageHash = async (
81
83
  const version = metadata.version;
82
84
 
83
85
  if ('caller' in intent) {
84
- const call = isContractFunctionIntractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
86
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
85
87
  return computeOuterAuthWitHash(
86
88
  call.to,
87
89
  chainId,
@@ -102,14 +104,12 @@ export const computeAuthWitMessageHash = async (
102
104
  * @returns The message hash for the intent
103
105
  */
104
106
  export async function getMessageHashFromIntent(
105
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
107
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
106
108
  chainInfo: ChainInfo,
107
109
  ) {
108
110
  let messageHash: Fr;
109
111
  const { chainId, version } = chainInfo;
110
- if (Buffer.isBuffer(messageHashOrIntent)) {
111
- messageHash = Fr.fromBuffer(messageHashOrIntent);
112
- } else if (messageHashOrIntent instanceof Fr) {
112
+ if (messageHashOrIntent instanceof Fr) {
113
113
  messageHash = messageHashOrIntent;
114
114
  } else {
115
115
  messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
@@ -156,12 +156,9 @@ export async function lookupValidity(
156
156
  }> {
157
157
  let innerHash, consumer;
158
158
  if ('caller' in intent) {
159
- const call = isContractFunctionIntractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
159
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
160
160
  innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
161
161
  consumer = call.to;
162
- } else if (Buffer.isBuffer(intent.innerHash)) {
163
- innerHash = Fr.fromBuffer(intent.innerHash);
164
- consumer = intent.consumer;
165
162
  } else {
166
163
  ({ innerHash, consumer } = intent);
167
164
  }
@@ -174,9 +171,20 @@ export async function lookupValidity(
174
171
  name: 'lookup_validity',
175
172
  isInitializer: false,
176
173
  functionType: FunctionType.UTILITY,
177
- isInternal: false,
174
+ isOnlySelf: false,
178
175
  isStatic: false,
179
- parameters: [{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility }],
176
+ parameters: [
177
+ {
178
+ name: 'consumer',
179
+ type: {
180
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
181
+ kind: 'struct',
182
+ path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
183
+ },
184
+ visibility: 'private' as ABIParameterVisibility,
185
+ },
186
+ { name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
187
+ ],
180
188
  returnTypes: [{ kind: 'boolean' }],
181
189
  errorTypes: {},
182
190
  } as FunctionAbi;
@@ -194,7 +202,7 @@ export async function lookupValidity(
194
202
  name: 'utility_is_consumable',
195
203
  isInitializer: false,
196
204
  functionType: FunctionType.UTILITY,
197
- isInternal: false,
205
+ isOnlySelf: false,
198
206
  isStatic: false,
199
207
  parameters: [
200
208
  {
@@ -240,7 +248,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
240
248
  static async create(
241
249
  wallet: Wallet,
242
250
  from: AztecAddress,
243
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
251
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
244
252
  authorized: boolean,
245
253
  ) {
246
254
  const chainInfo = await wallet.getChainInfo();
@@ -280,9 +288,19 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
280
288
  * Overrides the send method, adding the sender of the authwit (authorizer) as from
281
289
  * and preventing misuse
282
290
  * @param options - An optional object containing 'fee' options information
283
- * @returns A SentTx instance for tracking the transaction status and information.
291
+ * @returns A TxReceipt (if wait is true/undefined) or TxHash (if wait is false)
284
292
  */
285
- public override send(options: Omit<SendInteractionOptions, 'from'> = {}): SentTx {
293
+ // Overload for when wait is not specified at all - returns TxReceipt
294
+ public override send(options?: Omit<SendInteractionOptionsWithoutWait, 'from'>): Promise<TxReceipt>;
295
+ // Generic overload for explicit wait values
296
+ // eslint-disable-next-line jsdoc/require-jsdoc
297
+ public override send<W extends InteractionWaitOptions>(
298
+ options?: Omit<SendInteractionOptions<W>, 'from'>,
299
+ ): Promise<SendReturn<W>>;
300
+ // eslint-disable-next-line jsdoc/require-jsdoc
301
+ public override send(
302
+ options?: Omit<SendInteractionOptions<InteractionWaitOptions>, 'from'>,
303
+ ): Promise<TxReceipt | TxHash> {
286
304
  return super.send({ ...options, from: this.from });
287
305
  }
288
306
 
@@ -291,7 +309,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
291
309
  name: 'set_authorized',
292
310
  isInitializer: false,
293
311
  functionType: FunctionType.PUBLIC,
294
- isInternal: true,
312
+ isOnlySelf: true,
295
313
  isStatic: false,
296
314
  parameters: [
297
315
  {
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
@@ -6,7 +6,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
6
6
 
7
7
  /**
8
8
  * Returns the owner's fee juice balance.
9
- * Note: This is used only e2e_sandbox_example test. TODO: Consider nuking.
9
+ * Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
10
10
  */
11
11
  export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
12
12
  const slot = await deriveStorageSlotInMap(new Fr(1), owner);
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  /**
4
4
  * The representation of a FieldCompressedString in aztec.nr
package/src/utils/node.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
+ import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
5
+ import { SortedTxStatuses, TxStatus } from '@aztec/stdlib/tx';
6
+
7
+ import { DefaultWaitOpts, type WaitOpts } from '../contract/wait_opts.js';
4
8
 
5
9
  export const waitForNode = async (node: AztecNode, logger?: Logger) => {
6
10
  await retryUntil(async () => {
@@ -16,4 +20,62 @@ export const waitForNode = async (node: AztecNode, logger?: Logger) => {
16
20
  }, 'RPC Get Node Info');
17
21
  };
18
22
 
23
+ /** Returns true if the receipt status is at least the desired status level. */
24
+ function hasReachedStatus(receipt: TxReceipt, desiredStatus: TxStatus): boolean {
25
+ return SortedTxStatuses.indexOf(receipt.status) >= SortedTxStatuses.indexOf(desiredStatus);
26
+ }
27
+
28
+ /**
29
+ * Waits for a transaction to be mined and returns its receipt.
30
+ * @param node - The Aztec node to query for transaction status
31
+ * @param txHash - The hash of the transaction to wait for
32
+ * @param opts - Optional configuration for waiting behavior
33
+ * @returns The transaction receipt
34
+ * @throws If the transaction fails and dontThrowOnRevert is not set
35
+ */
36
+ export async function waitForTx(node: AztecNode, txHash: TxHash, opts?: WaitOpts): Promise<TxReceipt> {
37
+ const startTime = Date.now();
38
+ const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
39
+ const waitForStatus = opts?.waitForStatus ?? TxStatus.CHECKPOINTED;
40
+
41
+ const receipt = await retryUntil(
42
+ async () => {
43
+ const txReceipt = await node.getTxReceipt(txHash);
44
+ // If receipt is not yet available, try again
45
+ if (txReceipt.isPending()) {
46
+ return undefined;
47
+ }
48
+ // If the tx was "dropped", either return it or ignore based on timing.
49
+ // We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
50
+ // If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
51
+ if (txReceipt.isDropped()) {
52
+ const elapsedSeconds = (Date.now() - startTime) / 1000;
53
+ if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
54
+ return txReceipt;
55
+ }
56
+ return undefined;
57
+ }
58
+ // Check if the receipt has reached the desired status level
59
+ if (!hasReachedStatus(txReceipt, waitForStatus)) {
60
+ return undefined;
61
+ }
62
+ return txReceipt;
63
+ },
64
+ 'isMined',
65
+ opts?.timeout ?? DefaultWaitOpts.timeout,
66
+ opts?.interval ?? DefaultWaitOpts.interval,
67
+ );
68
+
69
+ if (!receipt.isMined()) {
70
+ throw new Error(`Transaction ${txHash.toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
71
+ }
72
+ if (!receipt.hasExecutionSucceeded() && !opts?.dontThrowOnRevert) {
73
+ throw new Error(
74
+ `Transaction ${txHash.toString()} reverted: ${receipt.executionResult}. Reason: ${receipt.error ?? 'unknown'}`,
75
+ );
76
+ }
77
+
78
+ return receipt;
79
+ }
80
+
19
81
  export { createAztecNodeClient, type AztecNode } from '@aztec/stdlib/interfaces/client';
@@ -1,5 +1,5 @@
1
- import { Grumpkin } from '@aztec/foundation/crypto';
2
- import type { GrumpkinScalar } from '@aztec/foundation/fields';
1
+ import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
2
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
3
3
  import type { PublicKey } from '@aztec/stdlib/keys';
4
4
 
5
5
  /**
@@ -1,20 +1,11 @@
1
1
  import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
2
- import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
3
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
4
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
- import {
6
- type ContractArtifact,
7
- type FunctionArtifact,
8
- FunctionCall,
9
- FunctionSelector,
10
- encodeArguments,
11
- getFunctionArtifactByName,
12
- } from '@aztec/stdlib/abi';
13
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
4
  import type { GasSettings } from '@aztec/stdlib/gas';
5
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
15
6
 
7
+ import type { Account } from '../account/account.js';
16
8
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
17
- import type { Wallet } from './index.js';
18
9
 
19
10
  /**
20
11
  * Fee payment method that allows an account contract to pay for its own deployment
@@ -33,11 +24,9 @@ import type { Wallet } from './index.js';
33
24
  */
34
25
  export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
35
26
  constructor(
36
- private wallet: Wallet,
37
- private artifact: ContractArtifact,
38
- private feePaymentNameOrArtifact: string | FunctionArtifact,
39
- private accountAddress: AztecAddress,
27
+ private account: Account,
40
28
  private paymentMethod?: FeePaymentMethod,
29
+ private feeEntrypointOptions?: any,
41
30
  ) {}
42
31
 
43
32
  getAsset(): Promise<AztecAddress> {
@@ -45,58 +34,38 @@ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
45
34
  }
46
35
 
47
36
  async getExecutionPayload(): Promise<ExecutionPayload> {
48
- // Get the execution payload for the fee, it includes the calls and potentially authWitnesses
49
- // It can be empty because the account might attempt to pay for the tx fee using its own
50
- // FeeJuice balance
51
- const { calls: feeCalls, authWitnesses: feeAuthwitnesses } =
52
- (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
53
- // Encode the calls for the fee
54
- const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.accountAddress;
55
- const isFeePayer = feePayer.equals(this.accountAddress);
56
- let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
57
- if (isFeePayer) {
58
- // If the account is the fee payer, and the incoming fee payload has calls
59
- // it can only be FeeJuicePaymentMethodWithClaim
60
- // If the payload has no calls, it's paying using
61
- // its own fee juice balance
62
- accountFeePaymentMethodOptions =
63
- feeCalls.length === 0
64
- ? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
65
- : AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
66
- }
67
- const feeEncodedCalls = await EncodedAppEntrypointCalls.create(feeCalls);
37
+ // Get the execution payload for the fee
38
+ const innerPayload = (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
68
39
 
69
- // Get the entrypoint args
70
- const args = [feeEncodedCalls, accountFeePaymentMethodOptions, false];
71
- const feePaymentArtifact =
72
- typeof this.feePaymentNameOrArtifact === 'string'
73
- ? getFunctionArtifactByName(this.artifact, this.feePaymentNameOrArtifact)
74
- : this.feePaymentNameOrArtifact;
40
+ // If no fee entrypoint options were provided, compute them based on the wrapped payment method
41
+ // This mimics how the actual account contract works when invoked directly:
42
+ // - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
43
+ // only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
44
+ // - If we are the fee payer, but there are no calls, then we assume the account already has
45
+ // fee juice and can pay directly with PREEXISTING_FEE_JUICE
46
+ // - If we are not the fee payer, then EXTERNAL is used
47
+ let options = this.feeEntrypointOptions;
48
+ if (!options) {
49
+ const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.account.getAddress();
50
+ const isFeePayer = feePayer.equals(this.account.getAddress());
75
51
 
76
- const entrypointCall = new FunctionCall(
77
- feePaymentArtifact.name,
78
- this.accountAddress,
79
- await FunctionSelector.fromNameAndParameters(feePaymentArtifact.name, feePaymentArtifact.parameters),
80
- feePaymentArtifact.functionType,
81
- false /** hideMsgSender -- set to `false`, because it's not applicable for an entrypoint function (only for enqueued public calls) */,
82
- feePaymentArtifact.isStatic,
83
- encodeArguments(feePaymentArtifact, args),
84
- feePaymentArtifact.returnTypes,
85
- );
52
+ let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
53
+ if (isFeePayer) {
54
+ accountFeePaymentMethodOptions =
55
+ innerPayload.calls.length === 0
56
+ ? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
57
+ : AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
58
+ }
86
59
 
87
- // Compute the authwitness required to verify the combined payload
88
- const payloadAuthWitness = await this.wallet.createAuthWit(this.accountAddress, await feeEncodedCalls.hash());
60
+ options = { feePaymentMethodOptions: accountFeePaymentMethodOptions };
61
+ }
89
62
 
90
- return new ExecutionPayload(
91
- [entrypointCall],
92
- [payloadAuthWitness, ...feeAuthwitnesses],
93
- [],
94
- feeEncodedCalls.hashedArguments,
95
- );
63
+ // Use the generic wrapping mechanism from the account interface
64
+ return this.account.wrapExecutionPayload(innerPayload, options);
96
65
  }
97
66
 
98
67
  getFeePayer(): Promise<AztecAddress> {
99
- return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.accountAddress);
68
+ return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
100
69
  }
101
70
 
102
71
  getGasSettings(): GasSettings | undefined {
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import {
3
3
  CompleteAddress,
4
4
  type ContractInstanceWithAddress,
@@ -9,7 +9,6 @@ import { deriveKeys } from '@aztec/stdlib/keys';
9
9
  import type { AccountContract } from '../account/account_contract.js';
10
10
  import { AccountWithSecretKey } from '../account/account_with_secret_key.js';
11
11
  import type { Salt } from '../account/index.js';
12
- import type { AccountInterface } from '../account/interface.js';
13
12
  import { Contract } from '../contract/contract.js';
14
13
  import { DeployAccountMethod } from './deploy_account_method.js';
15
14
  import type { Wallet } from './wallet.js';
@@ -58,16 +57,6 @@ export class AccountManager {
58
57
  return this.getPublicKeys().hash();
59
58
  }
60
59
 
61
- /**
62
- * Returns the entrypoint for this account as defined by its account contract.
63
- * @returns An entrypoint.
64
- */
65
- public async getAccountInterface(): Promise<AccountInterface> {
66
- const chainInfo = await this.wallet.getChainInfo();
67
- const completeAddress = await this.getCompleteAddress();
68
- return this.accountContract.getInterface(completeAddress, chainInfo);
69
- }
70
-
71
60
  /**
72
61
  * Gets the calculated complete address associated with this account.
73
62
  * Does not require the account to have been published for public execution.
@@ -103,8 +92,9 @@ export class AccountManager {
103
92
  * @returns A Wallet instance.
104
93
  */
105
94
  public async getAccount(): Promise<AccountWithSecretKey> {
106
- const accountInterface = await this.getAccountInterface();
107
- return new AccountWithSecretKey(accountInterface, this.secretKey, this.salt);
95
+ const completeAddress = await this.getCompleteAddress();
96
+ const account = this.accountContract.getAccount(completeAddress);
97
+ return new AccountWithSecretKey(account, this.secretKey, this.salt);
108
98
  }
109
99
 
110
100
  /**
@@ -134,12 +124,14 @@ export class AccountManager {
134
124
  constructorArgs: undefined,
135
125
  };
136
126
 
127
+ const account = await this.getAccount();
137
128
  return new DeployAccountMethod(
138
129
  this.getPublicKeys(),
139
130
  this.wallet,
140
131
  artifact,
141
- address => Contract.at(address, artifact, this.wallet),
132
+ instance => Contract.at(instance.address, artifact, this.wallet),
142
133
  new Fr(this.salt),
134
+ account,
143
135
  constructorArgs,
144
136
  constructorName,
145
137
  );
@@ -1,33 +1,62 @@
1
- import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
4
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
5
  import type { PublicKeys } from '@aztec/stdlib/keys';
6
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
6
7
 
8
+ import type { Account } from '../account/account.js';
7
9
  import type { Contract } from '../contract/contract.js';
8
10
  import type { ContractBase } from '../contract/contract_base.js';
9
11
  import {
10
12
  DeployMethod,
11
- type DeployOptions,
13
+ type DeployOptionsWithoutWait,
12
14
  type RequestDeployOptions,
13
15
  type SimulateDeployOptions,
14
16
  } from '../contract/deploy_method.js';
17
+ import type { FeePaymentMethodOption, InteractionWaitOptions } from '../contract/interaction_options.js';
15
18
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
16
19
  import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
17
20
  import type { Wallet } from './index.js';
18
21
 
22
+ /**
23
+ * Extended fee payment method option for account deployments that includes entrypoint wrapping options
24
+ */
25
+ export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
26
+ /** Optional entrypoint-specific options for wrapping execution payloads */
27
+ feeEntrypointOptions?: unknown;
28
+ };
29
+
19
30
  /**
20
31
  * The configuration options for the request method. Omits the contractAddressSalt, since
21
32
  * for account contracts that is fixed in the constructor
22
33
  */
23
- export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'>;
34
+ export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
35
+ /** Fee options specific to account deployment */
36
+ fee?: DeployAccountFeePaymentMethodOption;
37
+ };
38
+
39
+ /**
40
+ * Base configuration options for the send/prove methods without wait parameter. Omits:
41
+ * - The contractAddressSalt, since for account contracts that is fixed in the constructor.
42
+ * - UniversalDeployment flag, since account contracts are always deployed with it set to true
43
+ */
44
+ export type DeployAccountOptionsWithoutWait = Omit<DeployOptionsWithoutWait, 'contractAddressSalt' | 'universalDeploy'>;
24
45
 
25
46
  /**
26
47
  * The configuration options for the send/prove methods. Omits:
27
48
  * - The contractAddressSalt, since for account contracts that is fixed in the constructor.
28
49
  * - UniversalDeployment flag, since account contracts are always deployed with it set to true
29
50
  */
30
- export type DeployAccountOptions = Omit<DeployOptions, 'contractAddressSalt' | 'universalDeploy'>;
51
+ export type DeployAccountOptions<W extends InteractionWaitOptions = undefined> = DeployAccountOptionsWithoutWait & {
52
+ /**
53
+ * Whether to wait for the transaction to be mined.
54
+ * - undefined (default): wait with default options and return TxReceipt
55
+ * - WaitOpts object: wait with custom options and return TxReceipt
56
+ * - false: return txHash immediately without waiting
57
+ */
58
+ wait?: W;
59
+ };
31
60
 
32
61
  /**
33
62
  * The configuration options for the simulate method. Omits the contractAddressSalt, since
@@ -44,8 +73,9 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
44
73
  publicKeys: PublicKeys,
45
74
  wallet: Wallet,
46
75
  artifact: ContractArtifact,
47
- postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
76
+ postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
48
77
  private salt: Fr,
78
+ private account: Account,
49
79
  args: any[] = [],
50
80
  constructorNameOrArtifact?: string | FunctionArtifact,
51
81
  ) {
@@ -60,19 +90,14 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
60
90
  * For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
61
91
  *
62
92
  * @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
93
+ * @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
63
94
  * @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
64
95
  */
65
- private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
96
+ private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod, feeEntrypointOptions?: any) {
66
97
  if (!this.address) {
67
98
  throw new Error('Instance is not yet constructed. This is a bug!');
68
99
  }
69
- return new AccountEntrypointMetaPaymentMethod(
70
- this.wallet,
71
- this.artifact,
72
- 'entrypoint',
73
- this.address,
74
- originalPaymentMethod,
75
- );
100
+ return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
76
101
  }
77
102
 
78
103
  /**
@@ -96,7 +121,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
96
121
  const executionPayloads = [deploymentExecutionPayload];
97
122
  // If this is a self-deployment, manage the fee accordingly
98
123
  if (opts?.deployer?.equals(AztecAddress.ZERO)) {
99
- const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
124
+ const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
100
125
  const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
101
126
  // Notice they are reversed (fee payment usually goes first):
102
127
  // this is because we need to construct the contract BEFORE it can pay for its own fee
@@ -112,7 +137,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
112
137
  return mergeExecutionPayloads(executionPayloads);
113
138
  }
114
139
 
115
- override convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
140
+ override convertDeployOptionsToRequestOptions(options: DeployAccountOptionsWithoutWait): RequestDeployOptions {
116
141
  return {
117
142
  ...options,
118
143
  // Deployer is handled in the request method and forcibly set to undefined,
@@ -1,3 +1,2 @@
1
1
  export * from './wallet.js';
2
- export * from './base_wallet.js';
3
2
  export * from './account_manager.js';