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

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 (278) hide show
  1. package/dest/account/account.d.ts +60 -0
  2. package/dest/account/account.d.ts.map +1 -0
  3. package/dest/account/account.js +59 -0
  4. package/dest/account/account_contract.d.ts +5 -5
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_contract.js +0 -1
  7. package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
  8. package/dest/account/account_with_secret_key.d.ts.map +1 -0
  9. package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
  10. package/dest/account/index.d.ts +1 -4
  11. package/dest/account/index.d.ts.map +1 -1
  12. package/dest/account/index.js +1 -4
  13. package/dest/account/signerless_account.d.ts +24 -0
  14. package/dest/account/signerless_account.d.ts.map +1 -0
  15. package/dest/account/signerless_account.js +27 -0
  16. package/dest/api/abi.d.ts +1 -0
  17. package/dest/api/abi.d.ts.map +1 -1
  18. package/dest/api/account.d.ts +4 -2
  19. package/dest/api/account.d.ts.map +1 -1
  20. package/dest/api/account.js +3 -1
  21. package/dest/api/addresses.d.ts +1 -0
  22. package/dest/api/addresses.d.ts.map +1 -1
  23. package/dest/api/addresses.js +1 -0
  24. package/dest/api/authorization.d.ts +2 -0
  25. package/dest/api/authorization.d.ts.map +1 -1
  26. package/dest/api/authorization.js +2 -0
  27. package/dest/api/block.d.ts +3 -0
  28. package/dest/api/block.d.ts.map +1 -0
  29. package/dest/api/block.js +2 -0
  30. package/dest/api/contract.d.ts +4 -5
  31. package/dest/api/contract.d.ts.map +1 -1
  32. package/dest/api/contract.js +3 -3
  33. package/dest/api/crypto.d.ts +2 -0
  34. package/dest/api/crypto.d.ts.map +1 -0
  35. package/dest/api/crypto.js +1 -0
  36. package/dest/api/ethereum.d.ts +0 -1
  37. package/dest/api/ethereum.d.ts.map +1 -1
  38. package/dest/api/ethereum.js +0 -1
  39. package/dest/api/events.d.ts +12 -0
  40. package/dest/api/events.d.ts.map +1 -0
  41. package/dest/api/events.js +30 -0
  42. package/dest/api/fee.d.ts +1 -2
  43. package/dest/api/fee.d.ts.map +1 -1
  44. package/dest/api/fee.js +0 -1
  45. package/dest/api/keys.d.ts +4 -0
  46. package/dest/api/keys.d.ts.map +1 -0
  47. package/dest/api/keys.js +3 -0
  48. package/dest/api/log.d.ts +1 -0
  49. package/dest/api/log.d.ts.map +1 -1
  50. package/dest/api/log.js +1 -0
  51. package/dest/api/messaging.d.ts +3 -0
  52. package/dest/api/messaging.d.ts.map +1 -0
  53. package/dest/api/messaging.js +2 -0
  54. package/dest/api/node.d.ts +21 -0
  55. package/dest/api/node.d.ts.map +1 -0
  56. package/dest/api/node.js +18 -0
  57. package/dest/api/note.d.ts +2 -0
  58. package/dest/api/note.d.ts.map +1 -0
  59. package/dest/api/note.js +1 -0
  60. package/dest/api/protocol.d.ts +3 -0
  61. package/dest/api/protocol.d.ts.map +1 -0
  62. package/dest/api/protocol.js +2 -0
  63. package/dest/api/trees.d.ts +3 -0
  64. package/dest/api/trees.d.ts.map +1 -0
  65. package/dest/api/trees.js +2 -0
  66. package/dest/api/tx.d.ts +2 -0
  67. package/dest/api/tx.d.ts.map +1 -0
  68. package/dest/api/tx.js +1 -0
  69. package/dest/api/utils.d.ts +10 -6
  70. package/dest/api/utils.d.ts.map +1 -1
  71. package/dest/api/utils.js +10 -5
  72. package/dest/api/wallet.d.ts +4 -1
  73. package/dest/api/wallet.d.ts.map +1 -1
  74. package/dest/api/wallet.js +4 -1
  75. package/dest/contract/base_contract_interaction.d.ts +6 -48
  76. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  77. package/dest/contract/base_contract_interaction.js +6 -106
  78. package/dest/contract/batch_call.d.ts +6 -14
  79. package/dest/contract/batch_call.d.ts.map +1 -1
  80. package/dest/contract/batch_call.js +42 -52
  81. package/dest/contract/contract.d.ts +1 -1
  82. package/dest/contract/contract.d.ts.map +1 -1
  83. package/dest/contract/contract.js +2 -12
  84. package/dest/contract/contract_base.d.ts +1 -1
  85. package/dest/contract/contract_base.d.ts.map +1 -1
  86. package/dest/contract/contract_function_interaction.d.ts +29 -40
  87. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  88. package/dest/contract/contract_function_interaction.js +41 -53
  89. package/dest/contract/deploy_method.d.ts +63 -56
  90. package/dest/contract/deploy_method.d.ts.map +1 -1
  91. package/dest/contract/deploy_method.js +68 -86
  92. package/dest/contract/deploy_sent_tx.d.ts +0 -1
  93. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  94. package/dest/contract/deploy_sent_tx.js +7 -10
  95. package/dest/contract/interaction_options.d.ts +74 -19
  96. package/dest/contract/interaction_options.d.ts.map +1 -1
  97. package/dest/contract/interaction_options.js +51 -3
  98. package/dest/contract/sent_tx.d.ts +3 -3
  99. package/dest/contract/sent_tx.d.ts.map +1 -1
  100. package/dest/contract/sent_tx.js +5 -5
  101. package/dest/contract/wait_for_proven.d.ts +3 -3
  102. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  103. package/dest/contract/wait_for_proven.js +2 -2
  104. package/dest/deployment/publish_instance.d.ts +1 -1
  105. package/dest/deployment/publish_instance.d.ts.map +1 -1
  106. package/dest/deployment/publish_instance.js +2 -5
  107. package/dest/ethereum/portal_manager.d.ts +3 -4
  108. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  109. package/dest/ethereum/portal_manager.js +3 -5
  110. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +12 -7
  111. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  112. package/dest/fee/fee_juice_payment_method_with_claim.js +21 -12
  113. package/dest/fee/fee_payment_method.d.ts +26 -0
  114. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  115. package/dest/fee/fee_payment_method.js +3 -0
  116. package/dest/fee/private_fee_payment_method.d.ts +22 -5
  117. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  118. package/dest/fee/private_fee_payment_method.js +34 -13
  119. package/dest/fee/public_fee_payment_method.d.ts +22 -5
  120. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  121. package/dest/fee/public_fee_payment_method.js +37 -14
  122. package/dest/fee/sponsored_fee_payment.d.ts +2 -0
  123. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  124. package/dest/fee/sponsored_fee_payment.js +4 -0
  125. package/dest/utils/authwit.d.ts +77 -25
  126. package/dest/utils/authwit.d.ts.map +1 -1
  127. package/dest/utils/authwit.js +219 -24
  128. package/dest/utils/cross_chain.d.ts +24 -0
  129. package/dest/utils/cross_chain.d.ts.map +1 -0
  130. package/dest/utils/cross_chain.js +30 -0
  131. package/dest/utils/fee_juice.d.ts +3 -2
  132. package/dest/utils/fee_juice.d.ts.map +1 -1
  133. package/dest/utils/fee_juice.js +3 -2
  134. package/dest/{fee → wallet}/account_entrypoint_meta_payment_method.d.ts +13 -10
  135. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  136. package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
  137. package/dest/wallet/account_manager.d.ts +69 -0
  138. package/dest/wallet/account_manager.d.ts.map +1 -0
  139. package/dest/wallet/account_manager.js +113 -0
  140. package/dest/wallet/base_wallet.d.ts +78 -35
  141. package/dest/wallet/base_wallet.d.ts.map +1 -1
  142. package/dest/wallet/base_wallet.js +216 -48
  143. package/dest/wallet/deploy_account_method.d.ts +52 -0
  144. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  145. package/dest/wallet/deploy_account_method.js +77 -0
  146. package/dest/wallet/index.d.ts +2 -15
  147. package/dest/wallet/index.d.ts.map +1 -1
  148. package/dest/wallet/index.js +2 -19
  149. package/dest/wallet/wallet.d.ts +2473 -6
  150. package/dest/wallet/wallet.d.ts.map +1 -1
  151. package/dest/wallet/wallet.js +202 -3
  152. package/package.json +25 -21
  153. package/src/account/account.ts +97 -0
  154. package/src/account/account_contract.ts +4 -6
  155. package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
  156. package/src/account/index.ts +1 -4
  157. package/src/account/signerless_account.ts +46 -0
  158. package/src/api/abi.ts +11 -0
  159. package/src/api/account.ts +4 -2
  160. package/src/api/addresses.ts +1 -0
  161. package/src/api/authorization.ts +11 -0
  162. package/src/api/block.ts +2 -0
  163. package/src/api/contract.ts +16 -8
  164. package/src/api/crypto.ts +1 -0
  165. package/src/api/ethereum.ts +0 -1
  166. package/src/api/events.ts +44 -0
  167. package/src/api/fee.ts +1 -2
  168. package/src/api/keys.ts +8 -0
  169. package/src/api/log.ts +1 -0
  170. package/src/api/messaging.ts +2 -0
  171. package/src/api/node.ts +20 -0
  172. package/src/api/note.ts +1 -0
  173. package/src/api/protocol.ts +2 -0
  174. package/src/api/trees.ts +2 -0
  175. package/src/api/tx.ts +11 -0
  176. package/src/api/utils.ts +12 -19
  177. package/src/api/wallet.ts +33 -5
  178. package/src/contract/base_contract_interaction.ts +9 -138
  179. package/src/contract/batch_call.ts +52 -61
  180. package/src/contract/contract.ts +2 -12
  181. package/src/contract/contract_function_interaction.ts +65 -97
  182. package/src/contract/deploy_method.ts +117 -99
  183. package/src/contract/deploy_sent_tx.ts +4 -10
  184. package/src/contract/interaction_options.ts +126 -24
  185. package/src/contract/sent_tx.ts +4 -4
  186. package/src/contract/wait_for_proven.ts +4 -4
  187. package/src/deployment/publish_instance.ts +3 -8
  188. package/src/ethereum/portal_manager.ts +4 -12
  189. package/src/fee/fee_juice_payment_method_with_claim.ts +26 -17
  190. package/src/fee/fee_payment_method.ts +26 -0
  191. package/src/fee/private_fee_payment_method.ts +60 -41
  192. package/src/fee/public_fee_payment_method.ts +73 -49
  193. package/src/fee/sponsored_fee_payment.ts +6 -0
  194. package/src/utils/authwit.ts +250 -38
  195. package/src/utils/cross_chain.ts +53 -0
  196. package/src/utils/fee_juice.ts +4 -3
  197. package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
  198. package/src/wallet/account_manager.ts +154 -0
  199. package/src/wallet/base_wallet.ts +287 -78
  200. package/src/wallet/deploy_account_method.ts +125 -0
  201. package/src/wallet/index.ts +2 -32
  202. package/src/wallet/wallet.ts +357 -29
  203. package/dest/account_manager/account_manager.d.ts +0 -119
  204. package/dest/account_manager/account_manager.d.ts.map +0 -1
  205. package/dest/account_manager/account_manager.js +0 -202
  206. package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
  207. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
  208. package/dest/account_manager/deploy_account_sent_tx.js +0 -29
  209. package/dest/account_manager/index.d.ts +0 -3
  210. package/dest/account_manager/index.d.ts.map +0 -1
  211. package/dest/account_manager/index.js +0 -2
  212. package/dest/api/interfaces.d.ts +0 -2
  213. package/dest/api/interfaces.d.ts.map +0 -1
  214. package/dest/api/interfaces.js +0 -1
  215. package/dest/api/log_id.d.ts +0 -2
  216. package/dest/api/log_id.d.ts.map +0 -1
  217. package/dest/api/log_id.js +0 -1
  218. package/dest/api/rpc.d.ts +0 -3
  219. package/dest/api/rpc.d.ts.map +0 -1
  220. package/dest/api/rpc.js +0 -2
  221. package/dest/api/tx_hash.d.ts +0 -2
  222. package/dest/api/tx_hash.d.ts.map +0 -1
  223. package/dest/api/tx_hash.js +0 -1
  224. package/dest/contract/deploy_proven_tx.d.ts +0 -21
  225. package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
  226. package/dest/contract/deploy_proven_tx.js +0 -21
  227. package/dest/contract/proven_tx.d.ts +0 -21
  228. package/dest/contract/proven_tx.d.ts.map +0 -1
  229. package/dest/contract/proven_tx.js +0 -23
  230. package/dest/ethereum/l1_contracts.d.ts +0 -3
  231. package/dest/ethereum/l1_contracts.d.ts.map +0 -1
  232. package/dest/ethereum/l1_contracts.js +0 -13
  233. package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +0 -1
  234. package/dest/fee/account_entrypoint_meta_payment_method.js +0 -64
  235. package/dest/fee/fee_juice_payment_method.d.ts +0 -14
  236. package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
  237. package/dest/fee/fee_juice_payment_method.js +0 -21
  238. package/dest/fee/utils.d.ts +0 -13
  239. package/dest/fee/utils.d.ts.map +0 -1
  240. package/dest/fee/utils.js +0 -32
  241. package/dest/index.d.ts +0 -59
  242. package/dest/index.d.ts.map +0 -1
  243. package/dest/index.js +0 -62
  244. package/dest/rpc_clients/node/index.d.ts +0 -12
  245. package/dest/rpc_clients/node/index.d.ts.map +0 -1
  246. package/dest/rpc_clients/node/index.js +0 -72
  247. package/dest/rpc_clients/pxe_client.d.ts +0 -10
  248. package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
  249. package/dest/rpc_clients/pxe_client.js +0 -23
  250. package/dest/utils/pxe.d.ts +0 -4
  251. package/dest/utils/pxe.d.ts.map +0 -1
  252. package/dest/utils/pxe.js +0 -14
  253. package/dest/wallet/account_wallet.d.ts +0 -74
  254. package/dest/wallet/account_wallet.d.ts.map +0 -1
  255. package/dest/wallet/account_wallet.js +0 -232
  256. package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
  257. package/dest/wallet/signerless_wallet.d.ts +0 -23
  258. package/dest/wallet/signerless_wallet.d.ts.map +0 -1
  259. package/dest/wallet/signerless_wallet.js +0 -33
  260. package/src/account_manager/account_manager.ts +0 -276
  261. package/src/account_manager/deploy_account_sent_tx.ts +0 -46
  262. package/src/account_manager/index.ts +0 -2
  263. package/src/api/interfaces.ts +0 -1
  264. package/src/api/log_id.ts +0 -1
  265. package/src/api/rpc.ts +0 -2
  266. package/src/api/tx_hash.ts +0 -1
  267. package/src/contract/deploy_proven_tx.ts +0 -45
  268. package/src/contract/proven_tx.ts +0 -36
  269. package/src/ethereum/l1_contracts.ts +0 -21
  270. package/src/fee/account_entrypoint_meta_payment_method.ts +0 -89
  271. package/src/fee/fee_juice_payment_method.ts +0 -25
  272. package/src/fee/utils.ts +0 -39
  273. package/src/index.ts +0 -85
  274. package/src/rpc_clients/node/index.ts +0 -77
  275. package/src/rpc_clients/pxe_client.ts +0 -25
  276. package/src/utils/pxe.ts +0 -17
  277. package/src/wallet/account_wallet.ts +0 -246
  278. package/src/wallet/signerless_wallet.ts +0 -56
