@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,11 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecChainId
6
+
7
+ # Type Alias: AztecChainId
8
+
9
+ > **AztecChainId**: `` `aztec:${string}` ``
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:296](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L296)
@@ -0,0 +1,13 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecChainWalletMiddleware
6
+
7
+ # Type Alias: AztecChainWalletMiddleware
8
+
9
+ > **AztecChainWalletMiddleware**: `JSONRPCMiddleware`\<[`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md), [`AztecWalletContext`](AztecWalletContext.md)\>
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:149](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L149)
12
+
13
+ Type for Aztec Chain Wallet middleware.
@@ -0,0 +1,29 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletContext
6
+
7
+ # Type Alias: AztecWalletContext
8
+
9
+ > **AztecWalletContext**: `Record`\<`string`, `unknown`\> & `object`
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:133](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L133)
12
+
13
+ Holds the context passed through RPC middleware.
14
+
15
+ ## Type declaration
16
+
17
+ ### contractArtifactCache
18
+
19
+ > **contractArtifactCache**: [`ContractArtifactCache`](../classes/ContractArtifactCache.md)
20
+
21
+ ### pxe
22
+
23
+ > **pxe**: `PXE`
24
+
25
+ The PXE instance for the wallet
26
+
27
+ ### wallet
28
+
29
+ > **wallet**: `AccountWallet`
@@ -0,0 +1,37 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletMethodHandler
6
+
7
+ # Type Alias: AztecWalletMethodHandler()\<T, M, C\>
8
+
9
+ > **AztecWalletMethodHandler**\<`T`, `M`, `C`\>: (`context`, `params`, `accountWallet`) => `Promise`\<`T`\[`M`\]\[`"result"`\]\> \| `T`\[`M`\]\[`"result"`\]
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:286](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L286)
12
+
13
+ ## Type Parameters
14
+
15
+ • **T** *extends* [`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md)
16
+
17
+ • **M** *extends* keyof `T`
18
+
19
+ • **C** *extends* [`AztecWalletContext`](AztecWalletContext.md)
20
+
21
+ ## Parameters
22
+
23
+ ### context
24
+
25
+ `C`
26
+
27
+ ### params
28
+
29
+ `T`\[`M`\]\[`"params"`\]
30
+
31
+ ### accountWallet
32
+
33
+ `AccountWallet`
34
+
35
+ ## Returns
36
+
37
+ `Promise`\<`T`\[`M`\]\[`"result"`\]\> \| `T`\[`M`\]\[`"result"`\]
@@ -0,0 +1,13 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletMiddleware
6
+
7
+ # Type Alias: AztecWalletMiddleware
8
+
9
+ > **AztecWalletMiddleware**: `JSONRPCMiddleware`\<[`AztecWalletBaseMethodMap`](../interfaces/AztecWalletBaseMethodMap.md), [`AztecWalletContext`](AztecWalletContext.md)\>
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:144](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L144)
12
+
13
+ Type for Aztec Router Wallet middleware.
@@ -0,0 +1,13 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletRouterClient
6
+
7
+ # Type Alias: AztecWalletRouterClient
8
+
9
+ > **AztecWalletRouterClient**: `JSONRPCWalletClient`\<[`AztecWalletMethodMap`](../interfaces/AztecWalletMethodMap.md)\>
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:155](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L155)
12
+
13
+ Type for Aztec wallet router client.
@@ -0,0 +1,33 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / TransactionFunctionCall
6
+
7
+ # Type Alias: TransactionFunctionCall
8
+
9
+ > **TransactionFunctionCall**: `object`
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:49](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L49)
12
+
13
+ Represents a single function call to a contract.
14
+
15
+ ## Type declaration
16
+
17
+ ### args
18
+
19
+ > **args**: `unknown`[]
20
+
21
+ The arguments to pass to the function
22
+
23
+ ### contractAddress
24
+
25
+ > **contractAddress**: `string`
26
+
27
+ The address of the contract to interact with
28
+
29
+ ### functionName
30
+
31
+ > **functionName**: `string`
32
+
33
+ The name of the function to call
@@ -0,0 +1,27 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / TransactionParams
6
+
7
+ # Type Alias: TransactionParams
8
+
9
+ > **TransactionParams**: `object`
10
+
11
+ Defined in: [aztec/rpc-wallet/src/types.ts:62](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/types.ts#L62)
12
+
13
+ Parameters for sending transactions.
14
+
15
+ ## Type declaration
16
+
17
+ ### authwits?
18
+
19
+ > `optional` **authwits**: `string`[]
20
+
21
+ Optional array of authorization witnesses for the transaction
22
+
23
+ ### functionCalls
24
+
25
+ > **functionCalls**: [`TransactionFunctionCall`](TransactionFunctionCall.md)[]
26
+
27
+ Array of function calls to execute
@@ -0,0 +1,13 @@
1
+ [**@walletmesh/aztec-rpc-wallet v0.3.0**](../README.md)
2
+
3
+ ***
4
+
5
+ [@walletmesh/aztec-rpc-wallet](../globals.md) / AztecWalletErrorMap
6
+
7
+ # Variable: AztecWalletErrorMap
8
+
9
+ > `const` **AztecWalletErrorMap**: `Record`\<`AztecWalletErrorType`, \{ `code`: `number`; `message`: `string`; \}\>
10
+
11
+ Defined in: [aztec/rpc-wallet/src/errors.ts:37](https://github.com/WalletMesh/walletmesh-packages/blob/937a416f9c444488735f94f0d3eb35a7feadda3e/aztec/rpc-wallet/src/errors.ts#L37)
12
+
13
+ Map of error codes and messages for Aztec Wallet RPC errors.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walletmesh/aztec-rpc-wallet",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,12 +21,12 @@
21
21
  "typedoc-plugin-markdown": "^4.3.1"
22
22
  },
23
23
  "dependencies": {
24
- "@aztec/aztec.js": "0.72.1",
25
- "@aztec/circuit-types": "0.72.1",
26
- "@aztec/circuits.js": "0.72.1",
27
- "@aztec/foundation": "0.72.1",
28
- "@walletmesh/jsonrpc": "0.3.0",
29
- "@walletmesh/router": "0.3.0"
24
+ "@aztec/aztec.js": "0.73.0",
25
+ "@aztec/circuit-types": "0.73.0",
26
+ "@aztec/circuits.js": "0.73.0",
27
+ "@aztec/foundation": "0.73.0",
28
+ "@walletmesh/jsonrpc": "0.4.0",
29
+ "@walletmesh/router": "0.4.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsc --build tsconfig.build.json",
@@ -38,7 +38,7 @@
38
38
  "lint:fix": "biome lint --fix",
39
39
  "format": "biome format",
40
40
  "format:fix": "biome format --fix",
41
- "doc": "typedoc",
42
- "version": "pnpm clean && pnpm build && pnpm doc && git add docs/"
41
+ "docs": "typedoc",
42
+ "version": "pnpm clean && pnpm build && pnpm run docs"
43
43
  }
44
44
  }
