@aztec/aztec.js 0.0.1-commit.24de95ac → 0.0.1-commit.3469e52

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 (238) hide show
  1. package/dest/account/account.d.ts +26 -42
  2. package/dest/account/account.d.ts.map +1 -1
  3. package/dest/account/account.js +19 -47
  4. package/dest/account/account_contract.d.ts +9 -10
  5. package/dest/account/account_contract.d.ts.map +1 -1
  6. package/dest/account/account_with_secret_key.d.ts +20 -9
  7. package/dest/account/account_with_secret_key.d.ts.map +1 -1
  8. package/dest/account/account_with_secret_key.js +21 -4
  9. package/dest/account/index.d.ts +4 -3
  10. package/dest/account/index.d.ts.map +1 -1
  11. package/dest/account/index.js +2 -0
  12. package/dest/account/signerless_account.d.ts +7 -9
  13. package/dest/account/signerless_account.d.ts.map +1 -1
  14. package/dest/account/signerless_account.js +8 -11
  15. package/dest/api/abi.d.ts +1 -1
  16. package/dest/api/account.d.ts +3 -4
  17. package/dest/api/account.d.ts.map +1 -1
  18. package/dest/api/account.js +2 -3
  19. package/dest/api/addresses.d.ts +1 -1
  20. package/dest/api/authorization.d.ts +2 -2
  21. package/dest/api/authorization.d.ts.map +1 -1
  22. package/dest/api/authorization.js +1 -1
  23. package/dest/api/block.d.ts +2 -2
  24. package/dest/api/block.d.ts.map +1 -1
  25. package/dest/api/block.js +1 -1
  26. package/dest/api/contract.d.ts +3 -3
  27. package/dest/api/contract.d.ts.map +1 -1
  28. package/dest/api/contract.js +1 -1
  29. package/dest/api/crypto.d.ts +1 -1
  30. package/dest/api/deployment.d.ts +1 -1
  31. package/dest/api/eth_address.d.ts +1 -1
  32. package/dest/api/ethereum.d.ts +1 -1
  33. package/dest/api/events.d.ts +1 -1
  34. package/dest/api/fee.d.ts +1 -1
  35. package/dest/api/fee_testing.d.ts +1 -1
  36. package/dest/api/fields.d.ts +3 -2
  37. package/dest/api/fields.d.ts.map +1 -1
  38. package/dest/api/fields.js +2 -1
  39. package/dest/api/keys.d.ts +1 -1
  40. package/dest/api/log.d.ts +1 -1
  41. package/dest/api/messaging.d.ts +1 -1
  42. package/dest/api/node.d.ts +1 -1
  43. package/dest/api/note.d.ts +2 -2
  44. package/dest/api/note.d.ts.map +1 -1
  45. package/dest/api/note.js +1 -1
  46. package/dest/api/protocol.d.ts +7 -1
  47. package/dest/api/protocol.d.ts.map +1 -1
  48. package/dest/api/protocol.js +6 -0
  49. package/dest/api/trees.d.ts +1 -1
  50. package/dest/api/tx.d.ts +2 -2
  51. package/dest/api/tx.d.ts.map +1 -1
  52. package/dest/api/tx.js +1 -1
  53. package/dest/api/utils.d.ts +1 -1
  54. package/dest/api/wallet.d.ts +2 -3
  55. package/dest/api/wallet.d.ts.map +1 -1
  56. package/dest/api/wallet.js +1 -2
  57. package/dest/authorization/call_authorization_request.d.ts +2 -2
  58. package/dest/authorization/call_authorization_request.d.ts.map +1 -1
  59. package/dest/contract/base_contract_interaction.d.ts +2 -3
  60. package/dest/contract/base_contract_interaction.d.ts.map +1 -1
  61. package/dest/contract/base_contract_interaction.js +1 -1
  62. package/dest/contract/batch_call.d.ts +8 -9
  63. package/dest/contract/batch_call.d.ts.map +1 -1
  64. package/dest/contract/batch_call.js +54 -34
  65. package/dest/contract/checker.d.ts +1 -1
  66. package/dest/contract/contract.d.ts +2 -2
  67. package/dest/contract/contract.d.ts.map +1 -1
  68. package/dest/contract/contract.js +4 -5
  69. package/dest/contract/contract_base.d.ts +6 -10
  70. package/dest/contract/contract_base.d.ts.map +1 -1
  71. package/dest/contract/contract_base.js +5 -12
  72. package/dest/contract/contract_function_interaction.d.ts +3 -3
  73. package/dest/contract/contract_function_interaction.d.ts.map +1 -1
  74. package/dest/contract/contract_function_interaction.js +9 -6
  75. package/dest/contract/deploy_method.d.ts +9 -8
  76. package/dest/contract/deploy_method.d.ts.map +1 -1
  77. package/dest/contract/deploy_method.js +14 -11
  78. package/dest/contract/deploy_sent_tx.d.ts +12 -7
  79. package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
  80. package/dest/contract/deploy_sent_tx.js +10 -4
  81. package/dest/contract/get_gas_limits.d.ts +1 -1
  82. package/dest/contract/interaction_options.d.ts +4 -4
  83. package/dest/contract/interaction_options.d.ts.map +1 -1
  84. package/dest/contract/interaction_options.js +4 -10
  85. package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
  86. package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
  87. package/dest/contract/protocol_contracts/auth-registry.js +976 -0
  88. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
  89. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  90. package/dest/contract/protocol_contracts/contract-class-registry.js +797 -0
  91. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
  92. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  93. package/dest/contract/protocol_contracts/contract-instance-registry.js +871 -0
  94. package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
  95. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  96. package/dest/contract/protocol_contracts/fee-juice.js +840 -0
  97. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
  98. package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
  99. package/dest/contract/protocol_contracts/multi-call-entrypoint.js +576 -0
  100. package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
  101. package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
  102. package/dest/contract/protocol_contracts/public-checks.js +592 -0
  103. package/dest/contract/sent_tx.d.ts +2 -3
  104. package/dest/contract/sent_tx.d.ts.map +1 -1
  105. package/dest/contract/sent_tx.js +1 -1
  106. package/dest/contract/wait_for_proven.d.ts +2 -2
  107. package/dest/contract/wait_for_proven.d.ts.map +1 -1
  108. package/dest/deployment/broadcast_function.d.ts +1 -1
  109. package/dest/deployment/broadcast_function.js +4 -4
  110. package/dest/deployment/contract_deployer.d.ts +1 -1
  111. package/dest/deployment/contract_deployer.d.ts.map +1 -1
  112. package/dest/deployment/contract_deployer.js +1 -1
  113. package/dest/deployment/publish_class.d.ts +1 -1
  114. package/dest/deployment/publish_class.js +3 -3
  115. package/dest/deployment/publish_instance.d.ts +2 -2
  116. package/dest/deployment/publish_instance.d.ts.map +1 -1
  117. package/dest/deployment/publish_instance.js +3 -3
  118. package/dest/ethereum/portal_manager.d.ts +7 -6
  119. package/dest/ethereum/portal_manager.d.ts.map +1 -1
  120. package/dest/ethereum/portal_manager.js +48 -22
  121. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
  122. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
  123. package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
  124. package/dest/fee/fee_payment_method.d.ts +2 -2
  125. package/dest/fee/fee_payment_method.d.ts.map +1 -1
  126. package/dest/fee/private_fee_payment_method.d.ts +2 -2
  127. package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
  128. package/dest/fee/private_fee_payment_method.js +4 -4
  129. package/dest/fee/public_fee_payment_method.d.ts +2 -2
  130. package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
  131. package/dest/fee/public_fee_payment_method.js +4 -4
  132. package/dest/fee/sponsored_fee_payment.d.ts +2 -2
  133. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
  134. package/dest/fee/sponsored_fee_payment.js +2 -2
  135. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  136. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  137. package/dest/scripts/generate_protocol_contract_types.js +120 -0
  138. package/dest/utils/abi_types.d.ts +2 -2
  139. package/dest/utils/abi_types.d.ts.map +1 -1
  140. package/dest/utils/authwit.d.ts +9 -7
  141. package/dest/utils/authwit.d.ts.map +1 -1
  142. package/dest/utils/authwit.js +25 -14
  143. package/dest/utils/cross_chain.d.ts +2 -2
  144. package/dest/utils/cross_chain.d.ts.map +1 -1
  145. package/dest/utils/fee_juice.d.ts +2 -2
  146. package/dest/utils/fee_juice.js +2 -2
  147. package/dest/utils/field_compressed_string.d.ts +1 -1
  148. package/dest/utils/field_compressed_string.d.ts.map +1 -1
  149. package/dest/utils/field_compressed_string.js +1 -1
  150. package/dest/utils/node.d.ts +2 -2
  151. package/dest/utils/node.d.ts.map +1 -1
  152. package/dest/utils/pub_key.d.ts +2 -2
  153. package/dest/utils/pub_key.d.ts.map +1 -1
  154. package/dest/utils/pub_key.js +1 -1
  155. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +6 -9
  156. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
  157. package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
  158. package/dest/wallet/account_manager.d.ts +3 -9
  159. package/dest/wallet/account_manager.d.ts.map +1 -1
  160. package/dest/wallet/account_manager.js +6 -12
  161. package/dest/wallet/deploy_account_method.d.ts +20 -6
  162. package/dest/wallet/deploy_account_method.d.ts.map +1 -1
  163. package/dest/wallet/deploy_account_method.js +9 -7
  164. package/dest/wallet/index.d.ts +1 -2
  165. package/dest/wallet/index.d.ts.map +1 -1
  166. package/dest/wallet/index.js +0 -1
  167. package/dest/wallet/wallet.d.ts +273 -1499
  168. package/dest/wallet/wallet.d.ts.map +1 -1
  169. package/dest/wallet/wallet.js +71 -114
  170. package/package.json +16 -13
  171. package/src/account/account.ts +35 -60
  172. package/src/account/account_contract.ts +7 -8
  173. package/src/account/account_with_secret_key.ts +34 -9
  174. package/src/account/index.ts +3 -2
  175. package/src/account/signerless_account.ts +15 -15
  176. package/src/api/account.ts +10 -3
  177. package/src/api/authorization.ts +1 -0
  178. package/src/api/block.ts +1 -1
  179. package/src/api/contract.ts +2 -1
  180. package/src/api/fields.ts +2 -1
  181. package/src/api/note.ts +1 -1
  182. package/src/api/protocol.ts +7 -0
  183. package/src/api/tx.ts +2 -0
  184. package/src/api/wallet.ts +5 -9
  185. package/src/authorization/call_authorization_request.ts +1 -1
  186. package/src/contract/base_contract_interaction.ts +2 -3
  187. package/src/contract/batch_call.ts +67 -48
  188. package/src/contract/contract.ts +7 -5
  189. package/src/contract/contract_base.ts +5 -15
  190. package/src/contract/contract_function_interaction.ts +10 -11
  191. package/src/contract/deploy_method.ts +20 -18
  192. package/src/contract/deploy_sent_tx.ts +17 -10
  193. package/src/contract/interaction_options.ts +4 -10
  194. package/src/contract/protocol_contracts/auth-registry.ts +554 -0
  195. package/src/contract/protocol_contracts/contract-class-registry.ts +442 -0
  196. package/src/contract/protocol_contracts/contract-instance-registry.ts +502 -0
  197. package/src/contract/protocol_contracts/fee-juice.ts +466 -0
  198. package/src/contract/protocol_contracts/multi-call-entrypoint.ts +338 -0
  199. package/src/contract/protocol_contracts/public-checks.ts +324 -0
  200. package/src/contract/sent_tx.ts +2 -3
  201. package/src/deployment/broadcast_function.ts +4 -4
  202. package/src/deployment/contract_deployer.ts +3 -2
  203. package/src/deployment/publish_class.ts +3 -3
  204. package/src/deployment/publish_instance.ts +3 -6
  205. package/src/ethereum/portal_manager.ts +65 -34
  206. package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
  207. package/src/fee/fee_payment_method.ts +1 -1
  208. package/src/fee/private_fee_payment_method.ts +5 -3
  209. package/src/fee/public_fee_payment_method.ts +5 -3
  210. package/src/fee/sponsored_fee_payment.ts +3 -1
  211. package/src/scripts/generate_protocol_contract_types.ts +150 -0
  212. package/src/utils/abi_types.ts +1 -1
  213. package/src/utils/authwit.ts +24 -18
  214. package/src/utils/cross_chain.ts +1 -1
  215. package/src/utils/fee_juice.ts +2 -2
  216. package/src/utils/field_compressed_string.ts +1 -1
  217. package/src/utils/pub_key.ts +2 -2
  218. package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
  219. package/src/wallet/account_manager.ts +7 -15
  220. package/src/wallet/deploy_account_method.ts +23 -13
  221. package/src/wallet/index.ts +0 -1
  222. package/src/wallet/wallet.ts +177 -142
  223. package/dest/account/interface.d.ts +0 -19
  224. package/dest/account/interface.d.ts.map +0 -1
  225. package/dest/account/interface.js +0 -5
  226. package/dest/contract/protocol_contracts.d.ts +0 -9
  227. package/dest/contract/protocol_contracts.d.ts.map +0 -1
  228. package/dest/contract/protocol_contracts.js +0 -26
  229. package/dest/contract/unsafe_contract.d.ts +0 -15
  230. package/dest/contract/unsafe_contract.d.ts.map +0 -1
  231. package/dest/contract/unsafe_contract.js +0 -6
  232. package/dest/wallet/base_wallet.d.ts +0 -91
  233. package/dest/wallet/base_wallet.d.ts.map +0 -1
  234. package/dest/wallet/base_wallet.js +0 -238
  235. package/src/account/interface.ts +0 -25
  236. package/src/contract/protocol_contracts.ts +0 -35
  237. package/src/contract/unsafe_contract.ts +0 -19
  238. package/src/wallet/base_wallet.ts +0 -350