@@ -1,15 +1,16 @@
1
1
  import { mergeExecutionPayloads } from '@aztec/entrypoints/payload';
2
+ import { Fr } from '@aztec/foundation/fields';
2
3
  import { getInitializer } from '@aztec/stdlib/abi';
3
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
5
  import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
6
+ import { collectOffchainEffects } 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,82 +34,39 @@ 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
+ await this.wallet.registerContract(await this.getInstance(options), this.artifact);
83
43
  const initialization = await this.getInitializationExecutionPayload(options);
84
- const exec = [
44
+ const feeExecutionPayload = options?.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
45
+ const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
46
+ feeExecutionPayload,
47
+ publication,
48
+ initialization
49
+ ]) : mergeExecutionPayloads([
85
50
  publication,
86
51
  initialization
87
- ];
88
- const fnCalls = exec.map((exec)=>exec.calls).flat();
89
- if (!fnCalls.length) {
52
+ ]);
53
+ if (!finalExecutionPayload.calls.length) {
90
54
  throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
91
55
  }
92
- return mergeExecutionPayloads(exec);
56
+ return finalExecutionPayload;
93
57
  }
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);
58
+ convertDeployOptionsToRequestOptions(options) {
59
+ return {
60
+ ...options,
61
+ deployer: !options?.universalDeploy ? options.from : undefined
62
+ };
102
63
  }
