@walletmesh/aztec-rpc-wallet 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +290 -228
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/client/aztec-dapp-wallet.d.ts +401 -0
  5. package/dist/client/aztec-dapp-wallet.d.ts.map +1 -0
  6. package/dist/client/aztec-dapp-wallet.js +705 -0
  7. package/dist/client/aztec-router-provider.d.ts +58 -0
  8. package/dist/client/aztec-router-provider.d.ts.map +1 -0
  9. package/dist/client/aztec-router-provider.js +62 -0
  10. package/dist/client/helpers.d.ts +44 -0
  11. package/dist/client/helpers.d.ts.map +1 -0
  12. package/dist/client/helpers.js +79 -0
  13. package/dist/client/register-serializers.d.ts +41 -0
  14. package/dist/client/register-serializers.d.ts.map +1 -0
  15. package/dist/client/register-serializers.js +97 -0
  16. package/dist/contractArtifactCache.d.ts +49 -32
  17. package/dist/contractArtifactCache.d.ts.map +1 -1
  18. package/dist/contractArtifactCache.js +47 -34
  19. package/dist/errors.d.ts +50 -8
  20. package/dist/errors.d.ts.map +1 -1
  21. package/dist/errors.js +50 -10
  22. package/dist/index.d.ts +53 -40
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +52 -17
  25. package/dist/types.d.ts +345 -270
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/types.js +10 -8
  28. package/dist/wallet/create-node.d.ts +73 -0
  29. package/dist/wallet/create-node.d.ts.map +1 -0
  30. package/dist/wallet/create-node.js +99 -0
  31. package/dist/wallet/handlers/account.d.ts +67 -0
  32. package/dist/wallet/handlers/account.d.ts.map +1 -0
  33. package/dist/wallet/handlers/account.js +85 -0
  34. package/dist/wallet/handlers/contract-interaction.d.ts +77 -0
  35. package/dist/wallet/handlers/contract-interaction.d.ts.map +1 -0
  36. package/dist/wallet/handlers/contract-interaction.js +219 -0
  37. package/dist/wallet/handlers/contract.d.ts +96 -0
  38. package/dist/wallet/handlers/contract.d.ts.map +1 -0
  39. package/dist/wallet/handlers/contract.js +146 -0
  40. package/dist/wallet/handlers/event.d.ts +62 -0
  41. package/dist/wallet/handlers/event.d.ts.map +1 -0
  42. package/dist/wallet/handlers/event.js +85 -0
  43. package/dist/wallet/handlers/index.d.ts +88 -0
  44. package/dist/wallet/handlers/index.d.ts.map +1 -0
  45. package/dist/wallet/handlers/index.js +47 -0
  46. package/dist/wallet/handlers/node.d.ts +117 -0
  47. package/dist/wallet/handlers/node.d.ts.map +1 -0
  48. package/dist/wallet/handlers/node.js +196 -0
  49. package/dist/wallet/handlers/senders.d.ts +70 -0
  50. package/dist/wallet/handlers/senders.d.ts.map +1 -0
  51. package/dist/wallet/handlers/senders.js +92 -0
  52. package/dist/wallet/handlers/transaction.d.ts +123 -0
  53. package/dist/wallet/handlers/transaction.d.ts.map +1 -0
  54. package/dist/wallet/handlers/transaction.js +191 -0
  55. package/dist/wallet/serializers.d.ts +75 -0
  56. package/dist/wallet/serializers.d.ts.map +1 -0
  57. package/dist/wallet/serializers.js +501 -0
  58. package/docs/README.md +290 -229
  59. package/docs/classes/AztecDappWallet.md +1304 -0
  60. package/docs/classes/AztecRouterProvider.md +1058 -0
  61. package/docs/classes/AztecWalletError.md +124 -47
  62. package/docs/classes/ContractArtifactCache.md +48 -31
  63. package/docs/functions/connectAztec.md +62 -0
  64. package/docs/functions/createAztecWallet.md +46 -0
  65. package/docs/functions/createAztecWalletNode.md +96 -0
  66. package/docs/functions/registerAztecSerializers.md +61 -0
  67. package/docs/functions/registerWalletAztecSerializers.md +39 -0
  68. package/docs/globals.md +16 -14
  69. package/docs/interfaces/AztecHandlerContext.md +54 -0
  70. package/docs/interfaces/AztecWalletContext.md +50 -0
  71. package/docs/interfaces/AztecWalletMethodMap.md +470 -477
  72. package/docs/type-aliases/AztecChainId.md +16 -3
  73. package/docs/variables/ALL_AZTEC_METHODS.md +20 -0
  74. package/docs/variables/AztecWalletErrorMap.md +9 -4
  75. package/docs/variables/AztecWalletSerializer.md +45 -0
  76. package/package.json +9 -9
  77. package/src/client/aztec-dapp-wallet.test.ts +628 -0
  78. package/src/client/aztec-dapp-wallet.ts +879 -0
  79. package/src/client/aztec-router-provider.test.ts +235 -0
  80. package/src/client/aztec-router-provider.ts +64 -0
  81. package/src/client/helpers.test.ts +187 -0
  82. package/src/client/helpers.ts +91 -0
  83. package/src/client/register-serializers.ts +108 -0
  84. package/src/contractArtifactCache.test.ts +21 -10
  85. package/src/contractArtifactCache.ts +54 -35
  86. package/src/errors.ts +58 -10
  87. package/src/index.test.ts +2 -6
  88. package/src/index.ts +73 -37
  89. package/src/types.ts +379 -217
  90. package/src/wallet/create-node.test.ts +332 -0
  91. package/src/wallet/create-node.ts +120 -0
  92. package/src/wallet/handlers/account.test.ts +172 -0
  93. package/src/wallet/handlers/account.ts +99 -0
  94. package/src/wallet/handlers/contract-interaction.test.ts +248 -0
  95. package/src/wallet/handlers/contract-interaction.ts +269 -0
  96. package/src/wallet/handlers/contract.test.ts +245 -0
  97. package/src/wallet/handlers/contract.ts +174 -0
  98. package/src/wallet/handlers/event.test.ts +216 -0
  99. package/src/wallet/handlers/event.ts +99 -0
  100. package/src/wallet/handlers/index.ts +84 -0
  101. package/src/wallet/handlers/node.test.ts +304 -0
  102. package/src/wallet/handlers/node.ts +230 -0
  103. package/src/wallet/handlers/senders.test.ts +172 -0
  104. package/src/wallet/handlers/senders.ts +106 -0
  105. package/src/wallet/handlers/transaction.test.ts +371 -0
  106. package/src/wallet/handlers/transaction.ts +239 -0
  107. package/src/wallet/serializers.test.ts +253 -0
  108. package/src/wallet/serializers.ts +586 -0
  109. package/typedoc.json +23 -1
  110. package/dist/aztecRemoteWallet.d.ts +0 -70
  111. package/dist/aztecRemoteWallet.d.ts.map +0 -1
  112. package/dist/aztecRemoteWallet.js +0 -335
  113. package/dist/chainProvider.d.ts +0 -56
  114. package/dist/chainProvider.d.ts.map +0 -1
  115. package/dist/chainProvider.js +0 -98
  116. package/dist/handlers/aztecAccountWallet.d.ts +0 -4
  117. package/dist/handlers/aztecAccountWallet.d.ts.map +0 -1
  118. package/dist/handlers/aztecAccountWallet.js +0 -295
  119. package/dist/handlers/transactions.d.ts +0 -21
  120. package/dist/handlers/transactions.d.ts.map +0 -1
  121. package/dist/handlers/transactions.js +0 -98
  122. package/dist/handlers.d.ts +0 -27
  123. package/dist/handlers.d.ts.map +0 -1
  124. package/dist/handlers.js +0 -55
  125. package/dist/provider.d.ts +0 -105
  126. package/dist/provider.d.ts.map +0 -1
  127. package/dist/provider.js +0 -160
  128. package/dist/serializers/account.d.ts +0 -164
  129. package/dist/serializers/account.d.ts.map +0 -1
  130. package/dist/serializers/account.js +0 -244
  131. package/dist/serializers/contract.d.ts +0 -62
  132. package/dist/serializers/contract.d.ts.map +0 -1
  133. package/dist/serializers/contract.js +0 -130
  134. package/dist/serializers/index.d.ts +0 -21
  135. package/dist/serializers/index.d.ts.map +0 -1
  136. package/dist/serializers/index.js +0 -154
  137. package/dist/serializers/log.d.ts +0 -66
  138. package/dist/serializers/log.d.ts.map +0 -1
  139. package/dist/serializers/log.js +0 -222
  140. package/dist/serializers/note.d.ts +0 -124
  141. package/dist/serializers/note.d.ts.map +0 -1
  142. package/dist/serializers/note.js +0 -208
  143. package/dist/serializers/transaction.d.ts +0 -99
  144. package/dist/serializers/transaction.d.ts.map +0 -1
  145. package/dist/serializers/transaction.js +0 -275
  146. package/dist/wallet.d.ts +0 -62
  147. package/dist/wallet.d.ts.map +0 -1
  148. package/dist/wallet.js +0 -77
  149. package/docs/classes/AztecChainProvider.md +0 -553
  150. package/docs/classes/AztecChainWallet.md +0 -409
  151. package/docs/classes/AztecProvider.md +0 -1112
  152. package/docs/interfaces/AztecWalletBaseMethodMap.md +0 -135
  153. package/docs/interfaces/AztecWalletEventMap.md +0 -17
  154. package/docs/type-aliases/AztecChainWalletMiddleware.md +0 -13
  155. package/docs/type-aliases/AztecWalletContext.md +0 -29
  156. package/docs/type-aliases/AztecWalletMethodHandler.md +0 -37
  157. package/docs/type-aliases/AztecWalletMiddleware.md +0 -13
  158. package/docs/type-aliases/AztecWalletRouterClient.md +0 -13
  159. package/docs/type-aliases/TransactionFunctionCall.md +0 -33
  160. package/docs/type-aliases/TransactionParams.md +0 -27
  161. package/src/aztecRemoteWallet.test.ts +0 -505
  162. package/src/aztecRemoteWallet.ts +0 -467
  163. package/src/chainProvider.test.ts +0 -401
  164. package/src/chainProvider.ts +0 -116
  165. package/src/handlers/aztecAccountWallet.test.ts +0 -650
  166. package/src/handlers/aztecAccountWallet.ts +0 -531
  167. package/src/handlers/transactions.ts +0 -124
  168. package/src/handlers.test.ts +0 -270
  169. package/src/handlers.ts +0 -70
  170. package/src/provider.test.ts +0 -277
  171. package/src/provider.ts +0 -189
  172. package/src/serializers/account.test.ts +0 -125
  173. package/src/serializers/account.ts +0 -301
  174. package/src/serializers/contract.test.ts +0 -24
  175. package/src/serializers/contract.ts +0 -183
  176. package/src/serializers/index.test.ts +0 -136
  177. package/src/serializers/index.ts +0 -191
  178. package/src/serializers/log.test.ts +0 -286
  179. package/src/serializers/log.ts +0 -292
  180. package/src/serializers/note.test.ts +0 -125
  181. package/src/serializers/note.ts +0 -250
  182. package/src/serializers/transaction.test.ts +0 -320
  183. package/src/serializers/transaction.ts +0 -409
  184. package/src/wallet.test.ts +0 -275
  185. package/src/wallet.ts +0 -94
