@aztec/aztec.js 0.81.0 → 0.82.1-alpha-testnet.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) 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 +106 -0
  10. package/dest/account_manager/account_manager.d.ts.map +1 -0
  11. package/dest/account_manager/account_manager.js +216 -0
  12. package/dest/account_manager/deploy_account_sent_tx.d.ts +3 -3
  13. package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
  14. package/dest/account_manager/deploy_account_sent_tx.js +2 -2
  15. package/dest/account_manager/index.d.ts +1 -105
  16. package/dest/account_manager/index.d.ts.map +1 -1
  17. package/dest/account_manager/index.js +1 -166
  18. package/dest/api/account.d.ts +2 -1
  19. package/dest/api/account.d.ts.map +1 -1
  20. package/dest/api/contract.d.ts +4 -1
  21. package/dest/api/contract.d.ts.map +1 -1
  22. package/dest/api/contract.js +3 -0
  23. package/dest/api/fee.d.ts +2 -1
  24. package/dest/api/fee.d.ts.map +1 -1
  25. package/dest/api/fee.js +1 -0
  26. package/dest/api/fee_testing.d.ts +2 -0
  27. package/dest/api/fee_testing.d.ts.map +1 -0
  28. package/dest/api/fee_testing.js +1 -0
  29. package/dest/api/utils.d.ts +2 -1
  30. package/dest/api/utils.d.ts.map +1 -1
  31. package/dest/api/utils.js +2 -1
  32. package/dest/api/wallet.d.ts +1 -1
  33. package/dest/api/wallet.d.ts.map +1 -1
  34. package/dest/contract/base_contract_interaction.d.ts +22 -57
  35. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  36. package/dest/contract/base_contract_interaction.js +12 -67
  37. package/dest/contract/batch_call.d.ts +6 -18
  38. package/dest/contract/batch_call.d.ts.map +1 -1
  39. package/dest/contract/batch_call.js +25 -54
  40. package/dest/contract/contract.d.ts +1 -1
  41. package/dest/contract/contract.d.ts.map +1 -1
  42. package/dest/contract/contract_base.d.ts +1 -1
  43. package/dest/contract/contract_base.d.ts.map +1 -1
  44. package/dest/contract/contract_function_interaction.d.ts +38 -18
  45. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  46. package/dest/contract/contract_function_interaction.js +34 -41
  47. package/dest/contract/deploy_method.d.ts +7 -8
  48. package/dest/contract/deploy_method.d.ts.map +1 -1
  49. package/dest/contract/deploy_method.js +27 -32
  50. package/dest/contract/deploy_proven_tx.d.ts +2 -3
  51. package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
  52. package/dest/contract/deploy_proven_tx.js +1 -1
  53. package/dest/contract/deploy_sent_tx.d.ts +2 -3
  54. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  55. package/dest/contract/deploy_sent_tx.js +4 -4
  56. package/dest/contract/protocol_contracts.d.ts +1 -1
  57. package/dest/contract/protocol_contracts.d.ts.map +1 -1
  58. package/dest/contract/proven_tx.d.ts +3 -5
  59. package/dest/contract/proven_tx.d.ts.map +1 -1
  60. package/dest/contract/proven_tx.js +2 -6
  61. package/dest/contract/sent_tx.d.ts +4 -16
  62. package/dest/contract/sent_tx.d.ts.map +1 -1
  63. package/dest/contract/sent_tx.js +6 -37
  64. package/dest/contract/unsafe_contract.d.ts +1 -1
  65. package/dest/contract/unsafe_contract.d.ts.map +1 -1
  66. package/dest/contract/wait_for_proven.d.ts +17 -0
  67. package/dest/contract/wait_for_proven.d.ts.map +1 -0
  68. package/dest/contract/wait_for_proven.js +17 -0
  69. package/dest/deployment/broadcast_function.js +12 -8
  70. package/dest/deployment/contract_deployer.d.ts +1 -1
  71. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  72. package/dest/deployment/register_class.d.ts +1 -1
  73. package/dest/deployment/register_class.d.ts.map +1 -1
  74. package/dest/deployment/register_class.js +6 -11
  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/account_entrypoint_meta_payment_method.d.ts +31 -0
  79. package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  80. package/dest/fee/account_entrypoint_meta_payment_method.js +64 -0
  81. package/dest/fee/fee_juice_payment_method.d.ts +3 -3
  82. package/dest/fee/fee_juice_payment_method.d.ts.map +1 -1
  83. package/dest/fee/fee_juice_payment_method.js +3 -2
  84. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +4 -4
  85. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  86. package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
  87. package/dest/fee/private_fee_payment_method.d.ts +6 -6
  88. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  89. package/dest/fee/private_fee_payment_method.js +13 -12
  90. package/dest/fee/public_fee_payment_method.d.ts +7 -7
  91. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  92. package/dest/fee/public_fee_payment_method.js +10 -11
  93. package/dest/fee/sponsored_fee_payment.d.ts +15 -0
  94. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
  95. package/dest/fee/sponsored_fee_payment.js +30 -0
  96. package/dest/fee/utils.d.ts +13 -0
  97. package/dest/fee/utils.d.ts.map +1 -0
  98. package/dest/fee/utils.js +32 -0
  99. package/dest/utils/authwit.d.ts +16 -9
  100. package/dest/utils/authwit.d.ts.map +1 -1
  101. package/dest/utils/authwit.js +27 -36
  102. package/dest/wallet/account_wallet.d.ts +6 -6
  103. package/dest/wallet/account_wallet.d.ts.map +1 -1
  104. package/dest/wallet/account_wallet.js +15 -17
  105. package/dest/wallet/base_wallet.d.ts +12 -35
  106. package/dest/wallet/base_wallet.d.ts.map +1 -1
  107. package/dest/wallet/base_wallet.js +11 -64
  108. package/dest/wallet/index.d.ts +2 -2
  109. package/dest/wallet/index.d.ts.map +1 -1
  110. package/dest/wallet/index.js +1 -1
  111. package/dest/wallet/signerless_wallet.d.ts +3 -3
  112. package/dest/wallet/signerless_wallet.d.ts.map +1 -1
  113. package/dest/wallet/signerless_wallet.js +3 -6
  114. package/dest/wallet/wallet.d.ts +11 -0
  115. package/dest/wallet/wallet.d.ts.map +1 -0
  116. package/package.json +10 -8
  117. package/src/account/{contract.ts → account_contract.ts} +2 -1
  118. package/src/account/index.ts +2 -3
  119. package/src/account/interface.ts +1 -12
  120. package/src/account_manager/account_manager.ts +294 -0
  121. package/src/account_manager/deploy_account_sent_tx.ts +4 -4
  122. package/src/account_manager/index.ts +1 -237
  123. package/src/api/account.ts +2 -8
  124. package/src/api/contract.ts +5 -5
  125. package/src/api/fee.ts +2 -1
  126. package/src/api/fee_testing.ts +1 -0
  127. package/src/api/utils.ts +1 -1
  128. package/src/api/wallet.ts +7 -1
  129. package/src/contract/base_contract_interaction.ts +32 -88
  130. package/src/contract/batch_call.ts +40 -43
  131. package/src/contract/contract.ts +1 -1
  132. package/src/contract/contract_base.ts +1 -1
  133. package/src/contract/contract_function_interaction.ts +85 -56
  134. package/src/contract/deploy_method.ts +24 -26
  135. package/src/contract/deploy_proven_tx.ts +3 -4
  136. package/src/contract/deploy_sent_tx.ts +6 -6
  137. package/src/contract/protocol_contracts.ts +1 -1
  138. package/src/contract/proven_tx.ts +4 -22
  139. package/src/contract/sent_tx.ts +6 -47
  140. package/src/contract/unsafe_contract.ts +1 -1
  141. package/src/contract/wait_for_proven.ts +38 -0
  142. package/src/deployment/broadcast_function.ts +40 -40
  143. package/src/deployment/contract_deployer.ts +1 -1
  144. package/src/deployment/register_class.ts +9 -22
  145. package/src/ethereum/portal_manager.ts +73 -24
  146. package/src/fee/account_entrypoint_meta_payment_method.ts +90 -0
  147. package/src/fee/fee_juice_payment_method.ts +4 -5
  148. package/src/fee/fee_juice_payment_method_with_claim.ts +24 -20
  149. package/src/fee/private_fee_payment_method.ts +29 -28
  150. package/src/fee/public_fee_payment_method.ts +29 -29
  151. package/src/fee/sponsored_fee_payment.ts +38 -0
  152. package/src/fee/utils.ts +39 -0
  153. package/src/utils/authwit.ts +26 -37
  154. package/src/wallet/account_wallet.ts +18 -17
  155. package/src/wallet/base_wallet.ts +27 -88
  156. package/src/wallet/index.ts +2 -2
  157. package/src/wallet/signerless_wallet.ts +9 -8
  158. package/src/wallet/wallet.ts +34 -0
  159. package/dest/account/contract.d.ts.map +0 -1
  160. package/dest/account/wallet.d.ts +0 -11
  161. package/dest/account/wallet.d.ts.map +0 -1
  162. package/dest/account_manager/deploy_account_method.d.ts +0 -15
  163. package/dest/account_manager/deploy_account_method.d.ts.map +0 -1
  164. package/dest/account_manager/deploy_account_method.js +0 -36
  165. package/dest/api/entrypoint.d.ts +0 -2
  166. package/dest/api/entrypoint.d.ts.map +0 -1
  167. package/dest/api/entrypoint.js +0 -1
  168. package/dest/entrypoint/default_entrypoint.d.ts +0 -12
  169. package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
  170. package/dest/entrypoint/default_entrypoint.js +0 -28
  171. package/dest/entrypoint/default_multi_call_entrypoint.d.ts +0 -15
  172. package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +0 -1
  173. package/dest/entrypoint/default_multi_call_entrypoint.js +0 -130
  174. package/dest/entrypoint/entrypoint.d.ts +0 -39
  175. package/dest/entrypoint/entrypoint.d.ts.map +0 -1
  176. package/dest/entrypoint/entrypoint.js +0 -20
  177. package/dest/entrypoint/payload.d.ts +0 -128
  178. package/dest/entrypoint/payload.d.ts.map +0 -1
  179. package/dest/entrypoint/payload.js +0 -143
  180. package/dest/fee/fee_payment_method.d.ts +0 -22
  181. package/dest/fee/fee_payment_method.d.ts.map +0 -1
  182. package/dest/fee/fee_payment_method.js +0 -3
  183. package/src/account/wallet.ts +0 -13
  184. package/src/account_manager/deploy_account_method.ts +0 -67
  185. package/src/api/entrypoint.ts +0 -1
  186. package/src/entrypoint/default_entrypoint.ts +0 -39
  187. package/src/entrypoint/default_multi_call_entrypoint.ts +0 -93
  188. package/src/entrypoint/entrypoint.ts +0 -60
  189. package/src/entrypoint/payload.ts +0 -238
  190. package/src/fee/fee_payment_method.ts +0 -22
  191. /package/dest/account/{contract.js → account_contract.js} +0 -0
  192. /package/dest/{account → wallet}/wallet.js +0 -0
