@walletmesh/aztec-rpc-wallet 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/aztecRemoteWallet.d.ts +4 -8
  4. package/dist/aztecRemoteWallet.d.ts.map +1 -1
  5. package/dist/aztecRemoteWallet.js +5 -29
  6. package/dist/contractArtifactCache.d.ts.map +1 -1
  7. package/dist/contractArtifactCache.js +20 -9
  8. package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
  9. package/dist/handlers/aztecAccountWallet.js +11 -44
  10. package/dist/serializers/account.d.ts +16 -16
  11. package/dist/serializers/account.d.ts.map +1 -1
  12. package/dist/serializers/account.js +43 -43
  13. package/dist/serializers/contract.d.ts +22 -76
  14. package/dist/serializers/contract.d.ts.map +1 -1
  15. package/dist/serializers/contract.js +68 -120
  16. package/dist/serializers/index.d.ts +0 -4
  17. package/dist/serializers/index.d.ts.map +1 -1
  18. package/dist/serializers/index.js +15 -20
  19. package/dist/serializers/log.d.ts +16 -16
  20. package/dist/serializers/log.d.ts.map +1 -1
  21. package/dist/serializers/log.js +43 -43
  22. package/dist/serializers/note.d.ts +12 -12
  23. package/dist/serializers/note.d.ts.map +1 -1
  24. package/dist/serializers/note.js +32 -32
  25. package/dist/serializers/transaction.d.ts +25 -26
  26. package/dist/serializers/transaction.d.ts.map +1 -1
  27. package/dist/serializers/transaction.js +92 -44
  28. package/dist/types.d.ts +7 -30
  29. package/dist/types.d.ts.map +1 -1
  30. package/dist/types.js +1 -1
  31. package/docs/README.md +264 -0
  32. package/docs/classes/AztecChainProvider.md +553 -0
  33. package/docs/classes/AztecChainWallet.md +409 -0
  34. package/docs/classes/AztecProvider.md +1112 -0
  35. package/docs/classes/AztecWalletError.md +213 -0
  36. package/docs/classes/ContractArtifactCache.md +81 -0
  37. package/docs/globals.md +34 -0
  38. package/docs/interfaces/AztecWalletBaseMethodMap.md +135 -0
  39. package/docs/interfaces/AztecWalletEventMap.md +17 -0
  40. package/docs/interfaces/AztecWalletMethodMap.md +1012 -0
  41. package/docs/type-aliases/AztecChainId.md +11 -0
  42. package/docs/type-aliases/AztecChainWalletMiddleware.md +13 -0
  43. package/docs/type-aliases/AztecWalletContext.md +29 -0
  44. package/docs/type-aliases/AztecWalletMethodHandler.md +37 -0
  45. package/docs/type-aliases/AztecWalletMiddleware.md +13 -0
  46. package/docs/type-aliases/AztecWalletRouterClient.md +13 -0
  47. package/docs/type-aliases/TransactionFunctionCall.md +33 -0
  48. package/docs/type-aliases/TransactionParams.md +27 -0
  49. package/docs/variables/AztecWalletErrorMap.md +13 -0
  50. package/package.json +9 -9
  51. package/src/aztecRemoteWallet.test.ts +22 -61
  52. package/src/aztecRemoteWallet.ts +8 -35
  53. package/src/chainProvider.test.ts +117 -38
  54. package/src/contractArtifactCache.test.ts +28 -45
  55. package/src/contractArtifactCache.ts +20 -10
  56. package/src/handlers/aztecAccountWallet.test.ts +12 -86
  57. package/src/handlers/aztecAccountWallet.ts +19 -77
  58. package/src/provider.test.ts +0 -2
  59. package/src/serializers/account.test.ts +19 -20
  60. package/src/serializers/account.ts +52 -52
  61. package/src/serializers/contract.test.ts +4 -140
  62. package/src/serializers/contract.ts +93 -166
  63. package/src/serializers/index.test.ts +30 -28
  64. package/src/serializers/index.ts +15 -21
  65. package/src/serializers/log.test.ts +42 -48
  66. package/src/serializers/log.ts +54 -54
  67. package/src/serializers/note.test.ts +43 -16
  68. package/src/serializers/note.ts +39 -39
  69. package/src/serializers/transaction.test.ts +48 -41
  70. package/src/serializers/transaction.ts +146 -58
  71. package/src/types.ts +7 -7
  72. package/src/wallet.test.ts +3 -3
  73. package/dist/serializers/transaction-utils.d.ts +0 -51
  74. package/dist/serializers/transaction-utils.d.ts.map +0 -1
  75. package/dist/serializers/transaction-utils.js +0 -103
  76. package/src/serializers/transaction-utils.ts +0 -174