package/src/types.ts CHANGED
@@ -1,296 +1,458 @@
1
1
  import type {
2
2
  AuthWitness,
3
3
  AztecAddress,
4
- ContractArtifact,
5
- ContractInstanceWithAddress,
6
- ExtendedNote,
7
4
  Fr,
8
5
  PXE,
9
6
  TxExecutionRequest,
10
7
  TxHash,
11
8
  TxReceipt,
12
9
  L2Block,
13
- LogFilter,
14
- Point,
15
- SiblingPath,
16
- PartialAddress,
17
10
  CompleteAddress,
18
- NodeInfo,
19
11
  AccountWallet,
20
12
  Tx,
21
13
  } from '@aztec/aztec.js';
22
14
  import type { IntentAction, IntentInnerHash } from '@aztec/aztec.js/utils';
23
- import type { ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
24
- import type { AbiDecoded } from '@aztec/foundation/abi';
15
+ import type { ExecutionPayload } from '@aztec/entrypoints/payload';
16
+
17
+ /**
18
+ * @module @walletmesh/aztec-rpc-wallet/types
19
+ *
20
+ * This module defines core types and interfaces used throughout the Aztec RPC Wallet package.
21
+ * Key definitions include:
22
+ * - {@link AztecChainId}: A type-safe representation of Aztec chain identifiers.
23
+ * - {@link AztecWalletContext}: The context object passed to wallet-side RPC method handlers.
24
+ * - {@link AztecWalletMethodMap}: A comprehensive map detailing all supported Aztec JSON-RPC
25
+ * methods, their parameters, and return types. This is central to the typed RPC system.
26
+ */
27
+
25
28
  import type {
26
- InBlock,
27
- NotesFilter,
28
- EventMetadataDefinition,
29
29
  PrivateExecutionResult,
30
- TxEffect,
30
+ TxProfileResult,
31
31
  TxProvingResult,
32
- UniqueNote,
33
- PXEInfo,
34
32
  TxSimulationResult,
35
- GetPublicLogsResponse,
36
- GetContractClassLogsResponse,
37
- ContractMetadata,
33
+ UtilitySimulationResult,
34
+ } from '@aztec/stdlib/tx';
35
+
36
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
37
+
38
+ import type {
38
39
  ContractClassMetadata,
39
- } from '@aztec/circuit-types';
40
- import type { GasFees, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js';
41
- import type { JSONRPCEventMap, JSONRPCMiddleware } from '@walletmesh/jsonrpc';
42
- import type { JSONRPCWalletClient, WalletMethodMap } from '@walletmesh/router';
40
+ ContractMetadata,
41
+ EventMetadataDefinition,
42
+ PXEInfo,
43
+ } from '@aztec/stdlib/interfaces/client';
44
+
45
+ import type { GasFees } from '@aztec/stdlib/gas';
46
+ import type { ContractInstanceWithAddress, NodeInfo } from '@aztec/stdlib/contract';
47
+
48
+ import type { WalletMethodMap } from '@walletmesh/router';
43
49
  import type { ContractArtifactCache } from './contractArtifactCache.js';
44
50
 
45
51
  /**
46
- * Represents a single function call to a contract.
47
- * @public
52
+ * Type-safe Aztec chain ID format following the CAIP-2 standard.
53
+ *
54
+ * Format: `aztec:{reference}` where reference is typically:
55
+ * - "mainnet" for the main Aztec network
56
+ * - A numeric chain ID for test networks (e.g., "31337" for local development)
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const mainnetChainId: AztecChainId = "aztec:mainnet";
61
+ * const localChainId: AztecChainId = "aztec:31337";
62
+ * ```
48
63
  */
49
- export type TransactionFunctionCall = {
50
- /** The address of the contract to interact with */
51
- contractAddress: string;
52
- /** The name of the function to call */
53
- functionName: string;
54
- /** The arguments to pass to the function */
55
- args: unknown[];
56
- };
64
+ export type AztecChainId = `aztec:${string}`;
57
65
 
58
66
  /**
59
- * Parameters for sending transactions.
60
- * @public
67
+ * Defines the context object provided to all Aztec wallet-side JSON-RPC method handlers.
68
+ * This context aggregates essential dependencies required by handlers to perform their operations.
69
+ *
70
+ * @see {@link createAztecWalletNode} where this context is constructed and provided to handlers.
61
71
  */
62
- export type TransactionParams = {
63
- /** Array of function calls to execute */
64
- functionCalls: TransactionFunctionCall[];
65
- /** Optional array of authorization witnesses for the transaction */
66
- authwits?: string[];
67
- };
72
+ export interface AztecWalletContext {
73
+ /**
74
+ * The `aztec.js` {@link AccountWallet} instance. This wallet holds the user's account keys
75
+ * and provides methods for signing, creating transactions, and interacting with the PXE.
76
+ */
77
+ wallet: AccountWallet;
78
+ /**
79
+ * The `aztec.js` {@link PXE} (Private Execution Environment) client instance.
80
+ * This is used for interacting with the Aztec network, such as simulating transactions,
81
+ * getting node information, fetching blocks, and managing private state.
82
+ */
83
+ pxe: PXE;
84
+ /**
85
+ * An instance of {@link ContractArtifactCache} used for caching contract artifacts.
86
+ * This helps optimize performance by avoiding redundant fetches of artifact data.
87
+ */
88
+ cache: ContractArtifactCache;
89
+ }
68
90
 
69
- export const BASE_WALLET_METHODS: (keyof AztecWalletBaseMethodMap)[] = [
70
- 'wm_getSupportedMethods',
71
- 'aztec_connect',
72
- 'aztec_getAccount',
73
- 'aztec_sendTransaction',
74
- 'aztec_simulateTransaction',
75
- ] as const;
91
+ /**
92
+ * A constant array defining a set of base wallet methods.
93
+ * These methods might be intended for initial wallet discovery or basic connection negotiation.
94
+ * Note: Current connection helpers like `connectAztec` default to `ALL_AZTEC_METHODS`.
95
+ * The `aztec_connect` method listed here is not currently defined in {@link AztecWalletMethodMap}.
96
+ *
97
+ * @readonly
98
+ */
99
+ export const BASE_WALLET_METHODS = ['wm_getSupportedMethods', 'aztec_connect', 'aztec_getAddress'] as const;
76
100
 
77
101
  /**
78
- * A mapping of JSON-RPC methods to their parameters and return types for Aztec Wallets.
102
+ * Defines the complete map of all JSON-RPC methods supported by the Aztec RPC Wallet.
103
+ * This interface extends the base {@link WalletMethodMap} from `@walletmesh/router`
104
+ * and specifies the parameter (`params`) and return (`result`) types for each Aztec-specific method.
105
+ *
106
+ * This map is crucial for:
107
+ * - Type safety in both client-side calls and wallet-side handlers.
108
+ * - Guiding the implementation of serializers and deserializers.
109
+ * - Documentation generation, as it serves as a single source of truth for method signatures.
110
+ *
111
+ * Methods are loosely grouped by functionality (Chain/Node, Account, Sender, etc.).
112
+ * "wm_" prefixed methods are typically WalletMesh-specific extensions or conveniences.
79
113
  *
80
- * This extends the base WalletMethodMap with Aztec-specific methods.
81
- * @public
114
+ * @see {@link AztecDappWallet} for the client-side implementation that calls these methods.
115
+ * @see {@link createAztecHandlers} for the wallet-side implementation that handles these methods.
82
116
  */
83
- export interface AztecWalletBaseMethodMap extends WalletMethodMap {
117
+ export interface AztecWalletMethodMap extends WalletMethodMap {
118
+ // Add wm_getSupportedMethods explicitly to ensure its params type is correctly overridden
119
+ // if WalletMethodMap already defines it differently.
84
120
  /**
85
- * Connects to the Aztec network.
86
- * @returns A boolean indicating if the connection was successful
121
+ * Retrieves a list of all JSON-RPC methods supported by this wallet implementation.
122
+ * Allows clients to discover the capabilities of the wallet.
123
+ * @param params - No parameters.
124
+ * @returns result - An array of strings, where each string is a supported method name.
87
125
  */
88
- aztec_connect: { result: boolean };
126
+ wm_getSupportedMethods: { params: []; result: string[] };
89
127
 
128
+ /* Chain/Node Methods */
90
129
  /**
91
- * Gets the account address from the wallet.
92
- * @returns The account address as a string
130
+ * Retrieves a specific L2 block by its number.
131
+ * @param params - A tuple containing the block number.
132
+ * @param params.0 blockNumber - The number of the block to retrieve.
133
+ * @returns result - The {@link L2Block} data, or null/undefined if not found (behavior depends on PXE).
93
134
  */
94
- aztec_getAccount: { result: string };
95
-
135
+ aztec_getBlock: { params: [number]; result: L2Block };
96
136
  /**
97
- * Sends transactions to the Aztec network.
98
- * @param params - The transactions to execute and optional authorization witnesses
99
- * @returns The transaction hash as a string
137
+ * Retrieves the current (latest) L2 block number.
138
+ * @param params - No parameters.
139
+ * @returns result - The current block number.
100
140
  */
101
- aztec_sendTransaction: {
102
- params: TransactionParams;
103
- result: string;
104
- };
141
+ aztec_getBlockNumber: { params: []; result: number };
142
+ /**
143
+ * Retrieves the chain ID of the connected Aztec network.
144
+ * @param params - No parameters.
145
+ * @returns result - The chain ID as an {@link Fr}.
146
+ */
147
+ aztec_getChainId: { params: []; result: Fr };
148
+ /**
149
+ * Retrieves the version of the connected PXE (Private Execution Environment) or node.
150
+ * @param params - No parameters.
151
+ * @returns result - The version as an {@link Fr}.
152
+ */
153
+ aztec_getVersion: { params: []; result: Fr };
154
+ /**
155
+ * Retrieves comprehensive information about the connected Aztec node.
156
+ * @param params - No parameters.
157
+ * @returns result - A {@link NodeInfo} object.
158
+ */
159
+ aztec_getNodeInfo: { params: []; result: NodeInfo };
160
+ /**
161
+ * Retrieves the latest L2 block number that has been proven.
162
+ * @param params - No parameters.
163
+ * @returns result - The latest proven block number.
164
+ */
165
+ aztec_getProvenBlockNumber: { params: []; result: number };
166
+ /**
167
+ * Retrieves information about the PXE service, including capabilities and version.
168
+ * @param params - No parameters.
169
+ * @returns result - A {@link PXEInfo} object.
170
+ */
171
+ aztec_getPXEInfo: { params: []; result: PXEInfo };
172
+ /**
173
+ * Retrieves the current base gas fees on the network.
174
+ * @param params - No parameters.
175
+ * @returns result - A {@link GasFees} object.
176
+ */
177
+ aztec_getCurrentBaseFees: { params: []; result: GasFees };
105
178
 
179
+ /* Account Methods */
106
180
  /**
107
- * Simulates a transaction without executing it.
108
- * @param params - The transaction to simulate
109
- * @returns The simulation result
181
+ * Retrieves the primary {@link AztecAddress} of the wallet's account.
182
+ * @param params - No parameters.
183
+ * @returns result - The wallet's {@link AztecAddress}.
110
184
  */
111
- aztec_simulateTransaction: {
112
- params: TransactionFunctionCall;
113
- result: unknown;
114
- };
185
+ aztec_getAddress: { params: []; result: AztecAddress };
186
+ /**
187
+ * Retrieves the {@link CompleteAddress} of the wallet's account, including public keys.
188
+ * @param params - No parameters.
189
+ * @returns result - The wallet's {@link CompleteAddress}.
190
+ */
191
+ aztec_getCompleteAddress: { params: []; result: CompleteAddress };
115
192
 
193
+ /* AuthWitness Methods */
116
194
  /**
117
- * Returns the list of supported methods for the wallet.
118
- * @returns An array of supported methods
195
+ * Creates an {@link AuthWitness} (authorization witness) for a given message hash or intent.
196
+ * Used for delegating actions.
197
+ * @param params - A tuple containing the intent to authorize.
198
+ * @param params.0 intent - The message hash ({@link Fr} or `Buffer`), {@link IntentInnerHash}, or {@link IntentAction} to authorize.
199
+ * @returns result - The created {@link AuthWitness}.
119
200
  */
120
- wm_getSupportedMethods: {
121
- result: string[];
201
+ aztec_createAuthWit: {
202
+ params: [Fr | Buffer | IntentAction | IntentInnerHash];
203
+ result: AuthWitness;
122
204
  };
123
- }
124
-
125
- export interface AztecWalletEventMap extends JSONRPCEventMap {
126
- // TODO: What events do we need?
127
- }
128
-
129
- /**
130
- * Holds the context passed through RPC middleware.
131
- * @public
132
- */
133
- export type AztecWalletContext = Record<string, unknown> & {
134
- /** The PXE instance for the wallet */
135
- pxe: PXE;
136
- wallet: AccountWallet;
137
- contractArtifactCache: ContractArtifactCache;
138
- };
139
-
140
- /**
141
- * Type for Aztec Router Wallet middleware.
142
- * @public
143
- */
144
- export type AztecWalletMiddleware = JSONRPCMiddleware<AztecWalletBaseMethodMap, AztecWalletContext>;
145
-
146
- /**
147
- * Type for Aztec Chain Wallet middleware.
148
- */
149
- export type AztecChainWalletMiddleware = JSONRPCMiddleware<AztecWalletMethodMap, AztecWalletContext>;
150
205
 
151
- /**
152
- * Type for Aztec wallet router client.
153
- * @public
154
- */
155
- export type AztecWalletRouterClient = JSONRPCWalletClient<AztecWalletMethodMap>;
156
-
157
- /**
158
- * Type for Aztec wallet RPC method map.
159
- * This extends the AztecWalletBaseMethodMap with the methods used in by Aztec's `AccountWallet`
160
- */
161
- export interface AztecWalletMethodMap extends AztecWalletBaseMethodMap {
162
- /* Chain */
163
- aztec_getBlock: { params: { number: number }; result: L2Block };
164
- aztec_getBlockNumber: { result: number };
165
- aztec_getChainId: { result: number };
166
- aztec_getVersion: { result: number };
167
- aztec_getNodeInfo: { result: NodeInfo };
168
- aztec_getProvenBlockNumber: { result: number };
169
- aztec_getPXEInfo: { result: PXEInfo };
170
- aztec_getCurrentBaseFees: { result: GasFees };
171
-
172
- /* Scopes */
173
- aztec_setScopes: { params: { scopes: AztecAddress[] }; result: boolean };
174
- aztec_getScopes: { result: AztecAddress[] };
175
-
176
- /* L1->L2 Messages */
177
- aztec_isL1ToL2MessageSynced: { params: { l1ToL2Message: Fr }; result: boolean };
178
- aztec_getL1ToL2MembershipWitness: {
179
- params: { contractAddress: AztecAddress; messageHash: Fr; secret: Fr };
180
- result: [bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>];
206
+ /* Sender Methods */
207
+ /**
208
+ * Registers a new authorized sender {@link AztecAddress}.
209
+ * @param params - A tuple containing the sender's address.
210
+ * @param params.0 senderAddress - The {@link AztecAddress} to authorize.
211
+ * @returns result - The registered {@link AztecAddress}.
212
+ */
213
+ aztec_registerSender: {
214
+ params: [AztecAddress];
215
+ result: AztecAddress;
181
216
  };
182
-
183
- /* Capsules */
184
- aztec_addCapsule: { params: { contract: AztecAddress; storageSlot: Fr; capsule: Fr[] }; result: undefined };
185
-
186
- /* Accounts */
187
- aztec_getAddress: { result: AztecAddress };
188
- aztec_getCompleteAddress: { result: CompleteAddress };
189
- aztec_registerAccount: {
190
- params: { secretKey: Fr; partialAddress: PartialAddress };
191
- result: CompleteAddress;
217
+ /**
218
+ * Retrieves a list of all currently authorized sender {@link AztecAddress}es.
219
+ * @param params - No parameters.
220
+ * @returns result - An array of authorized {@link AztecAddress}es.
221
+ */
222
+ aztec_getSenders: { params: []; result: AztecAddress[] };
223
+ /**
224
+ * Removes an {@link AztecAddress} from the list of authorized senders.
225
+ * @param params - A tuple containing the sender's address.
226
+ * @param params.0 senderAddress - The {@link AztecAddress} to de-authorize.
227
+ * @returns result - `true` if removal was successful.
228
+ */
229
+ aztec_removeSender: {
230
+ params: [AztecAddress];
231
+ result: boolean;
192
232
  };
193
- aztec_getRegisteredAccounts: { result: CompleteAddress[] };
194
233
 
195
- /* AuthWitness */
196
- aztec_addAuthWitness: { params: { authWitness: AuthWitness }; result: boolean };
197
- aztec_getAuthWitness: { params: { messageHash: Fr }; result: Fr[] };
198
- aztec_createAuthWit: {
199
- params: { intent: Fr | Buffer | IntentAction | IntentInnerHash };
200
- result: AuthWitness;
234
+ /* Contract Methods */
235
+ /**
236
+ * Retrieves a list of all {@link AztecAddress}es of contracts known to the PXE/wallet.
237
+ * @param params - No parameters.
238
+ * @returns result - An array of contract {@link AztecAddress}es.
239
+ */
240
+ aztec_getContracts: { params: []; result: AztecAddress[] };
241
+ /**
242
+ * Retrieves {@link ContractMetadata} for a specific deployed contract.
243
+ * @param params - A tuple containing the contract's address.
244
+ * @param params.0 contractAddress - The {@link AztecAddress} of the contract.
245
+ * @returns result - The {@link ContractMetadata} for the specified contract.
246
+ */
247
+ aztec_getContractMetadata: {
248
+ params: [AztecAddress];
249
+ result: ContractMetadata;
201
250
  };
202
-
203
- /* Senders */
204
-
205
251
  /**
206
- * Registers a contact in the user's PXE
207
- * @param params - The sender (contact) address to register
208
- * @returns True if registration was successful
252
+ * Retrieves {@link ContractClassMetadata} for a specific contract class.
253
+ * @param params - A tuple containing the class ID and an optional flag.
254
+ * @param params.0 classId - The {@link Fr} ID of the contract class.
255
+ * @param params.1 includeArtifact - Optional: Boolean indicating whether to include the full {@link ContractArtifact}.
256
+ * @returns result - The {@link ContractClassMetadata}.
209
257
  */
210
- aztec_registerSender: { params: { sender: AztecAddress }; result: AztecAddress };
211
- aztec_getSenders: { result: AztecAddress[] };
212
- aztec_removeSender: { params: { sender: AztecAddress }; result: boolean };
213
-
214
- /* Contracts */
215
-
216
- aztec_getContracts: { result: AztecAddress[] };
217
- aztec_getContractMetadata: { params: { address: AztecAddress }; result: ContractMetadata };
218
258
  aztec_getContractClassMetadata: {
219
- params: { id: Fr; includeArtifact?: boolean };
259
+ params: [Fr, boolean | undefined];
220
260
  result: ContractClassMetadata;
221
261
  };
222
-
223
262
  /**
224
- * Registers a contract instance in the user's PXE.
225
- * @param params - The contract details to register
226
- * @returns True if registration was successful
263
+ * Registers a deployed contract instance with the wallet.
264
+ * @param params - A tuple containing the instance and optional artifact.
265
+ * @param params.0 instance - The {@link ContractInstanceWithAddress} to register.
266
+ * @param params.1 artifact - Optional: The {@link ContractArtifact} for the instance.
267
+ * @returns result - `true` if registration was successful.
227
268
  */
228
269
  aztec_registerContract: {
229
- params: { instance: ContractInstanceWithAddress; artifact?: ContractArtifact | undefined };
270
+ params: [ContractInstanceWithAddress, ContractArtifact | undefined];
230
271
  result: boolean;
231
272
  };
232
-
233
273
  /**
234
- * Registers a contract class in the user's PXE.
235
- * @param params - The contract artifact to register
236
- * @returns True if registration was successful
274
+ * Registers a contract class (bytecode and ABI) with the wallet.
275
+ * @param params - A tuple containing the artifact.
276
+ * @param params.0 artifact - The {@link ContractArtifact} to register.
277
+ * @returns result - `true` if registration was successful.
237
278
  */
238
- aztec_registerContractClass: { params: { artifact: ContractArtifact }; result: boolean };
239
- // biome-ignore lint/suspicious/noExplicitAny: return type from aztec.js is `any`
240
- aztec_getPublicStorageAt: { params: { contract: AztecAddress; storageSlot: Fr }; result: any };
279
+ aztec_registerContractClass: {
280
+ params: [ContractArtifact];
281
+ result: boolean;
282
+ };
241
283
 
242
- /* Transactions */
243
- aztec_sendTx: { params: { tx: Tx }; result: TxHash };
244
- aztec_createTxExecutionRequest: { params: { exec: ExecutionRequestInit }; result: TxExecutionRequest };
284
+ /* Transaction Methods */
285
+ /**
286
+ * Generates proofs for a transaction execution request.
287
+ * @param params - A tuple containing the request and optional private execution result.
288
+ * @param params.0 txRequest - The {@link TxExecutionRequest} to prove.
289
+ * @param params.1 privateExecutionResult - Optional: {@link PrivateExecutionResult} from a prior private simulation.
290
+ * @returns result - The {@link TxProvingResult}, including the proven transaction.
291
+ */
245
292
  aztec_proveTx: {
246
- params: { txRequest: TxExecutionRequest; privateExecutionResult: PrivateExecutionResult };
293
+ params: [TxExecutionRequest, (PrivateExecutionResult | undefined)?];
247
294
  result: TxProvingResult;
248
295
  };
249
- aztec_getTxEffect: { params: { txHash: TxHash }; result: InBlock<TxEffect> };
250
- aztec_getTxReceipt: { params: { txHash: TxHash }; result: TxReceipt };
251
-
296
+ /**
297
+ * Sends a proven {@link Tx} (transaction) to the network.
298
+ * @param params - A tuple containing the proven transaction.
299
+ * @param params.0 tx - The proven {@link Tx} object to send.
300
+ * @returns result - The {@link TxHash} of the sent transaction.
301
+ */
302
+ aztec_sendTx: {
303
+ params: [Tx];
304
+ result: TxHash;
305
+ };
306
+ /**
307
+ * Retrieves the {@link TxReceipt} for a transaction.
308
+ * @param params - A tuple containing the transaction hash.
309
+ * @param params.0 txHash - The {@link TxHash} of the transaction.
310
+ * @returns result - The {@link TxReceipt}.
311
+ */
312
+ aztec_getTxReceipt: {
313
+ params: [TxHash];
314
+ result: TxReceipt;
315
+ };
316
+ /**
317
+ * Simulates a {@link TxExecutionRequest} without sending it to the network.
318
+ * @param params - A tuple containing the simulation parameters.
319
+ * @param params.0 txRequest - The {@link TxExecutionRequest} to simulate.
320
+ * @param params.1 simulatePublic - Optional: Whether to simulate public parts. Defaults to `false`.
321
+ * @param params.2 msgSender - Optional: {@link AztecAddress} for simulation context.
322
+ * @param params.3 skipTxValidation - Optional: Flag to skip validation. Defaults to `false`.
323
+ * @param params.4 skipFeeEnforcement - Optional: Flag to skip fee enforcement. Defaults to `false`.
324
+ * @returns result - The {@link TxSimulationResult}.
325
+ */
252
326
  aztec_simulateTx: {
253
- params: {
254
- txRequest: TxExecutionRequest;
255
- simulatePublic: boolean;
256
- msgSender?: AztecAddress;
257
- skipTxValidation?: boolean;
258
- enforceFeePayment?: boolean;
259
- profile?: boolean;
260
- };
327
+ params: [
328
+ TxExecutionRequest,
329
+ (boolean | undefined)?, // simulatePublic
330
+ (AztecAddress | undefined)?, // msgSender
331
+ (boolean | undefined)?, // skipTxValidation
332
+ (boolean | undefined)?, // skipFeeEnforcement
333
+ ];
261
334
  result: TxSimulationResult;
262
335
  };
263
- aztec_simulateUnconstrained: {
264
- params: { functionName: string; args: unknown[]; to: AztecAddress; from?: AztecAddress };
265
- result: AbiDecoded;
336
+ /**
337
+ * Profiles a {@link TxExecutionRequest} for performance analysis.
338
+ * @param params - A tuple containing the profiling parameters.
339
+ * @param params.0 txRequest - The {@link TxExecutionRequest} to profile.
340
+ * @param params.1 profileMode - Optional: Profiling mode ('gates', 'execution-steps', 'full'). Defaults to 'gates'.
341
+ * @param params.2 skipProofGeneration - Optional: Flag to skip proof generation. Defaults to `false`.
342
+ * @param params.3 msgSender - Optional: {@link AztecAddress} for profiling context.
343
+ * @returns result - The {@link TxProfileResult}.
344
+ */
345
+ aztec_profileTx: {
346
+ params: [
347
+ TxExecutionRequest,
348
+ ('gates' | 'execution-steps' | 'full' | undefined)?, // profileMode
349
+ (boolean | undefined)?, // skipProofGeneration
350
+ (AztecAddress | undefined)?, // msgSender
351
+ ];
352
+ result: TxProfileResult;
353
+ };
354
+ /**
355
+ * Simulates a utility (view) function call.
356
+ * @param params - A tuple containing the utility call parameters.
357
+ * @param params.0 functionName - Name of the utility function.
358
+ * @param params.1 args - Arguments for the function.
359
+ * @param params.2 to - {@link AztecAddress} of the contract/account.
360
+ * @param params.3 authWits - Optional: Array of {@link AuthWitness}.
361
+ * @param params.4 from - Optional: Sender {@link AztecAddress}.
362
+ * @returns result - The {@link UtilitySimulationResult}.
363
+ */
364
+ aztec_simulateUtility: {
365
+ params: [
366
+ string, // functionName
367
+ unknown[], // args
368
+ AztecAddress, // to
369
+ (AuthWitness[] | undefined)?, // authWits
370
+ (AztecAddress | undefined)?, // from
371
+ ];
372
+ result: UtilitySimulationResult;
266
373
  };
267
374
 
268
- /* Notes */
269
- aztec_getNotes: { params: { filter: NotesFilter }; result: UniqueNote[] };
270
- aztec_addNote: { params: { note: ExtendedNote }; result: boolean };
271
- aztec_addNullifiedNote: { params: { note: ExtendedNote }; result: boolean };
272
-
273
- /* Logs and Events */
274
- aztec_getPublicLogs: { params: { filter: LogFilter }; result: GetPublicLogsResponse };
275
- aztec_getContractClassLogs: { params: { filter: LogFilter }; result: GetContractClassLogsResponse };
375
+ /* Event Methods */
376
+ /**
377
+ * Retrieves private (encrypted) events from the blockchain.
378
+ * @param params - A tuple containing the query parameters.
379
+ * @param params.0 contractAddress - {@link AztecAddress} of the emitting contract.
380
+ * @param params.1 eventMetadata - {@link EventMetadataDefinition} for the event.
381
+ * @param params.2 fromBlock - Starting block number.
382
+ * @param params.3 numBlocks - Number of blocks to scan.
383
+ * @param params.4 recipients - Array of recipient {@link AztecAddress}es.
384
+ * @returns result - An array of decoded private event data (type `unknown[]`, actual type depends on `eventMetadata`).
385
+ */
276
386
  aztec_getPrivateEvents: {
277
- params: { event: EventMetadataDefinition; from: number; limit: number; vpks?: Point[] };
387
+ params: [
388
+ AztecAddress, // contractAddress
389
+ EventMetadataDefinition, // eventMetadata
390
+ number, // from
391
+ number, // numBlocks
392
+ AztecAddress[], // recipients
393
+ ];
278
394
  result: unknown[];
279
395
  };
396
+ /**
397
+ * Retrieves public (unencrypted) events from the blockchain.
398
+ * @param params - A tuple containing the query parameters.
399
+ * @param params.0 eventMetadata - {@link EventMetadataDefinition} for the event.
400
+ * @param params.1 fromBlock - Starting block number.
401
+ * @param params.2 limit - Maximum number of events to return.
402
+ * @returns result - An array of decoded public event data (type `unknown[]`, actual type depends on `eventMetadata`).
403
+ */
280
404
  aztec_getPublicEvents: {
281
- params: { event: EventMetadataDefinition; from: number; limit: number };
405
+ params: [
406
+ EventMetadataDefinition, // eventMetadata
407
+ number, // from
408
+ number, // limit
409
+ ];
282
410
  result: unknown[];
283
411
  };
284
- }
285
412
 
286
- export type AztecWalletMethodHandler<
287
- T extends AztecWalletMethodMap,
288
- M extends keyof T,
289
- C extends AztecWalletContext,
290
- > = (
291
- context: C,
292
- params: T[M]['params'],
293
- accountWallet: AccountWallet,
294
- ) => Promise<T[M]['result']> | T[M]['result'];
413
+ /* Contract Interaction Methods */
414
+ /**
415
+ * WalletMesh specific: Executes a contract function interaction using a pre-constructed {@link ExecutionPayload}.
416
+ * The wallet handles simulation, proving, and sending.
417
+ * @param params - A tuple containing the execution payload.
418
+ * @param params.0 executionPayload - The {@link ExecutionPayload} to execute.
419
+ * @returns result - The {@link TxHash} of the sent transaction.
420
+ */
421
+ aztec_wmExecuteTx: {
422
+ params: [executionPayload: ExecutionPayload];
423
+ result: TxHash;
424
+ };
295
425
 
296
- export type AztecChainId = `aztec:${string}`;
426
+ /**
427
+ * WalletMesh specific: Deploys a new contract using its artifact and constructor arguments.
428
+ * The wallet handles address computation, proving, and sending the deployment transaction.
429
+ * @param params - A tuple containing the deployment parameters.
430
+ * @param params.0 deploymentParams - Object containing `artifact` ({@link ContractArtifact}), `args` (array),
431
+ * and optional `constructorName` (string).
432
+ * @returns result - An object with `txHash` ({@link TxHash}) and `contractAddress` ({@link AztecAddress}).
433
+ */
434
+ aztec_wmDeployContract: {
435
+ params: [
436
+ {
437
+ artifact: ContractArtifact;
438
+ args: unknown[];
439
+ constructorName?: string;
440
+ },
441
+ ];
442
+ result: {
443
+ txHash: TxHash;
444
+ contractAddress: AztecAddress;
445
+ };
446
+ };
447
+
448
+ /**
449
+ * WalletMesh specific: Simulates a contract function interaction using a pre-constructed {@link ExecutionPayload}.
450
+ * @param params - A tuple containing the execution payload.
451
+ * @param params.0 executionPayload - The {@link ExecutionPayload} to simulate.
452
+ * @returns result - The {@link TxSimulationResult}.
453
+ */
454
+ aztec_wmSimulateTx: {
455
+ params: [executionPayload: ExecutionPayload];
456
+ result: TxSimulationResult;
457
+ };
458
+ }