@walletmesh/aztec-rpc-wallet 0.3.0 → 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 +26 -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 -268
  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 +471 -470
  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 -296
  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 -504
  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 -649
  166. package/src/handlers/aztecAccountWallet.ts +0 -532
  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 -274
  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
@@ -0,0 +1,1058 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecRouterProvider
6
+
7
+ # Class: AztecRouterProvider
8
+
9
+ Defined in: [aztec/rpc-wallet/src/client/aztec-router-provider.ts:46](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/client/aztec-router-provider.ts#L46)
10
+
11
+ An extended [WalletRouterProvider](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/WalletRouterProvider.md) specifically for Aztec network interactions.
12
+
13
+ This class automatically registers all necessary Aztec-specific type serializers
14
+ (e.g., for `AztecAddress`, `Fr`, `TxExecutionRequest`) upon instantiation.
15
+ This ensures that when dApps communicate with an Aztec wallet via this provider,
16
+ all Aztec types are correctly serialized for JSON-RPC transport and deserialized
17
+ back into their proper object instances on receipt.
18
+
19
+ It simplifies the setup for dApp developers, as they do not need to manually
20
+ register serializers for Aztec types.
21
+
22
+ ## Example
23
+
24
+ ```typescript
25
+ import { AztecRouterProvider, createAztecWallet } from '@walletmesh/aztec-rpc-wallet';
26
+ import { MyCustomTransport } from './my-custom-transport'; // Assuming a custom transport
27
+
28
+ // 1. Create a JSON-RPC transport
29
+ const transport = new MyCustomTransport();
30
+
31
+ // 2. Create the AztecRouterProvider instance
32
+ const provider = new AztecRouterProvider(transport);
33
+
34
+ // 3. Connect to the Aztec chain (e.g., testnet) and request permissions
35
+ await provider.connect({
36
+ 'aztec:testnet': ['aztec_getAddress', 'aztec_sendTx']
37
+ });
38
+
39
+ // 4. Create an AztecDappWallet instance using the provider
40
+ const wallet = await createAztecWallet(provider, 'aztec:testnet');
41
+
42
+ // Now, calls made through 'wallet' will automatically handle Aztec type serialization:
43
+ const address = await wallet.getAddress(); // AztecAddress instance
44
+ // const txRequest = ...;
45
+ // const txHash = await wallet.sendTx(await wallet.proveTx(txRequest)); // Tx, TxHash instances
46
+ ```
47
+
48
+ ## See
49
+
50
+ - [WalletRouterProvider](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/WalletRouterProvider.md) for the base class functionality.
51
+ - [registerAztecSerializers](../functions/registerAztecSerializers.md) for the underlying serializer registration.
52
+ - [AztecDappWallet](AztecDappWallet.md) which is typically used with this provider.
53
+
54
+ ## Extends
55
+
56
+ - [`WalletRouterProvider`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/WalletRouterProvider.md)
57
+
58
+ ## Constructors
59
+
60
+ ### Constructor
61
+
62
+ > **new AztecRouterProvider**(`transport`, `context?`): `AztecRouterProvider`
63
+
64
+ Defined in: [aztec/rpc-wallet/src/client/aztec-router-provider.ts:58](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/client/aztec-router-provider.ts#L58)
65
+
66
+ Constructs an instance of `AztecRouterProvider`.
67
+
68
+ Upon construction, it immediately registers all Aztec-specific serializers
69
+ with the underlying JSON-RPC node managed by the `WalletRouterProvider`.
70
+
71
+ #### Parameters
72
+
73
+ ##### transport
74
+
75
+ [`JSONRPCTransport`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCTransport.md)
76
+
77
+ The [JSONRPCTransport](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCTransport.md) instance to be used for
78
+ communication between the dApp and the WalletRouter.
79
+
80
+ ##### context?
81
+
82
+ `Record`\<`string`, `unknown`\>
83
+
84
+ Optional context object that can be passed to the
85
+ `WalletRouterProvider` constructor.
86
+
87
+ #### Returns
88
+
89
+ `AztecRouterProvider`
90
+
91
+ #### Overrides
92
+
93
+ `WalletRouterProvider.constructor`
94
+
95
+ ## Properties
96
+
97
+ ### context
98
+
99
+ > `readonly` **context**: `RouterContext`
100
+
101
+ Defined in: core/jsonrpc/dist/node.d.ts:51
102
+
103
+ #### Inherited from
104
+
105
+ `WalletRouterProvider.context`
106
+
107
+ ## Accessors
108
+
109
+ ### sessionId
110
+
111
+ #### Get Signature
112
+
113
+ > **get** **sessionId**(): `undefined` \| `string`
114
+
115
+ Defined in: core/router/dist/provider.d.ts:60
116
+
117
+ Gets the current session ID if connected, undefined otherwise.
118
+ The session ID is required for most operations and is set after
119
+ a successful connection.
120
+
121
+ ##### See
122
+
123
+ - [connect](#connect) for establishing a session
124
+ - [disconnect](#disconnect) for ending a session
125
+
126
+ ##### Returns
127
+
128
+ `undefined` \| `string`
129
+
130
+ The current session ID or undefined if not connected
131
+
132
+ #### Inherited from
133
+
134
+ `WalletRouterProvider.sessionId`
135
+
136
+ ## Methods
137
+
138
+ ### addMiddleware()
139
+
140
+ > **addMiddleware**(`middleware`): () => `void`
141
+
142
+ Defined in: core/jsonrpc/dist/node.d.ts:122
143
+
144
+ Adds a middleware function to the request processing chain.
145
+ Middleware functions can intercept and modify incoming requests and outgoing responses.
146
+
147
+ #### Parameters
148
+
149
+ ##### middleware
150
+
151
+ [`JSONRPCMiddleware`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/type-aliases/JSONRPCMiddleware.md)\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md), `RouterContext`\>
152
+
153
+ The middleware function to add.
154
+
155
+ #### Returns
156
+
157
+ A function that, when called, will remove this middleware.
158
+
159
+ > (): `void`
160
+
161
+ ##### Returns
162
+
163
+ `void`
164
+
165
+ #### Inherited from
166
+
167
+ `WalletRouterProvider.addMiddleware`
168
+
169
+ ***
170
+
171
+ ### bulkCall()
172
+
173
+ > **bulkCall**\<`T`\>(`chainId`, `calls`, `timeout?`): `Promise`\<[`MethodResults`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/MethodResults.md)\<`T`\>\>
174
+
175
+ Defined in: core/router/dist/provider.d.ts:201
176
+
177
+ Executes multiple method calls in sequence on the same chain.
178
+ More efficient than multiple individual calls for related operations.
179
+
180
+ #### Type Parameters
181
+
182
+ ##### T
183
+
184
+ `T` *extends* readonly [`MethodCall`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/MethodCall.md)\<keyof [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\>[]
185
+
186
+ #### Parameters
187
+
188
+ ##### chainId
189
+
190
+ `string`
191
+
192
+ Target chain identifier (must match the chain ID used to connect)
193
+
194
+ ##### calls
195
+
196
+ `T`
197
+
198
+ Array of method calls to execute
199
+
200
+ ##### timeout?
201
+
202
+ `number`
203
+
204
+ Optional timeout in milliseconds. If the request takes longer,
205
+ it will be cancelled and throw a TimeoutError
206
+
207
+ #### Returns
208
+
209
+ `Promise`\<[`MethodResults`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/MethodResults.md)\<`T`\>\>
210
+
211
+ Array of results from the wallet method calls
212
+
213
+ #### Throws
214
+
215
+ With code 'invalidSession' if not connected
216
+
217
+ #### Throws
218
+
219
+ With code 'unknownChain' if chain ID is invalid
220
+
221
+ #### Throws
222
+
223
+ With code 'insufficientPermissions' if any method not permitted
224
+
225
+ #### Throws
226
+
227
+ With code 'partialFailure' if some calls succeed but others fail
228
+
229
+ #### Throws
230
+
231
+ If the request times out
232
+
233
+ #### See
234
+
235
+ [\['wm\_bulkCall'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
236
+
237
+ #### Example
238
+
239
+ ```typescript
240
+ // Get accounts and balance in one request
241
+ const [accounts, balance] = await provider.bulkCall('eip155:1', [
242
+ { method: 'eth_accounts' },
243
+ {
244
+ method: 'eth_getBalance',
245
+ params: ['0x...', 'latest']
246
+ }
247
+ ]);
248
+ ```
249
+
250
+ #### Inherited from
251
+
252
+ `WalletRouterProvider.bulkCall`
253
+
254
+ ***
255
+
256
+ ### call()
257
+
258
+ > **call**\<`M`\>(`chainId`, `call`, `timeout?`): `Promise`\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"result"`\]\>
259
+
260
+ Defined in: core/router/dist/provider.d.ts:172
261
+
262
+ Invokes a method on the connected wallet.
263
+ Routes the call to the appropriate wallet client based on chain ID.
264
+
265
+ #### Type Parameters
266
+
267
+ ##### M
268
+
269
+ `M` *extends* keyof [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)
270
+
271
+ #### Parameters
272
+
273
+ ##### chainId
274
+
275
+ `string`
276
+
277
+ Target chain identifier (must match the chain ID used to connect)
278
+
279
+ ##### call
280
+
281
+ [`MethodCall`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/MethodCall.md)\<`M`\>
282
+
283
+ Method call details including name and parameters
284
+
285
+ ##### timeout?
286
+
287
+ `number`
288
+
289
+ Optional timeout in milliseconds. If the request takes longer,
290
+ it will be cancelled and throw a TimeoutError
291
+
292
+ #### Returns
293
+
294
+ `Promise`\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"result"`\]\>
295
+
296
+ Result from the wallet method call with proper type inference
297
+
298
+ #### Throws
299
+
300
+ With code 'invalidSession' if not connected
301
+
302
+ #### Throws
303
+
304
+ With code 'unknownChain' if chain ID is invalid
305
+
306
+ #### Throws
307
+
308
+ With code 'insufficientPermissions' if method not permitted
309
+
310
+ #### Throws
311
+
312
+ With code 'methodNotSupported' if method not supported
313
+
314
+ #### Throws
315
+
316
+ If the request times out
317
+
318
+ #### See
319
+
320
+ [\['wm\_call'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
321
+
322
+ #### Example
323
+
324
+ ```typescript
325
+ // Get accounts with proper type inference
326
+ const accounts = await provider.call('eip155:1', {
327
+ method: 'eth_accounts'
328
+ } as const);
329
+
330
+ // Send transaction with proper type inference
331
+ const txHash = await provider.call('eip155:1', {
332
+ method: 'eth_sendTransaction',
333
+ params: [{
334
+ to: '0x...',
335
+ value: '0x...'
336
+ }]
337
+ } as const);
338
+ ```
339
+
340
+ #### Inherited from
341
+
342
+ `WalletRouterProvider.call`
343
+
344
+ ***
345
+
346
+ ### callMethod()
347
+
348
+ > **callMethod**\<`M`\>(`method`, `params?`, `timeoutInSeconds?`): `Promise`\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"result"`\]\>
349
+
350
+ Defined in: core/jsonrpc/dist/node.d.ts:92
351
+
352
+ Calls a remote JSON-RPC method.
353
+
354
+ #### Type Parameters
355
+
356
+ ##### M
357
+
358
+ `M` *extends* keyof [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)
359
+
360
+ #### Parameters
361
+
362
+ ##### method
363
+
364
+ `M`
365
+
366
+ The name of the method to call.
367
+
368
+ ##### params?
369
+
370
+ [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"params"`\]
371
+
372
+ The parameters for the method call.
373
+
374
+ ##### timeoutInSeconds?
375
+
376
+ `number`
377
+
378
+ Optional timeout for the request in seconds. Defaults to 0 (no timeout).
379
+
380
+ #### Returns
381
+
382
+ `Promise`\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"result"`\]\>
383
+
384
+ A promise that resolves with the result of the method call.
385
+
386
+ #### Throws
387
+
388
+ If the request times out.
389
+
390
+ #### Throws
391
+
392
+ If the remote end returns an error.
393
+
394
+ #### Throws
395
+
396
+ If sending the request fails.
397
+
398
+ #### Inherited from
399
+
400
+ `WalletRouterProvider.callMethod`
401
+
402
+ ***
403
+
404
+ ### chain()
405
+
406
+ > **chain**(`chainId`): [`OperationBuilder`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/OperationBuilder.md)\<readonly \[\]\>
407
+
408
+ Defined in: core/router/dist/provider.d.ts:244
409
+
410
+ Creates a new operation builder for chaining method calls.
411
+ Enables fluent method call chaining with proper type inference.
412
+
413
+ #### Parameters
414
+
415
+ ##### chainId
416
+
417
+ `string`
418
+
419
+ The chain to execute operations on
420
+
421
+ #### Returns
422
+
423
+ [`OperationBuilder`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/OperationBuilder.md)\<readonly \[\]\>
424
+
425
+ A new operation builder instance
426
+
427
+ #### Example
428
+
429
+ ```typescript
430
+ const [balance, code] = await provider
431
+ .chain('eip155:1')
432
+ .call('eth_getBalance', ['0x123...'])
433
+ .call('eth_getCode', ['0x456...'])
434
+ .execute();
435
+ ```
436
+
437
+ #### Inherited from
438
+
439
+ `WalletRouterProvider.chain`
440
+
441
+ ***
442
+
443
+ ### close()
444
+
445
+ > **close**(): `Promise`\<`void`\>
446
+
447
+ Defined in: core/jsonrpc/dist/node.d.ts:150
448
+
449
+ Closes the JSON-RPC node, cleaning up resources.
450
+ This includes removing all event handlers, middleware, and rejecting any pending requests.
451
+ The underlying transport is not closed by this method and should be managed separately.
452
+
453
+ #### Returns
454
+
455
+ `Promise`\<`void`\>
456
+
457
+ #### Inherited from
458
+
459
+ `WalletRouterProvider.close`
460
+
461
+ ***
462
+
463
+ ### connect()
464
+
465
+ > **connect**(`permissions`, `timeout?`): `Promise`\<\{ `permissions`: [`HumanReadableChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md); `sessionId`: `string`; \}\>
466
+
467
+ Defined in: core/router/dist/provider.d.ts:88
468
+
469
+ Connects to multiple chains with specified permissions.
470
+ Establishes a session and requests method permissions for each chain.
471
+
472
+ #### Parameters
473
+
474
+ ##### permissions
475
+
476
+ [`ChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/ChainPermissions.md)
477
+
478
+ Map of chain IDs to their requested permissions
479
+
480
+ ##### timeout?
481
+
482
+ `number`
483
+
484
+ Optional timeout in milliseconds. If the request takes longer,
485
+ it will be cancelled and throw a TimeoutError
486
+
487
+ #### Returns
488
+
489
+ `Promise`\<\{ `permissions`: [`HumanReadableChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md); `sessionId`: `string`; \}\>
490
+
491
+ Session ID that can be used for future requests
492
+
493
+ #### Throws
494
+
495
+ With code 'invalidRequest' if permissions are invalid
496
+
497
+ #### Throws
498
+
499
+ With code 'unknownChain' if a chain is not supported
500
+
501
+ #### Throws
502
+
503
+ If the request times out
504
+
505
+ #### See
506
+
507
+ [\['wm\_connect'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
508
+
509
+ #### Example
510
+
511
+ ```typescript
512
+ // Connect to multiple chains with specific permissions
513
+ const { sessionId, permissions } = await provider.connect({
514
+ 'eip155:1': ['eth_accounts', 'eth_sendTransaction'],
515
+ 'eip155:137': ['eth_getBalance', 'eth_call']
516
+ });
517
+
518
+ // Connect with a 5 second timeout
519
+ const { sessionId, permissions } = await provider.connect({
520
+ 'eip155:1': ['eth_accounts']
521
+ }, 5000);
522
+ ```
523
+
524
+ #### Inherited from
525
+
526
+ `WalletRouterProvider.connect`
527
+
528
+ ***
529
+
530
+ ### disconnect()
531
+
532
+ > **disconnect**(`timeout?`): `Promise`\<`void`\>
533
+
534
+ Defined in: core/router/dist/provider.d.ts:102
535
+
536
+ Disconnects the current session if one exists.
537
+ Cleans up session state and notifies the router to terminate the session.
538
+
539
+ #### Parameters
540
+
541
+ ##### timeout?
542
+
543
+ `number`
544
+
545
+ Optional timeout in milliseconds. If the request takes longer,
546
+ it will be cancelled and throw a TimeoutError
547
+
548
+ #### Returns
549
+
550
+ `Promise`\<`void`\>
551
+
552
+ #### Throws
553
+
554
+ With code 'invalidSession' if not connected
555
+
556
+ #### Throws
557
+
558
+ If the request times out
559
+
560
+ #### See
561
+
562
+ [\['wm\_disconnect'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
563
+
564
+ #### Inherited from
565
+
566
+ `WalletRouterProvider.disconnect`
567
+
568
+ ***
569
+
570
+ ### emit()
571
+
572
+ > **emit**\<`K`\>(`event`, `params`): `Promise`\<`void`\>
573
+
574
+ Defined in: core/jsonrpc/dist/node.d.ts:114
575
+
576
+ Emits an event to the remote end.
577
+
578
+ #### Type Parameters
579
+
580
+ ##### K
581
+
582
+ `K` *extends* keyof [`RouterEventMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterEventMap.md)
583
+
584
+ #### Parameters
585
+
586
+ ##### event
587
+
588
+ `K`
589
+
590
+ The name of the event to emit.
591
+
592
+ ##### params
593
+
594
+ [`RouterEventMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterEventMap.md)\[`K`\]
595
+
596
+ The payload for the event.
597
+
598
+ #### Returns
599
+
600
+ `Promise`\<`void`\>
601
+
602
+ #### Inherited from
603
+
604
+ `WalletRouterProvider.emit`
605
+
606
+ ***
607
+
608
+ ### getPermissions()
609
+
610
+ > **getPermissions**(`chainIds?`, `timeout?`): `Promise`\<[`HumanReadableChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md)\>
611
+
612
+ Defined in: core/router/dist/provider.d.ts:116
613
+
614
+ Gets current session permissions.
615
+ Returns a human-readable format suitable for displaying to users.
616
+
617
+ #### Parameters
618
+
619
+ ##### chainIds?
620
+
621
+ `string`[]
622
+
623
+ Optional array of chain IDs to get permissions for. If not provided, returns permissions for all chains
624
+
625
+ ##### timeout?
626
+
627
+ `number`
628
+
629
+ Optional timeout in milliseconds. If the request takes longer,
630
+ it will be cancelled and throw a TimeoutError
631
+
632
+ #### Returns
633
+
634
+ `Promise`\<[`HumanReadableChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md)\>
635
+
636
+ Record of chain IDs to their permissions with human-readable descriptions
637
+
638
+ #### Throws
639
+
640
+ With code 'invalidSession' if not connected
641
+
642
+ #### Throws
643
+
644
+ If the request times out
645
+
646
+ #### See
647
+
648
+ - [HumanReadableChainPermissions](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md) for return type details
649
+ - [\['wm\_getPermissions'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
650
+
651
+ #### Inherited from
652
+
653
+ `WalletRouterProvider.getPermissions`
654
+
655
+ ***
656
+
657
+ ### getSupportedMethods()
658
+
659
+ > **getSupportedMethods**(`chainIds?`, `timeout?`): `Promise`\<`Record`\<`string`, `string`[]\>\>
660
+
661
+ Defined in: core/router/dist/provider.d.ts:227
662
+
663
+ Gets supported methods for one or more chains.
664
+ Used for capability discovery and feature detection.
665
+
666
+ #### Parameters
667
+
668
+ ##### chainIds?
669
+
670
+ `string`[]
671
+
672
+ Optional array of chain identifiers. If not provided, returns router's supported methods
673
+
674
+ ##### timeout?
675
+
676
+ `number`
677
+
678
+ Optional timeout in milliseconds. If the request takes longer,
679
+ it will be cancelled and throw a TimeoutError
680
+
681
+ #### Returns
682
+
683
+ `Promise`\<`Record`\<`string`, `string`[]\>\>
684
+
685
+ Record mapping chain IDs to their supported methods
686
+
687
+ #### Throws
688
+
689
+ With code 'unknownChain' if any chain ID is invalid
690
+
691
+ #### Throws
692
+
693
+ With code 'walletNotAvailable' if wallet capability check fails
694
+
695
+ #### Throws
696
+
697
+ If the request times out
698
+
699
+ #### See
700
+
701
+ [\['wm\_getSupportedMethods'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
702
+
703
+ #### Example
704
+
705
+ ```typescript
706
+ // Get methods for multiple chains
707
+ const methods = await provider.getSupportedMethods(['eip155:1', 'eip155:137']);
708
+ if (methods['eip155:1'].includes('eth_signMessage')) {
709
+ // Ethereum mainnet wallet supports message signing
710
+ }
711
+
712
+ // Get router's supported methods
713
+ const routerMethods = await provider.getSupportedMethods();
714
+ ```
715
+
716
+ #### Inherited from
717
+
718
+ `WalletRouterProvider.getSupportedMethods`
719
+
720
+ ***
721
+
722
+ ### notify()
723
+
724
+ > **notify**\<`M`\>(`method`, `params`): `Promise`\<`void`\>
725
+
726
+ Defined in: core/jsonrpc/dist/node.d.ts:99
727
+
728
+ Sends a JSON-RPC notification (a request without an ID, expecting no response).
729
+
730
+ #### Type Parameters
731
+
732
+ ##### M
733
+
734
+ `M` *extends* keyof [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)
735
+
736
+ #### Parameters
737
+
738
+ ##### method
739
+
740
+ `M`
741
+
742
+ The name of the method for the notification.
743
+
744
+ ##### params
745
+
746
+ [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"params"`\]
747
+
748
+ The parameters for the notification.
749
+
750
+ #### Returns
751
+
752
+ `Promise`\<`void`\>
753
+
754
+ #### Inherited from
755
+
756
+ `WalletRouterProvider.notify`
757
+
758
+ ***
759
+
760
+ ### on()
761
+
762
+ > **on**\<`K`\>(`event`, `handler`): () => `void`
763
+
764
+ Defined in: core/jsonrpc/dist/node.d.ts:107
765
+
766
+ Registers an event handler for a specific event name.
767
+
768
+ #### Type Parameters
769
+
770
+ ##### K
771
+
772
+ `K` *extends* keyof [`RouterEventMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterEventMap.md)
773
+
774
+ #### Parameters
775
+
776
+ ##### event
777
+
778
+ `K`
779
+
780
+ The name of the event to listen for.
781
+
782
+ ##### handler
783
+
784
+ (`params`) => `void`
785
+
786
+ The function to call when the event is received. It receives the event payload.
787
+
788
+ #### Returns
789
+
790
+ A function that, when called, will remove this event handler.
791
+
792
+ > (): `void`
793
+
794
+ ##### Returns
795
+
796
+ `void`
797
+
798
+ #### Inherited from
799
+
800
+ `WalletRouterProvider.on`
801
+
802
+ ***
803
+
804
+ ### receiveMessage()
805
+
806
+ > **receiveMessage**(`message`): `Promise`\<`void`\>
807
+
808
+ Defined in: core/jsonrpc/dist/node.d.ts:130
809
+
810
+ Processes an incoming message from the transport.
811
+ This method is typically called by the transport's `onMessage` handler.
812
+ It validates the message and routes it to the appropriate handler (request, response, or event).
813
+
814
+ #### Parameters
815
+
816
+ ##### message
817
+
818
+ `unknown`
819
+
820
+ The raw message received from the transport.
821
+
822
+ #### Returns
823
+
824
+ `Promise`\<`void`\>
825
+
826
+ #### Inherited from
827
+
828
+ `WalletRouterProvider.receiveMessage`
829
+
830
+ ***
831
+
832
+ ### registerMethod()
833
+
834
+ > **registerMethod**\<`M`\>(`name`, `handler`): `void`
835
+
836
+ Defined in: core/jsonrpc/dist/node.d.ts:73
837
+
838
+ Registers a method handler for a given method name.
839
+
840
+ #### Type Parameters
841
+
842
+ ##### M
843
+
844
+ `M` *extends* keyof [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)
845
+
846
+ #### Parameters
847
+
848
+ ##### name
849
+
850
+ `Extract`\<`M`, `string`\>
851
+
852
+ The name of the method to register.
853
+
854
+ ##### handler
855
+
856
+ (`context`, `params`) => `Promise`\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"result"`\]\>
857
+
858
+ The asynchronous function to handle requests for this method.
859
+ It receives the context and method parameters, and should return the result.
860
+
861
+ #### Returns
862
+
863
+ `void`
864
+
865
+ #### Inherited from
866
+
867
+ `WalletRouterProvider.registerMethod`
868
+
869
+ ***
870
+
871
+ ### registerMethodSerializer()
872
+
873
+ > **registerMethodSerializer**\<`P`, `R`\>(`method`, `serializer`): `void`
874
+
875
+ Defined in: core/router/dist/provider.d.ts:270
876
+
877
+ Registers a serializer for a specific wallet method.
878
+ This allows the provider to properly serialize parameters and deserialize results
879
+ for wallet methods before they are wrapped in wm_call.
880
+
881
+ #### Type Parameters
882
+
883
+ ##### P
884
+
885
+ `P` = `unknown`
886
+
887
+ ##### R
888
+
889
+ `R` = `unknown`
890
+
891
+ #### Parameters
892
+
893
+ ##### method
894
+
895
+ `string`
896
+
897
+ The wallet method name (e.g., 'aztec_getAddress', 'eth_getBalance')
898
+
899
+ ##### serializer
900
+
901
+ [`JSONRPCSerializer`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCSerializer.md)\<`P`, `R`\>
902
+
903
+ The serializer for the method
904
+
905
+ #### Returns
906
+
907
+ `void`
908
+
909
+ #### Example
910
+
911
+ ```typescript
912
+ // Register a serializer for Aztec addresses
913
+ provider.registerMethodSerializer('aztec_getAddress', {
914
+ result: {
915
+ serialize: async (result) => ({ serialized: result.toString() }),
916
+ deserialize: async (data) => AztecAddress.fromString(data.serialized)
917
+ }
918
+ });
919
+
920
+ // Now calls to aztec_getAddress will automatically serialize/deserialize
921
+ const address = await provider.call('aztec:mainnet', {
922
+ method: 'aztec_getAddress'
923
+ });
924
+ // address is properly typed as AztecAddress
925
+ ```
926
+
927
+ #### Inherited from
928
+
929
+ `WalletRouterProvider.registerMethodSerializer`
930
+
931
+ ***
932
+
933
+ ### registerSerializer()
934
+
935
+ > **registerSerializer**\<`M`\>(`method`, `serializer`): `void`
936
+
937
+ Defined in: core/jsonrpc/dist/node.d.ts:80
938
+
939
+ Registers a custom serializer for the parameters and/or result of a specific method.
940
+
941
+ #### Type Parameters
942
+
943
+ ##### M
944
+
945
+ `M` *extends* keyof [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)
946
+
947
+ #### Parameters
948
+
949
+ ##### method
950
+
951
+ `M`
952
+
953
+ The name of the method for which to register the serializer.
954
+
955
+ ##### serializer
956
+
957
+ [`JSONRPCSerializer`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCSerializer.md)\<[`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"params"`\], [`RouterMethodMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md)\[`M`\]\[`"result"`\]\>
958
+
959
+ The serializer implementation for the method's parameters and/or result.
960
+
961
+ #### Returns
962
+
963
+ `void`
964
+
965
+ #### Inherited from
966
+
967
+ `WalletRouterProvider.registerSerializer`
968
+
969
+ ***
970
+
971
+ ### setFallbackHandler()
972
+
973
+ > **setFallbackHandler**(`handler`): `void`
974
+
975
+ Defined in: core/jsonrpc/dist/node.d.ts:144
976
+
977
+ Sets a fallback handler for methods that are not explicitly registered.
978
+ This handler will be invoked if a request is received for a method name
979
+ that does not have a registered handler. The provided handler should return
980
+ the direct result of the operation, which will be wrapped into a MethodResponse.
981
+
982
+ #### Parameters
983
+
984
+ ##### handler
985
+
986
+ (`context`, `method`, `params`) => `Promise`\<`unknown`\>
987
+
988
+ The asynchronous function to handle fallback requests.
989
+ It receives the context, method name, and parameters, and should
990
+ return a Promise resolving to the method's result.
991
+
992
+ #### Returns
993
+
994
+ `void`
995
+
996
+ #### Inherited from
997
+
998
+ `WalletRouterProvider.setFallbackHandler`
999
+
1000
+ ***
1001
+
1002
+ ### updatePermissions()
1003
+
1004
+ > **updatePermissions**(`permissions`, `timeout?`): `Promise`\<[`HumanReadableChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md)\>
1005
+
1006
+ Defined in: core/router/dist/provider.d.ts:138
1007
+
1008
+ Updates session permissions.
1009
+ Requests additional permissions or modifies existing ones.
1010
+
1011
+ #### Parameters
1012
+
1013
+ ##### permissions
1014
+
1015
+ `Record`\<`ChainId`, `string`[]\>
1016
+
1017
+ Record of chain IDs to their new permissions
1018
+
1019
+ ##### timeout?
1020
+
1021
+ `number`
1022
+
1023
+ Optional timeout in milliseconds. If the request takes longer,
1024
+ it will be cancelled and throw a TimeoutError
1025
+
1026
+ #### Returns
1027
+
1028
+ `Promise`\<[`HumanReadableChainPermissions`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/type-aliases/HumanReadableChainPermissions.md)\>
1029
+
1030
+ #### Throws
1031
+
1032
+ With code 'invalidSession' if not connected
1033
+
1034
+ #### Throws
1035
+
1036
+ With code 'invalidRequest' if permissions are invalid
1037
+
1038
+ #### Throws
1039
+
1040
+ If the request times out
1041
+
1042
+ #### See
1043
+
1044
+ [\['wm\_updatePermissions'\]](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/interfaces/RouterMethodMap.md) for detailed request/response types
1045
+
1046
+ #### Example
1047
+
1048
+ ```typescript
1049
+ // Update permissions for multiple chains
1050
+ await provider.updatePermissions({
1051
+ 'eip155:1': ['eth_accounts', 'eth_sendTransaction'],
1052
+ 'eip155:137': ['eth_getBalance', 'eth_call']
1053
+ });
1054
+ ```
1055
+
1056
+ #### Inherited from
1057
+
1058
+ `WalletRouterProvider.updatePermissions`