@@ -202,34 +202,6 @@ describe('AztecRemoteWallet', () => {
202
202
  contractClass = await getContractClassFromArtifact(mockContract.artifact);
203
203
  });
204
204
 
205
- it('gets contract instance', async () => {
206
- mockChainBuilder.execute.mockResolvedValueOnce(mockContract.instance);
207
-
208
- const result = await wallet.getContractInstance(mockContract.instance.address);
209
- expect(result).toBe(mockContract.instance);
210
- expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_getContractInstance', {
211
- address: mockContract.instance.address,
212
- });
213
- });
214
-
215
- it('gets contract class', async () => {
216
- mockChainBuilder.execute.mockResolvedValueOnce(contractClass);
217
-
218
- const result = await wallet.getContractClass(contractClass.id);
219
- expect(result).toBe(contractClass);
220
- expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_getContractClass', { id: contractClass.id });
221
- });
222
-
223
- it('gets contract artifact', async () => {
224
- mockChainBuilder.execute.mockResolvedValueOnce(mockContract.artifact);
225
-
226
- const result = await wallet.getContractArtifact(contractClass.id);
227
- expect(result).toBe(mockContract.artifact);
228
- expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_getContractArtifact', {
229
- id: contractClass.id,
230
- });
231
- });
232
-
233
205
  it('registers contract', async () => {
234
206
  mockChainBuilder.execute.mockResolvedValueOnce(true);
235
207
  await wallet.registerContract({ instance: mockContract.instance, artifact: mockContract.artifact });
@@ -255,6 +227,28 @@ describe('AztecRemoteWallet', () => {
255
227
  expect(result).toBe(mockContracts);
256
228
  expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_getContracts');
257
229
  });
230
+
231
+ it('gets contract metadata', async () => {
232
+ const mockMetadata = { contractInstance: mockContract.instance };
233
+ mockChainBuilder.execute.mockResolvedValueOnce(mockMetadata);
234
+
235
+ const result = await wallet.getContractMetadata(mockContract.instance.address);
236
+ expect(result).toBe(mockMetadata);
237
+ expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_getContractMetadata', {
238
+ address: mockContract.instance.address,
239
+ });
240
+ });
241
+
242
+ it('gets contract class metadata', async () => {
243
+ const mockMetadata = { artifact: mockContract.artifact };
244
+ mockChainBuilder.execute.mockResolvedValueOnce(mockMetadata);
245
+
246
+ const result = await wallet.getContractClassMetadata(contractClass.id);
247
+ expect(result).toBe(mockMetadata);
248
+ expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_getContractClassMetadata', {
249
+ id: contractClass.id,
250
+ });
251
+ });
258
252
  });
259
253
 
260
254
  describe('auth witness operations', () => {
@@ -392,39 +386,6 @@ describe('AztecRemoteWallet', () => {
392
386
  });
393
387
  });
394
388
 
