@aztec/aztec.js 3.0.0-canary.a9708bd → 3.0.0-devnet.2-patch.1

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 (326) hide show
  1. package/README.md +1 -1
  2. package/dest/account/account.d.ts +59 -0
  3. package/dest/account/account.d.ts.map +1 -0
  4. package/dest/account/account.js +59 -0
  5. package/dest/account/account_contract.d.ts +7 -7
  6. package/dest/account/account_contract.d.ts.map +1 -1
  7. package/dest/account/account_contract.js +0 -1
  8. package/dest/account/account_with_secret_key.d.ts +24 -0
  9. package/dest/account/account_with_secret_key.d.ts.map +1 -0
  10. package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
  11. package/dest/account/index.d.ts +3 -6
  12. package/dest/account/index.d.ts.map +1 -1
  13. package/dest/account/index.js +1 -4
  14. package/dest/account/interface.d.ts +2 -2
  15. package/dest/account/interface.d.ts.map +1 -1
  16. package/dest/account/signerless_account.d.ts +23 -0
  17. package/dest/account/signerless_account.d.ts.map +1 -0
  18. package/dest/account/signerless_account.js +27 -0
  19. package/dest/api/abi.d.ts +2 -1
  20. package/dest/api/abi.d.ts.map +1 -1
  21. package/dest/api/account.d.ts +6 -3
  22. package/dest/api/account.d.ts.map +1 -1
  23. package/dest/api/account.js +4 -1
  24. package/dest/api/addresses.d.ts +2 -1
  25. package/dest/api/addresses.d.ts.map +1 -1
  26. package/dest/api/addresses.js +1 -0
  27. package/dest/api/authorization.d.ts +3 -1
  28. package/dest/api/authorization.d.ts.map +1 -1
  29. package/dest/api/authorization.js +2 -0
  30. package/dest/api/block.d.ts +3 -0
  31. package/dest/api/block.d.ts.map +1 -0
  32. package/dest/api/block.js +2 -0
  33. package/dest/api/contract.d.ts +8 -9
  34. package/dest/api/contract.d.ts.map +1 -1
  35. package/dest/api/contract.js +6 -6
  36. package/dest/api/crypto.d.ts +2 -0
  37. package/dest/api/crypto.d.ts.map +1 -0
  38. package/dest/api/crypto.js +1 -0
  39. package/dest/api/deployment.d.ts +1 -1
  40. package/dest/api/eth_address.d.ts +1 -1
  41. package/dest/api/ethereum.d.ts +1 -2
  42. package/dest/api/ethereum.d.ts.map +1 -1
  43. package/dest/api/ethereum.js +0 -1
  44. package/dest/api/events.d.ts +12 -0
  45. package/dest/api/events.d.ts.map +1 -0
  46. package/dest/api/events.js +30 -0
  47. package/dest/api/fee.d.ts +2 -3
  48. package/dest/api/fee.d.ts.map +1 -1
  49. package/dest/api/fee.js +0 -1
  50. package/dest/api/fee_testing.d.ts +1 -1
  51. package/dest/api/fields.d.ts +3 -2
  52. package/dest/api/fields.d.ts.map +1 -1
  53. package/dest/api/fields.js +2 -1
  54. package/dest/api/keys.d.ts +4 -0
  55. package/dest/api/keys.d.ts.map +1 -0
  56. package/dest/api/keys.js +3 -0
  57. package/dest/api/log.d.ts +2 -1
  58. package/dest/api/log.d.ts.map +1 -1
  59. package/dest/api/log.js +1 -0
  60. package/dest/api/messaging.d.ts +3 -0
  61. package/dest/api/messaging.d.ts.map +1 -0
  62. package/dest/api/messaging.js +2 -0
  63. package/dest/api/node.d.ts +21 -0
  64. package/dest/api/node.d.ts.map +1 -0
  65. package/dest/api/node.js +18 -0
  66. package/dest/api/note.d.ts +2 -0
  67. package/dest/api/note.d.ts.map +1 -0
  68. package/dest/api/note.js +1 -0
  69. package/dest/api/protocol.d.ts +3 -0
  70. package/dest/api/protocol.d.ts.map +1 -0
  71. package/dest/api/protocol.js +2 -0
  72. package/dest/api/trees.d.ts +3 -0
  73. package/dest/api/trees.d.ts.map +1 -0
  74. package/dest/api/trees.js +2 -0
  75. package/dest/api/tx.d.ts +2 -0
  76. package/dest/api/tx.d.ts.map +1 -0
  77. package/dest/api/tx.js +1 -0
  78. package/dest/api/utils.d.ts +11 -7
  79. package/dest/api/utils.d.ts.map +1 -1
  80. package/dest/api/utils.js +10 -5
  81. package/dest/api/wallet.d.ts +4 -2
  82. package/dest/api/wallet.d.ts.map +1 -1
  83. package/dest/api/wallet.js +3 -1
  84. package/dest/authorization/call_authorization_request.d.ts +2 -23
  85. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  86. package/dest/contract/base_contract_interaction.d.ts +7 -50
  87. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  88. package/dest/contract/base_contract_interaction.js +6 -106
  89. package/dest/contract/batch_call.d.ts +14 -23
  90. package/dest/contract/batch_call.d.ts.map +1 -1
  91. package/dest/contract/batch_call.js +72 -64
  92. package/dest/contract/checker.d.ts +1 -1
  93. package/dest/contract/contract.d.ts +3 -3
  94. package/dest/contract/contract.d.ts.map +1 -1
  95. package/dest/contract/contract.js +5 -16
  96. package/dest/contract/contract_base.d.ts +5 -12
  97. package/dest/contract/contract_base.d.ts.map +1 -1
  98. package/dest/contract/contract_base.js +5 -12
  99. package/dest/contract/contract_function_interaction.d.ts +32 -43
  100. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  101. package/dest/contract/contract_function_interaction.js +47 -56
  102. package/dest/contract/deploy_method.d.ts +69 -61
  103. package/dest/contract/deploy_method.d.ts.map +1 -1
  104. package/dest/contract/deploy_method.js +72 -88
  105. package/dest/contract/deploy_sent_tx.d.ts +12 -8
  106. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  107. package/dest/contract/deploy_sent_tx.js +15 -12
  108. package/dest/contract/get_gas_limits.d.ts +1 -1
  109. package/dest/contract/interaction_options.d.ts +76 -21
  110. package/dest/contract/interaction_options.d.ts.map +1 -1
  111. package/dest/contract/interaction_options.js +45 -3
  112. package/dest/contract/protocol_contracts.d.ts +1 -1
  113. package/dest/contract/sent_tx.d.ts +5 -6
  114. package/dest/contract/sent_tx.d.ts.map +1 -1
  115. package/dest/contract/sent_tx.js +6 -6
  116. package/dest/contract/unsafe_contract.d.ts +1 -1
  117. package/dest/contract/unsafe_contract.d.ts.map +1 -1
  118. package/dest/contract/unsafe_contract.js +1 -1
  119. package/dest/contract/wait_for_proven.d.ts +4 -4
  120. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  121. package/dest/contract/wait_for_proven.js +2 -2
  122. package/dest/deployment/broadcast_function.d.ts +1 -1
  123. package/dest/deployment/broadcast_function.js +1 -1
  124. package/dest/deployment/contract_deployer.d.ts +1 -1
  125. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  126. package/dest/deployment/contract_deployer.js +1 -1
  127. package/dest/deployment/publish_class.d.ts +1 -1
  128. package/dest/deployment/publish_class.js +1 -1
  129. package/dest/deployment/publish_instance.d.ts +2 -2
  130. package/dest/deployment/publish_instance.d.ts.map +1 -1
  131. package/dest/deployment/publish_instance.js +2 -5
  132. package/dest/ethereum/portal_manager.d.ts +7 -10
  133. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  134. package/dest/ethereum/portal_manager.js +43 -19
  135. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +14 -9
  136. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  137. package/dest/fee/fee_juice_payment_method_with_claim.js +24 -15
  138. package/dest/fee/fee_payment_method.d.ts +26 -0
  139. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  140. package/dest/fee/fee_payment_method.js +3 -0
  141. package/dest/fee/private_fee_payment_method.d.ts +24 -7
  142. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  143. package/dest/fee/private_fee_payment_method.js +38 -17
  144. package/dest/fee/public_fee_payment_method.d.ts +24 -7
  145. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  146. package/dest/fee/public_fee_payment_method.js +41 -18
  147. package/dest/fee/sponsored_fee_payment.d.ts +4 -2
  148. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  149. package/dest/fee/sponsored_fee_payment.js +6 -2
  150. package/dest/utils/abi_types.d.ts +2 -2
  151. package/dest/utils/abi_types.d.ts.map +1 -1
  152. package/dest/utils/authwit.d.ts +80 -28
  153. package/dest/utils/authwit.d.ts.map +1 -1
  154. package/dest/utils/authwit.js +231 -25
  155. package/dest/utils/cross_chain.d.ts +24 -0
  156. package/dest/utils/cross_chain.d.ts.map +1 -0
  157. package/dest/utils/cross_chain.js +30 -0
  158. package/dest/utils/fee_juice.d.ts +4 -3
  159. package/dest/utils/fee_juice.d.ts.map +1 -1
  160. package/dest/utils/fee_juice.js +4 -3
  161. package/dest/utils/field_compressed_string.d.ts +1 -1
  162. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  163. package/dest/utils/field_compressed_string.js +1 -1
  164. package/dest/utils/node.d.ts +2 -2
  165. package/dest/utils/node.d.ts.map +1 -1
  166. package/dest/utils/pub_key.d.ts +2 -2
  167. package/dest/utils/pub_key.d.ts.map +1 -1
  168. package/dest/utils/pub_key.js +2 -3
  169. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +34 -0
  170. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  171. package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
  172. package/dest/wallet/account_manager.d.ts +66 -0
  173. package/dest/wallet/account_manager.d.ts.map +1 -0
  174. package/dest/wallet/account_manager.js +113 -0
  175. package/dest/wallet/deploy_account_method.d.ts +52 -0
  176. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  177. package/dest/wallet/deploy_account_method.js +77 -0
  178. package/dest/wallet/index.d.ts +2 -16
  179. package/dest/wallet/index.d.ts.map +1 -1
  180. package/dest/wallet/index.js +1 -19
  181. package/dest/wallet/wallet.d.ts +2012 -7
  182. package/dest/wallet/wallet.d.ts.map +1 -1
  183. package/dest/wallet/wallet.js +198 -3
  184. package/package.json +29 -24
  185. package/src/account/account.ts +96 -0
  186. package/src/account/account_contract.ts +5 -7
  187. package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +7 -9
  188. package/src/account/index.ts +2 -5
  189. package/src/account/interface.ts +1 -1
  190. package/src/account/signerless_account.ts +45 -0
  191. package/src/api/abi.ts +11 -0
  192. package/src/api/account.ts +5 -2
  193. package/src/api/addresses.ts +1 -0
  194. package/src/api/authorization.ts +11 -0
  195. package/src/api/block.ts +2 -0
  196. package/src/api/contract.ts +20 -11
  197. package/src/api/crypto.ts +1 -0
  198. package/src/api/ethereum.ts +0 -1
  199. package/src/api/events.ts +44 -0
  200. package/src/api/fee.ts +1 -2
  201. package/src/api/fields.ts +2 -1
  202. package/src/api/keys.ts +8 -0
  203. package/src/api/log.ts +1 -0
  204. package/src/api/messaging.ts +2 -0
  205. package/src/api/node.ts +20 -0
  206. package/src/api/note.ts +1 -0
  207. package/src/api/protocol.ts +2 -0
  208. package/src/api/trees.ts +2 -0
  209. package/src/api/tx.ts +13 -0
  210. package/src/api/utils.ts +12 -19
  211. package/src/api/wallet.ts +31 -5
  212. package/src/authorization/call_authorization_request.ts +1 -1
  213. package/src/contract/base_contract_interaction.ts +9 -139
  214. package/src/contract/batch_call.ts +87 -79
  215. package/src/contract/contract.ts +8 -16
  216. package/src/contract/contract_base.ts +5 -15
  217. package/src/contract/contract_function_interaction.ts +72 -105
  218. package/src/contract/deploy_method.ts +123 -104
  219. package/src/contract/deploy_sent_tx.ts +19 -18
  220. package/src/contract/interaction_options.ts +121 -25
  221. package/src/contract/sent_tx.ts +6 -7
  222. package/src/contract/unsafe_contract.ts +1 -1
  223. package/src/contract/wait_for_proven.ts +4 -4
  224. package/src/deployment/broadcast_function.ts +1 -1
  225. package/src/deployment/contract_deployer.ts +3 -2
  226. package/src/deployment/publish_class.ts +1 -1
  227. package/src/deployment/publish_instance.ts +3 -8
  228. package/src/ethereum/portal_manager.ts +62 -40
  229. package/src/fee/fee_juice_payment_method_with_claim.ts +30 -19
  230. package/src/fee/fee_payment_method.ts +26 -0
  231. package/src/fee/private_fee_payment_method.ts +64 -43
  232. package/src/fee/public_fee_payment_method.ts +77 -51
  233. package/src/fee/sponsored_fee_payment.ts +9 -1
  234. package/src/utils/abi_types.ts +1 -1
  235. package/src/utils/authwit.ts +257 -39
  236. package/src/utils/cross_chain.ts +53 -0
  237. package/src/utils/fee_juice.ts +5 -4
  238. package/src/utils/field_compressed_string.ts +1 -1
  239. package/src/utils/pub_key.ts +3 -4
  240. package/src/wallet/account_entrypoint_meta_payment_method.ts +106 -0
  241. package/src/wallet/account_manager.ts +154 -0
  242. package/src/wallet/deploy_account_method.ts +126 -0
  243. package/src/wallet/index.ts +1 -32
  244. package/src/wallet/wallet.ts +358 -29
  245. package/dest/account_manager/account_manager.d.ts +0 -119
  246. package/dest/account_manager/account_manager.d.ts.map +0 -1
  247. package/dest/account_manager/account_manager.js +0 -202
  248. package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
  249. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
  250. package/dest/account_manager/deploy_account_sent_tx.js +0 -29
  251. package/dest/account_manager/index.d.ts +0 -3
  252. package/dest/account_manager/index.d.ts.map +0 -1
  253. package/dest/account_manager/index.js +0 -2
  254. package/dest/api/interfaces.d.ts +0 -2
  255. package/dest/api/interfaces.d.ts.map +0 -1
  256. package/dest/api/interfaces.js +0 -1
  257. package/dest/api/log_id.d.ts +0 -2
  258. package/dest/api/log_id.d.ts.map +0 -1
  259. package/dest/api/log_id.js +0 -1
  260. package/dest/api/rpc.d.ts +0 -3
  261. package/dest/api/rpc.d.ts.map +0 -1
  262. package/dest/api/rpc.js +0 -2
  263. package/dest/api/tx_hash.d.ts +0 -2
  264. package/dest/api/tx_hash.d.ts.map +0 -1
  265. package/dest/api/tx_hash.js +0 -1
  266. package/dest/contract/deploy_proven_tx.d.ts +0 -21
  267. package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
  268. package/dest/contract/deploy_proven_tx.js +0 -21
  269. package/dest/contract/proven_tx.d.ts +0 -21
  270. package/dest/contract/proven_tx.d.ts.map +0 -1
  271. package/dest/contract/proven_tx.js +0 -23
  272. package/dest/ethereum/l1_contracts.d.ts +0 -3
  273. package/dest/ethereum/l1_contracts.d.ts.map +0 -1
  274. package/dest/ethereum/l1_contracts.js +0 -13
  275. package/dest/fee/account_entrypoint_meta_payment_method.d.ts +0 -31
  276. package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +0 -1
  277. package/dest/fee/account_entrypoint_meta_payment_method.js +0 -64
  278. package/dest/fee/fee_juice_payment_method.d.ts +0 -14
  279. package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
  280. package/dest/fee/fee_juice_payment_method.js +0 -21
  281. package/dest/fee/utils.d.ts +0 -13
  282. package/dest/fee/utils.d.ts.map +0 -1
  283. package/dest/fee/utils.js +0 -32
  284. package/dest/index.d.ts +0 -59
  285. package/dest/index.d.ts.map +0 -1
  286. package/dest/index.js +0 -62
  287. package/dest/rpc_clients/node/index.d.ts +0 -12
  288. package/dest/rpc_clients/node/index.d.ts.map +0 -1
  289. package/dest/rpc_clients/node/index.js +0 -72
  290. package/dest/rpc_clients/pxe_client.d.ts +0 -10
  291. package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
  292. package/dest/rpc_clients/pxe_client.js +0 -23
  293. package/dest/utils/pxe.d.ts +0 -4
  294. package/dest/utils/pxe.d.ts.map +0 -1
  295. package/dest/utils/pxe.js +0 -14
  296. package/dest/wallet/account_wallet.d.ts +0 -74
  297. package/dest/wallet/account_wallet.d.ts.map +0 -1
  298. package/dest/wallet/account_wallet.js +0 -232
  299. package/dest/wallet/account_wallet_with_private_key.d.ts +0 -26
  300. package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
  301. package/dest/wallet/base_wallet.d.ts +0 -48
  302. package/dest/wallet/base_wallet.d.ts.map +0 -1
  303. package/dest/wallet/base_wallet.js +0 -70
  304. package/dest/wallet/signerless_wallet.d.ts +0 -23
  305. package/dest/wallet/signerless_wallet.d.ts.map +0 -1
  306. package/dest/wallet/signerless_wallet.js +0 -33
  307. package/src/account_manager/account_manager.ts +0 -276
  308. package/src/account_manager/deploy_account_sent_tx.ts +0 -46
  309. package/src/account_manager/index.ts +0 -2
  310. package/src/api/interfaces.ts +0 -1
  311. package/src/api/log_id.ts +0 -1
  312. package/src/api/rpc.ts +0 -2
  313. package/src/api/tx_hash.ts +0 -1
  314. package/src/contract/deploy_proven_tx.ts +0 -45
  315. package/src/contract/proven_tx.ts +0 -36
  316. package/src/ethereum/l1_contracts.ts +0 -21
  317. package/src/fee/account_entrypoint_meta_payment_method.ts +0 -89
  318. package/src/fee/fee_juice_payment_method.ts +0 -25
  319. package/src/fee/utils.ts +0 -39
  320. package/src/index.ts +0 -85
  321. package/src/rpc_clients/node/index.ts +0 -77
  322. package/src/rpc_clients/pxe_client.ts +0 -25
  323. package/src/utils/pxe.ts +0 -17
  324. package/src/wallet/account_wallet.ts +0 -246
  325. package/src/wallet/base_wallet.ts +0 -141
  326. package/src/wallet/signerless_wallet.ts +0 -56