@@ -0,0 +1,213 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletError
6
+
7
+ # Class: AztecWalletError
8
+
9
+ Defined in: [aztec/rpc-wallet/src/errors.ts:61](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/errors.ts#L61)
10
+
11
+ Custom error class for Aztec Wallet RPC errors.
12
+
13
+ ## Extends
14
+
15
+ - `JSONRPCError`
16
+
17
+ ## Constructors
18
+
19
+ ### new AztecWalletError()
20
+
21
+ > **new AztecWalletError**(`err`, `data`?): [`AztecWalletError`](AztecWalletError.md)
22
+
23
+ Defined in: [aztec/rpc-wallet/src/errors.ts:67](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/errors.ts#L67)
24
+
25
+ Creates a new AztecWalletError.
26
+
27
+ #### Parameters
28
+
29
+ ##### err
30
+
31
+ `AztecWalletErrorType`
32
+
33
+ The error type from AztecWalletErrorMap
34
+
35
+ ##### data?
36
+
37
+ `string`
38
+
39
+ Optional additional error data
40
+
41
+ #### Returns
42
+
43
+ [`AztecWalletError`](AztecWalletError.md)
44
+
45
+ #### Overrides
46
+
47
+ `JSONRPCError.constructor`
48
+
49
+ ## Properties
50
+
51
+ ### cause?
52
+
53
+ > `optional` **cause**: `unknown`
54
+
55
+ Defined in: node\_modules/typescript/lib/lib.es2022.error.d.ts:26
56
+
57
+ #### Inherited from
58
+
59
+ `JSONRPCError.cause`
60
+
61
+ ***
62
+
63
+ ### code
64
+
65
+ > **code**: `number`
66
+
67
+ Defined in: core/jsonrpc/dist/error.d.ts:62
68
+
69
+ The error code.
70
+
71
+ #### Inherited from
72
+
73
+ `JSONRPCError.code`
74
+
75
+ ***
76
+
77
+ ### data?
78
+
79
+ > `optional` **data**: `string` \| `Record`\<`string`, `unknown`\>
80
+
81
+ Defined in: core/jsonrpc/dist/error.d.ts:63
82
+
83
+ Additional error data.
84
+
85
+ #### Inherited from
86
+
87
+ `JSONRPCError.data`
88
+
89
+ ***
90
+
91
+ ### message
92
+
93
+ > **message**: `string`
94
+
95
+ Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1077
96
+
97
+ #### Inherited from
98
+
99
+ `JSONRPCError.message`
100
+
101
+ ***
102
+
103
+ ### name
104
+
105
+ > **name**: `string`
106
+
107
+ Defined in: core/jsonrpc/dist/error.d.ts:64
108
+
109
+ #### Inherited from
110
+
111
+ `JSONRPCError.name`
112
+
113
+ ***
114
+
115
+ ### stack?
116
+
117
+ > `optional` **stack**: `string`
118
+
119
+ Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1078
120
+
121
+ #### Inherited from
122
+
123
+ `JSONRPCError.stack`
124
+
125
+ ***
126
+
127
+ ### prepareStackTrace()?
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
+
155
+ `JSONRPCError.prepareStackTrace`
156
+
157
+ ***
158
+
159
+ ### stackTraceLimit
160
+
161
+ > `static` **stackTraceLimit**: `number`
162
+
163
+ Defined in: node\_modules/@types/node/globals.d.ts:145
164
+
165
+ #### Inherited from
166
+
167
+ `JSONRPCError.stackTraceLimit`
168
+
169
+ ## Methods
170
+
171
+ ### toString()
172
+
173
+ > **toString**(): `string`
174
+
175
+ Defined in: core/jsonrpc/dist/error.d.ts:89
176
+
177
+ Returns a string representation of an object.
178
+
179
+ #### Returns
180
+
181
+ `string`
182
+
183
+ #### Inherited from
184
+
185
+ `JSONRPCError.toString`
186
+
187
+ ***
188
+
189
+ ### captureStackTrace()
190
+
191
+ > `static` **captureStackTrace**(`targetObject`, `constructorOpt`?): `void`
192
+
193
+ Defined in: node\_modules/@types/node/globals.d.ts:136
194
+
195
+ Create .stack property on a target object
196
+
197
+ #### Parameters
198
+
199
+ ##### targetObject
200
+
201
+ `object`
202
+
203
+ ##### constructorOpt?
204
+
205
+ `Function`
206
+
207
+ #### Returns
208
+
209
+ `void`
210
+
211
+ #### Inherited from
212
+
213
+ `JSONRPCError.captureStackTrace`
@@ -0,0 +1,81 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / ContractArtifactCache
6
+
7
+ # Class: ContractArtifactCache
8
+
9
+ Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:27](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/contractArtifactCache.ts#L27)
10
+
11
+ Caches contract artifacts to optimize contract interactions.
12
+
13
+ This class maintains an in-memory cache of contract artifacts indexed by contract address.
14
+ When a contract artifact is requested:
15
+ 1. First checks the cache for an existing artifact
16
+ 2. If not found, fetches the contract instance and its artifact from the wallet
17
+ 3. Stores the artifact in the cache for future use
18
+ 4. Returns the artifact to the caller
19
+
20
+ This caching mechanism helps reduce:
21
+ - Network requests to fetch contract data
22
+ - Processing overhead of parsing contract artifacts
23
+ - Memory usage by reusing existing artifacts
24
+
25
+ ## Constructors
26
+
27
+ ### new ContractArtifactCache()
28
+
29
+ > **new ContractArtifactCache**(`wallet`): [`ContractArtifactCache`](ContractArtifactCache.md)
30
+
31
+ Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:37](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/contractArtifactCache.ts#L37)
32
+
33
+ Creates a new ContractArtifactCache instance.
34
+
35
+ #### Parameters
36
+
37
+ ##### wallet
38
+
39
+ `Wallet`
40
+
41
+ Wallet instance used to fetch contract data when cache misses occur
42
+
43
+ #### Returns
44
+
45
+ [`ContractArtifactCache`](ContractArtifactCache.md)
46
+
47
+ ## Methods
48
+
49
+ ### getContractArtifact()
50
+
51
+ > **getContractArtifact**(`contractAddress`): `Promise`\<`ContractArtifact`\>
52
+
53
+ Defined in: [aztec/rpc-wallet/src/contractArtifactCache.ts:56](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/contractArtifactCache.ts#L56)
54
+
55
+ Retrieves the contract artifact for a given contract address.
56
+ First checks the cache, then falls back to fetching from the wallet if needed.
57
+
58
+ The process:
59
+ 1. Check if artifact exists in cache
60
+ 2. If not, get contract instance from wallet
61
+ 3. Use instance to get contract class ID
62
+ 4. Fetch artifact using class ID
63
+ 5. Cache the artifact for future use
64
+
65
+ #### Parameters
66
+
67
+ ##### contractAddress
68
+
69
+ `AztecAddress`
70
+
71
+ The contract address to retrieve the artifact for
72
+
73
+ #### Returns
74
+
75
+ `Promise`\<`ContractArtifact`\>
76
+
77
+ Promise resolving to the contract artifact
78
+
79
+ #### Throws
80
+
81
+ If contract instance or class not registered
@@ -0,0 +1,34 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](README.md)
2
+
3
+ ***
4
+
5
+ # @walletmesh/aztec-rpc-wallet v0.3.0
6
+
7
+ ## Classes
8
+
9
+ - [AztecChainProvider](classes/AztecChainProvider.md)
10
+ - [AztecChainWallet](classes/AztecChainWallet.md)
11
+ - [AztecProvider](classes/AztecProvider.md)
12
+ - [AztecWalletError](classes/AztecWalletError.md)
13
+ - [ContractArtifactCache](classes/ContractArtifactCache.md)
14
+
15
+ ## Interfaces
16
+
17
+ - [AztecWalletBaseMethodMap](interfaces/AztecWalletBaseMethodMap.md)
18
+ - [AztecWalletEventMap](interfaces/AztecWalletEventMap.md)
19
+ - [AztecWalletMethodMap](interfaces/AztecWalletMethodMap.md)
20
+
21
+ ## Type Aliases
22
+
23
+ - [AztecChainId](type-aliases/AztecChainId.md)
24
+ - [AztecChainWalletMiddleware](type-aliases/AztecChainWalletMiddleware.md)
25
+ - [AztecWalletContext](type-aliases/AztecWalletContext.md)
26
+ - [AztecWalletMethodHandler](type-aliases/AztecWalletMethodHandler.md)
27
+ - [AztecWalletMiddleware](type-aliases/AztecWalletMiddleware.md)
28
+ - [AztecWalletRouterClient](type-aliases/AztecWalletRouterClient.md)
29
+ - [TransactionFunctionCall](type-aliases/TransactionFunctionCall.md)
30
+ - [TransactionParams](type-aliases/TransactionParams.md)
31
+
32
+ ## Variables
33
+
34
+ - [AztecWalletErrorMap](variables/AztecWalletErrorMap.md)
@@ -0,0 +1,135 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletBaseMethodMap
6
+
7
+ # Interface: AztecWalletBaseMethodMap
8
+
9
+ Defined in: [aztec/rpc-wallet/src/types.ts:83](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L83)
10
+
11
+ A mapping of JSON-RPC methods to their parameters and return types for Aztec Wallets.
12
+
13
+ This extends the base WalletMethodMap with Aztec-specific methods.
14
+
15
+ ## Extends
16
+
17
+ - `WalletMethodMap`
18
+
19
+ ## Extended by
20
+
21
+ - [`AztecWalletMethodMap`](AztecWalletMethodMap.md)
22
+
23
+ ## Indexable
24
+
25
+ \[`method`: `string`\]: `object`
26
+
27
+ ## Properties
28
+
29
+ ### aztec\_connect
30
+
31
+ > **aztec\_connect**: `object`
32
+
33
+ Defined in: [aztec/rpc-wallet/src/types.ts:88](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L88)
34
+
35
+ Connects to the Aztec network.
36
+
37
+ #### result
38
+
39
+ > **result**: `boolean`
40
+
41
+ #### Returns
42
+
43
+ A boolean indicating if the connection was successful
44
+
45
+ ***
46
+
47
+ ### aztec\_getAccount
48
+
49
+ > **aztec\_getAccount**: `object`
50
+
51
+ Defined in: [aztec/rpc-wallet/src/types.ts:94](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L94)
52
+
53
+ Gets the account address from the wallet.
54
+
55
+ #### result
56
+
57
+ > **result**: `string`
58
+
59
+ #### Returns
60
+
61
+ The account address as a string
62
+
63
+ ***
64
+
65
+ ### aztec\_sendTransaction
66
+
67
+ > **aztec\_sendTransaction**: `object`
68
+
69
+ Defined in: [aztec/rpc-wallet/src/types.ts:101](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L101)
70
+
71
+ Sends transactions to the Aztec network.
72
+
73
+ #### params
74
+
75
+ > **params**: [`TransactionParams`](../type-aliases/TransactionParams.md)
76
+
77
+ #### result
78
+
79
+ > **result**: `string`
80
+
81
+ #### Param
82
+
83
+ The transactions to execute and optional authorization witnesses
84
+
85
+ #### Returns
86
+
87
+ The transaction hash as a string
88
+
89
+ ***
90
+
91
+ ### aztec\_simulateTransaction
92
+
93
+ > **aztec\_simulateTransaction**: `object`
94
+
95
+ Defined in: [aztec/rpc-wallet/src/types.ts:111](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L111)
96
+
97
+ Simulates a transaction without executing it.
98
+
99
+ #### params
100
+
101
+ > **params**: [`TransactionFunctionCall`](../type-aliases/TransactionFunctionCall.md)
102
+
103
+ #### result
104
+
105
+ > **result**: `unknown`
106
+
107
+ #### Param
108
+
109
+ The transaction to simulate
110
+
111
+ #### Returns
112
+
113
+ The simulation result
114
+
115
+ ***
116
+
117
+ ### wm\_getSupportedMethods
118
+
119
+ > **wm\_getSupportedMethods**: `object`
120
+
121
+ Defined in: [aztec/rpc-wallet/src/types.ts:120](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L120)
122
+
123
+ Returns the list of supported methods for the wallet.
124
+
125
+ #### result
126
+
127
+ > **result**: `string`[]
128
+
129
+ #### Returns
130
+
131
+ An array of supported methods
132
+
133
+ #### Overrides
134
+
135
+ `WalletMethodMap.wm_getSupportedMethods`
@@ -0,0 +1,17 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletEventMap
6
+
7
+ # Interface: AztecWalletEventMap
8
+
9
+ Defined in: [aztec/rpc-wallet/src/types.ts:125](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L125)
10
+
11
+ ## Extends
12
+
13
+ - `JSONRPCEventMap`
14
+
15
+ ## Indexable
16
+
17
+ \[`event`: `string`\]: `unknown`