@aztec/aztec.js 0.81.0 → 0.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/dest/account/{contract.d.ts → account_contract.d.ts} +3 -2
  2. package/dest/account/account_contract.d.ts.map +1 -0
  3. package/dest/account/index.d.ts +2 -3
  4. package/dest/account/index.d.ts.map +1 -1
  5. package/dest/account/index.js +1 -2
  6. package/dest/account/interface.d.ts +1 -13
  7. package/dest/account/interface.d.ts.map +1 -1
  8. package/dest/account/interface.js +1 -0
  9. package/dest/account_manager/account_manager.d.ts +105 -0
  10. package/dest/account_manager/account_manager.d.ts.map +1 -0
  11. package/dest/account_manager/account_manager.js +165 -0
  12. package/dest/account_manager/deploy_account_method.d.ts +4 -4
  13. package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
  14. package/dest/account_manager/deploy_account_method.js +28 -13
  15. package/dest/account_manager/deploy_account_sent_tx.d.ts +3 -3
  16. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
  17. package/dest/account_manager/deploy_account_sent_tx.js +2 -2
  18. package/dest/account_manager/index.d.ts +1 -104
  19. package/dest/account_manager/index.d.ts.map +1 -1
  20. package/dest/account_manager/index.js +1 -165
  21. package/dest/api/account.d.ts +2 -1
  22. package/dest/api/account.d.ts.map +1 -1
  23. package/dest/api/contract.d.ts +4 -1
  24. package/dest/api/contract.d.ts.map +1 -1
  25. package/dest/api/contract.js +3 -0
  26. package/dest/api/fee.d.ts +1 -1
  27. package/dest/api/fee.d.ts.map +1 -1
  28. package/dest/api/utils.d.ts +2 -1
  29. package/dest/api/utils.d.ts.map +1 -1
  30. package/dest/api/utils.js +2 -1
  31. package/dest/api/wallet.d.ts +1 -1
  32. package/dest/api/wallet.d.ts.map +1 -1
  33. package/dest/contract/base_contract_interaction.d.ts +22 -57
  34. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  35. package/dest/contract/base_contract_interaction.js +12 -67
  36. package/dest/contract/batch_call.d.ts +6 -18
  37. package/dest/contract/batch_call.d.ts.map +1 -1
  38. package/dest/contract/batch_call.js +25 -54
  39. package/dest/contract/contract.d.ts +1 -1
  40. package/dest/contract/contract.d.ts.map +1 -1
  41. package/dest/contract/contract_base.d.ts +1 -1
  42. package/dest/contract/contract_base.d.ts.map +1 -1
  43. package/dest/contract/contract_function_interaction.d.ts +38 -18
  44. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  45. package/dest/contract/contract_function_interaction.js +34 -41
  46. package/dest/contract/deploy_method.d.ts +7 -8
  47. package/dest/contract/deploy_method.d.ts.map +1 -1
  48. package/dest/contract/deploy_method.js +27 -32
  49. package/dest/contract/deploy_proven_tx.d.ts +2 -3
  50. package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
  51. package/dest/contract/deploy_sent_tx.d.ts +2 -3
  52. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  53. package/dest/contract/deploy_sent_tx.js +4 -4
  54. package/dest/contract/protocol_contracts.d.ts +1 -1
  55. package/dest/contract/protocol_contracts.d.ts.map +1 -1
  56. package/dest/contract/proven_tx.d.ts +3 -4
  57. package/dest/contract/proven_tx.d.ts.map +1 -1
  58. package/dest/contract/sent_tx.d.ts +4 -16
  59. package/dest/contract/sent_tx.d.ts.map +1 -1
  60. package/dest/contract/sent_tx.js +6 -37
  61. package/dest/contract/unsafe_contract.d.ts +1 -1
  62. package/dest/contract/unsafe_contract.d.ts.map +1 -1
  63. package/dest/contract/wait_for_proven.d.ts +17 -0
  64. package/dest/contract/wait_for_proven.d.ts.map +1 -0
  65. package/dest/contract/wait_for_proven.js +17 -0
  66. package/dest/deployment/broadcast_function.js +12 -8
  67. package/dest/deployment/contract_deployer.d.ts +1 -1
  68. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  69. package/dest/deployment/register_class.d.ts +1 -1
  70. package/dest/deployment/register_class.d.ts.map +1 -1
  71. package/dest/deployment/register_class.js +6 -11
  72. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +3 -2
  73. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
  74. package/dest/entrypoint/default_multi_call_entrypoint.js +12 -8
  75. package/dest/ethereum/portal_manager.d.ts +20 -11
  76. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  77. package/dest/ethereum/portal_manager.js +64 -30
  78. package/dest/fee/fee_juice_payment_method.d.ts +3 -3
  79. package/dest/fee/fee_juice_payment_method.d.ts.map +1 -1
  80. package/dest/fee/fee_juice_payment_method.js +3 -2
  81. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +4 -4
  82. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  83. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
  84. package/dest/fee/private_fee_payment_method.d.ts +6 -6
  85. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  86. package/dest/fee/private_fee_payment_method.js +13 -12
  87. package/dest/fee/public_fee_payment_method.d.ts +7 -7
  88. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  89. package/dest/fee/public_fee_payment_method.js +10 -11
  90. package/dest/fee/utils.d.ts +13 -0
  91. package/dest/fee/utils.d.ts.map +1 -0
  92. package/dest/fee/utils.js +32 -0
  93. package/dest/utils/authwit.d.ts +16 -9
  94. package/dest/utils/authwit.d.ts.map +1 -1
  95. package/dest/utils/authwit.js +26 -35
  96. package/dest/wallet/account_wallet.d.ts +6 -6
  97. package/dest/wallet/account_wallet.d.ts.map +1 -1
  98. package/dest/wallet/account_wallet.js +15 -17
  99. package/dest/wallet/base_wallet.d.ts +12 -35
  100. package/dest/wallet/base_wallet.d.ts.map +1 -1
  101. package/dest/wallet/base_wallet.js +11 -64
  102. package/dest/wallet/index.d.ts +2 -2
  103. package/dest/wallet/index.d.ts.map +1 -1
  104. package/dest/wallet/index.js +1 -1
  105. package/dest/wallet/signerless_wallet.d.ts +3 -3
  106. package/dest/wallet/signerless_wallet.d.ts.map +1 -1
  107. package/dest/wallet/signerless_wallet.js +3 -6
  108. package/dest/wallet/wallet.d.ts +11 -0
  109. package/dest/wallet/wallet.d.ts.map +1 -0
  110. package/package.json +8 -7
  111. package/src/account/{contract.ts → account_contract.ts} +2 -1
  112. package/src/account/index.ts +2 -3
  113. package/src/account/interface.ts +1 -12
  114. package/src/account_manager/account_manager.ts +235 -0
  115. package/src/account_manager/deploy_account_method.ts +35 -15
  116. package/src/account_manager/deploy_account_sent_tx.ts +4 -4
  117. package/src/account_manager/index.ts +1 -236
  118. package/src/api/account.ts +2 -8
  119. package/src/api/contract.ts +5 -5
  120. package/src/api/fee.ts +1 -1
  121. package/src/api/utils.ts +1 -1
  122. package/src/api/wallet.ts +7 -1
  123. package/src/contract/base_contract_interaction.ts +32 -88
  124. package/src/contract/batch_call.ts +40 -43
  125. package/src/contract/contract.ts +1 -1
  126. package/src/contract/contract_base.ts +1 -1
  127. package/src/contract/contract_function_interaction.ts +85 -56
  128. package/src/contract/deploy_method.ts +24 -26
  129. package/src/contract/deploy_proven_tx.ts +2 -3
  130. package/src/contract/deploy_sent_tx.ts +6 -6
  131. package/src/contract/protocol_contracts.ts +1 -1
  132. package/src/contract/proven_tx.ts +2 -3
  133. package/src/contract/sent_tx.ts +6 -47
  134. package/src/contract/unsafe_contract.ts +1 -1
  135. package/src/contract/wait_for_proven.ts +38 -0
  136. package/src/deployment/broadcast_function.ts +40 -40
  137. package/src/deployment/contract_deployer.ts +1 -1
  138. package/src/deployment/register_class.ts +9 -22
  139. package/src/entrypoint/default_multi_call_entrypoint.ts +14 -7
  140. package/src/ethereum/portal_manager.ts +73 -24
  141. package/src/fee/fee_juice_payment_method.ts +4 -5
  142. package/src/fee/fee_juice_payment_method_with_claim.ts +24 -20
  143. package/src/fee/private_fee_payment_method.ts +29 -28
  144. package/src/fee/public_fee_payment_method.ts +29 -29
  145. package/src/fee/utils.ts +39 -0
  146. package/src/utils/authwit.ts +32 -35
  147. package/src/wallet/account_wallet.ts +18 -17
  148. package/src/wallet/base_wallet.ts +27 -88
  149. package/src/wallet/index.ts +2 -2
  150. package/src/wallet/signerless_wallet.ts +9 -8
  151. package/src/wallet/wallet.ts +34 -0
  152. package/dest/account/contract.d.ts.map +0 -1
  153. package/dest/account/wallet.d.ts +0 -11
  154. package/dest/account/wallet.d.ts.map +0 -1
  155. package/dest/api/entrypoint.d.ts +0 -2
  156. package/dest/api/entrypoint.d.ts.map +0 -1
  157. package/dest/api/entrypoint.js +0 -1
  158. package/dest/entrypoint/default_entrypoint.d.ts +0 -12
  159. package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
  160. package/dest/entrypoint/default_entrypoint.js +0 -28
  161. package/dest/entrypoint/entrypoint.d.ts +0 -39
  162. package/dest/entrypoint/entrypoint.d.ts.map +0 -1
  163. package/dest/entrypoint/entrypoint.js +0 -20
  164. package/dest/entrypoint/payload.d.ts +0 -128
  165. package/dest/entrypoint/payload.d.ts.map +0 -1
  166. package/dest/entrypoint/payload.js +0 -143
  167. package/dest/fee/fee_payment_method.d.ts +0 -22
  168. package/dest/fee/fee_payment_method.d.ts.map +0 -1
  169. package/dest/fee/fee_payment_method.js +0 -3
  170. package/src/account/wallet.ts +0 -13
  171. package/src/api/entrypoint.ts +0 -1
  172. package/src/entrypoint/default_entrypoint.ts +0 -39
  173. package/src/entrypoint/entrypoint.ts +0 -60
  174. package/src/entrypoint/payload.ts +0 -238
  175. package/src/fee/fee_payment_method.ts +0 -22
  176. /package/dest/account/{contract.js → account_contract.js} +0 -0
  177. /package/dest/{account → wallet}/wallet.js +0 -0