@@ -1,8 +1,9 @@
1
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
2
1
  import { FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
3
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
2
  import { collectOffchainEffects } from '@aztec/stdlib/tx';
3
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
5
4
  import { BaseContractInteraction } from './base_contract_interaction.js';
5
+ import { getGasLimits } from './get_gas_limits.js';
6
+ import { toProfileOptions, toSimulateOptions } from './interaction_options.js';
6
7
  /**
7
8
  * This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
8
9
  * It contains available interactions one can call on a method, including view.
@@ -17,67 +18,59 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
17
18
  throw new Error(`All function interaction arguments must be defined and not null. Received: ${args}`);
18
19
  }
19
20
  }
20
- // docs:start:create
21
21
  /**
22
- * Create a transaction execution request that represents this call, encoded and authenticated by the
23
- * user's wallet, ready to be simulated.
24
- * @param options - An optional object containing additional configuration for the transaction.
25
- * @returns A Promise that resolves to a transaction instance.
26
- */ async create(options = {}) {
27
- // docs:end:create
28
- if (this.functionDao.functionType === FunctionType.UTILITY) {
29
- throw new Error("Can't call `create` on a utility function.");
30
- }
31
- const requestWithoutFee = await this.request(options);
32
- const { fee: userFee, txNonce, cancellable } = options;
33
- const fee = await this.getFeeOptions(requestWithoutFee, userFee, {
34
- txNonce,
35
- cancellable
36
- });
37
- return await this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
38
- txNonce,
39
- cancellable
40
- });
22
+ * Returns the encoded function call wrapped by this interaction
23
+ * Useful when generating authwits
24
+ * @returns An encoded function call
25
+ */ async getFunctionCall() {
26
+ const args = encodeArguments(this.functionDao, this.args);
27
+ return {
28
+ name: this.functionDao.name,
29
+ args,
30
+ selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
31
+ type: this.functionDao.functionType,
32
+ to: this.contractAddress,
33
+ isStatic: this.functionDao.isStatic,
34
+ hideMsgSender: false,
35
+ returnTypes: this.functionDao.returnTypes
36
+ };
41
37
  }