395
- describe('contract verification operations', () => {
396
- it('checks if contract class is publicly registered', async () => {
397
- const mockId = Fr.fromString('1');
398
- mockChainBuilder.execute.mockResolvedValueOnce(true);
399
-
400
- const result = await wallet.isContractClassPubliclyRegistered(mockId);
401
- expect(result).toBe(true);
402
- expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_isContractClassPubliclyRegistered', {
403
- id: mockId,
404
- });
405
- });
406
-
407
- it('checks if contract is publicly deployed', async () => {
408
- mockChainBuilder.execute.mockResolvedValueOnce(true);
409
-
410
- const result = await wallet.isContractPubliclyDeployed(mockAddress);
411
- expect(result).toBe(true);
412
- expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_isContractPubliclyDeployed', {
413
- address: mockAddress,
414
- });
415
- });
416
-
417
- it('checks if contract is initialized', async () => {
418
- mockChainBuilder.execute.mockResolvedValueOnce(true);
419
-
420
- const result = await wallet.isContractInitialized(mockAddress);
421
- expect(result).toBe(true);
422
- expect(mockChainBuilder.call).toHaveBeenCalledWith('aztec_isContractInitialized', {
423
- address: mockAddress,
424
- });
425
- });
426
- });
427
-
428
389
  describe('PXE operations', () => {
429
390
  it('gets PXE info', async () => {
430
391
  const mockInfo = { version: '1.0.0' } as unknown as PXEInfo;
@@ -2,7 +2,6 @@ import type {
2
2
  AuthWitness,
3
3
  AztecAddress,
4
4
  ContractArtifact,
5
- ContractClassWithId,
6
5
  ContractInstanceWithAddress,
7
6
  ExtendedNote,
8
7
  TxExecutionRequest,
@@ -34,6 +33,8 @@ import type {
34
33
  TxEffect,
35
34
  GetPublicLogsResponse,
36
35
  GetContractClassLogsResponse,
36
+ ContractMetadata,
37
+ ContractClassMetadata,
37
38
  } from '@aztec/circuit-types';
38
39
  import type { GasFees, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js';
39
40
 
@@ -171,25 +172,18 @@ export class AztecRemoteWallet implements Wallet {
171
172
  return scopes;
172
173
  }
173
174
 
174
- async getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
175
+ async getContractMetadata(address: AztecAddress): Promise<ContractMetadata> {
175
176
  return this._provider
176
177
  .chain(this._providerChainId)
177
- .call('aztec_getContractInstance', { address })
178
- .execute() as Promise<AztecWalletMethodMap['aztec_getContractInstance']['result']>;
178
+ .call('aztec_getContractMetadata', { address })
179
+ .execute() as Promise<AztecWalletMethodMap['aztec_getContractMetadata']['result']>;
179
180
  }
180
181
 
181
- async getContractClass(id: Fr): Promise<ContractClassWithId | undefined> {
182
+ async getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata> {
182
183
  return this._provider
183
184
  .chain(this._providerChainId)
184
- .call('aztec_getContractClass', { id })
185
- .execute() as Promise<AztecWalletMethodMap['aztec_getContractClass']['result']>;
186
- }
187
-
188
- async getContractArtifact(id: Fr): Promise<ContractArtifact | undefined> {
189
- return this._provider
190
- .chain(this._providerChainId)
191
- .call('aztec_getContractArtifact', { id })
192
- .execute() as Promise<AztecWalletMethodMap['aztec_getContractArtifact']['result']>;
185
+ .call('aztec_getContractClassMetadata', { id, includeArtifact })
186
+ .execute() as Promise<AztecWalletMethodMap['aztec_getContractClassMetadata']['result']>;
193
187
  }
194
188
 
195
189
  async addCapsule(capsule: Fr[]): Promise<void> {
@@ -414,27 +408,6 @@ export class AztecRemoteWallet implements Wallet {
414
408
  .execute()) as Promise<AztecWalletMethodMap['aztec_getAuthWitness']['result']>;
415
409
  }
416
410
 
417
- async isContractClassPubliclyRegistered(id: Fr): Promise<boolean> {
418
- return this._provider
419
- .chain(this._providerChainId)
420
- .call('aztec_isContractClassPubliclyRegistered', { id })
421
- .execute() as Promise<AztecWalletMethodMap['aztec_isContractClassPubliclyRegistered']['result']>;
422
- }
423
-
424
- async isContractPubliclyDeployed(address: AztecAddress): Promise<boolean> {
425
- return this._provider
426
- .chain(this._providerChainId)
427
- .call('aztec_isContractPubliclyDeployed', { address })
428
- .execute() as Promise<AztecWalletMethodMap['aztec_isContractPubliclyDeployed']['result']>;
429
- }
430
-
431
- async isContractInitialized(address: AztecAddress): Promise<boolean> {
432
- return this._provider
433
- .chain(this._providerChainId)
434
- .call('aztec_isContractInitialized', { address })
435
- .execute() as Promise<AztecWalletMethodMap['aztec_isContractInitialized']['result']>;
436
- }
437
-
438
411
  async getPXEInfo(): Promise<PXEInfo> {
439
412
  return this._provider.chain(this._providerChainId).call('aztec_getPXEInfo').execute() as Promise<
440
413
  AztecWalletMethodMap['aztec_getPXEInfo']['result']