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