42
- // docs:start:request
43
38
  /**
44
- * Returns an execution request that represents this operation.
45
- * Can be used as a building block for constructing batch requests.
46
- * @param options - An optional object containing additional configuration for the request generation.
47
- * @returns An execution payload wrapped in promise.
39
+ * Returns the execution payload that allows this operation to happen on chain.
40
+ * @param options - Configuration options.
41
+ * @returns The execution payload for this operation
48
42
  */ async request(options = {}) {
49
- // docs:end:request
50
- const args = encodeArguments(this.functionDao, this.args);
51
43
  const calls = [
52
- {
53
- name: this.functionDao.name,
54
- args,
55
- selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
56
- type: this.functionDao.functionType,
57
- to: this.contractAddress,
58
- isStatic: this.functionDao.isStatic,
59
- returnTypes: this.functionDao.returnTypes
60
- }
44
+ await this.getFunctionCall()
61
45
  ];
62
46
  const { authWitnesses, capsules } = options;
63
- return new ExecutionPayload(calls, this.authWitnesses.concat(authWitnesses ?? []), this.capsules.concat(capsules ?? []), this.extraHashedArgs);
47
+ const feeExecutionPayload = options.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
48
+ const functionExecutionPayload = new ExecutionPayload(calls, this.authWitnesses.concat(authWitnesses ?? []), this.capsules.concat(capsules ?? []), this.extraHashedArgs);
49
+ const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
50
+ feeExecutionPayload,
51
+ functionExecutionPayload
52
+ ]) : functionExecutionPayload;
53
+ return finalExecutionPayload;
64
54
  }