@@ -1,5 +1,5 @@
1
1
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
4
4
  import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
5
5
  import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
@@ -22,7 +22,7 @@ export type IntentInnerHash = {
22
22
  /** The consumer */
23
23
  consumer: AztecAddress;
24
24
  /** The action to approve */
25
- innerHash: Buffer<ArrayBuffer> | Fr;
25
+ innerHash: Fr;
26
26
  };
27
27
 
28
28
  /** Intent with a call */
@@ -42,8 +42,8 @@ export type ContractFunctionInteractionCallIntent = {
42
42
  };
43
43
 
44
44
  /** Identifies ContractFunctionInteractionCallIntents */
45
- function isContractFunctionIntractionCallIntent(
46
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
45
+ export function isContractFunctionInteractionCallIntent(
46
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
47
47
  ): messageHashOrIntent is ContractFunctionInteractionCallIntent {
48
48
  return (
49
49
  'caller' in messageHashOrIntent &&
@@ -81,7 +81,7 @@ export const computeAuthWitMessageHash = async (
81
81
  const version = metadata.version;
82
82
 
83
83
  if ('caller' in intent) {
84
- const call = isContractFunctionIntractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
84
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
85
85
  return computeOuterAuthWitHash(
86
86
  call.to,
87
87
  chainId,
@@ -102,14 +102,12 @@ export const computeAuthWitMessageHash = async (
102
102
  * @returns The message hash for the intent
103
103
  */
104
104
  export async function getMessageHashFromIntent(
105
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
105
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
106
106
  chainInfo: ChainInfo,
107
107
  ) {
108
108
  let messageHash: Fr;
109
109
  const { chainId, version } = chainInfo;
110
- if (Buffer.isBuffer(messageHashOrIntent)) {
111
- messageHash = Fr.fromBuffer(messageHashOrIntent);
112
- } else if (messageHashOrIntent instanceof Fr) {
110
+ if (messageHashOrIntent instanceof Fr) {
113
111
  messageHash = messageHashOrIntent;
114
112
  } else {
115
113
  messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
@@ -156,12 +154,9 @@ export async function lookupValidity(
156
154
  }> {
157
155
  let innerHash, consumer;
158
156
  if ('caller' in intent) {
159
- const call = isContractFunctionIntractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
157
+ const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
160
158
  innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
161
159
  consumer = call.to;
162
- } else if (Buffer.isBuffer(intent.innerHash)) {
163
- innerHash = Fr.fromBuffer(intent.innerHash);
164
- consumer = intent.consumer;
165
160
  } else {
166
161
  ({ innerHash, consumer } = intent);
167
162
  }
@@ -174,9 +169,20 @@ export async function lookupValidity(
174
169
  name: 'lookup_validity',
175
170
  isInitializer: false,
176
171
  functionType: FunctionType.UTILITY,
177
- isInternal: false,
172
+ isOnlySelf: false,
178
173
  isStatic: false,
179
- parameters: [{ name: 'message_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility }],
174
+ parameters: [
175
+ {
176
+ name: 'consumer',
177
+ type: {
178
+ fields: [{ name: 'inner', type: { kind: 'field' } }],
179
+ kind: 'struct',
180
+ path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
181
+ },
182
+ visibility: 'private' as ABIParameterVisibility,
183
+ },
184
+ { name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
185
+ ],
180
186
  returnTypes: [{ kind: 'boolean' }],
181
187
  errorTypes: {},
182
188
  } as FunctionAbi;
@@ -194,7 +200,7 @@ export async function lookupValidity(
194
200
  name: 'utility_is_consumable',
195
201
  isInitializer: false,
196
202
  functionType: FunctionType.UTILITY,
197
- isInternal: false,
203
+ isOnlySelf: false,
198
204
  isStatic: false,
199
205
  parameters: [
200
206
  {
@@ -240,7 +246,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
240
246
  static async create(
241
247
  wallet: Wallet,
242
248
  from: AztecAddress,
243
- messageHashOrIntent: Fr | Buffer | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
249
+ messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
244
250
  authorized: boolean,
245
251
  ) {
246
252
  const chainInfo = await wallet.getChainInfo();
@@ -291,7 +297,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
291
297
  name: 'set_authorized',
292
298
  isInitializer: false,
293
299
  functionType: FunctionType.PUBLIC,
294
- isInternal: true,
300
+ isOnlySelf: true,
295
301
  isStatic: false,
296
302
  parameters: [
297
303
  {
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { retryUntil } from '@aztec/foundation/retry';
3
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
4
4
 
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
@@ -6,7 +6,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
6
6
 
7
7
  /**
8
8
  * Returns the owner's fee juice balance.
9
- * Note: This is used only e2e_sandbox_example test. TODO: Consider nuking.
9
+ * Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
10
10
  */
11
11
  export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
12
12
  const slot = await deriveStorageSlotInMap(new Fr(1), owner);
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
 
3
3
  /**
4
4
  * The representation of a FieldCompressedString in aztec.nr
@@ -1,5 +1,5 @@
1
- import { Grumpkin } from '@aztec/foundation/crypto';
2
- import type { GrumpkinScalar } from '@aztec/foundation/fields';
1
+ import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
2
+ import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
3
3
  import type { PublicKey } from '@aztec/stdlib/keys';
4
4
 
5
5
  /**
@@ -1,20 +1,11 @@
1
1
  import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
2
- import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
3
- import { ExecutionPayload } from '@aztec/entrypoints/payload';
4
2
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
- import {
6
- type ContractArtifact,
7
- type FunctionArtifact,
8
- FunctionCall,
9
- FunctionSelector,
10
- encodeArguments,
11
- getFunctionArtifactByName,
12
- } from '@aztec/stdlib/abi';
13
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
14
4
  import type { GasSettings } from '@aztec/stdlib/gas';
5
+ import { ExecutionPayload } from '@aztec/stdlib/tx';
15
6
 
7
+ import type { Account } from '../account/account.js';
16
8
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
17
- import type { Wallet } from './index.js';
18
9
 
19
10
  /**
20
11
  * Fee payment method that allows an account contract to pay for its own deployment
@@ -33,11 +24,9 @@ import type { Wallet } from './index.js';
33
24
  */
34
25
  export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
35
26
  constructor(
36
- private wallet: Wallet,
37
- private artifact: ContractArtifact,
38
- private feePaymentNameOrArtifact: string | FunctionArtifact,
39
- private accountAddress: AztecAddress,
27
+ private account: Account,
40
28
  private paymentMethod?: FeePaymentMethod,
29
+ private feeEntrypointOptions?: any,
41
30
  ) {}
42
31
 
43
32
  getAsset(): Promise<AztecAddress> {
@@ -45,58 +34,38 @@ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
45
34
  }
46
35
 
47
36
  async getExecutionPayload(): Promise<ExecutionPayload> {
48
- // Get the execution payload for the fee, it includes the calls and potentially authWitnesses
49
- // It can be empty because the account might attempt to pay for the tx fee using its own
50
- // FeeJuice balance
51
- const { calls: feeCalls, authWitnesses: feeAuthwitnesses } =
52
- (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
53
- // Encode the calls for the fee
54
- const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.accountAddress;
55
- const isFeePayer = feePayer.equals(this.accountAddress);
56
- let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
57
- if (isFeePayer) {
58
- // If the account is the fee payer, and the incoming fee payload has calls
59
- // it can only be FeeJuicePaymentMethodWithClaim
60
- // If the payload has no calls, it's paying using
61
- // its own fee juice balance
62
- accountFeePaymentMethodOptions =
63
- feeCalls.length === 0
64
- ? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
65
- : AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
66
- }
67
- const feeEncodedCalls = await EncodedAppEntrypointCalls.create(feeCalls);
37
+ // Get the execution payload for the fee
38
+ const innerPayload = (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
68
39
 
69
- // Get the entrypoint args
70
- const args = [feeEncodedCalls, accountFeePaymentMethodOptions, false];
71
- const feePaymentArtifact =
72
- typeof this.feePaymentNameOrArtifact === 'string'
73
- ? getFunctionArtifactByName(this.artifact, this.feePaymentNameOrArtifact)
74
- : this.feePaymentNameOrArtifact;
40
+ // If no fee entrypoint options were provided, compute them based on the wrapped payment method
41
+ // This mimics how the actual account contract works when invoked directly:
42
+ // - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
43
+ // only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
44
+ // - If we are the fee payer, but there are no calls, then we assume the account already has
45
+ // fee juice and can pay directly with PREEXISTING_FEE_JUICE
46
+ // - If we are not the fee payer, then EXTERNAL is used
47
+ let options = this.feeEntrypointOptions;
48
+ if (!options) {
49
+ const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.account.getAddress();
50
+ const isFeePayer = feePayer.equals(this.account.getAddress());
75
51
 
76
- const entrypointCall = new FunctionCall(
77
- feePaymentArtifact.name,
78
- this.accountAddress,
79
- await FunctionSelector.fromNameAndParameters(feePaymentArtifact.name, feePaymentArtifact.parameters),
80
- feePaymentArtifact.functionType,
81
- false /** hideMsgSender -- set to `false`, because it's not applicable for an entrypoint function (only for enqueued public calls) */,
82
- feePaymentArtifact.isStatic,
83
- encodeArguments(feePaymentArtifact, args),
84
- feePaymentArtifact.returnTypes,
85
- );
52
+ let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
53
+ if (isFeePayer) {
54
+ accountFeePaymentMethodOptions =
55
+ innerPayload.calls.length === 0
56
+ ? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
57
+ : AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
58
+ }
86
59
 
87
- // Compute the authwitness required to verify the combined payload
88
- const payloadAuthWitness = await this.wallet.createAuthWit(this.accountAddress, await feeEncodedCalls.hash());
60
+ options = { feePaymentMethodOptions: accountFeePaymentMethodOptions };
61
+ }
89
62
 
90
- return new ExecutionPayload(
91
- [entrypointCall],
92
- [payloadAuthWitness, ...feeAuthwitnesses],
93
- [],
94
- feeEncodedCalls.hashedArguments,
95
- );
63
+ // Use the generic wrapping mechanism from the account interface
64
+ return this.account.wrapExecutionPayload(innerPayload, options);
96
65
  }
97
66
 
98
67
  getFeePayer(): Promise<AztecAddress> {
99
- return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.accountAddress);
68
+ return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
100
69
  }
101
70
 
102
71
  getGasSettings(): GasSettings | undefined {
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import {
3
3
  CompleteAddress,
4
4
  type ContractInstanceWithAddress,
@@ -9,7 +9,6 @@ import { deriveKeys } from '@aztec/stdlib/keys';
9
9
  import type { AccountContract } from '../account/account_contract.js';
10
10
  import { AccountWithSecretKey } from '../account/account_with_secret_key.js';
11
11
  import type { Salt } from '../account/index.js';
12
- import type { AccountInterface } from '../account/interface.js';
13
12
  import { Contract } from '../contract/contract.js';
14
13
  import { DeployAccountMethod } from './deploy_account_method.js';
15
14
  import type { Wallet } from './wallet.js';
@@ -58,16 +57,6 @@ export class AccountManager {
58
57
  return this.getPublicKeys().hash();
59
58
  }
60
59
 
61
- /**
62
- * Returns the entrypoint for this account as defined by its account contract.
63
- * @returns An entrypoint.
64
- */
65
- public async getAccountInterface(): Promise<AccountInterface> {
66
- const chainInfo = await this.wallet.getChainInfo();
67
- const completeAddress = await this.getCompleteAddress();
68
- return this.accountContract.getInterface(completeAddress, chainInfo);
69
- }
70
-
71
60
  /**
72
61
  * Gets the calculated complete address associated with this account.
73
62
  * Does not require the account to have been published for public execution.
@@ -103,8 +92,9 @@ export class AccountManager {
103
92
  * @returns A Wallet instance.
104
93
  */
105
94
  public async getAccount(): Promise<AccountWithSecretKey> {
106
- const accountInterface = await this.getAccountInterface();
107
- return new AccountWithSecretKey(accountInterface, this.secretKey, this.salt);
95
+ const completeAddress = await this.getCompleteAddress();
96
+ const account = this.accountContract.getAccount(completeAddress);
97
+ return new AccountWithSecretKey(account, this.secretKey, this.salt);
108
98
  }
109
99
 
110
100
  /**
@@ -134,12 +124,14 @@ export class AccountManager {
134
124
  constructorArgs: undefined,
135
125
  };
136
126
 
127
+ const account = await this.getAccount();
137
128
  return new DeployAccountMethod(
138
129
  this.getPublicKeys(),
139
130
  this.wallet,
140
131
  artifact,
141
- address => Contract.at(address, artifact, this.wallet),
132
+ instance => Contract.at(instance.address, artifact, this.wallet),
142
133
  new Fr(this.salt),
134
+ account,
143
135
  constructorArgs,
144
136
  constructorName,
145
137
  );
@@ -1,9 +1,11 @@
1
- import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
2
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
4
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
5
5
  import type { PublicKeys } from '@aztec/stdlib/keys';
6
+ import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
6
7
 
8
+ import type { Account } from '../account/account.js';
7
9
  import type { Contract } from '../contract/contract.js';
8
10
  import type { ContractBase } from '../contract/contract_base.js';
9
11
  import {
@@ -12,15 +14,27 @@ import {
12
14
  type RequestDeployOptions,
13
15
  type SimulateDeployOptions,
14
16
  } from '../contract/deploy_method.js';
17
+ import type { FeePaymentMethodOption } from '../contract/interaction_options.js';
15
18
  import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
16
19
  import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
17
20
  import type { Wallet } from './index.js';
18
21
 
22
+ /**
23
+ * Extended fee payment method option for account deployments that includes entrypoint wrapping options
24
+ */
25
+ export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
26
+ /** Optional entrypoint-specific options for wrapping execution payloads */
27
+ feeEntrypointOptions?: unknown;
28
+ };
29
+
19
30
  /**
20
31
  * The configuration options for the request method. Omits the contractAddressSalt, since
21
32
  * for account contracts that is fixed in the constructor
22
33
  */
23
- export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'>;
34
+ export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
35
+ /** Fee options specific to account deployment */
36
+ fee?: DeployAccountFeePaymentMethodOption;
37
+ };
24
38
 
25
39
  /**
26
40
  * The configuration options for the send/prove methods. Omits:
@@ -44,8 +58,9 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
44
58
  publicKeys: PublicKeys,
45
59
  wallet: Wallet,
46
60
  artifact: ContractArtifact,
47
- postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
61
+ postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
48
62
  private salt: Fr,
63
+ private account: Account,
49
64
  args: any[] = [],
50
65
  constructorNameOrArtifact?: string | FunctionArtifact,
51
66
  ) {
@@ -60,19 +75,14 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
60
75
  * For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
61
76
  *
62
77
  * @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
78
+ * @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
63
79
  * @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
64
80
  */
65
- private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
81
+ private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod, feeEntrypointOptions?: any) {
66
82
  if (!this.address) {
67
83
  throw new Error('Instance is not yet constructed. This is a bug!');
68
84
  }
69
- return new AccountEntrypointMetaPaymentMethod(
70
- this.wallet,
71
- this.artifact,
72
- 'entrypoint',
73
- this.address,
74
- originalPaymentMethod,
75
- );
85
+ return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
76
86
  }
77
87
 
78
88
  /**
@@ -96,7 +106,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
96
106
  const executionPayloads = [deploymentExecutionPayload];
97
107
  // If this is a self-deployment, manage the fee accordingly
98
108
  if (opts?.deployer?.equals(AztecAddress.ZERO)) {
99
- const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
109
+ const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
100
110
  const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
101
111
  // Notice they are reversed (fee payment usually goes first):
102
112
  // this is because we need to construct the contract BEFORE it can pay for its own fee
@@ -1,3 +1,2 @@
1
1
  export * from './wallet.js';
2
- export * from './base_wallet.js';
3
2
  export * from './account_manager.js';