@aztec-labs/aztec.js 6.0.0-nightly.20260829

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 (275) hide show
  1. package/README.md +44 -0
  2. package/dest/account/account.d.ts +44 -0
  3. package/dest/account/account.d.ts.map +1 -0
  4. package/dest/account/account.js +31 -0
  5. package/dest/account/account_contract.d.ts +49 -0
  6. package/dest/account/account_contract.d.ts.map +1 -0
  7. package/dest/account/account_contract.js +20 -0
  8. package/dest/account/index.d.ts +11 -0
  9. package/dest/account/index.d.ts.map +1 -0
  10. package/dest/account/index.js +6 -0
  11. package/dest/api/abi.d.ts +4 -0
  12. package/dest/api/abi.d.ts.map +1 -0
  13. package/dest/api/abi.js +1 -0
  14. package/dest/api/account.d.ts +5 -0
  15. package/dest/api/account.d.ts.map +1 -0
  16. package/dest/api/account.js +3 -0
  17. package/dest/api/addresses.d.ts +4 -0
  18. package/dest/api/addresses.d.ts.map +1 -0
  19. package/dest/api/addresses.js +3 -0
  20. package/dest/api/authorization.d.ts +5 -0
  21. package/dest/api/authorization.d.ts.map +1 -0
  22. package/dest/api/authorization.js +4 -0
  23. package/dest/api/block.d.ts +3 -0
  24. package/dest/api/block.d.ts.map +1 -0
  25. package/dest/api/block.js +2 -0
  26. package/dest/api/contract.d.ts +48 -0
  27. package/dest/api/contract.d.ts.map +1 -0
  28. package/dest/api/contract.js +46 -0
  29. package/dest/api/crypto.d.ts +2 -0
  30. package/dest/api/crypto.d.ts.map +1 -0
  31. package/dest/api/crypto.js +1 -0
  32. package/dest/api/deployment.d.ts +4 -0
  33. package/dest/api/deployment.d.ts.map +1 -0
  34. package/dest/api/deployment.js +3 -0
  35. package/dest/api/eth_address.d.ts +2 -0
  36. package/dest/api/eth_address.d.ts.map +1 -0
  37. package/dest/api/eth_address.js +1 -0
  38. package/dest/api/ethereum.d.ts +2 -0
  39. package/dest/api/ethereum.d.ts.map +1 -0
  40. package/dest/api/ethereum.js +1 -0
  41. package/dest/api/event_cursor.d.ts +44 -0
  42. package/dest/api/event_cursor.d.ts.map +1 -0
  43. package/dest/api/event_cursor.js +42 -0
  44. package/dest/api/events.d.ts +36 -0
  45. package/dest/api/events.d.ts.map +1 -0
  46. package/dest/api/events.js +59 -0
  47. package/dest/api/fee.d.ts +6 -0
  48. package/dest/api/fee.d.ts.map +1 -0
  49. package/dest/api/fee.js +4 -0
  50. package/dest/api/fee_testing.d.ts +2 -0
  51. package/dest/api/fee_testing.d.ts.map +1 -0
  52. package/dest/api/fee_testing.js +1 -0
  53. package/dest/api/fields.d.ts +4 -0
  54. package/dest/api/fields.d.ts.map +1 -0
  55. package/dest/api/fields.js +3 -0
  56. package/dest/api/keys.d.ts +4 -0
  57. package/dest/api/keys.d.ts.map +1 -0
  58. package/dest/api/keys.js +3 -0
  59. package/dest/api/log.d.ts +3 -0
  60. package/dest/api/log.d.ts.map +1 -0
  61. package/dest/api/log.js +2 -0
  62. package/dest/api/messaging.d.ts +3 -0
  63. package/dest/api/messaging.d.ts.map +1 -0
  64. package/dest/api/messaging.js +2 -0
  65. package/dest/api/node.d.ts +25 -0
  66. package/dest/api/node.d.ts.map +1 -0
  67. package/dest/api/node.js +22 -0
  68. package/dest/api/note.d.ts +2 -0
  69. package/dest/api/note.d.ts.map +1 -0
  70. package/dest/api/note.js +1 -0
  71. package/dest/api/protocol.d.ts +6 -0
  72. package/dest/api/protocol.d.ts.map +1 -0
  73. package/dest/api/protocol.js +5 -0
  74. package/dest/api/trees.d.ts +3 -0
  75. package/dest/api/trees.d.ts.map +1 -0
  76. package/dest/api/trees.js +2 -0
  77. package/dest/api/tx.d.ts +3 -0
  78. package/dest/api/tx.d.ts.map +1 -0
  79. package/dest/api/tx.js +1 -0
  80. package/dest/api/utils.d.ts +13 -0
  81. package/dest/api/utils.d.ts.map +1 -0
  82. package/dest/api/utils.js +12 -0
  83. package/dest/api/wallet.d.ts +8 -0
  84. package/dest/api/wallet.d.ts.map +1 -0
  85. package/dest/api/wallet.js +7 -0
  86. package/dest/authorization/call_authorization_request.d.ts +46 -0
  87. package/dest/authorization/call_authorization_request.d.ts.map +1 -0
  88. package/dest/authorization/call_authorization_request.js +72 -0
  89. package/dest/contract/base_contract_interaction.d.ts +32 -0
  90. package/dest/contract/base_contract_interaction.d.ts.map +1 -0
  91. package/dest/contract/base_contract_interaction.js +24 -0
  92. package/dest/contract/batch_call.d.ts +27 -0
  93. package/dest/contract/batch_call.d.ts.map +1 -0
  94. package/dest/contract/batch_call.js +152 -0
  95. package/dest/contract/checker.d.ts +11 -0
  96. package/dest/contract/checker.d.ts.map +1 -0
  97. package/dest/contract/checker.js +107 -0
  98. package/dest/contract/contract.d.ts +33 -0
  99. package/dest/contract/contract.d.ts.map +1 -0
  100. package/dest/contract/contract.js +36 -0
  101. package/dest/contract/contract_base.d.ts +51 -0
  102. package/dest/contract/contract_base.d.ts.map +1 -0
  103. package/dest/contract/contract_base.js +38 -0
  104. package/dest/contract/contract_function_interaction.d.ts +67 -0
  105. package/dest/contract/contract_function_interaction.d.ts.map +1 -0
  106. package/dest/contract/contract_function_interaction.js +218 -0
  107. package/dest/contract/deploy_method.d.ts +433 -0
  108. package/dest/contract/deploy_method.d.ts.map +1 -0
  109. package/dest/contract/deploy_method.js +471 -0
  110. package/dest/contract/fastforward_contract_update.d.ts +25 -0
  111. package/dest/contract/fastforward_contract_update.d.ts.map +1 -0
  112. package/dest/contract/fastforward_contract_update.js +57 -0
  113. package/dest/contract/interaction_options.d.ts +213 -0
  114. package/dest/contract/interaction_options.d.ts.map +1 -0
  115. package/dest/contract/interaction_options.js +87 -0
  116. package/dest/contract/protocol_contracts/contract-class-registry.d.ts +18 -0
  117. package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
  118. package/dest/contract/protocol_contracts/contract-class-registry.js +137 -0
  119. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +25 -0
  120. package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
  121. package/dest/contract/protocol_contracts/contract-instance-registry.js +366 -0
  122. package/dest/contract/protocol_contracts/fee-juice.d.ts +24 -0
  123. package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
  124. package/dest/contract/protocol_contracts/fee-juice.js +383 -0
  125. package/dest/contract/wait_for_proven.d.ts +18 -0
  126. package/dest/contract/wait_for_proven.d.ts.map +1 -0
  127. package/dest/contract/wait_for_proven.js +17 -0
  128. package/dest/contract/wait_opts.d.ts +21 -0
  129. package/dest/contract/wait_opts.d.ts.map +1 -0
  130. package/dest/contract/wait_opts.js +5 -0
  131. package/dest/deployment/contract_deployer.d.ts +28 -0
  132. package/dest/deployment/contract_deployer.d.ts.map +1 -0
  133. package/dest/deployment/contract_deployer.js +35 -0
  134. package/dest/deployment/publish_class.d.ts +6 -0
  135. package/dest/deployment/publish_class.d.ts.map +1 -0
  136. package/dest/deployment/publish_class.js +17 -0
  137. package/dest/deployment/publish_instance.d.ts +10 -0
  138. package/dest/deployment/publish_instance.d.ts.map +1 -0
  139. package/dest/deployment/publish_instance.js +11 -0
  140. package/dest/ethereum/portal_manager.d.ts +146 -0
  141. package/dest/ethereum/portal_manager.d.ts.map +1 -0
  142. package/dest/ethereum/portal_manager.js +415 -0
  143. package/dest/fee/fee_juice_payment_method_with_claim.d.ts +23 -0
  144. package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -0
  145. package/dest/fee/fee_juice_payment_method_with_claim.js +46 -0
  146. package/dest/fee/fee_payment_method.d.ts +26 -0
  147. package/dest/fee/fee_payment_method.d.ts.map +1 -0
  148. package/dest/fee/fee_payment_method.js +3 -0
  149. package/dest/fee/private_fee_payment_method.d.ts +69 -0
  150. package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
  151. package/dest/fee/private_fee_payment_method.js +122 -0
  152. package/dest/fee/public_fee_payment_method.d.ts +59 -0
  153. package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
  154. package/dest/fee/public_fee_payment_method.js +116 -0
  155. package/dest/fee/sponsored_fee_payment.d.ts +17 -0
  156. package/dest/fee/sponsored_fee_payment.d.ts.map +1 -0
  157. package/dest/fee/sponsored_fee_payment.js +33 -0
  158. package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
  159. package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
  160. package/dest/scripts/generate_protocol_contract_types.js +128 -0
  161. package/dest/test/fixtures.d.ts +13 -0
  162. package/dest/test/fixtures.d.ts.map +1 -0
  163. package/dest/test/fixtures.js +185 -0
  164. package/dest/utils/abi_types.d.ts +32 -0
  165. package/dest/utils/abi_types.d.ts.map +1 -0
  166. package/dest/utils/abi_types.js +1 -0
  167. package/dest/utils/authwit.d.ts +119 -0
  168. package/dest/utils/authwit.d.ts.map +1 -0
  169. package/dest/utils/authwit.js +266 -0
  170. package/dest/utils/cross_chain.d.ts +28 -0
  171. package/dest/utils/cross_chain.d.ts.map +1 -0
  172. package/dest/utils/cross_chain.js +26 -0
  173. package/dest/utils/fee_juice.d.ts +8 -0
  174. package/dest/utils/fee_juice.d.ts.map +1 -0
  175. package/dest/utils/fee_juice.js +10 -0
  176. package/dest/utils/field_compressed_string.d.ts +17 -0
  177. package/dest/utils/field_compressed_string.d.ts.map +1 -0
  178. package/dest/utils/field_compressed_string.js +15 -0
  179. package/dest/utils/node.d.ts +24 -0
  180. package/dest/utils/node.d.ts.map +1 -0
  181. package/dest/utils/node.js +80 -0
  182. package/dest/utils/pub_key.d.ts +9 -0
  183. package/dest/utils/pub_key.d.ts.map +1 -0
  184. package/dest/utils/pub_key.js +8 -0
  185. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +33 -0
  186. package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
  187. package/dest/wallet/account_entrypoint_meta_payment_method.js +63 -0
  188. package/dest/wallet/account_manager.d.ts +73 -0
  189. package/dest/wallet/account_manager.d.ts.map +1 -0
  190. package/dest/wallet/account_manager.js +102 -0
  191. package/dest/wallet/capabilities.d.ts +456 -0
  192. package/dest/wallet/capabilities.d.ts.map +1 -0
  193. package/dest/wallet/capabilities.js +3 -0
  194. package/dest/wallet/deploy_account_method.d.ts +97 -0
  195. package/dest/wallet/deploy_account_method.d.ts.map +1 -0
  196. package/dest/wallet/deploy_account_method.js +127 -0
  197. package/dest/wallet/index.d.ts +5 -0
  198. package/dest/wallet/index.d.ts.map +1 -0
  199. package/dest/wallet/index.js +4 -0
  200. package/dest/wallet/tx_simulation_result_with_app_offset.d.ts +40 -0
  201. package/dest/wallet/tx_simulation_result_with_app_offset.d.ts.map +1 -0
  202. package/dest/wallet/tx_simulation_result_with_app_offset.js +65 -0
  203. package/dest/wallet/wallet.d.ts +1451 -0
  204. package/dest/wallet/wallet.d.ts.map +1 -0
  205. package/dest/wallet/wallet.js +430 -0
  206. package/package.json +138 -0
  207. package/src/account/account.ts +72 -0
  208. package/src/account/account_contract.ts +80 -0
  209. package/src/account/index.ts +12 -0
  210. package/src/api/README.md +7 -0
  211. package/src/api/abi.ts +42 -0
  212. package/src/api/account.ts +12 -0
  213. package/src/api/addresses.ts +3 -0
  214. package/src/api/authorization.ts +15 -0
  215. package/src/api/block.ts +2 -0
  216. package/src/api/contract.ts +86 -0
  217. package/src/api/crypto.ts +1 -0
  218. package/src/api/deployment.ts +3 -0
  219. package/src/api/eth_address.ts +1 -0
  220. package/src/api/ethereum.ts +10 -0
  221. package/src/api/event_cursor.ts +60 -0
  222. package/src/api/events.ts +79 -0
  223. package/src/api/fee.ts +5 -0
  224. package/src/api/fee_testing.ts +1 -0
  225. package/src/api/fields.ts +3 -0
  226. package/src/api/keys.ts +8 -0
  227. package/src/api/log.ts +2 -0
  228. package/src/api/messaging.ts +2 -0
  229. package/src/api/node.ts +30 -0
  230. package/src/api/note.ts +1 -0
  231. package/src/api/protocol.ts +6 -0
  232. package/src/api/trees.ts +2 -0
  233. package/src/api/tx.ts +20 -0
  234. package/src/api/utils.ts +14 -0
  235. package/src/api/wallet.ts +83 -0
  236. package/src/authorization/call_authorization_request.ts +93 -0
  237. package/src/contract/base_contract_interaction.ts +62 -0
  238. package/src/contract/batch_call.ts +188 -0
  239. package/src/contract/checker.ts +122 -0
  240. package/src/contract/contract.ts +52 -0
  241. package/src/contract/contract_base.ts +73 -0
  242. package/src/contract/contract_function_interaction.ts +297 -0
  243. package/src/contract/deploy_method.ts +877 -0
  244. package/src/contract/fastforward_contract_update.ts +71 -0
  245. package/src/contract/interaction_options.ts +301 -0
  246. package/src/contract/protocol_contracts/contract-class-registry.ts +104 -0
  247. package/src/contract/protocol_contracts/contract-instance-registry.ts +241 -0
  248. package/src/contract/protocol_contracts/fee-juice.ts +257 -0
  249. package/src/contract/wait_for_proven.ts +43 -0
  250. package/src/contract/wait_opts.ts +26 -0
  251. package/src/deployment/contract_deployer.ts +40 -0
  252. package/src/deployment/publish_class.ts +34 -0
  253. package/src/deployment/publish_instance.ts +24 -0
  254. package/src/ethereum/portal_manager.ts +539 -0
  255. package/src/fee/fee_juice_payment_method_with_claim.ts +63 -0
  256. package/src/fee/fee_payment_method.ts +26 -0
  257. package/src/fee/private_fee_payment_method.ts +145 -0
  258. package/src/fee/public_fee_payment_method.ts +145 -0
  259. package/src/fee/sponsored_fee_payment.ts +45 -0
  260. package/src/scripts/generate_protocol_contract_types.ts +160 -0
  261. package/src/test/fixtures.ts +126 -0
  262. package/src/utils/abi_types.ts +32 -0
  263. package/src/utils/authwit.ts +327 -0
  264. package/src/utils/cross_chain.ts +55 -0
  265. package/src/utils/fee_juice.ts +14 -0
  266. package/src/utils/field_compressed_string.ts +27 -0
  267. package/src/utils/node.ts +110 -0
  268. package/src/utils/pub_key.ts +12 -0
  269. package/src/wallet/account_entrypoint_meta_payment_method.ts +76 -0
  270. package/src/wallet/account_manager.ts +164 -0
  271. package/src/wallet/capabilities.ts +505 -0
  272. package/src/wallet/deploy_account_method.ts +234 -0
  273. package/src/wallet/index.ts +4 -0
  274. package/src/wallet/tx_simulation_result_with_app_offset.ts +100 -0
  275. package/src/wallet/wallet.ts +668 -0