65
55
  // eslint-disable-next-line jsdoc/require-jsdoc
66
56
  async simulate(options) {
67
57
  // docs:end:simulate
68
58
  if (this.functionDao.functionType == FunctionType.UTILITY) {
69
- const utilityResult = await this.wallet.simulateUtility(this.functionDao.name, this.args, this.contractAddress, options.authWitnesses ?? []);
59
+ const call = await this.getFunctionCall();
60
+ const utilityResult = await this.wallet.simulateUtility(call, options.authWitnesses ?? []);
61
+ // Decode the raw field elements to the actual return type
62
+ const returnValue = utilityResult.result ? decodeFromAbi(this.functionDao.returnTypes, utilityResult.result) : [];
70
63
  if (options.includeMetadata) {
71
64
  return {
72
65
  stats: utilityResult.stats,
73
- result: utilityResult.result
66
+ result: returnValue
74
67
  };
75
68
  } else {
76
- return utilityResult.result;
69
+ return returnValue;
77
70
  }
78
71
  }
79
- const txRequest = await this.create(options);
80
- const simulatedTx = await this.wallet.simulateTx(txRequest, true, options.skipTxValidation, options.skipFeeEnforcement ?? true);
72
+ const executionPayload = await this.request(options);
73
+ const simulatedTx = await this.wallet.simulateTx(executionPayload, toSimulateOptions(options));
81
74
  let rawReturnValues;
82
75
  if (this.functionDao.functionType == FunctionType.PRIVATE) {
83
76
  if (simulatedTx.getPrivateReturnValues().nested.length > 0) {
@@ -93,11 +86,17 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
93
86
  rawReturnValues = simulatedTx.getPublicReturnValues()?.[0]?.values;
94
87
  }
95
88
  const returnValue = rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
96
- if (options.includeMetadata) {
89
+ if (options.includeMetadata || options.fee?.estimateGas) {
90
+ const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
91
+ this.log.verbose(`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`);
97
92
  return {
98
93
  stats: simulatedTx.stats,
99
94
  offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
100
- result: returnValue
95
+ result: returnValue,
96
+ estimatedGas: {
97
+ gasLimits,
98
+ teardownGasLimits
99
+ }
101
100
  };
102
101
  } else {
103
102
  return returnValue;
@@ -109,19 +108,11 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
109
108
  *
110
109
  * @returns An object containing the function return value and profile result.
111
110
  */ async profile(options) {
112
- if (options.from !== AztecAddress.ZERO && !options.from.equals(this.wallet.getAddress())) {
113
- throw new Error(`The address provided as from does not match the wallet address. Expected ${this.wallet.getAddress().toString()}, got ${options.from.toString()}.`);
114
- }
115
111
  if (this.functionDao.functionType == FunctionType.UTILITY) {
116
112
  throw new Error("Can't profile a utility function.");
117
113
  }
118
- const { authWitnesses, capsules, fee } = options;
119
- const txRequest = await this.create({
120
- fee,
121
- authWitnesses,
122
- capsules
123
- });
124
- return await this.wallet.profileTx(txRequest, options.profileMode, options.skipProofGeneration, options?.from);
114
+ const executionPayload = await this.request(options);
115
+ return await this.wallet.profileTx(executionPayload, toProfileOptions(options));
125
116
  }
126
117
  /**
127
118
  * Augments this ContractFunctionInteraction with additional metadata, such as authWitnesses, capsules, and extraHashedArgs.
@@ -1,35 +1,65 @@
1
- import type { ExecutionPayload } from '@aztec/entrypoints/payload';
2
- import type { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import { type ContractArtifact, type FunctionArtifact } from '@aztec/stdlib/abi';
4
3
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
5
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
5
  import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
7
- import type { GasSettings } from '@aztec/stdlib/gas';
8
6
  import type { PublicKeys } from '@aztec/stdlib/keys';
9
- import type { Capsule, TxExecutionRequest, TxProfileResult } from '@aztec/stdlib/tx';
7
+ import { type Capsule, type TxProfileResult } from '@aztec/stdlib/tx';
8
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
10
9
  import type { Wallet } from '../wallet/wallet.js';
11
10
  import { BaseContractInteraction } from './base_contract_interaction.js';
12
- import type { Contract } from './contract.js';
13
11
  import type { ContractBase } from './contract_base.js';
14
- import { DeployProvenTx } from './deploy_proven_tx.js';
15
12
  import { DeploySentTx } from './deploy_sent_tx.js';
16
- import type { ProfileMethodOptions, SendMethodOptions } from './interaction_options.js';
13
+ import { type ProfileInteractionOptions, type RequestInteractionOptions, type SendInteractionOptions, type SimulationInteractionFeeOptions, type SimulationReturn } from './interaction_options.js';
17
14
  /**
18
15
  * Options for deploying a contract on the Aztec network.
19
- * Allows specifying a contract address salt, and additional send method options.
16
+ * Allows specifying a contract address salt and different options to tweak contract publication
17
+ * and initialization
20
18
  */
21
- export type DeployOptions = {
19
+ export type RequestDeployOptions = RequestInteractionOptions & {
22
20
  /** An optional salt value used to deterministically calculate the contract address. */
23
21
  contractAddressSalt?: Fr;
24
- /** Set to true to *not* include the sender in the address computation. */
25
- universalDeploy?: boolean;
22
+ /**
23
+ * Deployer address that will be used for the deployed contract's address computation.
24
+ * If set to 0, the sender's address won't be mixed in
25
+ */
26
+ deployer?: AztecAddress;
26
27
  /** Skip contract class publication. */
27
28
  skipClassPublication?: boolean;
28
29
  /** Skip publication, instead just privately initialize the contract. */
29
30
  skipInstancePublication?: boolean;
30
31
  /** Skip contract initialization. */
31
32
  skipInitialization?: boolean;
32
- } & SendMethodOptions;
33
+ /** Skip contract registration in the wallet */
34
+ skipRegistration?: boolean;
35
+ };
36
+ /**
37
+ * Extends the deployment options with the required parameters to send the transaction
38
+ */
39
+ export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
40
+ /**
41
+ * Set to true to *not* include the sender in the address computation. This option
42
+ * is mutually exclusive with "deployer"
43
+ */
44
+ universalDeploy?: boolean;
45
+ } & Pick<SendInteractionOptions, 'from' | 'fee'>;
46
+ /**
47
+ * Options for simulating the deployment of a contract
48
+ * Allows skipping certain validations and computing gas estimations
49
+ */
50
+ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
51
+ /** The fee options for the transaction. */
52
+ fee?: SimulationInteractionFeeOptions;
53
+ /** Simulate without checking for the validity of the resulting transaction,
54
+ * e.g. whether it emits any existing nullifiers. */
55
+ skipTxValidation?: boolean;
56
+ /** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
57
+ skipFeeEnforcement?: boolean;
58
+ /** Whether to include metadata such as offchain effects and performance statistics
59
+ * (e.g. timing information of the different circuits and oracles) in
60
+ * the simulation result, instead of just the return value of the function */
61
+ includeMetadata?: boolean;
62
+ };
33
63
  /**
34
64
  * Contract interaction for deployment.
35
65
  * Handles class publication, instance publication, and initialization of the contract.
@@ -42,54 +72,28 @@ export type DeployOptions = {
42
72
  *
43
73
  * Extends the BaseContractInteraction class.
44
74
  */
45
- export declare class DeployMethod<TContract extends ContractBase = Contract> extends BaseContractInteraction {
75
+ export declare class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
46
76
  private publicKeys;
47
- private artifact;
48
- private postDeployCtor;
77
+ protected artifact: ContractArtifact;
78
+ protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract;
49
79
  private args;
50
80
  /** The contract instance to be deployed. */
51
81
  private instance?;
52
82
  /** Constructor function to call. */
53
83
  private constructorArtifact;
54
- constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact, authWitnesses?: AuthWitness[], capsules?: Capsule[]);
84
+ constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact, authWitnesses?: AuthWitness[], capsules?: Capsule[]);
55
85
  /**
56
- * Prepare a transaction execution request which can optionally (depending on the `options`):
57
- * - Publish the contract's class_id
58
- * - Publish the contract instance data, to enable execution of its public functions.
59
- * - Initialize the contract
60
- *
61
- * A tx is not necessary if the function has no public functions nor any
62
- * initializer function.
63
- *
64
- * This function internally calls `request()` and `sign()` methods to prepare
65
- * the transaction for deployment. The resulting signed transaction can be
66
- * later sent using the `send()` method.
67
- *
68
- * @param options - An object containing optional deployment settings, contractAddressSalt, and from.
69
- * @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
86
+ * Returns the execution payload that allows this operation to happen on chain.
87
+ * @param options - Configuration options.
88
+ * @returns The execution payload for this operation
70
89
  */
71
- create(options: DeployOptions): Promise<TxExecutionRequest>;
90
+ request(options?: RequestDeployOptions): Promise<ExecutionPayload>;
91
+ convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions;
72
92
  /**
73
- * Returns an array of function calls that represent this operation. Useful as a building
74
- * block for constructing batch requests.
93
+ * Adds this contract to the wallet and returns the Contract object.
75
94
  * @param options - Deployment options.
76
- * @returns An array of function calls.
77
- * @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
78
- * it returns a promise for an array instead of a function call directly.
79
95
  */
80
- request(options: DeployOptions): Promise<ExecutionPayload>;
81
- /**
82
- * Simulate a deployment and profile the gate count for each function in the transaction.
83
- * @param options - Same options as `send`, plus extra profiling options.
84
- *
85
- * @returns An object containing the function return value and profile result.
86
- */
87
- profile(options: DeployOptions & ProfileMethodOptions): Promise<TxProfileResult>;
88
- /**
89
- * Adds this contract to the PXE and returns the Contract object.
90
- * @param options - Deployment options.
91
- */
92
- register(options?: Omit<DeployOptions, 'from'>): Promise<TContract>;
96
+ register(options?: RequestDeployOptions): Promise<TContract>;
93
97
  /**
94
98
  * Returns an execution payload for:
95
99
  * - publication of the contract class and
@@ -98,13 +102,13 @@ export declare class DeployMethod<TContract extends ContractBase = Contract> ext
98
102
  * @param options - Contract creation options.
99
103
  * @returns An execution payload with potentially calls (and bytecode capsule) to the class registry and instance registry.
100
104
  */
101
- protected getPublicationExecutionPayload(options?: Omit<DeployOptions, 'from'>): Promise<ExecutionPayload>;
105
+ protected getPublicationExecutionPayload(options?: RequestDeployOptions): Promise<ExecutionPayload>;
102
106
  /**
103
107
  * Returns the calls necessary to initialize the contract.
104
108
  * @param options - Deployment options.
105
109
  * @returns - An array of function calls.
106
110
  */
107
- protected getInitializationExecutionPayload(options?: Omit<DeployOptions, 'from'>): Promise<ExecutionPayload>;
111
+ protected getInitializationExecutionPayload(options?: RequestDeployOptions): Promise<ExecutionPayload>;
108
112
  /**
109
113
  * Send a contract deployment transaction (initialize and/or publish) using the provided options.
110
114
  * This function extends the 'send' method from the ContractFunctionInteraction class,
@@ -120,18 +124,22 @@ export declare class DeployMethod<TContract extends ContractBase = Contract> ext
120
124
  * @param options - An object containing various initialization and publication options.
121
125
  * @returns An instance object.
122
126
  */
123
- getInstance(options?: Omit<DeployOptions, 'from'>): Promise<ContractInstanceWithAddress>;
127
+ getInstance(options?: RequestDeployOptions): Promise<ContractInstanceWithAddress>;
124
128
  /**
125
- * Prove the request.
126
- * @param options - initialization and publication options.
127
- * @returns The proven tx.
129
+ * Simulate the deployment
130
+ *
131
+ * @param options - An optional object containing additional configuration for the simulation.
132
+ * @returns A simulation result object containing metadata of the execution, including gas
133
+ * estimations (if requested via options), execution statistics and emitted offchain effects
128
134
  */
129
- prove(options: DeployOptions): Promise<DeployProvenTx<TContract>>;
135
+ simulate(options: SimulateDeployOptions): Promise<SimulationReturn<true>>;
130
136
  /**
131
- * Estimates gas cost for this deployment operation.
132
- * @param options - Options.
137
+ * Simulate a deployment and profile the gate count for each function in the transaction.
138
+ * @param options - Same options as `send`, plus extra profiling options.
139
+ *
140
+ * @returns An object containing the function return value and profile result.
133
141
  */
134
- estimateGas(options: Omit<DeployOptions, 'estimateGas'>): Promise<Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>>;
142
+ profile(options: DeployOptions & ProfileInteractionOptions): Promise<TxProfileResult>;
135
143
  /** Return this deployment address. */
136
144
  get address(): AztecAddress | undefined;
137
145
  /** Returns the partial address for this deployment. */
@@ -141,11 +149,11 @@ export declare class DeployMethod<TContract extends ContractBase = Contract> ext
141
149
  * @param options - An object containing the metadata to add to the interaction
142
150
  * @returns A new DeployMethod with the added metadata, but calling the same original function in the same manner
143
151
  */
144
- with({ authWitnesses, capsules, }: {
152
+ with({ authWitnesses, capsules }: {
145
153
  /** The authWitnesses to add to the deployment */
146
154
  authWitnesses?: AuthWitness[];
147
155
  /** The capsules to add to the deployment */
148
156
  capsules?: Capsule[];
149
157
  }): DeployMethod;
150
158
  }
151
- //# sourceMappingURL=deploy_method.d.ts.map
159
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X21ldGhvZC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0L2RlcGxveV9tZXRob2QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3BELE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUFvQixLQUFLLGdCQUFnQixFQUFrQixNQUFNLG1CQUFtQixDQUFDO0FBQ25ILE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQzlELE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUMzRCxPQUFPLEVBQ0wsS0FBSywyQkFBMkIsRUFJakMsTUFBTSx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNyRCxPQUFPLEVBQU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AAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAcrF;IAED;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC,CAOjG;IAED,sCAAsC;IACtC,IAAW,OAAO,6BAEjB;IAED,uDAAuD;IACvD,IAAW,cAAc,4BAExB;IAED;;;;OAIG;IACI,IAAI,CAAC,EACV,aAAkB,EAClB,QAAa,EACd,EAAE;QACD,iDAAiD;QACjD,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;QAC9B,4CAA4C;QAC5C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;KACtB,GAAG,YAAY,CAWf;CACF"}
@@ -1,15 +1,16 @@
1
- import { mergeExecutionPayloads } from '@aztec/entrypoints/payload';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { getInitializer } from '@aztec/stdlib/abi';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
5
+ import { collectOffchainEffects } from '@aztec/stdlib/tx';
6
+ import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
5
7
  import { publishContractClass } from '../deployment/publish_class.js';
6
8
  import { publishInstance } from '../deployment/publish_instance.js';
7
9
  import { BaseContractInteraction } from './base_contract_interaction.js';
8
10
  import { ContractFunctionInteraction } from './contract_function_interaction.js';
9
- import { DeployProvenTx } from './deploy_proven_tx.js';
10
11
  import { DeploySentTx } from './deploy_sent_tx.js';
11
- // docs:end:deploy_options
12
- // TODO(@spalladino): Add unit tests for this class!
12
+ import { getGasLimits } from './get_gas_limits.js';
13
+ import { toProfileOptions, toSendOptions, toSimulateOptions } from './interaction_options.js';
13
14
  /**
14
15
  * Contract interaction for deployment.
15
16
  * Handles class publication, instance publication, and initialization of the contract.
@@ -33,83 +34,42 @@ import { DeploySentTx } from './deploy_sent_tx.js';
33
34
  this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
34
35
  }
35
36
  /**
36
- * Prepare a transaction execution request which can optionally (depending on the `options`):
37
- * - Publish the contract's class_id
38
- * - Publish the contract instance data, to enable execution of its public functions.
39
- * - Initialize the contract
40
- *
41
- * A tx is not necessary if the function has no public functions nor any
42
- * initializer function.
43
- *
44
- * This function internally calls `request()` and `sign()` methods to prepare
45
- * the transaction for deployment. The resulting signed transaction can be
46
- * later sent using the `send()` method.
47
- *
48
- * @param options - An object containing optional deployment settings, contractAddressSalt, and from.
49
- * @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
50
- */ async create(options) {
51
- const requestWithoutFee = await this.request(options);
52
- const { fee: userFee, txNonce, cancellable } = options;
53
- const fee = await this.getFeeOptions(requestWithoutFee, userFee, {
54
- txNonce,
55
- cancellable
56
- });
57
- return this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
58
- txNonce,
59
- cancellable
60
- });
61
- }
62
- // REFACTOR: Having a `request` method with different semantics than the ones in the other
63
- // derived ContractInteractions is confusing. We should unify the flow of all ContractInteractions.
64
- /**
65
- * Returns an array of function calls that represent this operation. Useful as a building
66
- * block for constructing batch requests.
67
- * @param options - Deployment options.
68
- * @returns An array of function calls.
69
- * @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
70
- * it returns a promise for an array instead of a function call directly.
37
+ * Returns the execution payload that allows this operation to happen on chain.
38
+ * @param options - Configuration options.
39
+ * @returns The execution payload for this operation
71
40
  */ async request(options) {
72
41
  const publication = await this.getPublicationExecutionPayload(options);
73
- // TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
74
- // Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
75
- // runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
76
- // in case the initializer is public. This hints at the need of having "transient" contracts scoped to a
77
- // simulation, so we can run the simulation with a set of contracts, but only "commit" them to the wallet
78
- // once this tx has gone through.
79
- await this.wallet.registerContract({
80
- artifact: this.artifact,
81
- instance: await this.getInstance(options)
82
- });
42
+ if (!options?.skipRegistration) {
43
+ await this.wallet.registerContract(await this.getInstance(options), this.artifact);
44
+ }
83
45
  const initialization = await this.getInitializationExecutionPayload(options);
84
- const exec = [
46
+ const feeExecutionPayload = options?.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
47
+ const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
48
+ feeExecutionPayload,
85
49
  publication,
86
50
  initialization
87
- ];
88
- const fnCalls = exec.map((exec)=>exec.calls).flat();
89
- if (!fnCalls.length) {
51
+ ]) : mergeExecutionPayloads([
52
+ publication,
53
+ initialization
54
+ ]);
55
+ if (!finalExecutionPayload.calls.length) {
90
56
  throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
91
57
  }