103
64
  /**
104
- * Adds this contract to the PXE and returns the Contract object.
65
+ * Adds this contract to the wallet and returns the Contract object.
105
66
  * @param options - Deployment options.
106
- */ async register(options = {}) {
67
+ */ async register(options) {
107
68
  const instance = await this.getInstance(options);
108
- await this.wallet.registerContract({
109
- artifact: this.artifact,
110
- instance
111
- });
69
+ await this.wallet.registerContract(instance, this.artifact);
112
70
  return this.postDeployCtor(instance.address, this.wallet);
113
71
  }
114
72
  /**
@@ -118,7 +76,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
118
76
  * depending on the provided options.
119
77
  * @param options - Contract creation options.
120
78
  * @returns An execution payload with potentially calls (and bytecode capsule) to the class registry and instance registry.
121
- */ async getPublicationExecutionPayload(options = {}) {
79
+ */ async getPublicationExecutionPayload(options) {
122
80
  const calls = [];
123
81
  // Set contract instance object so it's available for populating the DeploySendTx object
124
82
  const instance = await this.getInstance(options);
@@ -129,7 +87,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
129
87
  throw new Error(`Contract class mismatch when deploying contract: got ${instance.currentContractClassId.toString()} from instance and ${contractClass.id.toString()} from artifact`);
130
88
  }
131
89
  // Publish the contract class if it hasn't been published already.
132
- if (!options.skipClassPublication) {
90
+ if (!options?.skipClassPublication) {
133
91
  if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
134
92
  this.log.debug(`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`);
135
93
  } else {
@@ -139,7 +97,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
139
97
  }
140
98
  }
141
99
  // Publish the contract instance:
142
- if (!options.skipInstancePublication) {
100
+ if (!options?.skipInstancePublication) {
143
101
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
144
102
  // Read the artifact, and if there are no public functions, warn the caller that publication of the
145
103
  // contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
@@ -152,9 +110,9 @@ import { DeploySentTx } from './deploy_sent_tx.js';
152
110
  * Returns the calls necessary to initialize the contract.
153
111
  * @param options - Deployment options.
154
112
  * @returns - An array of function calls.
155
- */ async getInitializationExecutionPayload(options = {}) {
113
+ */ async getInitializationExecutionPayload(options) {
156
114
  const executionsPayloads = [];
157
- if (this.constructorArtifact && !options.skipInitialization) {
115
+ if (this.constructorArtifact && !options?.skipInitialization) {
158
116
  const { address } = await this.getInstance(options);
159
117
  const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
160
118
  executionsPayloads.push(await constructorCall.request());
@@ -169,7 +127,11 @@ import { DeploySentTx } from './deploy_sent_tx.js';
169
127
  * @param options - An object containing various deployment options such as contractAddressSalt and from.
170
128
  * @returns A SentTx object that returns the receipt and the deployed contract instance.
171
129
  */ send(options) {
172
- const sendTx = ()=>super.send(options).getTxHash();
130
+ const sendTx = async ()=>{
131
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
132
+ const sendOptions = await toSendOptions(options);
133
+ return this.wallet.sendTx(executionPayload, sendOptions);
134
+ };
173
135
  this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
174
136
  return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, ()=>this.getInstance(options));
175
137
  }
@@ -178,31 +140,51 @@ import { DeploySentTx } from './deploy_sent_tx.js';
178
140
  *
179
141
  * @param options - An object containing various initialization and publication options.
180
142
  * @returns An instance object.
181
- */ async getInstance(options = {}) {
143
+ */ async getInstance(options) {
182
144
  if (!this.instance) {
183
145
  this.instance = await getContractInstanceFromInstantiationParams(this.artifact, {
184
146
  constructorArgs: this.args,
185
- salt: options.contractAddressSalt,
147
+ salt: options?.contractAddressSalt ?? Fr.random(),
186
148
  publicKeys: this.publicKeys,
187
149
  constructorArtifact: this.constructorArtifact,
188
- deployer: options.universalDeploy ? AztecAddress.ZERO : this.wallet.getAddress()
150
+ deployer: options?.deployer ? options.deployer : AztecAddress.ZERO
189
151
  });
190
152
  }
191
153
  return this.instance;
192
154
  }
193
155
  /**
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);
156
+ * Simulate the deployment
157
+ *
158
+ * @param options - An optional object containing additional configuration for the simulation.
159
+ * @returns A simulation result object containing metadata of the execution, including gas
160
+ * estimations (if requested via options), execution statistics and emitted offchain effects
161
+ */ async simulate(options) {
162
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
163
+ const simulatedTx = await this.wallet.simulateTx(executionPayload, await toSimulateOptions(options));
164
+ const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
165
+ this.log.verbose(`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`);
166
+ return {
167
+ stats: simulatedTx.stats,
168
+ offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
169
+ result: undefined,
170
+ estimatedGas: {
171
+ gasLimits,
172
+ teardownGasLimits
173
+ }
174
+ };
200
175
  }
201
176
  /**
202
- * Estimates gas cost for this deployment operation.
203
- * @param options - Options.
204
- */ estimateGas(options) {
205
- return super.estimateGas(options);
177
+ * Simulate a deployment and profile the gate count for each function in the transaction.
178
+ * @param options - Same options as `send`, plus extra profiling options.
179
+ *
180
+ * @returns An object containing the function return value and profile result.
181
+ */ async profile(options) {
182
+ const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
183
+ return await this.wallet.profileTx(executionPayload, {
184
+ ...await toProfileOptions(options),
185
+ profileMode: options.profileMode,
186
+ skipProofGeneration: options.skipProofGeneration
187
+ });
206
188
  }
207
189
  /** Return this deployment address. */ get address() {
208
190
  return this.instance?.address;
@@ -39,6 +39,5 @@ export declare class DeploySentTx<TContract extends Contract = Contract> extends
39
39
  * @returns The transaction receipt with the deployed contract instance.
40
40
  */
41
41
  wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
42
- protected getContractObject(wallet?: Wallet): Promise<TContract>;
43
42
  }
44
43
  //# sourceMappingURL=deploy_sent_tx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,MA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;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;CAWzF"}
@@ -25,19 +25,16 @@ import { SentTx } from './sent_tx.js';
25
25
  * @returns The transaction receipt with the deployed contract instance.
26
26
  */ async wait(opts) {
27
27
  const receipt = await super.wait(opts);
28
- const contract = await this.getContractObject(opts?.wallet);
29
- return {
30
- ...receipt,
31
- contract
32
- };
33
- }
34
- async getContractObject(wallet) {
35
- const isWallet = (pxeWalletOrNode)=>!!pxeWalletOrNode.createTxExecutionRequest;
36
- const contractWallet = wallet ?? (isWallet(this.pxeWalletOrNode) && this.pxeWalletOrNode);
28
+ // In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
29
+ const contractWallet = opts?.wallet ?? this.walletOrNode;
37
30
  if (!contractWallet) {
38
31
  throw new Error(`A wallet is required for creating a contract instance`);
39
32
  }
40
33
  const instance = await this.instanceGetter();
41
- return this.postDeployCtor(instance.address, contractWallet);
34
+ const contract = await this.postDeployCtor(instance.address, contractWallet);
35
+ return {
36
+ ...receipt,
37
+ contract
38
+ };
42
39
  }
43
40
  }
@@ -1,44 +1,68 @@
1
- import type { UserFeeOptions } from '@aztec/entrypoints/interfaces';
2
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { FieldsOf } from '@aztec/foundation/types';
3
2
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
4
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { Capsule } from '@aztec/stdlib/tx';
4
+ import type { GasSettings } from '@aztec/stdlib/gas';
5
+ import type { Capsule, OffchainEffect, SimulationStats } from '@aztec/stdlib/tx';
6
+ import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
7
+ import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
8
+ /**
9
+ * Options used to tweak the simulation and add gas estimation capabilities
10
+ */
11
+ export type FeeEstimationOptions = {
12
+ /** Whether to modify the fee settings of the simulation with high gas limit to figure out actual gas settings. */
13
+ estimateGas?: boolean;
14
+ /** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
15
+ estimatedGasPadding?: number;
16
+ };
17
+ /**
18
+ * Interactions allow configuring a custom fee payment method that gets bundled with the transaction before
19
+ * sending it to the wallet
20
+ */
21
+ export type FeePaymentMethodOption = {
22
+ /** Fee payment method to embed in the interaction */
23
+ paymentMethod?: FeePaymentMethod;
24
+ };
25
+ /**
26
+ * User-defined partial gas settings for the interaction. This type is completely optional since
27
+ * the wallet will fill in the missing options
28
+ */
29
+ export type GasSettingsOption = {
30
+ /** The gas settings */
31
+ gasSettings?: Partial<FieldsOf<GasSettings>>;
32
+ };
33
+ /** Fee options as set by a user. */
34
+ export type InteractionFeeOptions = GasSettingsOption & FeePaymentMethodOption;
35
+ /** Fee options that can be set for simulation *only* */
36
+ export type SimulationInteractionFeeOptions = InteractionFeeOptions & FeeEstimationOptions;
6
37
  /**
7
38
  * Represents the options to configure a request from a contract interaction.
8
39
  * Allows specifying additional auth witnesses and capsules to use during execution
9
40
  */
10
- export type RequestMethodOptions = {
41
+ export type RequestInteractionOptions = {
11
42
  /** Extra authwits to use during execution */
12
43
  authWitnesses?: AuthWitness[];
13
44
  /** Extra capsules to use during execution */
14
45
  capsules?: Capsule[];
46
+ /** Fee payment method to embed in the interaction request */
47
+ fee?: FeePaymentMethodOption;
15
48
  };
16
49
  /**
17
50
  * Represents options for calling a (constrained) function in a contract.
18
51
  */
19
- export type SendMethodOptions = RequestMethodOptions & {
52
+ export type SendInteractionOptions = RequestInteractionOptions & {
20
53
  /** The sender's Aztec address. */
21
54
  from: AztecAddress;
22
55
  /** The fee options for the transaction. */
23
- fee?: UserFeeOptions;
24
- /**
25
- * A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
26
- * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
27
- * but higher fee. The nullifier ensures only one transaction can succeed.
28
- */
29
- txNonce?: Fr;
30
- /**
31
- * Whether the transaction can be cancelled by submitting a new transaction with the same txNonce but
32
- * higher fee.
33
- */
34
- cancellable?: boolean;
56
+ fee?: InteractionFeeOptions;
35
57
  };
36
58
  /**
37
59
  * Represents the options for simulating a contract function interaction.
38
60
  * Allows specifying the address from which the method should be called.
39
61
  * Disregarded for simulation of public functions
40
62
  */
41
- export type SimulateMethodOptions = Pick<SendMethodOptions, 'from' | 'authWitnesses' | 'capsules' | 'fee' | 'txNonce' | 'cancellable'> & {
63
+ export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
64
+ /** The fee options for the transaction. */
65
+ fee?: SimulationInteractionFeeOptions;
42
66
  /** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
43
67
  skipTxValidation?: boolean;
44
68
  /** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
@@ -50,10 +74,41 @@ export type SimulateMethodOptions = Pick<SendMethodOptions, 'from' | 'authWitnes
50
74
  /**
51
75
  * Represents the options for profiling an interaction.
52
76
  */
53
- export type ProfileMethodOptions = SimulateMethodOptions & {
77
+ export type ProfileInteractionOptions = SimulateInteractionOptions & {
54
78
  /** Whether to return gates information or the bytecode/witnesses. */
55
79
  profileMode: 'gates' | 'execution-steps' | 'full';
56
80
  /** Whether to generate a ClientIVC proof or not */
57
81
  skipProofGeneration?: boolean;
58
82
  };
83
+ /**
84
+ * Represents the result type of a simulation.
85
+ * By default, it will just be the return value of the simulated function
86
+ * If `includeMetadata` is set to true in `SimulateInteractionOptions` on the input of `simulate(...)`,
87
+ * it will provide extra information.
88
+ */
89
+ export type SimulationReturn<T extends boolean | undefined> = T extends true ? {
90
+ /** Additional stats about the simulation */
91
+ stats: SimulationStats;
92
+ /** Offchain effects generated during the simulation */
93
+ offchainEffects: OffchainEffect[];
94
+ /** Return value of the function */
95
+ result: any;
96
+ /** Gas estimation results */
97
+ estimatedGas: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>;
98
+ } : any;
99
+ /**
100
+ * Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
101
+ * SendOptions, which are the ones that can be serialized and forwarded to the wallet
102
+ */
103
+ export declare function toSendOptions(options: SendInteractionOptions): Promise<SendOptions>;
104
+ /**
105
+ * Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
106
+ * SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
107
+ */
108
+ export declare function toSimulateOptions(options: SimulateInteractionOptions): Promise<SimulateOptions>;
109
+ /**
110
+ * Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
111
+ * ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
112
+ */
113
+ export declare function toProfileOptions(options: ProfileInteractionOptions): Promise<ProfileOptions>;
59
114
  //# sourceMappingURL=interaction_options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interaction_options.d.ts","sourceRoot":"","sources":["../../src/contract/interaction_options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG;IACrD,kCAAkC;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,cAAc,CAAC;IACr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AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,0BAA0B,GAAG;IACnE,qEAAqE;IACrE,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,MAAM,CAAC;IAClD,mDAAmD;IACnD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,IAAI,CAAC,SAAS,IAAI,GACxE;IACE,4CAA4C;IAC5C,KAAK,EAAE,eAAe,CAAC;IACvB,uDAAuD;IACvD,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,oCAAoC;IACpC,MAAM,EAAE,GAAG,CAAC;IACZ,6BAA6B;IAC7B,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,mBAAmB,CAAC,CAAC;CACpE,GACD,GAAG,CAAC;AAER;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAgBzF;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,eAAe,CAAC,CAkBrG;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC,CAMlG"}
@@ -1,4 +1,52 @@
1
1
  /**
2
- * Represents the options for profiling an interaction.
3
- */ // docs:start:profile-method-options
4
- export { }; // docs:end:profile-method-options
2
+ * Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
3
+ * SendOptions, which are the ones that can be serialized and forwarded to the wallet
4
+ */ export async function toSendOptions(options) {
5
+ return {
6
+ ...options,
7
+ fee: {
8
+ // If this interaction includes a fee payment method, pass the fee payer
9
+ // as a hint to the wallet
10
+ embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
11
+ // If a payment method that includes gas settings was used,
12
+ // try to reuse as much as possible while still allowing
13
+ // manual override. CAREFUL: this can cause mismatches during proving
14
+ gasSettings: {
15
+ ...options.fee?.paymentMethod?.getGasSettings(),
16
+ ...options.fee?.gasSettings
17
+ }
18
+ }
19
+ };
20
+ }
21
+ /**
22
+ * Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
23
+ * SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
24
+ */ export async function toSimulateOptions(options) {
25
+ return {
26
+ ...options,
27
+ fee: {
28
+ // If this interaction includes a fee payment method, pass the fee payer
29
+ // as a hint to the wallet
30
+ embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
31
+ // If a payment method that includes gas settings was used,
32
+ // try to reuse as much as possible while still allowing
33
+ // manual override. CAREFUL: this can cause mismatches during proving
34
+ gasSettings: {
35
+ ...options.fee?.paymentMethod?.getGasSettings(),
36
+ ...options.fee?.gasSettings
37
+ },
38
+ estimateGas: options.fee?.estimateGas,
39
+ estimatedGasPadding: options.fee?.estimatedGasPadding
40
+ }
41
+ };
42
+ }
43
+ /**
44
+ * Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
45
+ * ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
46
+ */ export async function toProfileOptions(options) {
47
+ return {
48
+ ...await toSimulateOptions(options),
49
+ profileMode: options.profileMode,
50
+ skipProofGeneration: options.skipProofGeneration
51
+ };
52
+ }
@@ -1,5 +1,5 @@
1
1
  import type { FieldsOf } from '@aztec/foundation/types';
2
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
2
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
3
  import { TxHash, type TxReceipt } from '@aztec/stdlib/tx';
4
4
  import type { Wallet } from '../wallet/wallet.js';
5
5
  /** Options related to waiting for a tx. */
@@ -19,11 +19,11 @@ export declare const DefaultWaitOpts: WaitOpts;
19
19
  * its hash, receipt, and mining status.
20
20
  */
21
21
  export declare class SentTx {
22
- protected pxeWalletOrNode: Wallet | AztecNode | PXE;
22
+ protected walletOrNode: Wallet | AztecNode;
23
23
  protected sendTxPromise: Promise<void>;
24
24
  protected sendTxError?: Error;
25
25
  protected txHash?: TxHash;
26
- constructor(pxeWalletOrNode: Wallet | AztecNode | PXE, sendTx: () => Promise<TxHash>);
26
+ constructor(walletOrNode: Wallet | AztecNode, sendTx: () => Promise<TxHash>);
27
27
  /**
28
28
  * Retrieves the transaction hash of the SentTx instance.
29
29
  * The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
@@ -1 +1 @@
1
- {"version":3,"file":"sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/sent_tx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACrB,gKAAgK;IAChK,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAMf,SAAS,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG;IALrD,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;g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C;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGd,YAAY,EAAE,MAAM,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAgB/B;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAazC;;;;;;OAMG;IACU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;IAK7C;;;;OAIG;IACU,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;cAUhD,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CA6BpE"}
@@ -10,12 +10,12 @@ export const DefaultWaitOpts = {
10
10
  * The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
11
11
  * its hash, receipt, and mining status.
12
12
  */ export class SentTx {
13
- pxeWalletOrNode;
13
+ walletOrNode;
14
14
  sendTxPromise;
15
15
  sendTxError;
16
16
  txHash;
17
- constructor(pxeWalletOrNode, sendTx){
18
- this.pxeWalletOrNode = pxeWalletOrNode;
17
+ constructor(walletOrNode, sendTx){
18
+ this.walletOrNode = walletOrNode;
19
19
  const { promise, resolve } = promiseWithResolvers();
20
20
  this.sendTxPromise = promise;
21
21
  sendTx().then((txHash)=>{
@@ -51,7 +51,7 @@ export const DefaultWaitOpts = {
51
51
  * @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
52
52
  */ async getReceipt() {
53
53
  const txHash = await this.getTxHash();
54
- return await this.pxeWalletOrNode.getTxReceipt(txHash);
54
+ return await this.walletOrNode.getTxReceipt(txHash);
55
55
  }
56
56
  /**
57
57
  * Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
@@ -69,7 +69,7 @@ export const DefaultWaitOpts = {
69
69
  const startTime = Date.now();
70
70
  const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
71
71
  return await retryUntil(async ()=>{
72
- const txReceipt = await this.pxeWalletOrNode.getTxReceipt(txHash);
72
+ const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
73
73
  // If receipt is not yet available, try again
74
74
  if (txReceipt.status === TxStatus.PENDING) {
75
75
  return undefined;
@@ -1,5 +1,5 @@
1
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
2
- import type { TxReceipt } from '../index.js';
1
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
2
+ import type { TxReceipt } from '@aztec/stdlib/tx';
3
3
  /**
4
4
  * Options for waiting for a transaction to be proven.
5
5
  */
@@ -13,5 +13,5 @@ export declare const DefaultWaitForProvenOpts: WaitForProvenOpts;
13
13
  /**
14
14
  * Wait for a transaction to be proven by polling the node
15
15
  */
16
- export declare function waitForProven(pxeOrNode: PXE | AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts): Promise<number>;
16
+ export declare function waitForProven(node: AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts): Promise<number>;
17
17
  //# sourceMappingURL=wait_for_proven.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wait_for_proven.d.ts","sourceRoot":"","sources":["../../src/contract/wait_for_proven.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC;AAEF;;GAEG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,iBAAiB,mBAa3G"}
1
+ {"version":3,"file":"wait_for_proven.d.ts","sourceRoot":"","sources":["../../src/contract/wait_for_proven.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC;AAEF;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,iBAAiB,mBAahG"}
@@ -6,12 +6,12 @@ export const DefaultWaitForProvenOpts = {
6
6
  };
7
7
  /**
8
8
  * Wait for a transaction to be proven by polling the node
9
- */ export async function waitForProven(pxeOrNode, receipt, opts) {
9
+ */ export async function waitForProven(node, receipt, opts) {
10
10
  if (!receipt.blockNumber) {
11
11
  throw new Error(`Cannot wait for proven: receipt of tx ${receipt.txHash} does not have a block number`);
12
12
  }
13
13
  return await retryUntil(async ()=>{
14
- const provenBlock = await pxeOrNode.getProvenBlockNumber();
14
+ const provenBlock = await node.getProvenBlockNumber();
15
15
  return provenBlock >= receipt.blockNumber ? provenBlock : undefined;
16
16
  }, 'isProven', opts?.provenTimeout ?? DefaultWaitForProvenOpts.provenTimeout, opts?.interval ?? DefaultWaitForProvenOpts.interval);
17
17
  }
@@ -1,6 +1,6 @@
1
1
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
2
2
  import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
3
- import type { Wallet } from '../wallet/index.js';
3
+ import type { Wallet } from '../wallet/wallet.js';
4
4
  /**
5
5
  * Sets up a call to the canonical contract instance registry to publish a contract instance.
6
6
  * @param wallet - The wallet to use for the publication (setup) tx.
@@ -1 +1 @@
1
- {"version":3,"file":"publish_instance.d.ts","sourceRoot":"","sources":["../../src/deployment/publish_instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAgBtC"}
1
+ {"version":3,"file":"publish_instance.d.ts","sourceRoot":"","sources":["../../src/deployment/publish_instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAWtC"}
@@ -5,10 +5,7 @@ import { getInstanceRegistryContract } from '../contract/protocol_contracts.js';
5
5
  * @param instance - The instance to publish.
6
6
  */ export async function publishInstance(wallet, instance) {
7
7
  const contractInstanceRegistry = await getInstanceRegistryContract(wallet);
8
- const { salt, currentContractClassId: contractClassId, publicKeys, deployer } = instance;
9
- const isUniversalDeploy = deployer.isZero();
10
- if (!isUniversalDeploy && !wallet.getAddress().equals(deployer)) {
11
- throw new Error(`Expected deployer ${deployer.toString()} does not match sender wallet ${wallet.getAddress().toString()}`);
12
- }
8
+ const { salt, currentContractClassId: contractClassId, publicKeys, deployer: instanceDeployer } = instance;
9
+ const isUniversalDeploy = instanceDeployer.isZero();
13
10
  return contractInstanceRegistry.methods.publish_for_public_execution(salt, contractClassId, instance.initializationHash, publicKeys, isUniversalDeploy);
14
11
  }