@@ -0,0 +1,668 @@
1
+ import type { ChainInfo } from '@aztec-labs/entrypoints/interfaces';
2
+ import { BlockNumber, BlockNumberPositiveSchema } from '@aztec-labs/foundation/branded-types';
3
+ import type { Fr } from '@aztec-labs/foundation/curves/bn254';
4
+ import {
5
+ type AbiDecoded,
6
+ AbiTypeSchema,
7
+ type ContractArtifact,
8
+ ContractArtifactSchema,
9
+ type EventMetadataDefinition,
10
+ FunctionCall,
11
+ } from '@aztec-labs/stdlib/abi';
12
+ import { AuthWitness } from '@aztec-labs/stdlib/auth-witness';
13
+ import type { AztecAddress } from '@aztec-labs/stdlib/aztec-address';
14
+ import {
15
+ type ContractInstancePreimage,
16
+ ContractInstancePreimageSchema,
17
+ type ContractInstancePreimageWithAddress,
18
+ ContractInstancePreimageWithAddressSchema,
19
+ } from '@aztec-labs/stdlib/contract';
20
+ import { Gas, ManaUsageEstimate } from '@aztec-labs/stdlib/gas';
21
+ import type { MasterSecretKeys } from '@aztec-labs/stdlib/keys';
22
+ import { refineTxHashAndRange } from '@aztec-labs/stdlib/logs';
23
+ import {
24
+ AbiDecodedSchema,
25
+ type ApiSchemaFor,
26
+ getSchemaParameters,
27
+ getSchemaReturnType,
28
+ optional,
29
+ schemas,
30
+ zodFor,
31
+ } from '@aztec-labs/stdlib/schemas';
32
+ import type { ExecutionPayload, InTx } from '@aztec-labs/stdlib/tx';
33
+ import {
34
+ Capsule,
35
+ HashedValues,
36
+ SimulationOverrides,
37
+ TxHash,
38
+ TxProfileResult,
39
+ TxReceiptSchema,
40
+ UtilityExecutionResult,
41
+ inTxSchema,
42
+ } from '@aztec-labs/stdlib/tx';
43
+ import { z } from 'zod';
44
+
45
+ import { EventCursor } from '../api/event_cursor.js';
46
+ import {
47
+ type GasSettingsOption,
48
+ type InteractionWaitOptions,
49
+ NO_FROM,
50
+ NO_WAIT,
51
+ type ProfileInteractionOptions,
52
+ type SendInteractionOptionsWithoutWait,
53
+ type SendReturn,
54
+ type SimulateInteractionOptions,
55
+ } from '../contract/interaction_options.js';
56
+ import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
57
+ import type { AppCapabilities, WalletCapabilities } from './capabilities.js';
58
+ import { TxSimulationResultWithAppOffset } from './tx_simulation_result_with_app_offset.js';
59
+
60
+ /**
61
+ * A wrapper type that allows any item to be associated with an alias.
62
+ */
63
+ export type Aliased<T> = {
64
+ /**
65
+ * The alias
66
+ */
67
+ alias: string;
68
+ /**
69
+ * The item being aliased.
70
+ */
71
+ item: T;
72
+ };
73
+
74
+ /**
75
+ * Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
76
+ * a simplified version that only hints at the wallet whether the interaction contains a
77
+ * fee payment method or not
78
+ */
79
+ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
80
+ /** The fee options */
81
+ fee?: GasSettingsOption;
82
+ };
83
+
84
+ /**
85
+ * Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
86
+ * a simplified version that only hints at the wallet whether the interaction contains a
87
+ * fee payment method or not
88
+ */
89
+ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
90
+ /** The fee options */
91
+ fee?: GasSettingsOption;
92
+ };
93
+
94
+ /**
95
+ * Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
96
+ * a simplified version that only hints at the wallet whether the interaction contains a
97
+ * fee payment method or not
98
+ */
99
+ export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
100
+ SendInteractionOptionsWithoutWait,
101
+ 'fee'
102
+ > & {
103
+ /** The fee options */
104
+ fee?: GasSettingsOption;
105
+ /** Whether to wait for the transaction to be mined */
106
+ wait?: W;
107
+ };
108
+
109
+ /**
110
+ * Helper type that represents all methods that can be batched (all methods except batch itself).
111
+ */
112
+ export type BatchableMethods = Omit<Wallet, 'batch'>;
113
+
114
+ /**
115
+ * A method call with its name and arguments.
116
+ */
117
+ type BatchedMethodInternal<T extends keyof BatchableMethods> = {
118
+ /** The method name */
119
+ name: T;
120
+ /** The method arguments */
121
+ args: Parameters<BatchableMethods[T]>;
122
+ };
123
+
124
+ /**
125
+ * Union of all possible batched method calls.
126
+ * This ensures type safety: the `args` must match the specific `name`.
127
+ */
128
+ export type BatchedMethod = {
129
+ [K in keyof BatchableMethods]: BatchedMethodInternal<K>;
130
+ }[keyof BatchableMethods];
131
+
132
+ /**
133
+ * Helper type to extract the return type of a batched method
134
+ */
135
+ export type BatchedMethodResult<T> =
136
+ T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
137
+
138
+ /**
139
+ * Wrapper type for batch results that includes the method name for discriminated union deserialization.
140
+ * Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
141
+ * when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
142
+ */
143
+ export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
144
+ /** The method name */
145
+ name: T['name'];
146
+ /** The method result */
147
+ result: BatchedMethodResult<T>;
148
+ };
149
+
150
+ /**
151
+ * Maps a tuple of BatchedMethod to a tuple of their wrapped return types
152
+ */
153
+ export type BatchResults<T extends readonly BatchedMethod[]> = {
154
+ [K in keyof T]: BatchedMethodResultWrapper<T[K]>;
155
+ };
156
+
157
+ /**
158
+ * Base filter options for event queries.
159
+ */
160
+ export type EventFilterBase = {
161
+ /** Transaction in which the events were emitted. */
162
+ txHash?: TxHash;
163
+ /** The block number from which to start fetching events (inclusive).
164
+ * Optional. If provided, it must be greater or equal than 1.
165
+ * Defaults to the initial L2 block number (INITIAL_L2_BLOCK_NUM).
166
+ */
167
+ fromBlock?: BlockNumber;
168
+ /** The block number until which to fetch logs (not inclusive).
169
+ * Optional. If provided, it must be greater than fromBlock.
170
+ */
171
+ toBlock?: BlockNumber;
172
+ };
173
+
174
+ /**
175
+ * Filter options when querying private events.
176
+ */
177
+ export type PrivateEventFilter = EventFilterBase & {
178
+ /** The address of the contract that emitted the events. */
179
+ contractAddress: AztecAddress;
180
+ /** Addresses of accounts that are in scope for this filter. */
181
+ scopes: AztecAddress[];
182
+ };
183
+
184
+ /**
185
+ * Filter options when querying public events. The contract address is required because the public log index is
186
+ * keyed on `(contract, tag)`; tag-only queries are not supported.
187
+ */
188
+ export type PublicEventFilter = EventFilterBase & {
189
+ /** The address of the contract that emitted the events. Required. */
190
+ contractAddress: AztecAddress;
191
+ /**
192
+ * Cursor to resume strictly after, for pagination. Pass {@link GetPublicEventsResult.nextCursor} from a
193
+ * previous page here to fetch the next one. Omit to start from the beginning of the range.
194
+ */
195
+ afterEvent?: EventCursor;
196
+ };
197
+
198
+ /**
199
+ * An ABI decoded event with associated metadata.
200
+ * @typeParam T - The decoded event type
201
+ * @typeParam M - Additional metadata fields (empty by default)
202
+ */
203
+ export type Event<T, M extends object = object> = {
204
+ /** The ABI decoded event */
205
+ event: T;
206
+ /** Metadata describing event context information such as tx and block */
207
+ metadata: InTx & M;
208
+ };
209
+
210
+ /** An ABI decoded private event with associated metadata. */
211
+ export type PrivateEvent<T> = Event<T>;
212
+
213
+ /** An ABI decoded public event with associated metadata (includes contract address). */
214
+ export type PublicEvent<T> = Event<
215
+ T,
216
+ {
217
+ /**
218
+ * Address of the contract that emitted this event
219
+ */
220
+ contractAddress: AztecAddress;
221
+ }
222
+ >;
223
+
224
+ /** Whether the contract has been initialized. */
225
+ export enum ContractInitializationStatus {
226
+ /** The contract has been initialized (initialization nullifier found). */
227
+ INITIALIZED = 'INITIALIZED',
228
+ /** The contract has not been initialized (instance is known, but no initialization nullifier found). */
229
+ UNINITIALIZED = 'UNINITIALIZED',
230
+ /**
231
+ * Initialization status cannot be determined. The contract instance is not registered in this wallet, so we have
232
+ * limited ability to check for initialization. The contract may or may not have been initialized.
233
+ */
234
+ UNKNOWN = 'UNKNOWN',
235
+ }
236
+
237
+ /**
238
+ * Contract metadata including deployment and registration status.
239
+ */
240
+ export type ContractMetadata = {
241
+ /** The contract instance preimage and address. */
242
+ instance?: ContractInstancePreimageWithAddress;
243
+ /** Whether the contract has been initialized. */
244
+ initializationStatus: ContractInitializationStatus;
245
+ /** Whether the contract instance is publicly deployed onchain */
246
+ isContractPublished: boolean;
247
+ /** Whether the contract has been updated to a different class */
248
+ isContractUpdated: boolean;
249
+ /** The updated contract class ID if the contract has been updated */
250
+ updatedContractClassId?: Fr | undefined;
251
+ };
252
+
253
+ /**
254
+ * Contract class metadata.
255
+ */
256
+ export type ContractClassMetadata = {
257
+ /** Whether the artifact is registered in the wallet */
258
+ isArtifactRegistered: boolean;
259
+ /** Whether the contract class is publicly registered onchain */
260
+ isContractClassPubliclyRegistered: boolean;
261
+ };
262
+
263
+ /**
264
+ * Options for executing a utility function call.
265
+ */
266
+ export type ExecuteUtilityOptions = {
267
+ /** The scopes for the utility execution (determines which notes and keys are visible). */
268
+ scopes: AztecAddress[];
269
+ /** Optional auth witnesses to use during execution. */
270
+ authWitnesses?: AuthWitness[];
271
+ };
272
+
273
+ /**
274
+ * The wallet interface.
275
+ */
276
+ export type Wallet = {
277
+ getPrivateEvents<T>(
278
+ eventMetadata: EventMetadataDefinition,
279
+ eventFilter: PrivateEventFilter,
280
+ ): Promise<PrivateEvent<T>[]>;
281
+ getChainInfo(): Promise<ChainInfo>;
282
+ getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
283
+ getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
284
+ registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
285
+ getAddressBook(): Promise<Aliased<AztecAddress>[]>;
286
+ getAccounts(): Promise<Aliased<AztecAddress>[]>;
287
+ registerContract(
288
+ instance: ContractInstancePreimage,
289
+ artifact?: ContractArtifact,
290
+ secretKeyOrKeys?: Fr | MasterSecretKeys,
291
+ ): Promise<void>;
292
+ /**
293
+ * Registers a contract class artifact in the local PXE without binding it to any instance.
294
+ * Useful for simulation flows that need the artifact available locally before any onchain
295
+ * upgrade has taken effect. No chain check.
296
+ */
297
+ registerContractClass(artifact: ContractArtifact): Promise<void>;
298
+ simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset>;
299
+ executeUtility(call: FunctionCall, opts: ExecuteUtilityOptions): Promise<UtilityExecutionResult>;
300
+ profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
301
+ sendTx<W extends InteractionWaitOptions = undefined>(
302
+ exec: ExecutionPayload,
303
+ opts: SendOptions<W>,
304
+ ): Promise<SendReturn<W>>;
305
+ createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
306
+ requestCapabilities(manifest: AppCapabilities): Promise<WalletCapabilities>;
307
+ batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
308
+ };
309
+
310
+ export const ExecutionPayloadSchema = z.object({
311
+ calls: z.array(FunctionCall.schema),
312
+ authWitnesses: z.array(AuthWitness.schema),
313
+ capsules: z.array(Capsule.schema),
314
+ extraHashedArgs: z.array(HashedValues.schema),
315
+ feePayer: optional(schemas.AztecAddress),
316
+ });
317
+
318
+ export const GasSettingsOptionSchema = z.object({
319
+ gasSettings: optional(
320
+ z.object({
321
+ gasLimits: optional(Gas.schema),
322
+ teardownGasLimits: optional(Gas.schema),
323
+ maxFeePerGas: optional(z.object({ feePerDaGas: schemas.BigInt, feePerL2Gas: schemas.BigInt })),
324
+ maxPriorityFeePerGas: optional(z.object({ feePerDaGas: schemas.BigInt, feePerL2Gas: schemas.BigInt })),
325
+ }),
326
+ ),
327
+ congestionEstimate: optional(z.nativeEnum(ManaUsageEstimate)),
328
+ });
329
+
330
+ export const WaitOptsSchema = z.object({
331
+ ignoreDroppedReceiptsFor: optional(z.number()),
332
+ timeout: optional(z.number()),
333
+ interval: optional(z.number()),
334
+ dontThrowOnRevert: optional(z.boolean()),
335
+ initialDelay: optional(z.number()),
336
+ });
337
+
338
+ const FromSchema = z.union([schemas.AztecAddress, z.literal(NO_FROM)]);
339
+
340
+ export const SendOptionsSchema = z.object({
341
+ from: FromSchema,
342
+ authWitnesses: optional(z.array(AuthWitness.schema)),
343
+ capsules: optional(z.array(Capsule.schema)),
344
+ fee: optional(GasSettingsOptionSchema),
345
+ wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
346
+ additionalScopes: optional(z.array(schemas.AztecAddress)),
347
+ sendMessagesAs: optional(schemas.AztecAddress),
348
+ });
349
+
350
+ export const SimulateOptionsSchema = z.object({
351
+ from: FromSchema,
352
+ authWitnesses: optional(z.array(AuthWitness.schema)),
353
+ capsules: optional(z.array(Capsule.schema)),
354
+ fee: optional(GasSettingsOptionSchema),
355
+ skipTxValidation: optional(z.boolean()),
356
+ skipFeeEnforcement: optional(z.boolean()),
357
+ includeMetadata: optional(z.boolean()),
358
+ additionalScopes: optional(z.array(schemas.AztecAddress)),
359
+ sendMessagesAs: optional(schemas.AztecAddress),
360
+ overrides: optional(SimulationOverrides.schema),
361
+ });
362
+
363
+ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
364
+ profileMode: z.enum(['gates', 'execution-steps', 'full']),
365
+ skipProofGeneration: optional(z.boolean()),
366
+ });
367
+
368
+ export const MessageHashOrIntentSchema = z.union([
369
+ z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
370
+ z.object({
371
+ caller: schemas.AztecAddress,
372
+ call: FunctionCall.schema,
373
+ }),
374
+ ]);
375
+
376
+ export const EventMetadataDefinitionSchema = z.object({
377
+ eventSelector: schemas.EventSelector,
378
+ abiType: AbiTypeSchema,
379
+ fieldNames: z.array(z.string()),
380
+ });
381
+
382
+ // Event filters share `txHash ⊕ block-range` semantics with `LogsQueryBase` (see stdlib `logs_query.ts`)
383
+ // but the field schemas stay local.
384
+ const eventFilterBaseShape = {
385
+ txHash: optional(TxHash.schema),
386
+ fromBlock: optional(BlockNumberPositiveSchema),
387
+ toBlock: optional(BlockNumberPositiveSchema),
388
+ };
389
+
390
+ export const PrivateEventFilterSchema = refineTxHashAndRange(
391
+ z.object({
392
+ ...eventFilterBaseShape,
393
+ contractAddress: schemas.AztecAddress,
394
+ scopes: z.array(schemas.AztecAddress),
395
+ }),
396
+ );
397
+
398
+ export const PublicEventFilterSchema = refineTxHashAndRange(
399
+ z.object({
400
+ ...eventFilterBaseShape,
401
+ contractAddress: schemas.AztecAddress,
402
+ afterEvent: optional(EventCursor.schema),
403
+ }),
404
+ );
405
+
406
+ export const PrivateEventSchema: z.ZodType<any> = zodFor<PrivateEvent<AbiDecoded>>()(
407
+ z.object({
408
+ event: AbiDecodedSchema,
409
+ metadata: inTxSchema(),
410
+ }),
411
+ );
412
+
413
+ export const PublicEventSchema: z.ZodType<PublicEvent<AbiDecoded>> = zodFor<PublicEvent<AbiDecoded>>()(
414
+ z.object({
415
+ event: AbiDecodedSchema,
416
+ metadata: z.intersection(inTxSchema(), z.object({ contractAddress: schemas.AztecAddress })),
417
+ }),
418
+ );
419
+
420
+ export const ContractMetadataSchema = z.object({
421
+ instance: optional(ContractInstancePreimageWithAddressSchema),
422
+ initializationStatus: z.nativeEnum(ContractInitializationStatus),
423
+ isContractPublished: z.boolean(),
424
+ isContractUpdated: z.boolean(),
425
+ updatedContractClassId: optional(schemas.Fr),
426
+ });
427
+
428
+ export const ContractClassMetadataSchema = z.object({
429
+ isArtifactRegistered: z.boolean(),
430
+ isContractClassPubliclyRegistered: z.boolean(),
431
+ });
432
+
433
+ export const ContractFunctionPatternSchema = z.object({
434
+ contract: z.union([schemas.AztecAddress, z.literal('*')]),
435
+ function: z.union([z.string(), z.literal('*')]),
436
+ additionalScopes: optional(z.union([z.array(schemas.AztecAddress), z.literal('*')])),
437
+ });
438
+
439
+ export const AccountsCapabilitySchema = z.object({
440
+ type: z.literal('accounts'),
441
+ canGet: optional(z.boolean()),
442
+ canCreateAuthWit: optional(z.boolean()),
443
+ });
444
+
445
+ export const GrantedAccountsCapabilitySchema = AccountsCapabilitySchema.extend({
446
+ accounts: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
447
+ });
448
+
449
+ export const ContractsCapabilitySchema = z.object({
450
+ type: z.literal('contracts'),
451
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
452
+ canRegister: optional(z.boolean()),
453
+ canGetMetadata: optional(z.boolean()),
454
+ });
455
+
456
+ export const GrantedContractsCapabilitySchema = ContractsCapabilitySchema;
457
+
458
+ export const ContractClassesCapabilitySchema = z.object({
459
+ type: z.literal('contractClasses'),
460
+ classes: z.union([z.literal('*'), z.array(schemas.Fr)]),
461
+ canRegister: optional(z.boolean()),
462
+ canGetMetadata: z.boolean(),
463
+ });
464
+
465
+ export const GrantedContractClassesCapabilitySchema = ContractClassesCapabilitySchema;
466
+
467
+ export const SimulationCapabilitySchema = z.object({
468
+ type: z.literal('simulation'),
469
+ transactions: optional(
470
+ z.object({
471
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
472
+ }),
473
+ ),
474
+ utilities: optional(
475
+ z.object({
476
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
477
+ }),
478
+ ),
479
+ });
480
+
481
+ export const GrantedSimulationCapabilitySchema = SimulationCapabilitySchema;
482
+
483
+ export const TransactionCapabilitySchema = z.object({
484
+ type: z.literal('transaction'),
485
+ scope: z.union([z.literal('*'), z.array(ContractFunctionPatternSchema)]),
486
+ });
487
+
488
+ export const GrantedTransactionCapabilitySchema = TransactionCapabilitySchema;
489
+
490
+ export const DataCapabilitySchema = z.object({
491
+ type: z.literal('data'),
492
+ addressBook: optional(z.boolean()),
493
+ privateEvents: optional(
494
+ z.object({
495
+ contracts: z.union([z.literal('*'), z.array(schemas.AztecAddress)]),
496
+ }),
497
+ ),
498
+ });
499
+
500
+ export const GrantedDataCapabilitySchema = DataCapabilitySchema;
501
+
502
+ export const CapabilitySchema = z.discriminatedUnion('type', [
503
+ AccountsCapabilitySchema,
504
+ ContractsCapabilitySchema,
505
+ ContractClassesCapabilitySchema,
506
+ SimulationCapabilitySchema,
507
+ TransactionCapabilitySchema,
508
+ DataCapabilitySchema,
509
+ ]);
510
+
511
+ export const GrantedCapabilitySchema = z.discriminatedUnion('type', [
512
+ GrantedAccountsCapabilitySchema,
513
+ GrantedContractsCapabilitySchema,
514
+ GrantedContractClassesCapabilitySchema,
515
+ GrantedSimulationCapabilitySchema,
516
+ GrantedTransactionCapabilitySchema,
517
+ GrantedDataCapabilitySchema,
518
+ ]);
519
+
520
+ export const AppCapabilitiesSchema = z.object({
521
+ version: z.literal('1.0'),
522
+ metadata: z.object({
523
+ name: z.string(),
524
+ version: z.string(),
525
+ description: optional(z.string()),
526
+ url: optional(z.string()),
527
+ icon: optional(z.string()),
528
+ }),
529
+ capabilities: z.array(CapabilitySchema),
530
+ behavior: optional(
531
+ z.object({
532
+ mode: optional(z.enum(['strict', 'permissive'])),
533
+ expiration: optional(z.number()),
534
+ }),
535
+ ),
536
+ });
537
+
538
+ export const WalletCapabilitiesSchema = z.object({
539
+ version: z.literal('1.0'),
540
+ granted: z.array(GrantedCapabilitySchema),
541
+ wallet: z.object({
542
+ name: z.string(),
543
+ version: z.string(),
544
+ }),
545
+ expiresAt: optional(z.number()),
546
+ });
547
+
548
+ const OffchainEffectSchema = z.object({
549
+ data: z.array(schemas.Fr),
550
+ contractAddress: schemas.AztecAddress,
551
+ });
552
+
553
+ const OffchainMessageSchema = z.object({
554
+ recipient: schemas.AztecAddress,
555
+ payload: z.array(schemas.Fr),
556
+ contractAddress: schemas.AztecAddress,
557
+ });
558
+
559
+ const OffchainOutputSchema = z.object({
560
+ offchainEffects: z.array(OffchainEffectSchema),
561
+ offchainMessages: z.array(OffchainMessageSchema),
562
+ });
563
+
564
+ /**
565
+ * Record of all wallet method schemas (excluding batch).
566
+ * This is the single source of truth for method schemas - batch schemas are derived from this.
567
+ */
568
+ const WalletMethodSchemas = {
569
+ getChainInfo: z.function({ input: z.tuple([]), output: z.object({ chainId: schemas.Fr, version: schemas.Fr }) }),
570
+ getContractMetadata: z.function({ input: z.tuple([schemas.AztecAddress]), output: ContractMetadataSchema }),
571
+ getContractClassMetadata: z.function({ input: z.tuple([schemas.Fr]), output: ContractClassMetadataSchema }),
572
+ getPrivateEvents: z.function({
573
+ input: z.tuple([EventMetadataDefinitionSchema, PrivateEventFilterSchema]),
574
+ output: z.array(PrivateEventSchema),
575
+ }),
576
+ registerSender: z.function({
577
+ input: z.tuple([schemas.AztecAddress, optional(z.string())]),
578
+ output: schemas.AztecAddress,
579
+ }),
580
+ getAddressBook: z.function({
581
+ input: z.tuple([]),
582
+ output: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
583
+ }),
584
+ getAccounts: z.function({
585
+ input: z.tuple([]),
586
+ output: z.array(z.object({ alias: z.string(), item: schemas.AztecAddress })),
587
+ }),
588
+ registerContract: z.function({
589
+ input: z.tuple([ContractInstancePreimageSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
590
+ output: z.void(),
591
+ }),
592
+ registerContractClass: z.function({ input: z.tuple([ContractArtifactSchema]), output: z.void() }),
593
+ simulateTx: z.function({
594
+ input: z.tuple([ExecutionPayloadSchema, SimulateOptionsSchema]),
595
+ output: TxSimulationResultWithAppOffset.schema,
596
+ }),
597
+ executeUtility: z.function({
598
+ input: z.tuple([
599
+ FunctionCall.schema,
600
+ z.object({
601
+ scopes: z.array(schemas.AztecAddress),
602
+ authWitnesses: optional(z.array(AuthWitness.schema)),
603
+ }),
604
+ ]),
605
+ output: UtilityExecutionResult.schema,
606
+ }),
607
+ profileTx: z.function({
608
+ input: z.tuple([ExecutionPayloadSchema, ProfileOptionsSchema]),
609
+ output: TxProfileResult.schema,
610
+ }),
611
+ sendTx: z.function({
612
+ input: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
613
+ output: z.union([
614
+ z.object({ txHash: TxHash.schema }).merge(OffchainOutputSchema),
615
+ z.object({ receipt: TxReceiptSchema }).merge(OffchainOutputSchema),
616
+ ]),
617
+ }),
618
+ createAuthWit: z.function({
619
+ input: z.tuple([schemas.AztecAddress, MessageHashOrIntentSchema]),
620
+ output: AuthWitness.schema,
621
+ }),
622
+ requestCapabilities: z.function({ input: z.tuple([AppCapabilitiesSchema]), output: WalletCapabilitiesSchema }),
623
+ };
624
+
625
+ /**
626
+ * Creates batch schemas from the individual wallet methods.
627
+ * This allows us to define them once and derive batch schemas automatically,
628
+ * reducing duplication and ensuring consistency.
629
+ */
630
+ function createBatchSchemas<T extends Record<string, z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>>(
631
+ methodSchemas: T,
632
+ ) {
633
+ const names = Object.keys(methodSchemas) as Extract<keyof T, string>[];
634
+
635
+ const namesAndArgs = names.map(name =>
636
+ z.object({
637
+ name: z.literal(name),
638
+ args: getSchemaParameters(methodSchemas[name]),
639
+ }),
640
+ );
641
+
642
+ const namesAndReturns = names.map(name => {
643
+ const returnType = getSchemaReturnType(methodSchemas[name]);
644
+ return z.object({
645
+ name: z.literal(name),
646
+ // void-returning methods serialize to a missing `result` key over JSON-RPC, so their field must be optional:
647
+ // value-returning methods keep it required so a dropped result is still caught.
648
+ result: returnType instanceof z.ZodVoid ? returnType.optional() : returnType,
649
+ });
650
+ });
651
+
652
+ // Type assertion needed because discriminatedUnion expects a tuple type [T, T, ...T[]]
653
+ // but we're building the array dynamically. The runtime behavior is correct.
654
+ return {
655
+ input: z.discriminatedUnion('name', namesAndArgs as [(typeof namesAndArgs)[0], ...typeof namesAndArgs]),
656
+ output: z.discriminatedUnion('name', namesAndReturns as [(typeof namesAndReturns)[0], ...typeof namesAndReturns]),
657
+ };
658
+ }
659
+
660
+ const { input: BatchedMethodSchema, output: BatchedResultSchema } = createBatchSchemas(WalletMethodSchemas);
661
+
662
+ export { BatchedMethodSchema, BatchedResultSchema };
663
+
664
+ export const WalletSchema: ApiSchemaFor<Wallet> = {
665
+ ...WalletMethodSchemas,
666
+ // @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
667
+ batch: z.function({ input: z.tuple([z.array(BatchedMethodSchema)]), output: z.array(BatchedResultSchema) }),
668
+ };