@@ -1,11 +0,0 @@
1
- import type { AuthWitness } from '@aztec/stdlib/auth-witness';
2
- import type { PXE } from '@aztec/stdlib/interfaces/client';
3
- import type { IntentAction, IntentInnerHash } from '../utils/authwit.js';
4
- import type { AccountInterface } from './interface.js';
5
- /**
6
- * The wallet interface.
7
- */
8
- export type Wallet = AccountInterface & PXE & {
9
- createAuthWit(intent: IntentInnerHash | IntentAction): Promise<AuthWitness>;
10
- };
11
- //# sourceMappingURL=wallet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/account/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,gBAAgB,GACnC,GAAG,GAAG;IACJ,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAC7E,CAAC"}
@@ -1,15 +0,0 @@
1
- import { type ContractArtifact, type FunctionArtifact } from '@aztec/stdlib/abi';
2
- import type { PublicKeys } from '@aztec/stdlib/keys';
3
- import type { AuthWitnessProvider } from '../account/interface.js';
4
- import type { Wallet } from '../account/wallet.js';
5
- import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
6
- import { DeployMethod, type DeployOptions } from '../contract/deploy_method.js';
7
- /**
8
- * Contract interaction for deploying an account contract. Handles fee preparation and contract initialization.
9
- */
10
- export declare class DeployAccountMethod extends DeployMethod {
11
- #private;
12
- constructor(authWitnessProvider: AuthWitnessProvider, publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact, feePaymentNameOrArtifact?: string | FunctionArtifact);
13
- protected getInitializeFunctionCalls(options: DeployOptions): Promise<ContractFunctionInteraction[]>;
14
- }
15
- //# sourceMappingURL=deploy_account_method.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deploy_account_method.d.ts","sourceRoot":"","sources":["../../src/account_manager/deploy_account_method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAA6B,MAAM,mBAAmB,CAAC;AAC5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGhF;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;;gBAKjD,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,GAAE,GAAG,EAAO,EAChB,yBAAyB,CAAC,EAAE,MAAM,GAAG,gBAAgB,EACrD,wBAAwB,CAAC,EAAE,MAAM,GAAG,gBAAgB;cAkB7B,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,2BAA2B,EAAE,CAAC;CAwBpH"}
@@ -1,36 +0,0 @@
1
- import { getFunctionArtifactByName } from '@aztec/stdlib/abi';
2
- import { Contract } from '../contract/contract.js';
3
- import { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
4
- import { DeployMethod } from '../contract/deploy_method.js';
5
- import { EntrypointPayload, computeCombinedPayloadHash } from '../entrypoint/payload.js';
6
- /**
7
- * Contract interaction for deploying an account contract. Handles fee preparation and contract initialization.
8
- */ export class DeployAccountMethod extends DeployMethod {
9
- #authWitnessProvider;
10
- #feePaymentArtifact;
11
- constructor(authWitnessProvider, publicKeys, wallet, artifact, args = [], constructorNameOrArtifact, feePaymentNameOrArtifact){
12
- super(publicKeys, wallet, artifact, (address, wallet)=>Contract.at(address, artifact, wallet), args, constructorNameOrArtifact);
13
- this.#authWitnessProvider = authWitnessProvider;
14
- this.#feePaymentArtifact = typeof feePaymentNameOrArtifact === 'string' ? getFunctionArtifactByName(artifact, feePaymentNameOrArtifact) : feePaymentNameOrArtifact;
15
- }
16
- async getInitializeFunctionCalls(options) {
17
- const calls = await super.getInitializeFunctionCalls(options);
18
- if (options.fee && this.#feePaymentArtifact) {
19
- const { address } = await this.getInstance();
20
- const emptyAppPayload = await EntrypointPayload.fromAppExecution([]);
21
- const fee = await this.getDefaultFeeOptions(options.fee);
22
- const feePayload = await EntrypointPayload.fromFeeOptions(address, fee);
23
- const args = [
24
- emptyAppPayload,
25
- feePayload,
26
- false
27
- ];
28
- const call = new ContractFunctionInteraction(this.wallet, address, this.#feePaymentArtifact, args);
29
- call.addAuthWitness(await this.#authWitnessProvider.createAuthWit(await computeCombinedPayloadHash(emptyAppPayload, feePayload)));
30
- call.addHashedArguments(emptyAppPayload.hashedArguments);
31
- call.addHashedArguments(feePayload.hashedArguments);
32
- calls.push(call);
33
- }
34
- return calls;
35
- }
36
- }
@@ -1,2 +0,0 @@
1
- export * from '../entrypoint/entrypoint.js';
2
- //# sourceMappingURL=entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/api/entrypoint.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -1 +0,0 @@
1
- export * from '../entrypoint/entrypoint.js';
@@ -1,12 +0,0 @@
1
- import { TxExecutionRequest } from '@aztec/stdlib/tx';
2
- import type { EntrypointInterface, ExecutionRequestInit } from './entrypoint.js';
3
- /**
4
- * Default implementation of the entrypoint interface. It calls a function on a contract directly
5
- */
6
- export declare class DefaultEntrypoint implements EntrypointInterface {
7
- private chainId;
8
- private protocolVersion;
9
- constructor(chainId: number, protocolVersion: number);
10
- createTxExecutionRequest(exec: ExecutionRequestInit): Promise<TxExecutionRequest>;
11
- }
12
- //# sourceMappingURL=default_entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default_entrypoint.d.ts","sourceRoot":"","sources":["../../src/entrypoint/default_entrypoint.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEjF;;GAEG;AACH,qBAAa,iBAAkB,YAAW,mBAAmB;IAC/C,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,eAAe;gBAAxC,OAAO,EAAE,MAAM,EAAU,eAAe,EAAE,MAAM;IAE9D,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA2BxF"}
@@ -1,28 +0,0 @@
1
- import { FunctionType } from '@aztec/stdlib/abi';
2
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
3
- /**
4
- * Default implementation of the entrypoint interface. It calls a function on a contract directly
5
- */ export class DefaultEntrypoint {
6
- chainId;
7
- protocolVersion;
8
- constructor(chainId, protocolVersion){
9
- this.chainId = chainId;
10
- this.protocolVersion = protocolVersion;
11
- }
12
- async createTxExecutionRequest(exec) {
13
- const { fee, calls, authWitnesses = [], hashedArguments = [], capsules = [] } = exec;
14
- if (calls.length > 1) {
15
- throw new Error(`Expected a single call, got ${calls.length}`);
16
- }
17
- const call = calls[0];
18
- if (call.type !== FunctionType.PRIVATE) {
19
- throw new Error('Public entrypoints are not allowed');
20
- }
21
- const entrypointHashedValues = await HashedValues.fromValues(call.args);
22
- const txContext = new TxContext(this.chainId, this.protocolVersion, fee.gasSettings);
23
- return Promise.resolve(new TxExecutionRequest(call.to, call.selector, entrypointHashedValues.hash, txContext, [
24
- ...hashedArguments,
25
- entrypointHashedValues
26
- ], authWitnesses, capsules));
27
- }
28
- }
@@ -1,15 +0,0 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import { TxExecutionRequest } from '@aztec/stdlib/tx';
3
- import { type EntrypointInterface, type ExecutionRequestInit } from './entrypoint.js';
4
- /**
5
- * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
6
- */
7
- export declare class DefaultMultiCallEntrypoint implements EntrypointInterface {
8
- private chainId;
9
- private version;
10
- private address;
11
- constructor(chainId: number, version: number, address?: AztecAddress);
12
- createTxExecutionRequest(executions: ExecutionRequestInit): Promise<TxExecutionRequest>;
13
- private getEntrypointAbi;
14
- }
15
- //# sourceMappingURL=default_multi_call_entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default_multi_call_entrypoint.d.ts","sourceRoot":"","sources":["../../src/entrypoint/default_multi_call_entrypoint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAA2B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAE,KAAK,mBAAmB,EAAqB,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEzG;;GAEG;AACH,qBAAa,0BAA2B,YAAW,mBAAmB;IAElE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,OAAO;gBAFP,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAA0D;IAGvE,wBAAwB,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAmB7F,OAAO,CAAC,gBAAgB;CAwDzB"}
@@ -1,130 +0,0 @@
1
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
- import { FunctionSelector, encodeArguments } from '@aztec/stdlib/abi';
3
- import { HashedValues, TxContext, TxExecutionRequest } from '@aztec/stdlib/tx';
4
- import { EntrypointPayload } from './entrypoint.js';
5
- /**
6
- * Implementation for an entrypoint interface that can execute multiple function calls in a single transaction
7
- */ export class DefaultMultiCallEntrypoint {
8
- chainId;
9
- version;
10
- address;
11
- constructor(chainId, version, address = ProtocolContractAddress.MultiCallEntrypoint){
12
- this.chainId = chainId;
13
- this.version = version;
14
- this.address = address;
15
- }
16
- async createTxExecutionRequest(executions) {
17
- const { fee, calls, authWitnesses = [], hashedArguments = [], capsules = [] } = executions;
18
- const payload = await EntrypointPayload.fromAppExecution(calls);
19
- const abi = this.getEntrypointAbi();
20
- const entrypointHashedArgs = await HashedValues.fromValues(encodeArguments(abi, [
21
- payload
22
- ]));
23
- const txRequest = TxExecutionRequest.from({
24
- firstCallArgsHash: entrypointHashedArgs.hash,
25
- origin: this.address,
26
- functionSelector: await FunctionSelector.fromNameAndParameters(abi.name, abi.parameters),
27
- txContext: new TxContext(this.chainId, this.version, fee.gasSettings),
28
- argsOfCalls: [
29
- ...payload.hashedArguments,
30
- ...hashedArguments,
31
- entrypointHashedArgs
32
- ],
33
- authWitnesses,
34
- capsules
35
- });
36
- return Promise.resolve(txRequest);
37
- }
38
- getEntrypointAbi() {
39
- return {
40
- name: 'entrypoint',
41
- isInitializer: false,
42
- functionType: 'private',
43
- isInternal: false,
44
- isStatic: false,
45
- parameters: [
46
- {
47
- name: 'app_payload',
48
- type: {
49
- kind: 'struct',
50
- path: 'authwit::entrypoint::app::AppPayload',
51
- fields: [
52
- {
53
- name: 'function_calls',
54
- type: {
55
- kind: 'array',
56
- length: 4,
57
- type: {
58
- kind: 'struct',
59
- path: 'authwit::entrypoint::function_call::FunctionCall',
60
- fields: [
61
- {
62
- name: 'args_hash',
63
- type: {
64
- kind: 'field'
65
- }
66
- },
67
- {
68
- name: 'function_selector',
69
- type: {
70
- kind: 'struct',
71
- path: 'authwit::aztec::protocol_types::abis::function_selector::FunctionSelector',
72
- fields: [
73
- {
74
- name: 'inner',
75
- type: {
76
- kind: 'integer',
77
- sign: 'unsigned',
78
- width: 32
79
- }
80
- }
81
- ]
82
- }
83
- },
84
- {
85
- name: 'target_address',
86
- type: {
87
- kind: 'struct',
88
- path: 'authwit::aztec::protocol_types::address::AztecAddress',
89
- fields: [
90
- {
91
- name: 'inner',
92
- type: {
93
- kind: 'field'
94
- }
95
- }
96
- ]
97
- }
98
- },
99
- {
100
- name: 'is_public',
101
- type: {
102
- kind: 'boolean'
103
- }
104
- },
105
- {
106
- name: 'is_static',
107
- type: {
108
- kind: 'boolean'
109
- }
110
- }
111
- ]
112
- }
113
- }
114
- },
115
- {
116
- name: 'nonce',
117
- type: {
118
- kind: 'field'
119
- }
120
- }
121
- ]
122
- },
123
- visibility: 'public'
124
- }
125
- ],
126
- returnTypes: [],
127
- errorTypes: {}
128
- };
129
- }
130
- }
@@ -1,39 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import type { FunctionCall } from '@aztec/stdlib/abi';
3
- import type { AuthWitness } from '@aztec/stdlib/auth-witness';
4
- import type { Capsule, HashedValues, TxExecutionRequest } from '@aztec/stdlib/tx';
5
- import { EntrypointPayload, type FeeOptions, computeCombinedPayloadHash } from './payload.js';
6
- export { EntrypointPayload, type FeeOptions, computeCombinedPayloadHash };
7
- export { DefaultEntrypoint } from './default_entrypoint.js';
8
- export { DefaultMultiCallEntrypoint } from './default_multi_call_entrypoint.js';
9
- /** Encodes the calls to be done in a transaction. */
10
- export type ExecutionRequestInit = {
11
- /** The function calls to be executed. */
12
- calls: FunctionCall[];
13
- /** Any transient auth witnesses needed for this execution */
14
- authWitnesses?: AuthWitness[];
15
- /** Any transient hashed arguments for this execution */
16
- hashedArguments?: HashedValues[];
17
- /** Data passed through an oracle for this execution. */
18
- capsules?: Capsule[];
19
- /** How the fee is going to be payed */
20
- fee: FeeOptions;
21
- /** An optional nonce. Used to repeat a previous tx with a higher fee so that the first one is cancelled */
22
- nonce?: Fr;
23
- /** Whether the transaction can be cancelled. If true, an extra nullifier will be emitted: H(nonce, GENERATOR_INDEX__TX_NULLIFIER) */
24
- cancellable?: boolean;
25
- };
26
- /**
27
- * Merges an array of ExecutionRequestInits.
28
- */
29
- export declare function mergeExecutionRequestInits(requests: Pick<ExecutionRequestInit, 'calls' | 'authWitnesses' | 'hashedArguments' | 'capsules'>[], { nonce, cancellable }?: Pick<ExecutionRequestInit, 'nonce' | 'cancellable'>): Omit<ExecutionRequestInit, 'fee'>;
30
- /** Creates transaction execution requests out of a set of function calls. */
31
- export interface EntrypointInterface {
32
- /**
33
- * Generates an execution request out of set of function calls.
34
- * @param execution - The execution intents to be run.
35
- * @returns The authenticated transaction execution request.
36
- */
37
- createTxExecutionRequest(execution: ExecutionRequestInit): Promise<TxExecutionRequest>;
38
- }
39
- //# sourceMappingURL=entrypoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/entrypoint/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE9F,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,0BAA0B,EAAE,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAEhF,qDAAqD;AACrD,MAAM,MAAM,oBAAoB,GAAG;IACjC,yCAAyC;IACzC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,wDAAwD;IACxD,eAAe,CAAC,EAAE,YAAY,EAAE,CAAC;IACjC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,uCAAuC;IACvC,GAAG,EAAE,UAAU,CAAC;IAChB,2GAA2G;IAC3G,KAAK,CAAC,EAAE,EAAE,CAAC;IACX,qIAAqI;IACrI,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,eAAe,GAAG,iBAAiB,GAAG,UAAU,CAAC,EAAE,EAClG,EAAE,KAAK,EAAE,WAAW,EAAE,GAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,aAAa,CAAM,GAC/E,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAanC;AAED,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,wBAAwB,CAAC,SAAS,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACxF"}
@@ -1,20 +0,0 @@
1
- import { EntrypointPayload, computeCombinedPayloadHash } from './payload.js';
2
- export { EntrypointPayload, computeCombinedPayloadHash };
3
- export { DefaultEntrypoint } from './default_entrypoint.js';
4
- export { DefaultMultiCallEntrypoint } from './default_multi_call_entrypoint.js';
5
- /**
6
- * Merges an array of ExecutionRequestInits.
7
- */ export function mergeExecutionRequestInits(requests, { nonce, cancellable } = {}) {
8
- const calls = requests.map((r)=>r.calls).flat();
9
- const authWitnesses = requests.map((r)=>r.authWitnesses ?? []).flat();
10
- const hashedArguments = requests.map((r)=>r.hashedArguments ?? []).flat();
11
- const capsules = requests.map((r)=>r.capsules ?? []).flat();
12
- return {
13
- calls,
14
- authWitnesses,
15
- hashedArguments,
16
- capsules,
17
- nonce,
18
- cancellable
19
- };
20
- }
@@ -1,128 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import type { Tuple } from '@aztec/foundation/serialize';
3
- import type { FieldsOf } from '@aztec/foundation/types';
4
- import { FunctionCall } from '@aztec/stdlib/abi';
5
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import type { GasSettings } from '@aztec/stdlib/gas';
7
- import { HashedValues } from '@aztec/stdlib/tx';
8
- import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
9
- /**
10
- * Fee payment options for a transaction.
11
- */
12
- export type FeeOptions = {
13
- /** The fee payment method to use */
14
- paymentMethod: FeePaymentMethod;
15
- /** The gas settings */
16
- gasSettings: GasSettings;
17
- };
18
- /** Fee options as set by a user. */
19
- export type UserFeeOptions = {
20
- /** The fee payment method to use */
21
- paymentMethod?: FeePaymentMethod;
22
- /** The gas settings */
23
- gasSettings?: Partial<FieldsOf<GasSettings>>;
24
- /** Percentage to pad the base fee by, if empty, defaults to 0.5 */
25
- baseFeePadding?: number;
26
- /** Whether to run an initial simulation of the tx with high gas limit to figure out actual gas settings. */
27
- estimateGas?: boolean;
28
- /** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
29
- estimatedGasPadding?: number;
30
- };
31
- /** Encoded function call for account contract entrypoint */
32
- type EncodedFunctionCall = {
33
- /** Arguments hash for the call */
34
- args_hash: Fr;
35
- /** Selector of the function to call */
36
- function_selector: Fr;
37
- /** Address of the contract to call */
38
- target_address: Fr;
39
- /** Whether the function is public or private */
40
- is_public: boolean;
41
- /** Whether the function can alter state */
42
- is_static: boolean;
43
- };
44
- /** Assembles an entrypoint payload */
45
- export declare abstract class EntrypointPayload {
46
- private functionCalls;
47
- private _hashedArguments;
48
- private generatorIndex;
49
- private _nonce;
50
- protected constructor(functionCalls: EncodedFunctionCall[], _hashedArguments: HashedValues[], generatorIndex: number, _nonce: Fr);
51
- protected static create(functionCalls: FunctionCall[]): Promise<{
52
- encodedFunctionCalls: {
53
- args_hash: Fr;
54
- function_selector: Fr;
55
- target_address: Fr;
56
- is_public: boolean;
57
- is_static: boolean;
58
- }[];
59
- hashedArguments: HashedValues[];
60
- }>;
61
- /**
62
- * The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
63
- * @internal
64
- */
65
- get function_calls(): EncodedFunctionCall[];
66
- /**
67
- * The nonce
68
- * @internal
69
- */
70
- get nonce(): Fr;
71
- /**
72
- * The hashed arguments for the function calls
73
- */
74
- get hashedArguments(): HashedValues[];
75
- /**
76
- * Serializes the payload to an array of fields
77
- * @returns The fields of the payload
78
- */
79
- abstract toFields(): Fr[];
80
- /**
81
- * Hashes the payload
82
- * @returns The hash of the payload
83
- */
84
- hash(): Promise<Fr>;
85
- /** Serializes the function calls to an array of fields. */
86
- protected functionCallsToFields(): Fr[];
87
- /**
88
- * Creates an execution payload for a dapp from a set of function calls
89
- * @param functionCalls - The function calls to execute
90
- * @returns The execution payload
91
- */
92
- static fromFunctionCalls(functionCalls: FunctionCall[]): Promise<AppEntrypointPayload>;
93
- /**
94
- * Creates an execution payload for the app-portion of a transaction from a set of function calls
95
- * @param functionCalls - The function calls to execute
96
- * @param nonce - The nonce for the payload, used to emit a nullifier identifying the call
97
- * @returns The execution payload
98
- */
99
- static fromAppExecution(functionCalls: FunctionCall[] | Tuple<FunctionCall, 4>, nonce?: Fr): Promise<AppEntrypointPayload>;
100
- /**
101
- * Creates an execution payload to pay the fee for a transaction
102
- * @param sender - The address sending this payload
103
- * @param feeOpts - The fee payment options
104
- * @returns The execution payload
105
- */
106
- static fromFeeOptions(sender: AztecAddress, feeOpts?: FeeOptions): Promise<FeeEntrypointPayload>;
107
- }
108
- /** Entrypoint payload for app phase execution. */
109
- declare class AppEntrypointPayload extends EntrypointPayload {
110
- toFields(): Fr[];
111
- }
112
- /** Entrypoint payload for fee payment to be run during setup phase. */
113
- declare class FeeEntrypointPayload extends EntrypointPayload {
114
- #private;
115
- constructor(functionCalls: EncodedFunctionCall[], hashedArguments: HashedValues[], generatorIndex: number, nonce: Fr, isFeePayer: boolean);
116
- toFields(): Fr[];
117
- /** Whether the sender should be appointed as fee payer. */
118
- get is_fee_payer(): boolean;
119
- }
120
- /**
121
- * Computes a hash of a combined payload.
122
- * @param appPayload - An app payload.
123
- * @param feePayload - A fee payload.
124
- * @returns A hash of a combined payload.
125
- */
126
- export declare function computeCombinedPayloadHash(appPayload: AppEntrypointPayload, feePayload: FeeEntrypointPayload): Promise<Fr>;
127
- export {};
128
- //# sourceMappingURL=payload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/entrypoint/payload.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,oCAAoC;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,uBAAuB;IACvB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAGF,oCAAoC;AACpC,MAAM,MAAM,cAAc,GAAG;IAC3B,oCAAoC;IACpC,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,uBAAuB;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4GAA4G;IAC5G,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qHAAqH;IACrH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAUF,4DAA4D;AAC5D,KAAK,mBAAmB,GAAG;IACzB,kCAAkC;IAClC,SAAS,EAAE,EAAE,CAAC;IACd,uCAAuC;IACvC,iBAAiB,EAAE,EAAE,CAAC;IACtB,sCAAsC;IACtC,cAAc,EAAE,EAAE,CAAC;IACnB,gDAAgD;IAChD,SAAS,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAGF,sCAAsC;AACtC,8BAAsB,iBAAiB;IAEnC,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,MAAM;IAJhB,SAAS,aACC,aAAa,EAAE,mBAAmB,EAAE,EACpC,gBAAgB,EAAE,YAAY,EAAE,EAChC,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,EAAE;qBAGG,MAAM,CAAC,aAAa,EAAE,YAAY,EAAE;;;;;;;;;;IAuB3D;;;OAGG;IACH,IAAI,cAAc,0BAEjB;IAGD;;;OAGG;IACH,IAAI,KAAK,OAER;IAED;;OAEG;IACH,IAAI,eAAe,mBAElB;IAED;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE;IAEzB;;;OAGG;IACH,IAAI;IAIJ,2DAA2D;IAC3D,SAAS,CAAC,qBAAqB;IAU/B;;;;OAIG;WACU,iBAAiB,CAAC,aAAa,EAAE,YAAY,EAAE;IAK5D;;;;;OAKG;WACU,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,KAAc;IASzG;;;;;OAKG;WACU,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,UAAU;CAcvE;AAED,kDAAkD;AAClD,cAAM,oBAAqB,SAAQ,iBAAiB;IACzC,QAAQ,IAAI,EAAE,EAAE;CAG1B;AAED,uEAAuE;AACvE,cAAM,oBAAqB,SAAQ,iBAAiB;;gBAIhD,aAAa,EAAE,mBAAmB,EAAE,EACpC,eAAe,EAAE,YAAY,EAAE,EAC/B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,EAAE,EACT,UAAU,EAAE,OAAO;IAMZ,QAAQ,IAAI,EAAE,EAAE;IAKzB,2DAA2D;IAC3D,IAAI,YAAY,YAEf;CAEF;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,oBAAoB,EAChC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,EAAE,CAAC,CAKb"}
@@ -1,143 +0,0 @@
1
- import { GeneratorIndex } from '@aztec/constants';
2
- import { padArrayEnd } from '@aztec/foundation/collection';
3
- import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
4
- import { Fr } from '@aztec/foundation/fields';
5
- import { FunctionCall, FunctionType } from '@aztec/stdlib/abi';
6
- import { HashedValues } from '@aztec/stdlib/tx';
7
- // docs:end:user_fee_options
8
- // These must match the values defined in:
9
- // - noir-projects/aztec-nr/aztec/src/entrypoint/app.nr
10
- const APP_MAX_CALLS = 4;
11
- // - and noir-projects/aztec-nr/aztec/src/entrypoint/fee.nr
12
- const FEE_MAX_CALLS = 2;
13
- /* eslint-enable camelcase */ /** Assembles an entrypoint payload */ export class EntrypointPayload {
14
- functionCalls;
15
- _hashedArguments;
16
- generatorIndex;
17
- _nonce;
18
- constructor(functionCalls, _hashedArguments, generatorIndex, _nonce){
19
- this.functionCalls = functionCalls;
20
- this._hashedArguments = _hashedArguments;
21
- this.generatorIndex = generatorIndex;
22
- this._nonce = _nonce;
23
- }
24
- static async create(functionCalls) {
25
- const hashedArguments = [];
26
- for (const call of functionCalls){
27
- hashedArguments.push(await HashedValues.fromValues(call.args));
28
- }
29
- /* eslint-disable camelcase */ const encodedFunctionCalls = functionCalls.map((call, index)=>({
30
- args_hash: hashedArguments[index].hash,
31
- function_selector: call.selector.toField(),
32
- target_address: call.to.toField(),
33
- is_public: call.type == FunctionType.PUBLIC,
34
- is_static: call.isStatic
35
- }));
36
- /* eslint-enable camelcase */ return {
37
- encodedFunctionCalls,
38
- hashedArguments
39
- };
40
- }
41
- /* eslint-disable camelcase */ /**
42
- * The function calls to execute. This uses snake_case naming so that it is compatible with Noir encoding
43
- * @internal
44
- */ get function_calls() {
45
- return this.functionCalls;
46
- }
47
- /* eslint-enable camelcase */ /**
48
- * The nonce
49
- * @internal
50
- */ get nonce() {
51
- return this._nonce;
52
- }
53
- /**
54
- * The hashed arguments for the function calls
55
- */ get hashedArguments() {
56
- return this._hashedArguments;
57
- }
58
- /**
59
- * Hashes the payload
60
- * @returns The hash of the payload
61
- */ hash() {
62
- return poseidon2HashWithSeparator(this.toFields(), this.generatorIndex);
63
- }
64
- /** Serializes the function calls to an array of fields. */ functionCallsToFields() {
65
- return this.functionCalls.flatMap((call)=>[
66
- call.args_hash,
67
- call.function_selector,
68
- call.target_address,
69
- new Fr(call.is_public),
70
- new Fr(call.is_static)
71
- ]);
72
- }
73
- /**
74
- * Creates an execution payload for a dapp from a set of function calls
75
- * @param functionCalls - The function calls to execute
76
- * @returns The execution payload
77
- */ static async fromFunctionCalls(functionCalls) {
78
- const { encodedFunctionCalls, hashedArguments } = await this.create(functionCalls);
79
- return new AppEntrypointPayload(encodedFunctionCalls, hashedArguments, 0, Fr.random());
80
- }
81
- /**
82
- * Creates an execution payload for the app-portion of a transaction from a set of function calls
83
- * @param functionCalls - The function calls to execute
84
- * @param nonce - The nonce for the payload, used to emit a nullifier identifying the call
85
- * @returns The execution payload
86
- */ static async fromAppExecution(functionCalls, nonce = Fr.random()) {
87
- if (functionCalls.length > APP_MAX_CALLS) {
88
- throw new Error(`Expected at most ${APP_MAX_CALLS} function calls, got ${functionCalls.length}`);
89
- }
90
- const paddedCalls = padArrayEnd(functionCalls, FunctionCall.empty(), APP_MAX_CALLS);
91
- const { encodedFunctionCalls, hashedArguments } = await this.create(paddedCalls);
92
- return new AppEntrypointPayload(encodedFunctionCalls, hashedArguments, GeneratorIndex.SIGNATURE_PAYLOAD, nonce);
93
- }
94
- /**
95
- * Creates an execution payload to pay the fee for a transaction
96
- * @param sender - The address sending this payload
97
- * @param feeOpts - The fee payment options
98
- * @returns The execution payload
99
- */ static async fromFeeOptions(sender, feeOpts) {
100
- const calls = await feeOpts?.paymentMethod.getFunctionCalls(feeOpts?.gasSettings) ?? [];
101
- const feePayer = await feeOpts?.paymentMethod.getFeePayer(feeOpts?.gasSettings);
102
- const isFeePayer = !!feePayer && feePayer.equals(sender);
103
- const paddedCalls = padArrayEnd(calls, FunctionCall.empty(), FEE_MAX_CALLS);
104
- const { encodedFunctionCalls, hashedArguments } = await this.create(paddedCalls);
105
- return new FeeEntrypointPayload(encodedFunctionCalls, hashedArguments, GeneratorIndex.FEE_PAYLOAD, Fr.random(), isFeePayer);
106
- }
107
- }
108
- /** Entrypoint payload for app phase execution. */ class AppEntrypointPayload extends EntrypointPayload {
109
- toFields() {
110
- return [
111
- ...this.functionCallsToFields(),
112
- this.nonce
113
- ];
114
- }
115
- }
116
- /** Entrypoint payload for fee payment to be run during setup phase. */ class FeeEntrypointPayload extends EntrypointPayload {
117
- #isFeePayer;
118
- constructor(functionCalls, hashedArguments, generatorIndex, nonce, isFeePayer){
119
- super(functionCalls, hashedArguments, generatorIndex, nonce);
120
- this.#isFeePayer = isFeePayer;
121
- }
122
- toFields() {
123
- return [
124
- ...this.functionCallsToFields(),
125
- this.nonce,
126
- new Fr(this.#isFeePayer)
127
- ];
128
- }
129
- /* eslint-disable camelcase */ /** Whether the sender should be appointed as fee payer. */ get is_fee_payer() {
130
- return this.#isFeePayer;
131
- }
132
- }
133
- /**
134
- * Computes a hash of a combined payload.
135
- * @param appPayload - An app payload.
136
- * @param feePayload - A fee payload.
137
- * @returns A hash of a combined payload.
138
- */ export async function computeCombinedPayloadHash(appPayload, feePayload) {
139
- return poseidon2HashWithSeparator([
140
- await appPayload.hash(),
141
- await feePayload.hash()
142
- ], GeneratorIndex.COMBINED_PAYLOAD);
143
- }
@@ -1,22 +0,0 @@
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';
4
- /**
5
- * Holds information about how the fee for a transaction is to be paid.
6
- */
7
- export interface FeePaymentMethod {
8
- /** The asset used to pay the fee. */
9
- getAsset(): Promise<AztecAddress>;
10
- /**
11
- * Creates a function call to pay the fee in the given asset.
12
- * @param gasSettings - The gas limits and max fees.
13
- * @returns The function call to pay the fee.
14
- */
15
- getFunctionCalls(gasSettings: GasSettings): Promise<FunctionCall[]>;
16
- /**
17
- * The expected fee payer for this tx.
18
- * @param gasSettings - The gas limits and max fees.
19
- */
20
- getFeePayer(gasSettings: GasSettings): Promise<AztecAddress>;
21
- }
22
- //# sourceMappingURL=fee_payment_method.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/fee/fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAClC;;;;OAIG;IACH,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACpE;;;OAGG;IACH,WAAW,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9D"}