@@ -2,6 +2,7 @@ import { extractEvent } from '@aztec/ethereum/utils';
2
2
  import { sha256ToField } from '@aztec/foundation/crypto';
3
3
  import { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
+ import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts/FeeAssetHandlerAbi';
5
6
  import { FeeJuicePortalAbi } from '@aztec/l1-artifacts/FeeJuicePortalAbi';
6
7
  import { OutboxAbi } from '@aztec/l1-artifacts/OutboxAbi';
7
8
  import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
@@ -21,21 +22,39 @@ import { getContract, toFunctionSelector } from 'viem';
21
22
  ];
22
23
  }
23
24
  /** Helper for managing an ERC20 on L1. */ export class L1TokenManager {
24
- address;
25
+ tokenAddress;
26
+ handlerAddress;
25
27
  publicClient;
26
28
  walletClient;
27
29
  logger;
28
30
  contract;
29
- constructor(/** Address of the ERC20 contract. */ address, publicClient, walletClient, logger){
30
- this.address = address;
31
+ handler;
32
+ constructor(/** Address of the ERC20 contract. */ tokenAddress, /** Address of the handler/faucet contract. */ handlerAddress, publicClient, walletClient, logger){
33
+ this.tokenAddress = tokenAddress;
34
+ this.handlerAddress = handlerAddress;
31
35
  this.publicClient = publicClient;
32
36
  this.walletClient = walletClient;
33
37
  this.logger = logger;
34
38
  this.contract = getContract({
35
- address: this.address.toString(),
39
+ address: this.tokenAddress.toString(),
36
40
  abi: TestERC20Abi,
37
41
  client: this.walletClient
38
42
  });
43
+ if (this.handlerAddress) {
44
+ this.handler = getContract({
45
+ address: this.handlerAddress.toString(),
46
+ abi: FeeAssetHandlerAbi,
47
+ client: this.walletClient
48
+ });
49
+ }
50
+ }
51
+ /** Returns the amount of tokens available to mint via the handler.
52
+ * @throws if the handler is not provided.
53
+ */ async getMintAmount() {
54
+ if (!this.handler) {
55
+ throw new Error('Minting handler was not provided');
56
+ }
57
+ return await this.handler.read.mintAmount();
39
58
  }
40
59
  /**
41
60
  * Returns the balance of the given address.
@@ -46,18 +65,19 @@ import { getContract, toFunctionSelector } from 'viem';
46
65
  ]);
47
66
  }
48
67
  /**
49
- * Mints tokens for the given address. Returns once the tx has been mined.
50
- * @param amount - Amount to mint.
68
+ * Mints a fixed amount of tokens for the given address. Returns once the tx has been mined.
51
69
  * @param address - Address to mint the tokens for.
52
70
  * @param addressName - Optional name of the address for logging.
53
- */ async mint(amount, address, addressName) {
54
- this.logger.info(`Minting ${amount} tokens for ${stringifyEthAddress(address, addressName)}`);
55
- await this.publicClient.waitForTransactionReceipt({
56
- hash: await this.contract.write.mint([
57
- address,
58
- amount
59
- ])
60
- });
71
+ */ async mint(address, addressName) {
72
+ if (!this.handler) {
73
+ throw new Error('Minting handler was not provided');
74
+ }
75
+ const mintAmount = await this.getMintAmount();
76
+ this.logger.info(`Minting ${mintAmount} tokens for ${stringifyEthAddress(address, addressName)}`);
77
+ // NOTE: the handler mints a fixed amount.
78
+ await this.handler.write.mint([
79
+ address
80
+ ]);
61
81
  }
62
82
  /**
63
83
  * Approves tokens for the given address. Returns once the tx has been mined.
@@ -80,11 +100,11 @@ import { getContract, toFunctionSelector } from 'viem';
80
100
  logger;
81
101
  tokenManager;
82
102
  contract;
83
- constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
103
+ constructor(portalAddress, tokenAddress, handlerAddress, publicClient, walletClient, logger){
84
104
  this.publicClient = publicClient;
85
105
  this.walletClient = walletClient;
86
106
  this.logger = logger;
87
- this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
107
+ this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, publicClient, walletClient, logger);
88
108
  this.contract = getContract({
89
109
  address: portalAddress.toString(),
90
110
  abi: FeeJuicePortalAbi,
@@ -101,14 +121,19 @@ import { getContract, toFunctionSelector } from 'viem';
101
121
  * @param mint - Whether to mint the tokens before sending (only during testing).
102
122
  */ async bridgeTokensPublic(to, amount, mint = false) {
103
123
  const [claimSecret, claimSecretHash] = await generateClaimSecret();
124
+ const mintableAmount = await this.tokenManager.getMintAmount();
125
+ const amountToBridge = amount ?? mintableAmount;
104
126
  if (mint) {
105
- await this.tokenManager.mint(amount, this.walletClient.account.address);
127
+ if (amountToBridge !== mintableAmount) {
128
+ throw new Error(`Minting amount must be ${mintableAmount}`);
129
+ }
130
+ await this.tokenManager.mint(this.walletClient.account.address);
106
131
  }
107
- await this.tokenManager.approve(amount, this.contract.address, 'FeeJuice Portal');
132
+ await this.tokenManager.approve(amountToBridge, this.contract.address, 'FeeJuice Portal');
108
133
  this.logger.info('Sending L1 Fee Juice to L2 to be claimed publicly');
109
134
  const args = [
110
135
  to.toString(),
111
- amount,
136
+ amountToBridge,
112
137
  claimSecretHash.toString()
113
138
  ];
114
139
  await this.contract.simulate.depositToAztecPublic(args);
@@ -116,9 +141,9 @@ import { getContract, toFunctionSelector } from 'viem';
116
141
  hash: await this.contract.write.depositToAztecPublic(args)
117
142
  });
118
143
  this.logger.info('Deposited to Aztec public successfully');
119
- const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amount && log.args.to === to.toString(), this.logger);
144
+ const log = extractEvent(txReceipt.logs, this.contract.address, this.contract.abi, 'DepositToAztecPublic', (log)=>log.args.secretHash === claimSecretHash.toString() && log.args.amount === amountToBridge && log.args.to === to.toString(), this.logger);
120
145
  return {
121
- claimAmount: amount,
146
+ claimAmount: amountToBridge,
122
147
  claimSecret,
123
148
  claimSecretHash,
124
149
  messageHash: log.args.key,
@@ -127,16 +152,19 @@ import { getContract, toFunctionSelector } from 'viem';
127
152
  }
128
153
  /**
129
154
  * Creates a new instance
130
- * @param pxe - PXE client used for retrieving the L1 contract addresses.
155
+ * @param walletOrPxe - Wallet or PXE client used for retrieving the L1 contract addresses.
131
156
  * @param publicClient - L1 public client.
132
157
  * @param walletClient - L1 wallet client.
133
158
  * @param logger - Logger.
134
- */ static async new(pxe, publicClient, walletClient, logger) {
135
- const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress } } = await pxe.getNodeInfo();
159
+ */ static async new(walletOrPxe, publicClient, walletClient, logger) {
160
+ const { l1ContractAddresses: { feeJuiceAddress, feeJuicePortalAddress, feeAssetHandlerAddress } } = await walletOrPxe.getNodeInfo();
136
161
  if (feeJuiceAddress.isZero() || feeJuicePortalAddress.isZero()) {
137
162
  throw new Error('Portal or token not deployed on L1');
138
163
  }
139
- return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, publicClient, walletClient, logger);
164
+ if (!feeAssetHandlerAddress || feeAssetHandlerAddress.isZero()) {
165
+ throw new Error('Handler not deployed on L1, or handler address is zero');
166
+ }
167
+ return new L1FeeJuicePortalManager(feeJuicePortalAddress, feeJuiceAddress, feeAssetHandlerAddress, publicClient, walletClient, logger);
140
168
  }
