@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,27 +1,20 @@
1
1
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
2
- import type { ExecutionPayload } from '@aztec/entrypoints/payload';
3
- import type { Fr } from '@aztec/foundation/fields';
2
+ import { BlockNumber, BlockNumberPositiveSchema } from '@aztec/foundation/branded-types';
3
+ import type { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import {
5
+ type AbiDecoded,
5
6
  AbiTypeSchema,
6
7
  type ContractArtifact,
7
8
  ContractArtifactSchema,
8
9
  type EventMetadataDefinition,
9
- FunctionAbiSchema,
10
+ type FunctionCall,
10
11
  FunctionType,
11
12
  } from '@aztec/stdlib/abi';
12
13
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
13
14
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
14
- import {
15
- type ContractClassMetadata,
16
- ContractClassWithIdSchema,
17
- type ContractInstanceWithAddress,
18
- ContractInstanceWithAddressSchema,
19
- type ContractInstantiationData,
20
- type ContractMetadata,
21
- } from '@aztec/stdlib/contract';
15
+ import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
22
16
  import { Gas } from '@aztec/stdlib/gas';
23
- import { PublicKeys } from '@aztec/stdlib/keys';
24
- import { AbiDecodedSchema, type ApiSchemaFor, type ZodFor, optional, schemas } from '@aztec/stdlib/schemas';
17
+ import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
25
18
  import {
26
19
  Capsule,
27
20
  HashedValues,
@@ -30,11 +23,12 @@ import {
30
23
  TxReceipt,
31
24
  TxSimulationResult,
32
25
  UtilitySimulationResult,
26
+ inTxSchema,
33
27
  } from '@aztec/stdlib/tx';
28
+ import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
34
29
 
35
30
  import { z } from 'zod';
36
31
 
37
- import type { Contract } from '../contract/contract.js';
38
32
  import type {
39
33
  FeeEstimationOptions,
40
34
  GasSettingsOption,
@@ -58,80 +52,71 @@ export type Aliased<T> = {
58
52
  item: T;
59
53
  };
60
54
 
61
- /**
62
- * A reduced representation of a Contract, only including its instance and artifact
63
- */
64
- export type ContractInstanceAndArtifact = Pick<Contract, 'artifact' | 'instance'>;
65
-
66
- /**
67
- * Options that can be provided to the wallet for configuration of the fee payment.
68
- */
69
- export type UserFeeOptions = {
70
- /**
71
- * Informs the wallet that the crafted tx already contains the necessary calls to pay for its fee
72
- * and who is paying
73
- */
74
- embeddedPaymentMethodFeePayer?: AztecAddress;
75
- } & GasSettingsOption;
76
-
77
55
  /**
78
56
  * Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
79
- * a simplified version that only hints at the wallet wether the interaction contains a
57
+ * a simplified version that only hints at the wallet whether the interaction contains a
80
58
  * fee payment method or not
81
59
  */
82
60
  export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
83
61
  /** The fee options */
84
- fee?: UserFeeOptions & FeeEstimationOptions;
62
+ fee?: GasSettingsOption & FeeEstimationOptions;
85
63
  };
86
64
 
87
65
  /**
88
66
  * Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
89
- * a simplified version that only hints at the wallet wether the interaction contains a
67
+ * a simplified version that only hints at the wallet whether the interaction contains a
90
68
  * fee payment method or not
91
69
  */
92
70
  export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
93
71
  /** The fee options */
94
- fee?: UserFeeOptions;
72
+ fee?: GasSettingsOption;
95
73
  };
96
74
 
97
75
  /**
98
76
  * Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
99
- * a simplified version that only hints at the wallet wether the interaction contains a
77
+ * a simplified version that only hints at the wallet whether the interaction contains a
100
78
  * fee payment method or not
101
79
  */
102
80
  export type SendOptions = Omit<SendInteractionOptions, 'fee'> & {
103
81
  /** The fee options */
104
- fee?: UserFeeOptions;
82
+ fee?: GasSettingsOption;
105
83
  };
106
84
 
107
85
  /**
108
- * Helper type that represents all methods that can be batched.
86
+ * Helper type that represents all methods that can be batched (all methods except batch itself).
109
87
  */
110
- export type BatchableMethods = Pick<Wallet, 'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility'>;
88
+ export type BatchableMethods = Omit<Wallet, 'batch'>;
111
89
 
112
90
  /**
113
- * From the batchable methods, we create a type that represents a method call with its name and arguments.
114
- * This is what the wallet will accept as arguments to the `batch` method.
91
+ * A method call with its name and arguments.
115
92
  */
116
- export type BatchedMethod<T extends keyof BatchableMethods> = {
93
+ type BatchedMethodInternal<T extends keyof BatchableMethods> = {
117
94
  /** The method name */
118
95
  name: T;
119
96
  /** The method arguments */
120
97
  args: Parameters<BatchableMethods[T]>;
121
98
  };
122
99
 
100
+ /**
101
+ * Union of all possible batched method calls.
102
+ * This ensures type safety: the `args` must match the specific `name`.
103
+ */
104
+ export type BatchedMethod = {
105
+ [K in keyof BatchableMethods]: BatchedMethodInternal<K>;
106
+ }[keyof BatchableMethods];
107
+
123
108
  /**
124
109
  * Helper type to extract the return type of a batched method
125
110
  */
126
111
  export type BatchedMethodResult<T> =
127
- T extends BatchedMethod<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
112
+ T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
128
113
 
129
114
  /**
130
115
  * Wrapper type for batch results that includes the method name for discriminated union deserialization.
131
116
  * Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
132
117
  * when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
133
118
  */
134
- export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMethods>> = {
119
+ export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
135
120
  /** The method name */
136
121
  name: T['name'];
137
122
  /** The method result */
@@ -141,66 +126,96 @@ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMe
141
126
  /**
142
127
  * Maps a tuple of BatchedMethod to a tuple of their wrapped return types
143
128
  */
144
- export type BatchResults<T extends readonly BatchedMethod<keyof BatchableMethods>[]> = {
129
+ export type BatchResults<T extends readonly BatchedMethod[]> = {
145
130
  [K in keyof T]: BatchedMethodResultWrapper<T[K]>;
146
131
  };
147
132
 
133
+ /**
134
+ * Filter options when querying private events.
135
+ */
136
+ export type PrivateEventFilter = {
137
+ /** The address of the contract that emitted the events. */
138
+ contractAddress: AztecAddress;
139
+ /** Addresses of accounts that are in scope for this filter. */
140
+ scopes: AztecAddress[];
141
+ /** Transaction in which the events were emitted. */
142
+ txHash?: TxHash;
143
+ /** The block number from which to start fetching events (inclusive).
144
+ * Optional. If provided, it must be greater or equal than 1.
145
+ * Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
146
+ * */
147
+ fromBlock?: BlockNumber;
148
+ /** The block number until which to fetch logs (not inclusive).
149
+ * Optional. If provided, it must be greater than fromBlock.
150
+ * Defaults to the latest known block to PXE + 1.
151
+ */
152
+ toBlock?: BlockNumber;
153
+ };
154
+
155
+ /**
156
+ * An ABI decoded private event with associated metadata.
157
+ */
158
+ export type PrivateEvent<T> = {
159
+ /** The ABI decoded event */
160
+ event: T;
161
+ /** Metadata describing event context information such as tx and block */
162
+ metadata: InTx;
163
+ };
164
+
165
+ /**
166
+ * Contract metadata including deployment and registration status.
167
+ */
168
+ export type ContractMetadata = {
169
+ /** The contract instance */
170
+ instance?: ContractInstanceWithAddress;
171
+ /** Whether the contract has been initialized (init nullifier exists) */
172
+ isContractInitialized: boolean;
173
+ /** Whether the contract instance is publicly deployed on-chain */
174
+ isContractPublished: boolean;
175
+ /** Whether the contract has been updated to a different class */
176
+ isContractUpdated: boolean;
177
+ /** The updated contract class ID if the contract has been updated */
178
+ updatedContractClassId?: Fr | undefined;
179
+ };
180
+
181
+ /**
182
+ * Contract class metadata.
183
+ */
184
+ export type ContractClassMetadata = {
185
+ /** Whether the artifact is registered in the wallet */
186
+ isArtifactRegistered: boolean;
187
+ /** Whether the contract class is publicly registered on-chain */
188
+ isContractClassPubliclyRegistered: boolean;
189
+ };
190
+
148
191
  /**
149
192
  * The wallet interface.
150
193
  */
151
194
  export type Wallet = {
152
- getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
153
- getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
154
195
  getPrivateEvents<T>(
155
- contractAddress: AztecAddress,
156
196
  eventMetadata: EventMetadataDefinition,
157
- from: number,
158
- numBlocks: number,
159
- recipients: AztecAddress[],
160
- ): Promise<T[]>;
197
+ eventFilter: PrivateEventFilter,
198
+ ): Promise<PrivateEvent<T>[]>;
161
199
  getChainInfo(): Promise<ChainInfo>;
162
200
  getTxReceipt(txHash: TxHash): Promise<TxReceipt>;
201
+ getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
202
+ getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
163
203
  registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
164
204
  getAddressBook(): Promise<Aliased<AztecAddress>[]>;
165
205
  getAccounts(): Promise<Aliased<AztecAddress>[]>;
166
206
  registerContract(
167
- instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
168
- ): Promise<ContractInstanceWithAddress>;
169
- // Overloaded definition to avoid zod issues
170
- registerContract(
171
- instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
172
- artifact: ContractArtifact,
173
- ): Promise<ContractInstanceWithAddress>;
174
- registerContract(
175
- instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
176
- artifact: ContractArtifact | undefined,
177
- secretKey: Fr | undefined,
207
+ instance: ContractInstanceWithAddress,
208
+ artifact?: ContractArtifact,
209
+ secretKey?: Fr,
178
210
  ): Promise<ContractInstanceWithAddress>;
179
211
  simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
180
- simulateUtility(
181
- functionName: string,
182
- args: any[],
183
- to: AztecAddress,
184
- authwits?: AuthWitness[],
185
- ): Promise<UtilitySimulationResult>;
212
+ simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
186
213
  profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
187
214
  sendTx(exec: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
188
- createAuthWit(
189
- from: AztecAddress,
190
- messageHashOrIntent: Fr | Buffer<ArrayBuffer> | IntentInnerHash | CallIntent,
191
- ): Promise<AuthWitness>;
192
- batch<const T extends readonly BatchedMethod<keyof BatchableMethods>[]>(methods: T): Promise<BatchResults<T>>;
215
+ createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
216
+ batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
193
217
  };
194
218
 
195
- export const ContractInstantiationDataSchema = z.object({
196
- constructorArtifact: optional(z.union([FunctionAbiSchema, z.string()])),
197
- constructorArgs: optional(z.array(z.any())),
198
- skipArgsDecoding: optional(z.boolean()),
199
- salt: schemas.Fr,
200
- publicKeys: optional(PublicKeys.schema),
201
- deployer: optional(schemas.AztecAddress),
202
- });
203
-
204
219
  export const FunctionCallSchema = z.object({
205
220
  name: z.string(),
206
221
  to: schemas.AztecAddress,
@@ -217,9 +232,10 @@ export const ExecutionPayloadSchema = z.object({
217
232
  authWitnesses: z.array(AuthWitness.schema),
218
233
  capsules: z.array(Capsule.schema),
219
234
  extraHashedArgs: z.array(HashedValues.schema),
235
+ feePayer: optional(schemas.AztecAddress),
220
236
  });
221
237
 
222
- export const UserFeeOptionsSchema = z.object({
238
+ export const GasSettingsOptionSchema = z.object({
223
239
  gasSettings: optional(
224
240
  z.object({
225
241
  gasLimits: optional(Gas.schema),
@@ -228,10 +244,9 @@ export const UserFeeOptionsSchema = z.object({
228
244
  maxPriorityFeePerGas: optional(z.object({ feePerDaGas: schemas.BigInt, feePerL2Gas: schemas.BigInt })),
229
245
  }),
230
246
  ),
231
- embeddedPaymentMethodFeePayer: optional(schemas.AztecAddress),
232
247
  });
233
248
 
234
- export const WalletSimulationFeeOptionSchema = UserFeeOptionsSchema.extend({
249
+ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
235
250
  estimatedGasPadding: optional(z.number()),
236
251
  estimateGas: optional(z.boolean()),
237
252
  });
@@ -240,7 +255,7 @@ export const SendOptionsSchema = z.object({
240
255
  from: schemas.AztecAddress,
241
256
  authWitnesses: optional(z.array(AuthWitness.schema)),
242
257
  capsules: optional(z.array(Capsule.schema)),
243
- fee: optional(UserFeeOptionsSchema),
258
+ fee: optional(GasSettingsOptionSchema),
244
259
  });
245
260
 
246
261
  export const SimulateOptionsSchema = z.object({
@@ -258,72 +273,64 @@ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
258
273
  skipProofGeneration: optional(z.boolean()),
259
274
  });
260
275
 
261
- export const InstanceDataSchema = z.union([
262
- schemas.AztecAddress,
263
- ContractInstanceWithAddressSchema,
264
- ContractInstantiationDataSchema,
265
- z.object({ instance: ContractInstanceWithAddressSchema, artifact: ContractArtifactSchema }),
266
- ]);
267
-
268
276
  export const MessageHashOrIntentSchema = z.union([
269
- schemas.Fr,
270
- schemas.Buffer,
271
- z.object({ consumer: schemas.AztecAddress, innerHash: z.union([schemas.Buffer, schemas.Fr]) }),
277
+ z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
272
278
  z.object({
273
279
  caller: schemas.AztecAddress,
274
280
  call: FunctionCallSchema,
275
281
  }),
276
282
  ]);
277
283
 
278
- export const BatchedMethodSchema = z.union([
279
- z.object({
280
- name: z.literal('registerSender'),
281
- args: z.tuple([schemas.AztecAddress, optional(z.string())]),
282
- }),
283
- z.object({
284
- name: z.literal('registerContract'),
285
- args: z.tuple([InstanceDataSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
286
- }),
287
- z.object({
288
- name: z.literal('sendTx'),
289
- args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
290
- }),
284
+ export const EventMetadataDefinitionSchema = z.object({
285
+ eventSelector: schemas.EventSelector,
286
+ abiType: AbiTypeSchema,
287
+ fieldNames: z.array(z.string()),
288
+ });
289
+
290
+ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
291
291
  z.object({
292
- name: z.literal('simulateUtility'),
293
- args: z.tuple([z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema))]),
292
+ event: AbiDecodedSchema,
293
+ metadata: inTxSchema(),
294
294
  }),
295
- ]);
295
+ );
296
+
297
+ export const PrivateEventFilterSchema = z.object({
298
+ contractAddress: schemas.AztecAddress,
299
+ scopes: z.array(schemas.AztecAddress),
300
+ txHash: optional(TxHash.schema),
301
+ fromBlock: optional(BlockNumberPositiveSchema),
302
+ toBlock: optional(BlockNumberPositiveSchema),
303
+ });
296
304
 
297
305
  export const ContractMetadataSchema = z.object({
298
- contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
306
+ instance: optional(ContractInstanceWithAddressSchema),
299
307
  isContractInitialized: z.boolean(),
300
308
  isContractPublished: z.boolean(),
301
- }) satisfies ZodFor<ContractMetadata>;
309
+ isContractUpdated: z.boolean(),
310
+ updatedContractClassId: optional(schemas.Fr),
311
+ });
302
312
 
303
313
  export const ContractClassMetadataSchema = z.object({
304
- contractClass: z.union([ContractClassWithIdSchema, z.undefined()]),
314
+ isArtifactRegistered: z.boolean(),
305
315
  isContractClassPubliclyRegistered: z.boolean(),
306
- artifact: z.union([ContractArtifactSchema, z.undefined()]),
307
- }) satisfies ZodFor<ContractClassMetadata>;
308
-
309
- export const EventMetadataDefinitionSchema = z.object({
310
- eventSelector: schemas.EventSelector,
311
- abiType: AbiTypeSchema,
312
- fieldNames: z.array(z.string()),
313
316
  });
314
317
 
315
- export const WalletSchema: ApiSchemaFor<Wallet> = {
318
+ /**
319
+ * Record of all wallet method schemas (excluding batch).
320
+ * This is the single source of truth for method schemas - batch schemas are derived from this.
321
+ */
322
+ const WalletMethodSchemas = {
316
323
  getChainInfo: z
317
324
  .function()
318
325
  .args()
319
326
  .returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
320
- getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
321
- getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
322
327
  getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
328
+ getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
329
+ getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
323
330
  getPrivateEvents: z
324
331
  .function()
325
- .args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress))
326
- .returns(z.array(AbiDecodedSchema)),
332
+ .args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
333
+ .returns(z.array(PrivateEventSchema)),
327
334
  registerSender: z.function().args(schemas.AztecAddress, optional(z.string())).returns(schemas.AztecAddress),
328
335
  getAddressBook: z
329
336
  .function()
@@ -335,28 +342,56 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
335
342
  .returns(z.array(z.object({ alias: z.string(), item: schemas.AztecAddress }))),
336
343
  registerContract: z
337
344
  .function()
338
- .args(InstanceDataSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
345
+ .args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
339
346
  .returns(ContractInstanceWithAddressSchema),
340
347
  simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
341
348
  simulateUtility: z
342
349
  .function()
343
- .args(z.string(), z.array(z.any()), schemas.AztecAddress, optional(z.array(AuthWitness.schema)))
350
+ .args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
344
351
  .returns(UtilitySimulationResult.schema),
345
352
  profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
346
353
  sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
347
354
  createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
355
+ };
356
+
357
+ /**
358
+ * Creates batch schemas from the individual wallet methods.
359
+ * This allows us to define them once and derive batch schemas automatically,
360
+ * reducing duplication and ensuring consistency.
361
+ */
362
+ function createBatchSchemas<T extends Record<string, z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>>(
363
+ methodSchemas: T,
364
+ ) {
365
+ const names = Object.keys(methodSchemas) as (keyof T)[];
366
+
367
+ const namesAndArgs = names.map(name =>
368
+ z.object({
369
+ name: z.literal(name),
370
+ args: methodSchemas[name].parameters(),
371
+ }),
372
+ );
373
+
374
+ const namesAndReturns = names.map(name =>
375
+ z.object({
376
+ name: z.literal(name),
377
+ result: methodSchemas[name].returnType(),
378
+ }),
379
+ );
380
+
381
+ // Type assertion needed because discriminatedUnion expects a tuple type [T, T, ...T[]]
382
+ // but we're building the array dynamically. The runtime behavior is correct.
383
+ return {
384
+ input: z.discriminatedUnion('name', namesAndArgs as [(typeof namesAndArgs)[0], ...typeof namesAndArgs]),
385
+ output: z.discriminatedUnion('name', namesAndReturns as [(typeof namesAndReturns)[0], ...typeof namesAndReturns]),
386
+ };
387
+ }
388
+
389
+ const { input: BatchedMethodSchema, output: BatchedResultSchema } = createBatchSchemas(WalletMethodSchemas);
390
+
391
+ export { BatchedMethodSchema, BatchedResultSchema };
392
+
393
+ export const WalletSchema: ApiSchemaFor<Wallet> = {
394
+ ...WalletMethodSchemas,
348
395
  // @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
349
- batch: z
350
- .function()
351
- .args(z.array(BatchedMethodSchema))
352
- .returns(
353
- z.array(
354
- z.discriminatedUnion('name', [
355
- z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
356
- z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
357
- z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
358
- z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
359
- ]),
360
- ),
361
- ),
396
+ batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(BatchedResultSchema)),
362
397
  };
@@ -1,19 +0,0 @@
1
- import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
2
- import type { Fr } from '@aztec/foundation/fields';
3
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import type { CompleteAddress } from '@aztec/stdlib/contract';
5
- /**
6
- * Handler for interfacing with an account. Knows how to create transaction execution
7
- * requests and authorize actions for its corresponding account.
8
- */
9
- export interface AccountInterface extends EntrypointInterface, AuthWitnessProvider {
10
- /** Returns the complete address for this account. */
11
- getCompleteAddress(): CompleteAddress;
12
- /** Returns the address for this account. */
13
- getAddress(): AztecAddress;
14
- /** Returns the chain id for this account */
15
- getChainId(): Fr;
16
- /** Returns the rollup version for this account */
17
- getVersion(): Fr;
18
- }
19
- //# sourceMappingURL=interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/account/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAI9D;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB,EAAE,mBAAmB;IAChF,qDAAqD;IACrD,kBAAkB,IAAI,eAAe,CAAC;IAEtC,4CAA4C;IAC5C,UAAU,IAAI,YAAY,CAAC;IAE3B,4CAA4C;IAC5C,UAAU,IAAI,EAAE,CAAC;IAEjB,kDAAkD;IAClD,UAAU,IAAI,EAAE,CAAC;CAClB"}
@@ -1,5 +0,0 @@
1
- // docs:start:account-interface
2
- /**
3
- * Handler for interfacing with an account. Knows how to create transaction execution
4
- * requests and authorize actions for its corresponding account.
5
- */ export { }; // docs:end:account-interface
@@ -1,9 +0,0 @@
1
- import type { Wallet } from '../wallet/wallet.js';
2
- import { UnsafeContract } from './unsafe_contract.js';
3
- /** Returns a Contract wrapper for the contract class registry. */
4
- export declare function getClassRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
5
- /** Returns a Contract wrapper for the contract instance registry. */
6
- export declare function getInstanceRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
7
- /** Returns a Contract wrapper for the fee juice contract */
8
- export declare function getFeeJuice(wallet: Wallet): Promise<UnsafeContract>;
9
- //# sourceMappingURL=protocol_contracts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol_contracts.d.ts","sourceRoot":"","sources":["../../src/contract/protocol_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,kEAAkE;AAClE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,MAAM,2BAQ5D;AAED,qEAAqE;AACrE,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,MAAM,2BAO/D;AAED,4DAA4D;AAC5D,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,2BAO/C"}
@@ -1,26 +0,0 @@
1
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
- import { UnsafeContract } from './unsafe_contract.js';
3
- /** Returns a Contract wrapper for the contract class registry. */ export async function getClassRegistryContract(wallet) {
4
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
5
- if (!contractInstance) {
6
- throw new Error("ContractClassRegistry is not registered in this wallet's instance");
7
- }
8
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
9
- return new UnsafeContract(contractInstance, artifact, wallet);
10
- }
11
- /** Returns a Contract wrapper for the contract instance registry. */ export async function getInstanceRegistryContract(wallet) {
12
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
13
- if (!contractInstance) {
14
- throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
15
- }
16
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
17
- return new UnsafeContract(contractInstance, artifact, wallet);
18
- }
19
- /** Returns a Contract wrapper for the fee juice contract */ export async function getFeeJuice(wallet) {
20
- const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
21
- if (!contractInstance) {
22
- throw new Error("FeeJuice is not registered in this wallet's instance");
23
- }
24
- const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
25
- return new UnsafeContract(contractInstance, artifact, wallet);
26
- }
@@ -1,15 +0,0 @@
1
- import type { ContractArtifact } from '@aztec/stdlib/abi';
2
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
3
- import type { Wallet } from '../wallet/wallet.js';
4
- import { ContractBase } from './contract_base.js';
5
- /** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */
6
- export declare class UnsafeContract extends ContractBase {
7
- constructor(
8
- /** The deployed contract instance definition. */
9
- instance: ContractInstanceWithAddress,
10
- /** The Application Binary Interface for the contract. */
11
- artifact: ContractArtifact,
12
- /** The wallet used for interacting with this contract. */
13
- wallet: Wallet);
14
- }
15
- //# sourceMappingURL=unsafe_contract.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unsafe_contract.d.ts","sourceRoot":"","sources":["../../src/contract/unsafe_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,iHAAiH;AACjH,qBAAa,cAAe,SAAQ,YAAY;;IAE5C,iDAAiD;IACjD,QAAQ,EAAE,2BAA2B;IACrC,yDAAyD;IACzD,QAAQ,EAAE,gBAAgB;IAC1B,0DAA0D;IAC1D,MAAM,EAAE,MAAM;CAIjB"}
@@ -1,6 +0,0 @@
1
- import { ContractBase } from './contract_base.js';
2
- /** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */ export class UnsafeContract extends ContractBase {
3
- constructor(/** The deployed contract instance definition. */ instance, /** The Application Binary Interface for the contract. */ artifact, /** The wallet used for interacting with this contract. */ wallet){
4
- super(instance, artifact, wallet);
5
- }
6
- }