@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,39 +1,67 @@
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
+
7
+ import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
8
+ import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
9
+
10
+ /**
11
+ * Options used to tweak the simulation and add gas estimation capabilities
12
+ */
13
+ export type FeeEstimationOptions = {
14
+ /** Whether to modify the fee settings of the simulation with high gas limit to figure out actual gas settings. */
15
+ estimateGas?: boolean;
16
+ /** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
17
+ estimatedGasPadding?: number;
18
+ };
19
+
20
+ /**
21
+ * Interactions allow configuring a custom fee payment method that gets bundled with the transaction before
22
+ * sending it to the wallet
23
+ */
24
+ export type FeePaymentMethodOption = {
25
+ /** Fee payment method to embed in the interaction */
26
+ paymentMethod?: FeePaymentMethod;
27
+ };
28
+
29
+ /**
30
+ * User-defined partial gas settings for the interaction. This type is completely optional since
31
+ * the wallet will fill in the missing options
32
+ */
33
+ export type GasSettingsOption = {
34
+ /** The gas settings */
35
+ gasSettings?: Partial<FieldsOf<GasSettings>>;
36
+ };
37
+
38
+ /** Fee options as set by a user. */
39
+ export type InteractionFeeOptions = GasSettingsOption & FeePaymentMethodOption;
40
+
41
+ /** Fee options that can be set for simulation *only* */
42
+ export type SimulationInteractionFeeOptions = InteractionFeeOptions & FeeEstimationOptions;
6
43
 
7
44
  /**
8
45
  * Represents the options to configure a request from a contract interaction.
9
46
  * Allows specifying additional auth witnesses and capsules to use during execution
10
47
  */
11
- export type RequestMethodOptions = {
48
+ export type RequestInteractionOptions = {
12
49
  /** Extra authwits to use during execution */
13
50
  authWitnesses?: AuthWitness[];
14
51
  /** Extra capsules to use during execution */
15
52
  capsules?: Capsule[];
53
+ /** Fee payment method to embed in the interaction request */
54
+ fee?: FeePaymentMethodOption;
16
55
  };
17
56
 
18
57
  /**
19
58
  * Represents options for calling a (constrained) function in a contract.
20
59
  */
21
- export type SendMethodOptions = RequestMethodOptions & {
60
+ export type SendInteractionOptions = RequestInteractionOptions & {
22
61
  /** The sender's Aztec address. */
23
62
  from: AztecAddress;
24
63
  /** The fee options for the transaction. */
25
- fee?: UserFeeOptions;
26
- /**
27
- * A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
28
- * used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
29
- * but higher fee. The nullifier ensures only one transaction can succeed.
30
- */
31
- txNonce?: Fr;
32
- /**
33
- * Whether the transaction can be cancelled by submitting a new transaction with the same txNonce but
34
- * higher fee.
35
- */
36
- cancellable?: boolean;
64
+ fee?: InteractionFeeOptions;
37
65
  };
38
66
 
39
67
  /**
@@ -41,10 +69,9 @@ export type SendMethodOptions = RequestMethodOptions & {
41
69
  * Allows specifying the address from which the method should be called.
42
70
  * Disregarded for simulation of public functions
43
71
  */
44
- export type SimulateMethodOptions = Pick<
45
- SendMethodOptions,
46
- 'from' | 'authWitnesses' | 'capsules' | 'fee' | 'txNonce' | 'cancellable'
47
- > & {
72
+ export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
73
+ /** The fee options for the transaction. */
74
+ fee?: SimulationInteractionFeeOptions;
48
75
  /** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
49
76
  skipTxValidation?: boolean;
50
77
  /** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
@@ -57,11 +84,86 @@ export type SimulateMethodOptions = Pick<
57
84
  /**
58
85
  * Represents the options for profiling an interaction.
59
86
  */
60
- // docs:start:profile-method-options
61
- export type ProfileMethodOptions = SimulateMethodOptions & {
87
+ export type ProfileInteractionOptions = SimulateInteractionOptions & {
62
88
  /** Whether to return gates information or the bytecode/witnesses. */
63
89
  profileMode: 'gates' | 'execution-steps' | 'full';
64
90
  /** Whether to generate a ClientIVC proof or not */
65
91
  skipProofGeneration?: boolean;
66
92
  };
67
- // docs:end:profile-method-options
93
+
94
+ /**
95
+ * Represents the result type of a simulation.
96
+ * By default, it will just be the return value of the simulated function
97
+ * If `includeMetadata` is set to true in `SimulateInteractionOptions` on the input of `simulate(...)`,
98
+ * it will provide extra information.
99
+ */
100
+ export type SimulationReturn<T extends boolean | undefined> = T extends true
101
+ ? {
102
+ /** Additional stats about the simulation */
103
+ stats: SimulationStats;
104
+ /** Offchain effects generated during the simulation */
105
+ offchainEffects: OffchainEffect[];
106
+ /** Return value of the function */
107
+ result: any;
108
+ /** Gas estimation results */
109
+ estimatedGas: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>;
110
+ }
111
+ : any;
112
+
113
+ /**
114
+ * Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
115
+ * SendOptions, which are the ones that can be serialized and forwarded to the wallet
116
+ */
117
+ export async function toSendOptions(options: SendInteractionOptions): Promise<SendOptions> {
118
+ return {
119
+ ...options,
120
+ fee: {
121
+ // If this interaction includes a fee payment method, pass the fee payer
122
+ // as a hint to the wallet
123
+ embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
124
+ // If a payment method that includes gas settings was used,
125
+ // try to reuse as much as possible while still allowing
126
+ // manual override. CAREFUL: this can cause mismatches during proving
127
+ gasSettings: {
128
+ ...options.fee?.paymentMethod?.getGasSettings(),
129
+ ...options.fee?.gasSettings,
130
+ },
131
+ },
132
+ };
133
+ }
134
+
135
+ /**
136
+ * Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
137
+ * SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
138
+ */
139
+ export async function toSimulateOptions(options: SimulateInteractionOptions): Promise<SimulateOptions> {
140
+ return {
141
+ ...options,
142
+ fee: {
143
+ // If this interaction includes a fee payment method, pass the fee payer
144
+ // as a hint to the wallet
145
+ embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
146
+ // If a payment method that includes gas settings was used,
147
+ // try to reuse as much as possible while still allowing
148
+ // manual override. CAREFUL: this can cause mismatches during proving
149
+ gasSettings: {
150
+ ...options.fee?.paymentMethod?.getGasSettings(),
151
+ ...options.fee?.gasSettings,
152
+ },
153
+ estimateGas: options.fee?.estimateGas,
154
+ estimatedGasPadding: options.fee?.estimatedGasPadding,
155
+ },
156
+ };
157
+ }
158
+
159
+ /**
160
+ * Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
161
+ * ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
162
+ */
163
+ export async function toProfileOptions(options: ProfileInteractionOptions): Promise<ProfileOptions> {
164
+ return {
165
+ ...(await toSimulateOptions(options)),
166
+ profileMode: options.profileMode,
167
+ skipProofGeneration: options.skipProofGeneration,
168
+ };
169
+ }
@@ -1,7 +1,7 @@
1
1
  import { promiseWithResolvers } from '@aztec/foundation/promise';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import type { FieldsOf } from '@aztec/foundation/types';
4
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
4
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
5
  import { TxHash, type TxReceipt, TxStatus } from '@aztec/stdlib/tx';
6
6
 
7
7
  import type { Wallet } from '../wallet/wallet.js';
@@ -34,7 +34,7 @@ export class SentTx {
34
34
  protected txHash?: TxHash;
35
35
 
36
36
  constructor(
37
- protected pxeWalletOrNode: Wallet | AztecNode | PXE,
37
+ protected walletOrNode: Wallet | AztecNode,
38
38
  sendTx: () => Promise<TxHash>,
39
39
  ) {
40
40
  const { promise, resolve } = promiseWithResolvers<void>();
@@ -80,7 +80,7 @@ export class SentTx {
80
80
  */
81
81
  public async getReceipt(): Promise<TxReceipt> {
82
82
  const txHash = await this.getTxHash();
83
- return await this.pxeWalletOrNode.getTxReceipt(txHash);
83
+ return await this.walletOrNode.getTxReceipt(txHash);
84
84
  }
85
85
 
86
86
  /**
@@ -105,7 +105,7 @@ export class SentTx {
105
105
 
106
106
  return await retryUntil(
107
107
  async () => {
108
- const txReceipt = await this.pxeWalletOrNode.getTxReceipt(txHash);
108
+ const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
109
109
  // If receipt is not yet available, try again
110
110
  if (txReceipt.status === TxStatus.PENDING) {
111
111
  return undefined;
@@ -1,7 +1,7 @@
1
1
  import { retryUntil } from '@aztec/foundation/retry';
2
- import type { AztecNode, PXE } from '@aztec/stdlib/interfaces/client';
2
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
+ import type { TxReceipt } from '@aztec/stdlib/tx';
3
4
 
4
- import type { TxReceipt } from '../index.js';
5
5
  import { DefaultWaitOpts } from './sent_tx.js';
6
6
 
7
7
  /**
@@ -22,13 +22,13 @@ export const DefaultWaitForProvenOpts: WaitForProvenOpts = {
22
22
  /**
23
23
  * Wait for a transaction to be proven by polling the node
24
24
  */
25
- export async function waitForProven(pxeOrNode: PXE | AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts) {
25
+ export async function waitForProven(node: AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts) {
26
26
  if (!receipt.blockNumber) {
27
27
  throw new Error(`Cannot wait for proven: receipt of tx ${receipt.txHash} does not have a block number`);
28
28
  }
29
29
  return await retryUntil(
30
30
  async () => {
31
- const provenBlock = await pxeOrNode.getProvenBlockNumber();
31
+ const provenBlock = await node.getProvenBlockNumber();
32
32
  return provenBlock >= receipt.blockNumber! ? provenBlock : undefined;
33
33
  },
34
34
  'isProven',
@@ -2,7 +2,7 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
2
2
 
3
3
  import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
4
4
  import { getInstanceRegistryContract } from '../contract/protocol_contracts.js';
5
- import type { Wallet } from '../wallet/index.js';
5
+ import type { Wallet } from '../wallet/wallet.js';
6
6
 
7
7
  /**
8
8
  * Sets up a call to the canonical contract instance registry to publish a contract instance.
@@ -14,13 +14,8 @@ export async function publishInstance(
14
14
  instance: ContractInstanceWithAddress,
15
15
  ): Promise<ContractFunctionInteraction> {
16
16
  const contractInstanceRegistry = await getInstanceRegistryContract(wallet);
17
- const { salt, currentContractClassId: contractClassId, publicKeys, deployer } = instance;
18
- const isUniversalDeploy = deployer.isZero();
19
- if (!isUniversalDeploy && !wallet.getAddress().equals(deployer)) {
20
- throw new Error(
21
- `Expected deployer ${deployer.toString()} does not match sender wallet ${wallet.getAddress().toString()}`,
22
- );
23
- }
17
+ const { salt, currentContractClassId: contractClassId, publicKeys, deployer: instanceDeployer } = instance;
18
+ const isUniversalDeploy = instanceDeployer.isZero();
24
19
  return contractInstanceRegistry.methods.publish_for_public_execution(
25
20
  salt,
26
21
  contractClassId,
@@ -12,15 +12,11 @@ import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
12
12
  import { TokenPortalAbi } from '@aztec/l1-artifacts/TokenPortalAbi';
13
13
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import { computeL2ToL1MessageHash, computeSecretHash } from '@aztec/stdlib/hash';
15
- import type { PXE } from '@aztec/stdlib/interfaces/client';
15
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
16
16
  import { getL2ToL1MessageLeafId } from '@aztec/stdlib/messaging';
17
17
 
18
18
  import { type Hex, getContract, toFunctionSelector } from 'viem';
19
19
 
20
- import type { Wallet } from '../index.js';
21
-
22
- // docs:start:claim_type
23
- // docs:start:claim_type_amount
24
20
  /** L1 to L2 message info to claim it on L2. */
25
21
  export type L2Claim = {
26
22
  /** Secret for claiming. */
@@ -32,11 +28,9 @@ export type L2Claim = {
32
28
  /** Leaf index in the L1 to L2 message tree. */
33
29
  messageLeafIndex: bigint;
34
30
  };
35
- // docs:end:claim_type
36
31
 
37
32
  /** L1 to L2 message info that corresponds to an amount to claim. */
38
33
  export type L2AmountClaim = L2Claim & { /** Amount to claim */ claimAmount: bigint };
39
- // docs:end:claim_type_amount
40
34
 
41
35
  /** L1 to L2 message info that corresponds to an amount to claim with associated recipient. */
42
36
  export type L2AmountClaimWithRecipient = L2AmountClaim & {
@@ -208,18 +202,18 @@ export class L1FeeJuicePortalManager {
208
202
 
209
203
  /**
210
204
  * Creates a new instance
211
- * @param walletOrPxe - Wallet or PXE client used for retrieving the L1 contract addresses.
205
+ * @param node - Aztec node client used for retrieving the L1 contract addresses.
212
206
  * @param extendedClient - Wallet client, extended with public actions.
213
207
  * @param logger - Logger.
214
208
  */
215
209
  public static async new(
216
- walletOrPxe: Wallet | PXE,
210
+ node: AztecNode,
217
211
  extendedClient: ExtendedViemWalletClient,
218
212
  logger: Logger,
219
213
  ): Promise<L1FeeJuicePortalManager> {
220
214
  const {
221
215
  l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress },
222
- } = await walletOrPxe.getNodeInfo();
216
+ } = await node.getNodeInfo();
223
217
 
224
218
  if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
225
219
  throw new Error('Portal or token not deployed on L1');
@@ -304,7 +298,6 @@ export class L1ToL2TokenPortalManager {
304
298
  };
305
299
  }
306
300
 
307
- // docs:start:bridge_tokens_private
308
301
  /**
309
302
  * Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
310
303
  * @param to - Address to send the tokens to on L2.
@@ -316,7 +309,6 @@ export class L1ToL2TokenPortalManager {
316
309
  amount: bigint,
317
310
  mint = false,
318
311
  ): Promise<L2AmountClaimWithRecipient> {
319
- // docs:end:bridge_tokens_private
320
312
  const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
321
313
 
322
314
  this.logger.info('Sending L1 tokens to L2 to be claimed privately');
@@ -2,42 +2,39 @@ import { ExecutionPayload } from '@aztec/entrypoints/payload';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
4
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+ import type { GasSettings } from '@aztec/stdlib/gas';
5
7
 
6
- import { getFeeJuice } from '../contract/protocol_contracts.js';
7
8
  import type { L2AmountClaim } from '../ethereum/portal_manager.js';
8
- import type { Wallet } from '../wallet/index.js';
9
- import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
9
+ import type { FeePaymentMethod } from './fee_payment_method.js';
10
10
 
11
11
  /**
12
- * Pay fee directly with Fee Juice claimed on the same tx.
12
+ * Pay fee directly with Fee Juice claimed in the same tx. Claiming consumes an L1 to L2 message that "contains"
13
+ * the fee juice bridged from L1.
13
14
  */
14
- export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
15
+ export class FeeJuicePaymentMethodWithClaim implements FeePaymentMethod {
15
16
  constructor(
16
- private senderWallet: Wallet,
17
+ private sender: AztecAddress,
17
18
  private claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>,
18
- ) {
19
- super(senderWallet.getAddress());
20
- }
19
+ ) {}
21
20
 
22
21
  /**
23
22
  * Creates an execution payload to pay the fee in Fee Juice.
24
- * @returns An execution payload that just contains the claim function call.
23
+ * @returns An execution payload that just contains the `claim_and_end_setup` function call.
25
24
  */
26
- override async getExecutionPayload(): Promise<ExecutionPayload> {
27
- const canonicalFeeJuice = await getFeeJuice(this.senderWallet);
28
- const selector = await FunctionSelector.fromNameAndParameters(
29
- canonicalFeeJuice.artifact.functions.find(f => f.name === 'claim')!,
30
- );
25
+ async getExecutionPayload(): Promise<ExecutionPayload> {
26
+ const selector = await FunctionSelector.fromSignature('claim_and_end_setup((Field),u128,Field,Field)');
31
27
 
32
28
  return new ExecutionPayload(
33
29
  [
34
30
  {
35
31
  to: ProtocolContractAddress.FeeJuice,
36
- name: 'claim',
32
+ name: 'claim_and_end_setup',
37
33
  selector,
34
+ hideMsgSender: false,
38
35
  isStatic: false,
39
36
  args: [
40
- this.senderWallet.getAddress().toField(),
37
+ this.sender.toField(),
41
38
  new Fr(this.claim.claimAmount),
42
39
  this.claim.claimSecret,
43
40
  new Fr(this.claim.messageLeafIndex),
@@ -50,4 +47,16 @@ export class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMethod {
50
47
  [],
51
48
  );
52
49
  }
50
+
51
+ getAsset() {
52
+ return Promise.resolve(ProtocolContractAddress.FeeJuice);
53
+ }
54
+
55
+ getFeePayer(): Promise<AztecAddress> {
56
+ return Promise.resolve(this.sender);
57
+ }
58
+
59
+ getGasSettings(): GasSettings | undefined {
60
+ return;
61
+ }
53
62
  }
@@ -0,0 +1,26 @@
1
+ import type { ExecutionPayload } from '@aztec/entrypoints/payload';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { GasSettings } from '@aztec/stdlib/gas';
4
+
5
+ /**
6
+ * Holds information about how the fee for a transaction is to be paid.
7
+ */
8
+ export interface FeePaymentMethod {
9
+ /** The asset used to pay the fee. */
10
+ getAsset(): Promise<AztecAddress>;
11
+ /**
12
+ * Returns the data to be added to the final execution request
13
+ * to pay the fee in the given asset
14
+ * @returns The function calls to pay the fee.
15
+ */
16
+ getExecutionPayload(): Promise<ExecutionPayload>;
17
+ /**
18
+ * The expected fee payer for this tx.
19
+ */
20
+ getFeePayer(): Promise<AztecAddress>;
21
+ /**
22
+ * The gas settings (if any) used to compute the
23
+ * execution payload of the payment method
24
+ */
25
+ getGasSettings(): GasSettings | undefined;
26
+ }
@@ -1,12 +1,12 @@
1
- import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
2
1
  import { ExecutionPayload } from '@aztec/entrypoints/payload';
3
2
  import { Fr } from '@aztec/foundation/fields';
4
- import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
5
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import { type FunctionAbi, FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
5
  import type { GasSettings } from '@aztec/stdlib/gas';
7
6
 
7
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
8
8
  import type { Wallet } from '../wallet/wallet.js';
9
- import { simulateWithoutSignature } from './utils.js';
9
+ import type { FeePaymentMethod } from './fee_payment_method.js';
10
10
 
11
11
  /**
12
12
  * Holds information about how the fee for a transaction is to be paid.
@@ -21,10 +21,18 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
21
21
  private paymentContract: AztecAddress,
22
22
 
23
23
  /**
24
- * An auth witness provider to authorize fee payments
24
+ * Address of the account that will pay the fee
25
25
  */
26
- private wallet: Wallet,
26
+ private sender: AztecAddress,
27
27
 
28
+ /**
29
+ * A wallet to perform the simulation to get the accepted asset
30
+ */
31
+ private wallet: Wallet,
32
+ /**
33
+ * Gas settings used to compute the maximum fee the user is willing to pay
34
+ */
35
+ protected gasSettings: GasSettings,
28
36
  /**
29
37
  * If true, the max fee will be set to 1.
30
38
  * TODO(#7694): Remove this param once the lacking feature in TXE is implemented.
@@ -36,38 +44,43 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
36
44
  * The asset used to pay the fee.
37
45
  * @returns The asset used to pay the fee.
38
46
  */
39
- getAsset(): Promise<AztecAddress> {
47
+ async getAsset(): Promise<AztecAddress> {
40
48
  if (!this.assetPromise) {
41
- // We use the utility method to avoid a signature because this function could be triggered
42
- // before the associated account is deployed.
43
- this.assetPromise = simulateWithoutSignature(
44
- this.wallet,
45
- this.paymentContract,
46
- {
47
- name: 'get_accepted_asset',
48
- functionType: FunctionType.PRIVATE,
49
- isInternal: false,
50
- isStatic: false,
51
- parameters: [],
52
- returnTypes: [
53
- {
54
- kind: 'struct',
55
- path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
56
- fields: [
57
- {
58
- name: 'inner',
59
- type: {
60
- kind: 'field',
61
- },
49
+ const abi = {
50
+ name: 'get_accepted_asset',
51
+ functionType: FunctionType.PRIVATE,
52
+ isInternal: false,
53
+ isStatic: false,
54
+ parameters: [],
55
+ returnTypes: [
56
+ {
57
+ kind: 'struct',
58
+ path: 'authwit::aztec::protocol_types::address::aztec_address::AztecAddress',
59
+ fields: [
60
+ {
61
+ name: 'inner',
62
+ type: {
63
+ kind: 'field',
62
64
  },
63
- ],
64
- },
65
- ],
66
- errorTypes: {},
67
- isInitializer: false,
68
- },
69
- [],
70
- ) as Promise<AztecAddress>;
65
+ },
66
+ ],
67
+ },
68
+ ],
69
+ errorTypes: {},
70
+ isInitializer: false,
71
+ } as FunctionAbi;
72
+ const interaction = new ContractFunctionInteraction(this.wallet, this.paymentContract, abi, []);
73
+
74
+ const executionPayload = await interaction.request();
75
+ this.assetPromise = this.wallet
76
+ .simulateTx(executionPayload, {
77
+ from: AztecAddress.ZERO,
78
+ skipFeeEnforcement: true,
79
+ })
80
+ .then(simulationResult => {
81
+ const rawReturnValues = simulationResult.getPrivateReturnValues().nested[0].values;
82
+ return decodeFromAbi(abi.returnTypes, rawReturnValues!);
83
+ }) as Promise<AztecAddress>;
71
84
  }
72
85
  return this.assetPromise!;
73
86
  }
@@ -81,19 +94,20 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
81
94
  * @param gasSettings - The gas settings.
82
95
  * @returns An execution payload that contains the required function calls and auth witnesses.
83
96
  */
84
- async getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload> {
97
+ async getExecutionPayload(): Promise<ExecutionPayload> {
85
98
  // We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
86
99
  // (maxFee) to be in token denomination.
87
- const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
100
+ const maxFee = this.setMaxFeeToOne ? Fr.ONE : this.gasSettings.getFeeLimit();
88
101
  const txNonce = Fr.random();
89
102
 
90
- const witness = await this.wallet.createAuthWit({
103
+ const witness = await this.wallet.createAuthWit(this.sender, {
91
104
  caller: this.paymentContract,
92
- action: {
105
+ call: {
93
106
  name: 'transfer_to_public',
94
- args: [this.wallet.getAddress().toField(), this.paymentContract.toField(), maxFee, txNonce],
107
+ args: [this.sender.toField(), this.paymentContract.toField(), maxFee, txNonce],
95
108
  selector: await FunctionSelector.fromSignature('transfer_to_public((Field),(Field),u128,Field)'),
96
109
  type: FunctionType.PRIVATE,
110
+ hideMsgSender: false,
97
111
  isStatic: false,
98
112
  to: await this.getAsset(),
99
113
  returnTypes: [],
@@ -107,6 +121,7 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
107
121
  to: this.paymentContract,
108
122
  selector: await FunctionSelector.fromSignature('fee_entrypoint_private(u128,Field)'),
109
123
  type: FunctionType.PRIVATE,
124
+ hideMsgSender: false,
110
125
  isStatic: false,
111
126
  args: [maxFee, txNonce],
112
127
  returnTypes: [],
@@ -116,4 +131,8 @@ export class PrivateFeePaymentMethod implements FeePaymentMethod {
116
131
  [],
117
132
  );
118
133
  }
134
+
135
+ getGasSettings(): GasSettings | undefined {
136
+ return this.gasSettings;
137
+ }
119
138
  }