@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.
- package/CHANGELOG.md +26 -0
- package/README.md +290 -228
- package/dist/.tsbuildinfo +1 -1
- package/dist/client/aztec-dapp-wallet.d.ts +401 -0
- package/dist/client/aztec-dapp-wallet.d.ts.map +1 -0
- package/dist/client/aztec-dapp-wallet.js +705 -0
- package/dist/client/aztec-router-provider.d.ts +58 -0
- package/dist/client/aztec-router-provider.d.ts.map +1 -0
- package/dist/client/aztec-router-provider.js +62 -0
- package/dist/client/helpers.d.ts +44 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +79 -0
- package/dist/client/register-serializers.d.ts +41 -0
- package/dist/client/register-serializers.d.ts.map +1 -0
- package/dist/client/register-serializers.js +97 -0
- package/dist/contractArtifactCache.d.ts +49 -32
- package/dist/contractArtifactCache.d.ts.map +1 -1
- package/dist/contractArtifactCache.js +47 -34
- package/dist/errors.d.ts +50 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +50 -10
- package/dist/index.d.ts +53 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -17
- package/dist/types.d.ts +345 -268
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -8
- package/dist/wallet/create-node.d.ts +73 -0
- package/dist/wallet/create-node.d.ts.map +1 -0
- package/dist/wallet/create-node.js +99 -0
- package/dist/wallet/handlers/account.d.ts +67 -0
- package/dist/wallet/handlers/account.d.ts.map +1 -0
- package/dist/wallet/handlers/account.js +85 -0
- package/dist/wallet/handlers/contract-interaction.d.ts +77 -0
- package/dist/wallet/handlers/contract-interaction.d.ts.map +1 -0
- package/dist/wallet/handlers/contract-interaction.js +219 -0
- package/dist/wallet/handlers/contract.d.ts +96 -0
- package/dist/wallet/handlers/contract.d.ts.map +1 -0
- package/dist/wallet/handlers/contract.js +146 -0
- package/dist/wallet/handlers/event.d.ts +62 -0
- package/dist/wallet/handlers/event.d.ts.map +1 -0
- package/dist/wallet/handlers/event.js +85 -0
- package/dist/wallet/handlers/index.d.ts +88 -0
- package/dist/wallet/handlers/index.d.ts.map +1 -0
- package/dist/wallet/handlers/index.js +47 -0
- package/dist/wallet/handlers/node.d.ts +117 -0
- package/dist/wallet/handlers/node.d.ts.map +1 -0
- package/dist/wallet/handlers/node.js +196 -0
- package/dist/wallet/handlers/senders.d.ts +70 -0
- package/dist/wallet/handlers/senders.d.ts.map +1 -0
- package/dist/wallet/handlers/senders.js +92 -0
- package/dist/wallet/handlers/transaction.d.ts +123 -0
- package/dist/wallet/handlers/transaction.d.ts.map +1 -0
- package/dist/wallet/handlers/transaction.js +191 -0
- package/dist/wallet/serializers.d.ts +75 -0
- package/dist/wallet/serializers.d.ts.map +1 -0
- package/dist/wallet/serializers.js +501 -0
- package/docs/README.md +290 -229
- package/docs/classes/AztecDappWallet.md +1304 -0
- package/docs/classes/AztecRouterProvider.md +1058 -0
- package/docs/classes/AztecWalletError.md +124 -47
- package/docs/classes/ContractArtifactCache.md +48 -31
- package/docs/functions/connectAztec.md +62 -0
- package/docs/functions/createAztecWallet.md +46 -0
- package/docs/functions/createAztecWalletNode.md +96 -0
- package/docs/functions/registerAztecSerializers.md +61 -0
- package/docs/functions/registerWalletAztecSerializers.md +39 -0
- package/docs/globals.md +16 -14
- package/docs/interfaces/AztecHandlerContext.md +54 -0
- package/docs/interfaces/AztecWalletContext.md +50 -0
- package/docs/interfaces/AztecWalletMethodMap.md +471 -470
- package/docs/type-aliases/AztecChainId.md +16 -3
- package/docs/variables/ALL_AZTEC_METHODS.md +20 -0
- package/docs/variables/AztecWalletErrorMap.md +9 -4
- package/docs/variables/AztecWalletSerializer.md +45 -0
- package/package.json +9 -9
- package/src/client/aztec-dapp-wallet.test.ts +628 -0
- package/src/client/aztec-dapp-wallet.ts +879 -0
- package/src/client/aztec-router-provider.test.ts +235 -0
- package/src/client/aztec-router-provider.ts +64 -0
- package/src/client/helpers.test.ts +187 -0
- package/src/client/helpers.ts +91 -0
- package/src/client/register-serializers.ts +108 -0
- package/src/contractArtifactCache.test.ts +21 -10
- package/src/contractArtifactCache.ts +54 -35
- package/src/errors.ts +58 -10
- package/src/index.test.ts +2 -6
- package/src/index.ts +73 -37
- package/src/types.ts +379 -217
- package/src/wallet/create-node.test.ts +332 -0
- package/src/wallet/create-node.ts +120 -0
- package/src/wallet/handlers/account.test.ts +172 -0
- package/src/wallet/handlers/account.ts +99 -0
- package/src/wallet/handlers/contract-interaction.test.ts +248 -0
- package/src/wallet/handlers/contract-interaction.ts +269 -0
- package/src/wallet/handlers/contract.test.ts +245 -0
- package/src/wallet/handlers/contract.ts +174 -0
- package/src/wallet/handlers/event.test.ts +216 -0
- package/src/wallet/handlers/event.ts +99 -0
- package/src/wallet/handlers/index.ts +84 -0
- package/src/wallet/handlers/node.test.ts +304 -0
- package/src/wallet/handlers/node.ts +230 -0
- package/src/wallet/handlers/senders.test.ts +172 -0
- package/src/wallet/handlers/senders.ts +106 -0
- package/src/wallet/handlers/transaction.test.ts +371 -0
- package/src/wallet/handlers/transaction.ts +239 -0
- package/src/wallet/serializers.test.ts +253 -0
- package/src/wallet/serializers.ts +586 -0
- package/typedoc.json +23 -1
- package/dist/aztecRemoteWallet.d.ts +0 -70
- package/dist/aztecRemoteWallet.d.ts.map +0 -1
- package/dist/aztecRemoteWallet.js +0 -335
- package/dist/chainProvider.d.ts +0 -56
- package/dist/chainProvider.d.ts.map +0 -1
- package/dist/chainProvider.js +0 -98
- package/dist/handlers/aztecAccountWallet.d.ts +0 -4
- package/dist/handlers/aztecAccountWallet.d.ts.map +0 -1
- package/dist/handlers/aztecAccountWallet.js +0 -296
- package/dist/handlers/transactions.d.ts +0 -21
- package/dist/handlers/transactions.d.ts.map +0 -1
- package/dist/handlers/transactions.js +0 -98
- package/dist/handlers.d.ts +0 -27
- package/dist/handlers.d.ts.map +0 -1
- package/dist/handlers.js +0 -55
- package/dist/provider.d.ts +0 -105
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -160
- package/dist/serializers/account.d.ts +0 -164
- package/dist/serializers/account.d.ts.map +0 -1
- package/dist/serializers/account.js +0 -244
- package/dist/serializers/contract.d.ts +0 -62
- package/dist/serializers/contract.d.ts.map +0 -1
- package/dist/serializers/contract.js +0 -130
- package/dist/serializers/index.d.ts +0 -21
- package/dist/serializers/index.d.ts.map +0 -1
- package/dist/serializers/index.js +0 -154
- package/dist/serializers/log.d.ts +0 -66
- package/dist/serializers/log.d.ts.map +0 -1
- package/dist/serializers/log.js +0 -222
- package/dist/serializers/note.d.ts +0 -124
- package/dist/serializers/note.d.ts.map +0 -1
- package/dist/serializers/note.js +0 -208
- package/dist/serializers/transaction.d.ts +0 -99
- package/dist/serializers/transaction.d.ts.map +0 -1
- package/dist/serializers/transaction.js +0 -275
- package/dist/wallet.d.ts +0 -62
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -77
- package/docs/classes/AztecChainProvider.md +0 -553
- package/docs/classes/AztecChainWallet.md +0 -409
- package/docs/classes/AztecProvider.md +0 -1112
- package/docs/interfaces/AztecWalletBaseMethodMap.md +0 -135
- package/docs/interfaces/AztecWalletEventMap.md +0 -17
- package/docs/type-aliases/AztecChainWalletMiddleware.md +0 -13
- package/docs/type-aliases/AztecWalletContext.md +0 -29
- package/docs/type-aliases/AztecWalletMethodHandler.md +0 -37
- package/docs/type-aliases/AztecWalletMiddleware.md +0 -13
- package/docs/type-aliases/AztecWalletRouterClient.md +0 -13
- package/docs/type-aliases/TransactionFunctionCall.md +0 -33
- package/docs/type-aliases/TransactionParams.md +0 -27
- package/src/aztecRemoteWallet.test.ts +0 -504
- package/src/aztecRemoteWallet.ts +0 -467
- package/src/chainProvider.test.ts +0 -401
- package/src/chainProvider.ts +0 -116
- package/src/handlers/aztecAccountWallet.test.ts +0 -649
- package/src/handlers/aztecAccountWallet.ts +0 -532
- package/src/handlers/transactions.ts +0 -124
- package/src/handlers.test.ts +0 -270
- package/src/handlers.ts +0 -70
- package/src/provider.test.ts +0 -274
- package/src/provider.ts +0 -189
- package/src/serializers/account.test.ts +0 -125
- package/src/serializers/account.ts +0 -301
- package/src/serializers/contract.test.ts +0 -24
- package/src/serializers/contract.ts +0 -183
- package/src/serializers/index.test.ts +0 -136
- package/src/serializers/index.ts +0 -191
- package/src/serializers/log.test.ts +0 -286
- package/src/serializers/log.ts +0 -292
- package/src/serializers/note.test.ts +0 -125
- package/src/serializers/note.ts +0 -250
- package/src/serializers/transaction.test.ts +0 -320
- package/src/serializers/transaction.ts +0 -409
- package/src/wallet.test.ts +0 -275
- package/src/wallet.ts +0 -94
@@ -1,4 +1,4 @@
|
|
1
|
-
[**@walletmesh/aztec-rpc-wallet v0.
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
2
|
|
3
3
|
***
|
4
4
|
|
@@ -6,9 +6,23 @@
|
|
6
6
|
|
7
7
|
# Class: AztecWalletError
|
8
8
|
|
9
|
-
Defined in: [aztec/rpc-wallet/src/errors.ts:
|
9
|
+
Defined in: [aztec/rpc-wallet/src/errors.ts:96](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/errors.ts#L96)
|
10
10
|
|
11
|
-
Custom error class for Aztec
|
11
|
+
Custom error class for representing errors specific to the Aztec RPC Wallet.
|
12
|
+
It extends the base JSONRPCError from `@walletmesh/jsonrpc` and uses
|
13
|
+
predefined error types and messages from [AztecWalletErrorMap](../variables/AztecWalletErrorMap.md).
|
14
|
+
|
15
|
+
This class allows for consistent error handling and reporting within the
|
16
|
+
Aztec wallet system, providing both a standard JSON-RPC error code and
|
17
|
+
a more specific Aztec error type.
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
```typescript
|
22
|
+
if (!isConnected) {
|
23
|
+
throw new AztecWalletError('walletNotConnected', 'Attempted to call method while disconnected.');
|
24
|
+
}
|
25
|
+
```
|
12
26
|
|
13
27
|
## Extends
|
14
28
|
|
@@ -16,31 +30,34 @@ Custom error class for Aztec Wallet RPC errors.
|
|
16
30
|
|
17
31
|
## Constructors
|
18
32
|
|
19
|
-
###
|
33
|
+
### Constructor
|
20
34
|
|
21
|
-
> **new AztecWalletError**(`
|
35
|
+
> **new AztecWalletError**(`errorType`, `data?`): `AztecWalletError`
|
22
36
|
|
23
|
-
Defined in: [aztec/rpc-wallet/src/errors.ts:
|
37
|
+
Defined in: [aztec/rpc-wallet/src/errors.ts:111](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/errors.ts#L111)
|
24
38
|
|
25
|
-
Creates a new AztecWalletError.
|
39
|
+
Creates a new `AztecWalletError` instance.
|
26
40
|
|
27
41
|
#### Parameters
|
28
42
|
|
29
|
-
#####
|
43
|
+
##### errorType
|
30
44
|
|
31
45
|
`AztecWalletErrorType`
|
32
46
|
|
33
|
-
The
|
47
|
+
The specific AztecWalletErrorType identifying the error.
|
48
|
+
This key is used to look up the code and message from [AztecWalletErrorMap](../variables/AztecWalletErrorMap.md).
|
34
49
|
|
35
50
|
##### data?
|
36
51
|
|
37
|
-
|
52
|
+
Optional additional data associated with the error. This can be a string
|
53
|
+
or a record, providing more context. It will be included in the `data`
|
54
|
+
field of the JSON-RPC error object.
|
38
55
|
|
39
|
-
|
56
|
+
`string` | `Record`\<`string`, `unknown`\>
|
40
57
|
|
41
58
|
#### Returns
|
42
59
|
|
43
|
-
|
60
|
+
`AztecWalletError`
|
44
61
|
|
45
62
|
#### Overrides
|
46
63
|
|
@@ -48,6 +65,16 @@ Optional additional error data
|
|
48
65
|
|
49
66
|
## Properties
|
50
67
|
|
68
|
+
### aztecErrorType
|
69
|
+
|
70
|
+
> `readonly` **aztecErrorType**: `AztecWalletErrorType`
|
71
|
+
|
72
|
+
Defined in: [aztec/rpc-wallet/src/errors.ts:100](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/errors.ts#L100)
|
73
|
+
|
74
|
+
The specific Aztec wallet error type.
|
75
|
+
|
76
|
+
***
|
77
|
+
|
51
78
|
### cause?
|
52
79
|
|
53
80
|
> `optional` **cause**: `unknown`
|
@@ -124,43 +151,21 @@ Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1078
|
|
124
151
|
|
125
152
|
***
|
126
153
|
|
127
|
-
###
|
128
|
-
|
129
|
-
> `static` `optional` **prepareStackTrace**: (`err`, `stackTraces`) => `any`
|
130
|
-
|
131
|
-
Defined in: node\_modules/@types/node/globals.d.ts:143
|
132
|
-
|
133
|
-
Optional override for formatting stack traces
|
134
|
-
|
135
|
-
#### Parameters
|
136
|
-
|
137
|
-
##### err
|
138
|
-
|
139
|
-
`Error`
|
140
|
-
|
141
|
-
##### stackTraces
|
142
|
-
|
143
|
-
`CallSite`[]
|
144
|
-
|
145
|
-
#### Returns
|
146
|
-
|
147
|
-
`any`
|
148
|
-
|
149
|
-
#### See
|
150
|
-
|
151
|
-
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
152
|
-
|
153
|
-
#### Inherited from
|
154
|
+
### stackTraceLimit
|
154
155
|
|
155
|
-
`
|
156
|
+
> `static` **stackTraceLimit**: `number`
|
156
157
|
|
157
|
-
|
158
|
+
Defined in: node\_modules/@types/node/globals.d.ts:161
|
158
159
|
|
159
|
-
|
160
|
+
The `Error.stackTraceLimit` property specifies the number of stack frames
|
161
|
+
collected by a stack trace (whether generated by `new Error().stack` or
|
162
|
+
`Error.captureStackTrace(obj)`).
|
160
163
|
|
161
|
-
|
164
|
+
The default value is `10` but may be set to any valid JavaScript number. Changes
|
165
|
+
will affect any stack trace captured _after_ the value has been changed.
|
162
166
|
|
163
|
-
|
167
|
+
If set to a non-number value, or set to a negative number, stack traces will
|
168
|
+
not capture any frames.
|
164
169
|
|
165
170
|
#### Inherited from
|
166
171
|
|
@@ -188,11 +193,53 @@ Returns a string representation of an object.
|
|
188
193
|
|
189
194
|
### captureStackTrace()
|
190
195
|
|
191
|
-
> `static` **captureStackTrace**(`targetObject`, `constructorOpt
|
196
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
197
|
+
|
198
|
+
Defined in: node\_modules/@types/node/globals.d.ts:145
|
199
|
+
|
200
|
+
Creates a `.stack` property on `targetObject`, which when accessed returns
|
201
|
+
a string representing the location in the code at which
|
202
|
+
`Error.captureStackTrace()` was called.
|
203
|
+
|
204
|
+
```js
|
205
|
+
const myObject = {};
|
206
|
+
Error.captureStackTrace(myObject);
|
207
|
+
myObject.stack; // Similar to `new Error().stack`
|
208
|
+
```
|
209
|
+
|
210
|
+
The first line of the trace will be prefixed with
|
211
|
+
`${myObject.name}: ${myObject.message}`.
|
212
|
+
|
213
|
+
The optional `constructorOpt` argument accepts a function. If given, all frames
|
214
|
+
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
215
|
+
generated stack trace.
|
216
|
+
|
217
|
+
The `constructorOpt` argument is useful for hiding implementation
|
218
|
+
details of error generation from the user. For instance:
|
219
|
+
|
220
|
+
```js
|
221
|
+
function a() {
|
222
|
+
b();
|
223
|
+
}
|
192
224
|
|
193
|
-
|
225
|
+
function b() {
|
226
|
+
c();
|
227
|
+
}
|
194
228
|
|
195
|
-
|
229
|
+
function c() {
|
230
|
+
// Create an error without stack trace to avoid calculating the stack trace twice.
|
231
|
+
const { stackTraceLimit } = Error;
|
232
|
+
Error.stackTraceLimit = 0;
|
233
|
+
const error = new Error();
|
234
|
+
Error.stackTraceLimit = stackTraceLimit;
|
235
|
+
|
236
|
+
// Capture the stack trace above function b
|
237
|
+
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
238
|
+
throw error;
|
239
|
+
}
|
240
|
+
|
241
|
+
a();
|
242
|
+
```
|
196
243
|
|
197
244
|
#### Parameters
|
198
245
|
|
@@ -211,3 +258,33 @@ Create .stack property on a target object
|
|
211
258
|
#### Inherited from
|
212
259
|
|
213
260
|
`JSONRPCError.captureStackTrace`
|
261
|
+
|
262
|
+
***
|
263
|
+
|
264
|
+
### prepareStackTrace()
|
265
|
+
|
266
|
+
> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
|
267
|
+
|
268
|
+
Defined in: node\_modules/@types/node/globals.d.ts:149
|
269
|
+
|
270
|
+
#### Parameters
|
271
|
+
|
272
|
+
##### err
|
273
|
+
|
274
|
+
`Error`
|
275
|
+
|
276
|
+
##### stackTraces
|
277
|
+
|
278
|
+
`CallSite`[]
|
279
|
+
|
280
|
+
#### Returns
|
281
|
+
|
282
|
+
`any`
|
283
|
+
|
284
|
+
#### See
|
285
|
+
|
286
|
+
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
287
|
+
|
288
|
+
#### Inherited from
|
289
|
+
|
290
|
+
`JSONRPCError.prepareStackTrace`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
[**@walletmesh/aztec-rpc-wallet v0.
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
2
|
|
3
3
|
***
|
4
4
|
|
@@ -6,31 +6,41 @@
|
|
6
6
|
|
7
7
|
# Class: ContractArtifactCache
|
8
8
|
|
9
|
-
Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:
|
9
|
+
Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:28](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/contractArtifactCache.ts#L28)
|
10
10
|
|
11
|
-
|
11
|
+
Manages an in-memory cache for Aztec ContractArtifacts.
|
12
12
|
|
13
|
-
This class
|
14
|
-
When
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
This class is designed to optimize performance by reducing redundant fetches
|
14
|
+
of contract artifacts. When an artifact is requested for a given contract address,
|
15
|
+
the cache first checks its local store. If the artifact is not found (a cache miss),
|
16
|
+
it uses the provided Wallet instance to retrieve the contract's metadata,
|
17
|
+
then its class metadata (which includes the artifact), stores it in the cache,
|
18
|
+
and finally returns it. Subsequent requests for the same artifact will be served
|
19
|
+
directly from the cache.
|
19
20
|
|
20
|
-
This caching
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
21
|
+
This caching strategy helps to:
|
22
|
+
- Minimize network requests to the PXE or node for contract data.
|
23
|
+
- Reduce processing overhead associated with fetching and parsing artifacts.
|
24
|
+
- Conserve memory by reusing already loaded artifact instances.
|
25
|
+
|
26
|
+
The cache is typically used within the `AztecHandlerContext` on the wallet-side
|
27
|
+
to provide efficient artifact access to RPC method handlers.
|
28
|
+
|
29
|
+
## See
|
30
|
+
|
31
|
+
- [AztecHandlerContext](../interfaces/AztecHandlerContext.md)
|
32
|
+
- Wallet
|
33
|
+
- ContractArtifact
|
24
34
|
|
25
35
|
## Constructors
|
26
36
|
|
27
|
-
###
|
37
|
+
### Constructor
|
28
38
|
|
29
|
-
> **new ContractArtifactCache**(`wallet`):
|
39
|
+
> **new ContractArtifactCache**(`wallet`): `ContractArtifactCache`
|
30
40
|
|
31
|
-
Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:
|
41
|
+
Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:50](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/contractArtifactCache.ts#L50)
|
32
42
|
|
33
|
-
Creates a new ContractArtifactCache instance.
|
43
|
+
Creates a new `ContractArtifactCache` instance.
|
34
44
|
|
35
45
|
#### Parameters
|
36
46
|
|
@@ -38,11 +48,14 @@ Creates a new ContractArtifactCache instance.
|
|
38
48
|
|
39
49
|
`Wallet`
|
40
50
|
|
41
|
-
Wallet instance
|
51
|
+
The `aztec.js` Wallet instance that will be used to
|
52
|
+
fetch contract metadata and artifacts if they are not found
|
53
|
+
in the cache. This wallet should be capable of calling
|
54
|
+
`getContractMetadata` and `getContractClassMetadata`.
|
42
55
|
|
43
56
|
#### Returns
|
44
57
|
|
45
|
-
|
58
|
+
`ContractArtifactCache`
|
46
59
|
|
47
60
|
## Methods
|
48
61
|
|
@@ -50,17 +63,19 @@ Wallet instance used to fetch contract data when cache misses occur
|
|
50
63
|
|
51
64
|
> **getContractArtifact**(`contractAddress`): `Promise`\<`ContractArtifact`\>
|
52
65
|
|
53
|
-
Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:
|
66
|
+
Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:73](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/contractArtifactCache.ts#L73)
|
54
67
|
|
55
|
-
Retrieves the
|
56
|
-
First checks the cache, then falls back to fetching from the wallet if needed.
|
68
|
+
Retrieves the ContractArtifact for a given AztecAddress.
|
57
69
|
|
58
|
-
|
59
|
-
1.
|
60
|
-
2. If
|
61
|
-
3.
|
62
|
-
|
63
|
-
|
70
|
+
This method implements a cache-aside pattern:
|
71
|
+
1. It first checks if the artifact for the `contractAddress` is already in the cache.
|
72
|
+
2. If found (cache hit), the cached artifact is returned immediately.
|
73
|
+
3. If not found (cache miss):
|
74
|
+
a. It fetches the ContractMetadata for the `contractAddress` using the wallet.
|
75
|
+
b. It then fetches the ContractClassMetadata using the class ID from the contract metadata.
|
76
|
+
This class metadata is expected to contain the artifact.
|
77
|
+
c. The retrieved artifact is stored in the cache, associated with the `contractAddress`.
|
78
|
+
d. The artifact is then returned.
|
64
79
|
|
65
80
|
#### Parameters
|
66
81
|
|
@@ -68,14 +83,16 @@ The process:
|
|
68
83
|
|
69
84
|
`AztecAddress`
|
70
85
|
|
71
|
-
The
|
86
|
+
The AztecAddress of the contract whose artifact is to be retrieved.
|
72
87
|
|
73
88
|
#### Returns
|
74
89
|
|
75
90
|
`Promise`\<`ContractArtifact`\>
|
76
91
|
|
77
|
-
|
92
|
+
A promise that resolves to the ContractArtifact.
|
78
93
|
|
79
94
|
#### Throws
|
80
95
|
|
81
|
-
|
96
|
+
if the contract instance or its class (and thus artifact)
|
97
|
+
is not registered with the wallet or cannot be found.
|
98
|
+
Also re-throws other errors encountered during wallet calls.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@walletmesh/aztec-rpc-wallet](../globals.md) / connectAztec
|
6
|
+
|
7
|
+
# Function: connectAztec()
|
8
|
+
|
9
|
+
> **connectAztec**(`provider`, `chainId`, `methods`): `Promise`\<\{ `sessionId`: `string`; `wallet`: [`AztecDappWallet`](../classes/AztecDappWallet.md); \}\>
|
10
|
+
|
11
|
+
Defined in: [aztec/rpc-wallet/src/client/helpers.ts:75](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/client/helpers.ts#L75)
|
12
|
+
|
13
|
+
Establishes a connection to an Aztec wallet service and creates an initialized [AztecDappWallet](../classes/AztecDappWallet.md) instance.
|
14
|
+
This function requests permissions for the specified methods on the given Aztec chain,
|
15
|
+
then instantiates and initializes the wallet.
|
16
|
+
Initialization includes fetching and caching essential data like the wallet address and chain ID.
|
17
|
+
|
18
|
+
By default, it requests permissions for all methods defined in [ALL\_AZTEC\_METHODS](../variables/ALL_AZTEC_METHODS.md)
|
19
|
+
on the 'aztec:mainnet' chain.
|
20
|
+
|
21
|
+
## Parameters
|
22
|
+
|
23
|
+
### provider
|
24
|
+
|
25
|
+
[`AztecRouterProvider`](../classes/AztecRouterProvider.md)
|
26
|
+
|
27
|
+
The [AztecRouterProvider](../classes/AztecRouterProvider.md) instance to use for the connection.
|
28
|
+
This provider must be configured with appropriate transport and Aztec serializers.
|
29
|
+
|
30
|
+
### chainId
|
31
|
+
|
32
|
+
`` `aztec:${string}` `` = `'aztec:mainnet'`
|
33
|
+
|
34
|
+
The [AztecChainId](../type-aliases/AztecChainId.md) to connect to (e.g., 'aztec:mainnet', 'aztec:31337').
|
35
|
+
Defaults to 'aztec:mainnet'.
|
36
|
+
|
37
|
+
### methods
|
38
|
+
|
39
|
+
readonly keyof [`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md)[] = `ALL_AZTEC_METHODS`
|
40
|
+
|
41
|
+
An array of method names for which permissions are requested.
|
42
|
+
Defaults to [ALL\_AZTEC\_METHODS](../variables/ALL_AZTEC_METHODS.md).
|
43
|
+
|
44
|
+
## Returns
|
45
|
+
|
46
|
+
`Promise`\<\{ `sessionId`: `string`; `wallet`: [`AztecDappWallet`](../classes/AztecDappWallet.md); \}\>
|
47
|
+
|
48
|
+
A promise that resolves to an object containing the `sessionId` for the connection
|
49
|
+
and a fully initialized [AztecDappWallet](../classes/AztecDappWallet.md) instance.
|
50
|
+
|
51
|
+
## Throws
|
52
|
+
|
53
|
+
If the connection or wallet initialization fails.
|
54
|
+
|
55
|
+
## Example
|
56
|
+
|
57
|
+
```typescript
|
58
|
+
const provider = new AztecRouterProvider(myTransport);
|
59
|
+
const { sessionId, wallet } = await connectAztec(provider, 'aztec:testnet');
|
60
|
+
const address = wallet.getAddress(); // Wallet is ready to use
|
61
|
+
console.log('Connected with session ID:', sessionId, 'Wallet address:', address.toString());
|
62
|
+
```
|
@@ -0,0 +1,46 @@
|
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@walletmesh/aztec-rpc-wallet](../globals.md) / createAztecWallet
|
6
|
+
|
7
|
+
# Function: createAztecWallet()
|
8
|
+
|
9
|
+
> **createAztecWallet**(`provider`, `chainId`): `Promise`\<[`AztecDappWallet`](../classes/AztecDappWallet.md)\>
|
10
|
+
|
11
|
+
Defined in: [aztec/rpc-wallet/src/client/aztec-dapp-wallet.ts:872](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/client/aztec-dapp-wallet.ts#L872)
|
12
|
+
|
13
|
+
Helper function to create and initialize an AztecDappWallet instance.
|
14
|
+
This is the recommended way to instantiate an Aztec wallet for dApp use,
|
15
|
+
as it ensures all necessary asynchronous setup (like fetching initial
|
16
|
+
address and chain ID) is completed.
|
17
|
+
|
18
|
+
## Parameters
|
19
|
+
|
20
|
+
### provider
|
21
|
+
|
22
|
+
[`AztecRouterProvider`](../classes/AztecRouterProvider.md)
|
23
|
+
|
24
|
+
An [AztecRouterProvider](../classes/AztecRouterProvider.md) instance, which handles Aztec-specific type serialization.
|
25
|
+
|
26
|
+
### chainId
|
27
|
+
|
28
|
+
`` `aztec:${string}` `` = `'aztec:mainnet'`
|
29
|
+
|
30
|
+
The Aztec chain ID (e.g., 'aztec:mainnet', 'aztec:31337') for the wallet. Defaults to 'aztec:mainnet'.
|
31
|
+
|
32
|
+
## Returns
|
33
|
+
|
34
|
+
`Promise`\<[`AztecDappWallet`](../classes/AztecDappWallet.md)\>
|
35
|
+
|
36
|
+
A promise that resolves to a fully initialized [AztecDappWallet](../classes/AztecDappWallet.md) instance.
|
37
|
+
|
38
|
+
## Example
|
39
|
+
|
40
|
+
```typescript
|
41
|
+
const dAppTransport = { send: ..., onMessage: ... }; // User-defined transport
|
42
|
+
const provider = new AztecRouterProvider(dAppTransport);
|
43
|
+
await provider.connect({ 'aztec:mainnet': ['aztec_getAddress'] }); // Connect first
|
44
|
+
const wallet = await createAztecWallet(provider, 'aztec:mainnet');
|
45
|
+
const address = wallet.getAddress(); // Now usable
|
46
|
+
```
|
@@ -0,0 +1,96 @@
|
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@walletmesh/aztec-rpc-wallet](../globals.md) / createAztecWalletNode
|
6
|
+
|
7
|
+
# Function: createAztecWalletNode()
|
8
|
+
|
9
|
+
> **createAztecWalletNode**(`wallet`, `pxe`, `transport`): `JSONRPCNode`\<[`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md), [`JSONRPCEventMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCEventMap.md), [`AztecHandlerContext`](../interfaces/AztecHandlerContext.md)\>
|
10
|
+
|
11
|
+
Defined in: [aztec/rpc-wallet/src/wallet/create-node.ts:77](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/wallet/create-node.ts#L77)
|
12
|
+
|
13
|
+
Creates and configures a JSONRPCNode to serve as an Aztec wallet endpoint.
|
14
|
+
This node is intended to be used on the wallet-side (e.g., in a browser extension
|
15
|
+
or a backend service managing user accounts) and can be connected to a
|
16
|
+
WalletRouter instance.
|
17
|
+
|
18
|
+
The created node is equipped with:
|
19
|
+
- Handlers for all Aztec RPC methods defined in [AztecWalletMethodMap](../interfaces/AztecWalletMethodMap.md).
|
20
|
+
- Serializers for Aztec-specific data types, ensuring correct data exchange
|
21
|
+
over JSON-RPC.
|
22
|
+
- A context ([AztecHandlerContext](../interfaces/AztecHandlerContext.md)) providing handlers with access to the
|
23
|
+
necessary AccountWallet, PXE client, and a [ContractArtifactCache](../classes/ContractArtifactCache.md).
|
24
|
+
|
25
|
+
## Parameters
|
26
|
+
|
27
|
+
### wallet
|
28
|
+
|
29
|
+
`AccountWallet`
|
30
|
+
|
31
|
+
An instance of AccountWallet from `aztec.js`, representing
|
32
|
+
the user's Aztec account and signing capabilities.
|
33
|
+
|
34
|
+
### pxe
|
35
|
+
|
36
|
+
`PXE`
|
37
|
+
|
38
|
+
An instance of PXE (Private Execution Environment) client from
|
39
|
+
`aztec.js`, used for interacting with the Aztec network (e.g., simulating
|
40
|
+
transactions, getting node info).
|
41
|
+
|
42
|
+
### transport
|
43
|
+
|
44
|
+
[`JSONRPCTransport`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCTransport.md)
|
45
|
+
|
46
|
+
A [JSONRPCTransport](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCTransport.md) instance that the node will use for
|
47
|
+
sending and receiving JSON-RPC messages. This transport typically
|
48
|
+
connects to a corresponding transport on the client/dApp side,
|
49
|
+
often via the WalletRouter.
|
50
|
+
|
51
|
+
## Returns
|
52
|
+
|
53
|
+
`JSONRPCNode`\<[`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md), [`JSONRPCEventMap`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/jsonrpc/docs/interfaces/JSONRPCEventMap.md), [`AztecHandlerContext`](../interfaces/AztecHandlerContext.md)\>
|
54
|
+
|
55
|
+
A fully configured JSONRPCNode instance, typed with
|
56
|
+
[AztecWalletMethodMap](../interfaces/AztecWalletMethodMap.md) and [AztecHandlerContext](../interfaces/AztecHandlerContext.md), ready to
|
57
|
+
process Aztec wallet requests.
|
58
|
+
|
59
|
+
## Example
|
60
|
+
|
61
|
+
```typescript
|
62
|
+
import { createAztecWalletNode } from '@walletmesh/aztec-rpc-wallet';
|
63
|
+
import { WalletRouter, createLocalTransportPair } from '@walletmesh/router';
|
64
|
+
import { MyAccountWallet, MyPXE, MyRouterTransport, MyPermissionManager } from './my-setup'; // User's setup
|
65
|
+
|
66
|
+
// 1. Initialize Aztec AccountWallet and PXE
|
67
|
+
const accountWallet = new MyAccountWallet();
|
68
|
+
const pxe = new MyPXE();
|
69
|
+
|
70
|
+
// 2. Create a local transport pair for communication between router and wallet node
|
71
|
+
const [routerSideTransport, walletNodeSideTransport] = createLocalTransportPair();
|
72
|
+
|
73
|
+
// 3. Create the Aztec Wallet Node
|
74
|
+
const aztecNode = createAztecWalletNode(accountWallet, pxe, walletNodeSideTransport);
|
75
|
+
// aztecNode will start listening for requests on walletNodeSideTransport
|
76
|
+
|
77
|
+
// 4. Create and configure the WalletRouter
|
78
|
+
const routerTransport = new MyRouterTransport(); // Transport for dApp to router communication
|
79
|
+
const permissionManager = new MyPermissionManager();
|
80
|
+
const router = new WalletRouter(
|
81
|
+
routerTransport,
|
82
|
+
new Map([['aztec:testnet', routerSideTransport]]), // Route 'aztec:testnet' to our node
|
83
|
+
permissionManager
|
84
|
+
);
|
85
|
+
|
86
|
+
// The system is now set up. DApps can connect to 'routerTransport'
|
87
|
+
// and send requests to 'aztec:testnet', which will be handled by 'aztecNode'.
|
88
|
+
```
|
89
|
+
|
90
|
+
## See
|
91
|
+
|
92
|
+
- JSONRPCNode
|
93
|
+
- [AztecWalletMethodMap](../interfaces/AztecWalletMethodMap.md)
|
94
|
+
- [AztecHandlerContext](../interfaces/AztecHandlerContext.md)
|
95
|
+
- createAztecHandlers
|
96
|
+
- [registerAztecSerializers](registerWalletAztecSerializers.md) (wallet-side version)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@walletmesh/aztec-rpc-wallet](../globals.md) / registerAztecSerializers
|
6
|
+
|
7
|
+
# Function: registerAztecSerializers()
|
8
|
+
|
9
|
+
> **registerAztecSerializers**(`provider`): `void`
|
10
|
+
|
11
|
+
Defined in: [aztec/rpc-wallet/src/client/register-serializers.ts:43](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/client/register-serializers.ts#L43)
|
12
|
+
|
13
|
+
Registers the [AztecWalletSerializer](../variables/AztecWalletSerializer.md) for all relevant Aztec JSON-RPC methods
|
14
|
+
on a given [WalletRouterProvider](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/WalletRouterProvider.md) instance.
|
15
|
+
|
16
|
+
This utility function ensures that any `WalletRouterProvider` (not just the specialized
|
17
|
+
[AztecRouterProvider](../classes/AztecRouterProvider.md)) can be configured to correctly handle serialization and
|
18
|
+
deserialization of Aztec-specific data types (e.g., `AztecAddress`, `Fr`, `TxExecutionRequest`)
|
19
|
+
when interacting with an Aztec wallet.
|
20
|
+
|
21
|
+
It iterates through a predefined list of Aztec methods and associates them with
|
22
|
+
the comprehensive [AztecWalletSerializer](../variables/AztecWalletSerializer.md).
|
23
|
+
|
24
|
+
## Parameters
|
25
|
+
|
26
|
+
### provider
|
27
|
+
|
28
|
+
[`WalletRouterProvider`](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/WalletRouterProvider.md)
|
29
|
+
|
30
|
+
The [WalletRouterProvider](https://github.com/WalletMesh/walletmesh-packages/tree/main/core/router/docs/index/classes/WalletRouterProvider.md) instance on which to register the serializers.
|
31
|
+
After this function call, the provider will be equipped to handle Aztec methods.
|
32
|
+
|
33
|
+
## Returns
|
34
|
+
|
35
|
+
`void`
|
36
|
+
|
37
|
+
## Example
|
38
|
+
|
39
|
+
```typescript
|
40
|
+
import { WalletRouterProvider } from '@walletmesh/router';
|
41
|
+
import { registerAztecSerializers, ALL_AZTEC_METHODS } from '@walletmesh/aztec-rpc-wallet';
|
42
|
+
import { MyCustomTransport } from './my-custom-transport';
|
43
|
+
|
44
|
+
// 1. Create a generic WalletRouterProvider
|
45
|
+
const transport = new MyCustomTransport();
|
46
|
+
const provider = new WalletRouterProvider(transport);
|
47
|
+
|
48
|
+
// 2. Register Aztec serializers on it
|
49
|
+
registerAztecSerializers(provider);
|
50
|
+
|
51
|
+
// 3. Now the provider can correctly handle Aztec methods and types
|
52
|
+
await provider.connect({ 'aztec:testnet': ALL_AZTEC_METHODS });
|
53
|
+
const address = await provider.call('aztec:testnet', { method: 'aztec_getAddress' });
|
54
|
+
// 'address' will be correctly deserialized into an AztecAddress instance (or equivalent based on serializer)
|
55
|
+
```
|
56
|
+
|
57
|
+
## See
|
58
|
+
|
59
|
+
- [AztecWalletSerializer](../variables/AztecWalletSerializer.md) for the actual serialization logic.
|
60
|
+
- [AztecRouterProvider](../classes/AztecRouterProvider.md) for a provider that calls this automatically.
|
61
|
+
- [AztecWalletMethodMap](../interfaces/AztecWalletMethodMap.md) for the list of methods and their types.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
[**@walletmesh/aztec-rpc-wallet v0.4.0**](../README.md)
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@walletmesh/aztec-rpc-wallet](../globals.md) / registerWalletAztecSerializers
|
6
|
+
|
7
|
+
# Function: registerWalletAztecSerializers()
|
8
|
+
|
9
|
+
> **registerWalletAztecSerializers**(`node`): `void`
|
10
|
+
|
11
|
+
Defined in: [aztec/rpc-wallet/src/wallet/serializers.ts:548](https://github.com/WalletMesh/walletmesh-packages/blob/cb714b71a23dbdbacd8723a799d14c589fdf51f9/aztec/rpc-wallet/src/wallet/serializers.ts#L548)
|
12
|
+
|
13
|
+
Registers the [AztecWalletSerializer](../variables/AztecWalletSerializer.md) for all relevant Aztec JSON-RPC methods
|
14
|
+
on a given JSONRPCNode instance.
|
15
|
+
|
16
|
+
This function is typically called on the wallet-side (e.g., within
|
17
|
+
`createAztecWalletNode`) to equip the node with the necessary serialization
|
18
|
+
capabilities for handling Aztec methods.
|
19
|
+
|
20
|
+
It iterates through a predefined list of Aztec methods and associates each
|
21
|
+
with the `AztecWalletSerializer`.
|
22
|
+
|
23
|
+
## Parameters
|
24
|
+
|
25
|
+
### node
|
26
|
+
|
27
|
+
`JSONRPCNode`\<[`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md)\>
|
28
|
+
|
29
|
+
The JSONRPCNode instance on which to register the serializers.
|
30
|
+
This node should be typed with [AztecWalletMethodMap](../interfaces/AztecWalletMethodMap.md).
|
31
|
+
|
32
|
+
## Returns
|
33
|
+
|
34
|
+
`void`
|
35
|
+
|
36
|
+
## See
|
37
|
+
|
38
|
+
- [createAztecWalletNode](createAztecWalletNode.md) where this function is used.
|
39
|
+
- [AztecWalletSerializer](../variables/AztecWalletSerializer.md) which provides the serialization logic.
|