92
- return mergeExecutionPayloads(exec);
58
+ return finalExecutionPayload;
93
59
  }
94
- /**
95
- * Simulate a deployment and profile the gate count for each function in the transaction.
96
- * @param options - Same options as `send`, plus extra profiling options.
97
- *
98
- * @returns An object containing the function return value and profile result.
99
- */ async profile(options) {
100
- const txRequest = await this.create(options);
101
- return await this.wallet.profileTx(txRequest, options.profileMode, options.skipProofGeneration, options?.from);
60
+ convertDeployOptionsToRequestOptions(options) {
61
+ return {
62
+ ...options,
63
+ deployer: !options?.universalDeploy ? options.from : undefined
64
+ };
102
65
  }
103
66
  /**
104
- * Adds this contract to the PXE and returns the Contract object.
67
+ * Adds this contract to the wallet and returns the Contract object.
105
68
  * @param options - Deployment options.
106
- */ async register(options = {}) {
69
+ */ async register(options) {
107
70
  const instance = await this.getInstance(options);
108
- await this.wallet.registerContract({
109
- artifact: this.artifact,
110
- instance
111
- });
112
- return this.postDeployCtor(instance.address, this.wallet);
71
+ await this.wallet.registerContract(instance, this.artifact);
72
+ return this.postDeployCtor(instance, this.wallet);
113
73
  }
114
74
  /**
115
75
  * Returns an execution payload for:
@@ -118,7 +78,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
118
78
  * depending on the provided options.
119
79
  * @param options - Contract creation options.
120
80
  * @returns An execution payload with potentially calls (and bytecode capsule) to the class registry and instance registry.
121
- */ async getPublicationExecutionPayload(options = {}) {
81
+ */ async getPublicationExecutionPayload(options) {
122
82
  const calls = [];
123
83
  // Set contract instance object so it's available for populating the DeploySendTx object
124
84
  const instance = await this.getInstance(options);
@@ -129,7 +89,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
129
89
  throw new Error(`Contract class mismatch when deploying contract: got ${instance.currentContractClassId.toString()} from instance and ${contractClass.id.toString()} from artifact`);
130
90
  }
131
91
  // Publish the contract class if it hasn't been published already.
132
- if (!options.skipClassPublication) {
92
+ if (!options?.skipClassPublication) {
133
93
  if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
134
94
  this.log.debug(`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`);
135
95
  } else {
@@ -139,7 +99,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
139
99
  }
140
100
  }
141
101
  // Publish the contract instance:
142
- if (!options.skipInstancePublication) {
102
+ if (!options?.skipInstancePublication) {
143
103
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
144
104
  // Read the artifact, and if there are no public functions, warn the caller that publication of the
145
105
  // contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
@@ -152,9 +112,9 @@ import { DeploySentTx } from './deploy_sent_tx.js';
152
112
  * Returns the calls necessary to initialize the contract.
153
113
  * @param options - Deployment options.
154
114
  * @returns - An array of function calls.
155
- */ async getInitializationExecutionPayload(options = {}) {
115
+ */ async getInitializationExecutionPayload(options) {
156
116
  const executionsPayloads = [];
157
- if (this.constructorArtifact && !options.skipInitialization) {
117
+ if (this.constructorArtifact && !options?.skipInitialization) {
158
118
  const { address } = await this.getInstance(options);
159
119
  const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
160
120
  executionsPayloads.push(await constructorCall.request());
@@ -169,7 +129,11 @@ import { DeploySentTx } from './deploy_sent_tx.js';
169
129
  * @param options - An object containing various deployment options such as contractAddressSalt and from.
170
130
  * @returns A SentTx object that returns the receipt and the deployed contract instance.
171
131
  */ send(options) {
172
- const sendTx = ()=>super.send(options).getTxHash();
132
+ const sendTx = async ()=>{
133
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
134
+ const sendOptions = toSendOptions(options);
135
+ return this.wallet.sendTx(executionPayload, sendOptions);
136
+ };
173
137
  this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
174
138
  return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, ()=>this.getInstance(options));
175
139
  }
@@ -178,31 +142,51 @@ import { DeploySentTx } from './deploy_sent_tx.js';
178
142
  *
179
143
  * @param options - An object containing various initialization and publication options.
180
144
  * @returns An instance object.
181
- */ async getInstance(options = {}) {
145
+ */ async getInstance(options) {
182
146
  if (!this.instance) {
183
147
  this.instance = await getContractInstanceFromInstantiationParams(this.artifact, {
184
148
  constructorArgs: this.args,
185
- salt: options.contractAddressSalt,
149
+ salt: options?.contractAddressSalt ?? Fr.random(),
186
150
  publicKeys: this.publicKeys,
187
151
  constructorArtifact: this.constructorArtifact,
188
- deployer: options.universalDeploy ? AztecAddress.ZERO : this.wallet.getAddress()
152
+ deployer: options?.deployer ? options.deployer : AztecAddress.ZERO
189
153
  });
190
154
  }
191
155
  return this.instance;
192
156
  }
193
157
  /**
194
- * Prove the request.
195
- * @param options - initialization and publication options.
196
- * @returns The proven tx.
197
- */ async prove(options) {
198
- const txProvingResult = await this.proveInternal(options);
199
- return await DeployProvenTx.fromProvingResult(this.wallet, txProvingResult, this.postDeployCtor, ()=>this.getInstance(options), txProvingResult.stats);
158
+ * Simulate the deployment
159
+ *
160
+ * @param options - An optional object containing additional configuration for the simulation.
161
+ * @returns A simulation result object containing metadata of the execution, including gas
162
+ * estimations (if requested via options), execution statistics and emitted offchain effects
163
+ */ async simulate(options) {
164
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
165
+ const simulatedTx = await this.wallet.simulateTx(executionPayload, toSimulateOptions(options));
166
+ const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
167
+ this.log.verbose(`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`);
168
+ return {
169
+ stats: simulatedTx.stats,
170
+ offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
171
+ result: undefined,
172
+ estimatedGas: {
173
+ gasLimits,
174
+ teardownGasLimits
175
+ }
176
+ };
200
177
  }
201
178
  /**
202
- * Estimates gas cost for this deployment operation.
203
- * @param options - Options.
204
- */ estimateGas(options) {
205
- return super.estimateGas(options);
179
+ * Simulate a deployment and profile the gate count for each function in the transaction.
180
+ * @param options - Same options as `send`, plus extra profiling options.
181
+ *
182
+ * @returns An object containing the function return value and profile result.
183
+ */ async profile(options) {
184
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
185
+ return await this.wallet.profileTx(executionPayload, {
186
+ ...toProfileOptions(options),
187
+ profileMode: options.profileMode,
188
+ skipProofGeneration: options.skipProofGeneration
189
+ });
206
190
  }
207
191
  /** Return this deployment address. */ get address() {
208
192
  return this.instance?.address;