141
169
  }
142
170
  /** Helper for interacting with a test TokenPortal on L1 for sending tokens to L2. */ export class L1ToL2TokenPortalManager {
@@ -145,11 +173,11 @@ import { getContract, toFunctionSelector } from 'viem';
145
173
  logger;
146
174
  portal;
147
175
  tokenManager;
148
- constructor(portalAddress, tokenAddress, publicClient, walletClient, logger){
176
+ constructor(portalAddress, tokenAddress, handlerAddress, publicClient, walletClient, logger){
149
177
  this.publicClient = publicClient;
150
178
  this.walletClient = walletClient;
151
179
  this.logger = logger;
152
- this.tokenManager = new L1TokenManager(tokenAddress, publicClient, walletClient, logger);
180
+ this.tokenManager = new L1TokenManager(tokenAddress, handlerAddress, publicClient, walletClient, logger);
153
181
  this.portal = getContract({
154
182
  address: portalAddress.toString(),
155
183
  abi: TokenPortalAbi,
@@ -184,12 +212,14 @@ import { getContract, toFunctionSelector } from 'viem';
184
212
  messageLeafIndex: log.args.index
185
213
  };
186
214
  }
215
+ // docs:start:bridge_tokens_private
187
216
  /**
188
217
  * Bridges tokens from L1 to L2 privately. Handles token approvals. Returns once the tx has been mined.
189
218
  * @param to - Address to send the tokens to on L2.
190
219
  * @param amount - Amount of tokens to send.
191
220
  * @param mint - Whether to mint the tokens before sending (only during testing).
192
221
  */ async bridgeTokensPrivate(to, amount, mint = false) {
222
+ // docs:end:bridge_tokens_private
193
223
  const [claimSecret, claimSecretHash] = await this.bridgeSetup(amount, mint);
194
224
  this.logger.info('Sending L1 tokens to L2 to be claimed privately');
195
225
  const { request } = await this.portal.simulate.depositToAztecPrivate([
@@ -212,7 +242,11 @@ import { getContract, toFunctionSelector } from 'viem';
212
242
  }
213
243
  async bridgeSetup(amount, mint) {
214
244
  if (mint) {
215
- await this.tokenManager.mint(amount, this.walletClient.account.address);
245
+ const mintableAmount = await this.tokenManager.getMintAmount();
246
+ if (amount !== mintableAmount) {
247
+ throw new Error(`Minting amount must be ${mintableAmount} for testing`);
248
+ }
249
+ await this.tokenManager.mint(this.walletClient.account.address);
216
250
  }
217
251
  await this.tokenManager.approve(amount, this.portal.address, 'TokenPortal');
218
252
  return generateClaimSecret();
@@ -220,8 +254,8 @@ import { getContract, toFunctionSelector } from 'viem';
220
254
  }
221
255
  /** Helper for interacting with a test TokenPortal on L1 for both withdrawing from and bridging to L2. */ export class L1TokenPortalManager extends L1ToL2TokenPortalManager {
222
256
  outbox;
223
- constructor(portalAddress, tokenAddress, outboxAddress, publicClient, walletClient, logger){
224
- super(portalAddress, tokenAddress, publicClient, walletClient, logger);
257
+ constructor(portalAddress, tokenAddress, handlerAddress, outboxAddress, publicClient, walletClient, logger){
258
+ super(portalAddress, tokenAddress, handlerAddress, publicClient, walletClient, logger);
225
259
  this.outbox = getContract({
226
260
  address: outboxAddress.toString(),
227
261
  abi: OutboxAbi,
@@ -1,6 +1,6 @@
1
- import type { FunctionCall } from '@aztec/stdlib/abi';
1
+ import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
2
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
2
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { FeePaymentMethod } from './fee_payment_method.js';
4
4
  /**
5
5
  * Pay fee directly in the Fee Juice.
6
6
  */
@@ -8,7 +8,7 @@ export declare class FeeJuicePaymentMethod implements FeePaymentMethod {
8
8
  protected sender: AztecAddress;
9
9
  constructor(sender: AztecAddress);
10
10
  getAsset(): Promise<AztecAddress>;
11
- getFunctionCalls(): Promise<FunctionCall[]>;
11
+ getExecutionPayload(): Promise<ExecutionPayload>;
12
12
  getFeePayer(): Promise<AztecAddress>;
13
13
  }
14
14
  //# sourceMappingURL=fee_juice_payment_method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fee_juice_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE;;GAEG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;IAEhD,SAAS,CAAC,MAAM,EAAE,YAAY;gBAApB,MAAM,EAAE,YAAY;IAE1C,QAAQ;IAIR,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAI3C,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;CAGrC"}
1
+ {"version":3,"file":"fee_juice_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE;;GAEG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;IAEhD,SAAS,CAAC,MAAM,EAAE,YAAY;gBAApB,MAAM,EAAE,YAAY;IAE1C,QAAQ;IAIR,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAIhD,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;CAGrC"}
@@ -1,3 +1,4 @@
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
1
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
3
  // docs:start:fee_juice_method
3
4
  /**
@@ -11,8 +12,8 @@ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
11
12
  getAsset() {
12
13
  return Promise.resolve(ProtocolContractAddress.FeeJuice);
13
14
  }
14
- getFunctionCalls() {
15
- return Promise.resolve([]);
15
+ getExecutionPayload() {
16
+ return Promise.resolve(ExecutionPayload.empty());
16
17
  }
17
18
  getFeePayer() {
18
19
  return Promise.resolve(this.sender);
@@ -1,4 +1,4 @@
1
- import type { FunctionCall } from '@aztec/stdlib/abi';
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
2
2
  import type { L2AmountClaim } from '../ethereum/portal_manager.js';
3
3
  import type { Wallet } from '../wallet/index.js';
4
4
  import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
@@ -10,9 +10,9 @@ export declare class FeeJuicePaymentMethodWithClaim extends FeeJuicePaymentMetho
10
10
  private claim;
11
11
  constructor(senderWallet: Wallet, claim: Pick<L2AmountClaim, 'claimAmount' | 'claimSecret' | 'messageLeafIndex'>);
12
12
  /**
13
- * Creates a function call to pay the fee in Fee Juice.
14
- * @returns A function call
13
+ * Creates an execution payload to pay the fee in Fee Juice.
14
+ * @returns An execution payload that just contains the claim function call.
15
15
  */
16
- getFunctionCalls(): Promise<FunctionCall[]>;
16
+ getExecutionPayload(): Promise<ExecutionPayload>;
17
17
  }
18
18
  //# sourceMappingURL=fee_juice_payment_method_with_claim.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,qBAAqB;IAErE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,KAAK;gBADL,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAKxF;;;OAGG;IACY,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAuB3D"}
1
+ {"version":3,"file":"fee_juice_payment_method_with_claim.d.ts","sourceRoot":"","sources":["../../src/fee/fee_juice_payment_method_with_claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAM9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,qBAAqB;IAErE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,KAAK;gBADL,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAKxF;;;OAGG;IACY,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CA2BhE"}
@@ -1,3 +1,4 @@
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
4
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
@@ -12,12 +13,12 @@ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
12
13
  super(senderWallet.getAddress()), this.senderWallet = senderWallet, this.claim = claim;
13
14
  }
14
15
  /**
15
- * Creates a function call to pay the fee in Fee Juice.
16
- * @returns A function call
17
- */ async getFunctionCalls() {
16
+ * Creates an execution payload to pay the fee in Fee Juice.
17
+ * @returns An execution payload that just contains the claim function call.
18
+ */ async getExecutionPayload() {
18
19
  const canonicalFeeJuice = await getFeeJuice(this.senderWallet);
19
20
  const selector = await FunctionSelector.fromNameAndParameters(canonicalFeeJuice.artifact.functions.find((f)=>f.name === 'claim'));
20
- return Promise.resolve([
21
+ return new ExecutionPayload([
21
22
  {
22
23
  to: ProtocolContractAddress.FeeJuice,
23
24
  name: 'claim',
@@ -32,6 +33,6 @@ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
32
33
  returnTypes: [],
33
34
  type: FunctionType.PRIVATE
34
35
  }
35
- ]);
36
+ ], [], []);
36
37
  }
37
38
  }
@@ -1,8 +1,8 @@
1
- import { type FunctionCall } from '@aztec/stdlib/abi';
1
+ import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
2
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
2
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
4
  import type { GasSettings } from '@aztec/stdlib/gas';
4
- import type { Wallet } from '../account/wallet.js';
5
- import type { FeePaymentMethod } from './fee_payment_method.js';
5
+ import type { Wallet } from '../wallet/wallet.js';
6
6
  /**
7
7
  * Holds information about how the fee for a transaction is to be paid.
8
8
  */
@@ -42,10 +42,10 @@ export declare class PrivateFeePaymentMethod implements FeePaymentMethod {
42
42
  getAsset(): Promise<AztecAddress>;
43
43
  getFeePayer(): Promise<AztecAddress>;
44
44
  /**
45
- * Creates a function call to pay the fee in the given asset.
45
+ * Creates an execution payload to pay the fee using a private function through an FPC in the desired asset
46
46
  * @param gasSettings - The gas settings.
47
- * @returns The function call to pay the fee.
47
+ * @returns An execution payload that contains the required function calls and auth witnesses.
48
48
  */
49
- getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
49
+ getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
50
50
  }
51
51
  //# sourceMappingURL=private_fee_payment_method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"private_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/private_fee_payment_method.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAI5D;;OAEG;IACH,OAAO,CAAC,eAAe;IAEvB;;OAEG;IACH,OAAO,CAAC,MAAM;IAEd;;;OAGG;IACH,OAAO,CAAC,cAAc;IAjBxB,OAAO,CAAC,YAAY,CAAsC;;IAGxD;;OAEG;IACK,eAAe,EAAE,YAAY;IAErC;;OAEG;IACK,MAAM,EAAE,MAAM;IAEtB;;;OAGG;IACK,cAAc,UAAQ;IAGhC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAuCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CA+B1E"}
1
+ {"version":3,"file":"private_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/private_fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;GAEG;AACH,qBAAa,uBAAwB,YAAW,gBAAgB;IAI5D;;OAEG;IACH,OAAO,CAAC,eAAe;IAEvB;;OAEG;IACH,OAAO,CAAC,MAAM;IAEd;;;OAGG;IACH,OAAO,CAAC,cAAc;IAjBxB,OAAO,CAAC,YAAY,CAAsC;;IAGxD;;OAEG;IACK,eAAe,EAAE,YAAY;IAErC;;OAEG;IACK,MAAM,EAAE,MAAM;IAEtB;;;OAGG;IACK,cAAc,UAAQ;IAGhC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAoCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAmC/E"}
@@ -1,7 +1,7 @@
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
3
- import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
4
- import { SignerlessWallet } from '../wallet/signerless_wallet.js';
4
+ import { simulateWithoutSignature } from './utils.js';
5
5
  /**
6
6
  * Holds information about how the fee for a transaction is to be paid.
7
7
  */ export class PrivateFeePaymentMethod {
@@ -27,9 +27,9 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
27
27
  * @returns The asset used to pay the fee.
28
28
  */ getAsset() {
29
29
  if (!this.assetPromise) {
30
- // We use signer-less wallet because this function could be triggered before the associated account is deployed.
31
- const signerlessWallet = new SignerlessWallet(this.wallet);
32
- const interaction = new ContractFunctionInteraction(signerlessWallet, this.paymentContract, {
30
+ // We use the utility method to avoid a signature because this function could be triggered
31
+ // before the associated account is deployed.
32
+ this.assetPromise = simulateWithoutSignature(this.wallet, this.paymentContract, {
33
33
  name: 'get_accepted_asset',
34
34
  functionType: FunctionType.PRIVATE,
35
35
  isInternal: false,
@@ -52,7 +52,6 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
52
52
  errorTypes: {},
53
53
  isInitializer: false
54
54
  }, []);
55
- this.assetPromise = interaction.simulate();
56
55
  }
57
56
  return this.assetPromise;
58
57
  }
@@ -60,15 +59,15 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
60
59
  return Promise.resolve(this.paymentContract);
61
60
  }
62
61
  /**
63
- * Creates a function call to pay the fee in the given asset.
62
+ * Creates an execution payload to pay the fee using a private function through an FPC in the desired asset
64
63
  * @param gasSettings - The gas settings.
65
- * @returns The function call to pay the fee.
66
- */ async getFunctionCalls(gasSettings) {
64
+ * @returns An execution payload that contains the required function calls and auth witnesses.
65
+ */ async getExecutionPayload(gasSettings) {
67
66
  // We assume 1:1 exchange rate between fee juice and token. But in reality you would need to convert feeLimit
68
67
  // (maxFee) to be in token denomination.
69
68
  const maxFee = this.setMaxFeeToOne ? Fr.ONE : gasSettings.getFeeLimit();
70
69
  const nonce = Fr.random();
71
- await this.wallet.createAuthWit({
70
+ const witness = await this.wallet.createAuthWit({
72
71
  caller: this.paymentContract,
73
72
  action: {
74
73
  name: 'transfer_to_public',
@@ -85,7 +84,7 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
85
84
  returnTypes: []
86
85
  }
87
86
  });
88
- return [
87
+ return new ExecutionPayload([
89
88
  {
90
89
  name: 'fee_entrypoint_private',
91
90
  to: this.paymentContract,
@@ -98,6 +97,8 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
98
97
  ],
99
98
  returnTypes: []
100
99
  }
101
- ];
100
+ ], [
101
+ witness
102
+ ], []);
102
103
  }
103
104
  }
@@ -1,8 +1,8 @@
1
- import type { FunctionCall } from '@aztec/stdlib/abi';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { GasSettings } from '@aztec/stdlib/gas';
1
+ import type { FeePaymentMethod } from '@aztec/entrypoints/interfaces';
2
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { GasSettings } from '@aztec/stdlib/gas';
4
5
  import type { AccountWallet } from '../wallet/account_wallet.js';
5
- import type { FeePaymentMethod } from './fee_payment_method.js';
6
6
  /**
7
7
  * Holds information about how the fee for a transaction is to be paid.
8
8
  */
@@ -32,10 +32,10 @@ export declare class PublicFeePaymentMethod implements FeePaymentMethod {
32
32
  getAsset(): Promise<AztecAddress>;
33
33
  getFeePayer(): Promise<AztecAddress>;
34
34
  /**
35
- * Creates a function call to pay the fee in the given asset.
35
+ * Creates an execution payload to pay the fee using a public function through an FPC in the desired asset
36
36
  * @param gasSettings - The gas settings.
37
- * @returns The function call to pay the fee.
37
+ * @returns An execution payload that contains the required function calls.
38
38
  */
39
- getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
39
+ getExecutionPayload(gasSettings: GasSettings): Promise<ExecutionPayload>;
40
40
  }
41
41
  //# sourceMappingURL=public_fee_payment_method.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/public_fee_payment_method.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;GAEG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D;;OAEG;IACH,SAAS,CAAC,eAAe,EAAE,YAAY;IACvC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa;IAVjC,OAAO,CAAC,YAAY,CAAsC;;IAGxD;;OAEG;IACO,eAAe,EAAE,YAAY;IACvC;;OAEG;IACO,MAAM,EAAE,aAAa;IAGjC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAuCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;CAiC1E"}
1
+ {"version":3,"file":"public_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/public_fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;GAEG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D;;OAEG;IACH,SAAS,CAAC,eAAe,EAAE,YAAY;IACvC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,aAAa;IAVjC,OAAO,CAAC,YAAY,CAAsC;;IAGxD;;OAEG;IACO,eAAe,EAAE,YAAY;IACvC;;OAEG;IACO,MAAM,EAAE,aAAa;IAGjC;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAoCjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAIpC;;;;OAIG;IACG,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAqC/E"}
@@ -1,7 +1,7 @@
1
+ import { ExecutionPayload } from '@aztec/entrypoints/payload';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
3
- import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
4
- import { SignerlessWallet } from '../wallet/signerless_wallet.js';
4
+ import { simulateWithoutSignature } from './utils.js';
5
5
  /**
6
6
  * Holds information about how the fee for a transaction is to be paid.
7
7
  */ export class PublicFeePaymentMethod {
@@ -22,9 +22,9 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
22
22
  * @returns The asset used to pay the fee.
23
23
  */ getAsset() {
24
24
  if (!this.assetPromise) {
25
- // We use signer-less wallet because this function could be triggered before the associated account is deployed.
26
- const signerlessWallet = new SignerlessWallet(this.wallet);
27
- const interaction = new ContractFunctionInteraction(signerlessWallet, this.paymentContract, {
25
+ // We use the utility method to avoid a signature because this function could be triggered
26
+ // before the associated account is deployed.
27
+ this.assetPromise = simulateWithoutSignature(this.wallet, this.paymentContract, {
28
28
  name: 'get_accepted_asset',
29
29
  functionType: FunctionType.PRIVATE,
30
30
  isInternal: false,
@@ -47,7 +47,6 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
47
47
  errorTypes: {},
48
48
  isInitializer: false
49
49
  }, []);
50
- this.assetPromise = interaction.simulate();
51
50
  }
52
51
  return this.assetPromise;
53
52
  }
@@ -55,10 +54,10 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
55
54
  return Promise.resolve(this.paymentContract);
56
55
  }
57
56
  /**
58
- * Creates a function call to pay the fee in the given asset.
57
+ * Creates an execution payload to pay the fee using a public function through an FPC in the desired asset
59
58
  * @param gasSettings - The gas settings.
60
- * @returns The function call to pay the fee.
61
- */ async getFunctionCalls(gasSettings) {
59
+ * @returns An execution payload that contains the required function calls.
60
+ */ async getExecutionPayload(gasSettings) {
62
61
  const nonce = Fr.random();
63
62
  const maxFee = gasSettings.getFeeLimit();
64
63
  const setPublicAuthWitInteraction = await this.wallet.setPublicAuthWit({
@@ -78,7 +77,7 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
78
77
  returnTypes: []
79
78
  }
80
79
  }, true);
81
- return [
80
+ return new ExecutionPayload([
82
81
  ...(await setPublicAuthWitInteraction.request()).calls,
83
82
  {
84
83
  name: 'fee_entrypoint_public',
@@ -92,6 +91,6 @@ import { SignerlessWallet } from '../wallet/signerless_wallet.js';
92
91
  ],
93
92
  returnTypes: []
94
93
  }
95
- ];
94
+ ], [], []);
96
95
  }
97
96
  }
@@ -0,0 +1,13 @@
1
+ import { type FunctionAbi } from '@aztec/stdlib/abi';
2
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { Wallet } from '../wallet/wallet.js';
4
+ /**
5
+ * Use a wallet to simulate a function avoiding the wallet's entrypoint, as a SignerlessWallet would do
6
+ * @param wallet - The wallet to use for the simulation.
7
+ * @param contractAddress - The address of the contract to call.
8
+ * @param abi - The ABI of the function to simulate.
9
+ * @param args - The arguments to pass to the function.
10
+ * @returns The return values of the function call.
11
+ */
12
+ export declare function simulateWithoutSignature(wallet: Wallet, contractAddress: AztecAddress, abi: FunctionAbi, args: any[]): Promise<import("@aztec/stdlib/abi").AbiDecoded>;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fee/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAI3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,YAAY,EAC7B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,GAAG,EAAE,mDAiBZ"}
@@ -0,0 +1,32 @@
1
+ import { DefaultEntrypoint } from '@aztec/entrypoints/default';
2
+ import { decodeFromAbi } from '@aztec/stdlib/abi';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { GasSettings } from '@aztec/stdlib/gas';
5
+ import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
6
+ import { FeeJuicePaymentMethod } from './fee_juice_payment_method.js';
7
+ /**
8
+ * Use a wallet to simulate a function avoiding the wallet's entrypoint, as a SignerlessWallet would do
9
+ * @param wallet - The wallet to use for the simulation.
10
+ * @param contractAddress - The address of the contract to call.
11
+ * @param abi - The ABI of the function to simulate.
12
+ * @param args - The arguments to pass to the function.
13
+ * @returns The return values of the function call.
14
+ */ export async function simulateWithoutSignature(wallet, contractAddress, abi, args) {
15
+ const interaction = new ContractFunctionInteraction(wallet, contractAddress, abi, args);
16
+ const request = await interaction.request();
17
+ const maxFeesPerGas = (await wallet.getCurrentBaseFees()).mul(1.5);
18
+ const paymentMethod = new FeeJuicePaymentMethod(AztecAddress.ZERO);
19
+ const gasSettings = GasSettings.default({
20
+ maxFeesPerGas
21
+ });
22
+ const fee = {
23
+ gasSettings,
24
+ paymentMethod
25
+ };
26
+ const { l1ChainId: chainId, protocolVersion } = await wallet.getNodeInfo();
27
+ const entrypoint = new DefaultEntrypoint(chainId, protocolVersion);
28
+ const signerlessTxExecutionRequest = await entrypoint.createTxExecutionRequest(request, fee, {});
29
+ const simulationResult = await wallet.simulateTx(signerlessTxExecutionRequest, false, undefined, undefined, true);
30
+ const rawReturnValues = simulationResult.getPrivateReturnValues().values;
31
+ return decodeFromAbi(abi.returnTypes, rawReturnValues);
32
+ }
@@ -47,14 +47,21 @@ export type IntentAction = {
47
47
  * @returns The message hash for the action
48
48
  */
49
49
  export declare const computeAuthWitMessageHash: (intent: IntentInnerHash | IntentAction, metadata: IntentMetadata) => Promise<Fr>;
50
- export declare const computeInnerAuthWitHashFromAction: (caller: AztecAddress, action: FunctionCall) => Promise<Fr>;
51
50
  /**
52
- * Compute the inner hash for an authentication witness.
53
- * This is the "intent" of the message, before siloed with the consumer.
54
- * It is used as part of the `computeAuthWitMessageHash` but can also be used
55
- * in case the message is not a "call" to a function, but arbitrary data.
56
- * @param args - The arguments to hash
57
- * @returns The inner hash for the witness
58
- */
59
- export declare const computeInnerAuthWitHash: (args: Fr[]) => Promise<Fr>;
51
+ * Computes the inner authwitness hash for a function call, for it to later be combined with the metadata
52
+ * required for the outer hash and eventually the full AuthWitness.
53
+ * @param caller - Who is going to be calling the function
54
+ * @param fnCall - The function call to compute the inner hash from
55
+ * @returns The inner hash for the function call
56
+ **/
57
+ export declare const computeInnerAuthWitHashFromFunctionCall: (caller: AztecAddress, fnCall: FunctionCall) => Promise<Fr>;
58
+ /**
59
+ * Computes the inner authwitness hash for an action, that can either be a ContractFunctionInteraction
60
+ * or an isolated FunctionCall. Since the former is just a wrapper around the latter, we can just extract
61
+ * the first (and only) call from the ContractFunctionInteraction and use it to compute the inner hash.
62
+ * @param caller - Who is going to be performing the action
63
+ * @param action - The ContractFunctionInteraction or FunctionCall to compute the inner hash for
64
+ * @returns The inner hash for the action
65
+ **/
66
+ export declare const computeInnerAuthWitHashFromAction: (caller: AztecAddress, action: FunctionCall | ContractFunctionInteraction) => Promise<Fr>;
60
67
  //# sourceMappingURL=authwit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"authwit.d.ts","sourceRoot":"","sources":["../../src/utils/authwit.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F,8BAA8B;AAC9B,MAAM,MAAM,cAAc,GAAG;IAC3B,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG;IAC5B,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC;CACxB,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,YAAY,GAAG;IACzB,6BAA6B;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,4BAA4B;IAC5B,MAAM,EAAE,2BAA2B,GAAG,YAAY,CAAC;CACpD,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,WAAkB,eAAe,GAAG,YAAY,YAAY,cAAc,gBAiB/G,CAAC;AAGF,eAAO,MAAM,iCAAiC,WAAkB,YAAY,UAAU,YAAY,gBAK9F,CAAC;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,SAAU,EAAE,EAAE,gBAEjD,CAAC"}
1
+ {"version":3,"file":"authwit.d.ts","sourceRoot":"","sources":["../../src/utils/authwit.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAE3F,8BAA8B;AAC9B,MAAM,MAAM,cAAc,GAAG;IAC3B,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;IACZ,8BAA8B;IAC9B,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,gCAAgC;AAChC,MAAM,MAAM,eAAe,GAAG;IAC5B,qBAAqB;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC;CACxB,CAAC;AAEF,4BAA4B;AAC5B,MAAM,MAAM,YAAY,GAAG;IACzB,6BAA6B;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,4BAA4B;IAC5B,MAAM,EAAE,2BAA2B,GAAG,YAAY,CAAC;CACpD,CAAC;AAGF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,yBAAyB,WAAkB,eAAe,GAAG,YAAY,YAAY,cAAc,gBAiB/G,CAAC;AAGF;;;;;;IAMI;AACJ,eAAO,MAAM,uCAAuC,WAAkB,YAAY,UAAU,YAAY,gBAMvG,CAAC;AAEF;;;;;;;IAOI;AACJ,eAAO,MAAM,iCAAiC,WACpC,YAAY,UACZ,YAAY,GAAG,2BAA2B,gBAQnD,CAAC"}