@walletmesh/aztec-rpc-wallet 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +290 -228
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/client/aztec-dapp-wallet.d.ts +401 -0
  5. package/dist/client/aztec-dapp-wallet.d.ts.map +1 -0
  6. package/dist/client/aztec-dapp-wallet.js +705 -0
  7. package/dist/client/aztec-router-provider.d.ts +58 -0
  8. package/dist/client/aztec-router-provider.d.ts.map +1 -0
  9. package/dist/client/aztec-router-provider.js +62 -0
  10. package/dist/client/helpers.d.ts +44 -0
  11. package/dist/client/helpers.d.ts.map +1 -0
  12. package/dist/client/helpers.js +79 -0
  13. package/dist/client/register-serializers.d.ts +41 -0
  14. package/dist/client/register-serializers.d.ts.map +1 -0
  15. package/dist/client/register-serializers.js +97 -0
  16. package/dist/contractArtifactCache.d.ts +49 -32
  17. package/dist/contractArtifactCache.d.ts.map +1 -1
  18. package/dist/contractArtifactCache.js +47 -34
  19. package/dist/errors.d.ts +50 -8
  20. package/dist/errors.d.ts.map +1 -1
  21. package/dist/errors.js +50 -10
  22. package/dist/index.d.ts +53 -40
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +52 -17
  25. package/dist/types.d.ts +345 -268
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/types.js +10 -8
  28. package/dist/wallet/create-node.d.ts +73 -0
  29. package/dist/wallet/create-node.d.ts.map +1 -0
  30. package/dist/wallet/create-node.js +99 -0
  31. package/dist/wallet/handlers/account.d.ts +67 -0
  32. package/dist/wallet/handlers/account.d.ts.map +1 -0
  33. package/dist/wallet/handlers/account.js +85 -0
  34. package/dist/wallet/handlers/contract-interaction.d.ts +77 -0
  35. package/dist/wallet/handlers/contract-interaction.d.ts.map +1 -0
  36. package/dist/wallet/handlers/contract-interaction.js +219 -0
  37. package/dist/wallet/handlers/contract.d.ts +96 -0
  38. package/dist/wallet/handlers/contract.d.ts.map +1 -0
  39. package/dist/wallet/handlers/contract.js +146 -0
  40. package/dist/wallet/handlers/event.d.ts +62 -0
  41. package/dist/wallet/handlers/event.d.ts.map +1 -0
  42. package/dist/wallet/handlers/event.js +85 -0
  43. package/dist/wallet/handlers/index.d.ts +88 -0
  44. package/dist/wallet/handlers/index.d.ts.map +1 -0
  45. package/dist/wallet/handlers/index.js +47 -0
  46. package/dist/wallet/handlers/node.d.ts +117 -0
  47. package/dist/wallet/handlers/node.d.ts.map +1 -0
  48. package/dist/wallet/handlers/node.js +196 -0
  49. package/dist/wallet/handlers/senders.d.ts +70 -0
  50. package/dist/wallet/handlers/senders.d.ts.map +1 -0
  51. package/dist/wallet/handlers/senders.js +92 -0
  52. package/dist/wallet/handlers/transaction.d.ts +123 -0
  53. package/dist/wallet/handlers/transaction.d.ts.map +1 -0
  54. package/dist/wallet/handlers/transaction.js +191 -0
  55. package/dist/wallet/serializers.d.ts +75 -0
  56. package/dist/wallet/serializers.d.ts.map +1 -0
  57. package/dist/wallet/serializers.js +501 -0
  58. package/docs/README.md +290 -229
  59. package/docs/classes/AztecDappWallet.md +1304 -0
  60. package/docs/classes/AztecRouterProvider.md +1058 -0
  61. package/docs/classes/AztecWalletError.md +124 -47
  62. package/docs/classes/ContractArtifactCache.md +48 -31
  63. package/docs/functions/connectAztec.md +62 -0
  64. package/docs/functions/createAztecWallet.md +46 -0
  65. package/docs/functions/createAztecWalletNode.md +96 -0
  66. package/docs/functions/registerAztecSerializers.md +61 -0
  67. package/docs/functions/registerWalletAztecSerializers.md +39 -0
  68. package/docs/globals.md +16 -14
  69. package/docs/interfaces/AztecHandlerContext.md +54 -0
  70. package/docs/interfaces/AztecWalletContext.md +50 -0
  71. package/docs/interfaces/AztecWalletMethodMap.md +471 -470
  72. package/docs/type-aliases/AztecChainId.md +16 -3
  73. package/docs/variables/ALL_AZTEC_METHODS.md +20 -0
  74. package/docs/variables/AztecWalletErrorMap.md +9 -4
  75. package/docs/variables/AztecWalletSerializer.md +45 -0
  76. package/package.json +9 -9
  77. package/src/client/aztec-dapp-wallet.test.ts +628 -0
  78. package/src/client/aztec-dapp-wallet.ts +879 -0
  79. package/src/client/aztec-router-provider.test.ts +235 -0
  80. package/src/client/aztec-router-provider.ts +64 -0
  81. package/src/client/helpers.test.ts +187 -0
  82. package/src/client/helpers.ts +91 -0
  83. package/src/client/register-serializers.ts +108 -0
  84. package/src/contractArtifactCache.test.ts +21 -10
  85. package/src/contractArtifactCache.ts +54 -35
  86. package/src/errors.ts +58 -10
  87. package/src/index.test.ts +2 -6
  88. package/src/index.ts +73 -37
  89. package/src/types.ts +379 -217
  90. package/src/wallet/create-node.test.ts +332 -0
  91. package/src/wallet/create-node.ts +120 -0
  92. package/src/wallet/handlers/account.test.ts +172 -0
  93. package/src/wallet/handlers/account.ts +99 -0
  94. package/src/wallet/handlers/contract-interaction.test.ts +248 -0
  95. package/src/wallet/handlers/contract-interaction.ts +269 -0
  96. package/src/wallet/handlers/contract.test.ts +245 -0
  97. package/src/wallet/handlers/contract.ts +174 -0
  98. package/src/wallet/handlers/event.test.ts +216 -0
  99. package/src/wallet/handlers/event.ts +99 -0
  100. package/src/wallet/handlers/index.ts +84 -0
  101. package/src/wallet/handlers/node.test.ts +304 -0
  102. package/src/wallet/handlers/node.ts +230 -0
  103. package/src/wallet/handlers/senders.test.ts +172 -0
  104. package/src/wallet/handlers/senders.ts +106 -0
  105. package/src/wallet/handlers/transaction.test.ts +371 -0
  106. package/src/wallet/handlers/transaction.ts +239 -0
  107. package/src/wallet/serializers.test.ts +253 -0
  108. package/src/wallet/serializers.ts +586 -0
  109. package/typedoc.json +23 -1
  110. package/dist/aztecRemoteWallet.d.ts +0 -70
  111. package/dist/aztecRemoteWallet.d.ts.map +0 -1
  112. package/dist/aztecRemoteWallet.js +0 -335
  113. package/dist/chainProvider.d.ts +0 -56
  114. package/dist/chainProvider.d.ts.map +0 -1
  115. package/dist/chainProvider.js +0 -98
  116. package/dist/handlers/aztecAccountWallet.d.ts +0 -4
  117. package/dist/handlers/aztecAccountWallet.d.ts.map +0 -1
  118. package/dist/handlers/aztecAccountWallet.js +0 -296
  119. package/dist/handlers/transactions.d.ts +0 -21
  120. package/dist/handlers/transactions.d.ts.map +0 -1
  121. package/dist/handlers/transactions.js +0 -98
  122. package/dist/handlers.d.ts +0 -27
  123. package/dist/handlers.d.ts.map +0 -1
  124. package/dist/handlers.js +0 -55
  125. package/dist/provider.d.ts +0 -105
  126. package/dist/provider.d.ts.map +0 -1
  127. package/dist/provider.js +0 -160
  128. package/dist/serializers/account.d.ts +0 -164
  129. package/dist/serializers/account.d.ts.map +0 -1
  130. package/dist/serializers/account.js +0 -244
  131. package/dist/serializers/contract.d.ts +0 -62
  132. package/dist/serializers/contract.d.ts.map +0 -1
  133. package/dist/serializers/contract.js +0 -130
  134. package/dist/serializers/index.d.ts +0 -21
  135. package/dist/serializers/index.d.ts.map +0 -1
  136. package/dist/serializers/index.js +0 -154
  137. package/dist/serializers/log.d.ts +0 -66
  138. package/dist/serializers/log.d.ts.map +0 -1
  139. package/dist/serializers/log.js +0 -222
  140. package/dist/serializers/note.d.ts +0 -124
  141. package/dist/serializers/note.d.ts.map +0 -1
  142. package/dist/serializers/note.js +0 -208
  143. package/dist/serializers/transaction.d.ts +0 -99
  144. package/dist/serializers/transaction.d.ts.map +0 -1
  145. package/dist/serializers/transaction.js +0 -275
  146. package/dist/wallet.d.ts +0 -62
  147. package/dist/wallet.d.ts.map +0 -1
  148. package/dist/wallet.js +0 -77
  149. package/docs/classes/AztecChainProvider.md +0 -553
  150. package/docs/classes/AztecChainWallet.md +0 -409
  151. package/docs/classes/AztecProvider.md +0 -1112
  152. package/docs/interfaces/AztecWalletBaseMethodMap.md +0 -135
  153. package/docs/interfaces/AztecWalletEventMap.md +0 -17
  154. package/docs/type-aliases/AztecChainWalletMiddleware.md +0 -13
  155. package/docs/type-aliases/AztecWalletContext.md +0 -29
  156. package/docs/type-aliases/AztecWalletMethodHandler.md +0 -37
  157. package/docs/type-aliases/AztecWalletMiddleware.md +0 -13
  158. package/docs/type-aliases/AztecWalletRouterClient.md +0 -13
  159. package/docs/type-aliases/TransactionFunctionCall.md +0 -33
  160. package/docs/type-aliases/TransactionParams.md +0 -27
  161. package/src/aztecRemoteWallet.test.ts +0 -504
  162. package/src/aztecRemoteWallet.ts +0 -467
  163. package/src/chainProvider.test.ts +0 -401
  164. package/src/chainProvider.ts +0 -116
  165. package/src/handlers/aztecAccountWallet.test.ts +0 -649
  166. package/src/handlers/aztecAccountWallet.ts +0 -532
  167. package/src/handlers/transactions.ts +0 -124
  168. package/src/handlers.test.ts +0 -270
  169. package/src/handlers.ts +0 -70
  170. package/src/provider.test.ts +0 -274
  171. package/src/provider.ts +0 -189
  172. package/src/serializers/account.test.ts +0 -125
  173. package/src/serializers/account.ts +0 -301
  174. package/src/serializers/contract.test.ts +0 -24
  175. package/src/serializers/contract.ts +0 -183
  176. package/src/serializers/index.test.ts +0 -136
  177. package/src/serializers/index.ts +0 -191
  178. package/src/serializers/log.test.ts +0 -286
  179. package/src/serializers/log.ts +0 -292
  180. package/src/serializers/note.test.ts +0 -125
  181. package/src/serializers/note.ts +0 -250
  182. package/src/serializers/transaction.test.ts +0 -320
  183. package/src/serializers/transaction.ts +0 -409
  184. package/src/wallet.test.ts +0 -275
  185. package/src/wallet.ts +0 -94
@@ -0,0 +1,88 @@
1
+ import type { AccountWallet, PXE } from '@aztec/aztec.js';
2
+ import type { JSONRPCContext } from '@walletmesh/jsonrpc';
3
+ import type { ContractArtifactCache } from '../../contractArtifactCache.js';
4
+ import type { AztecWalletMethodMap } from '../../types.js';
5
+ /**
6
+ * Defines the context object that is passed to all Aztec wallet JSON-RPC method handlers.
7
+ * This context provides handlers with the necessary dependencies to perform their operations.
8
+ * It extends the base {@link JSONRPCContext} with Aztec-specific instances.
9
+ *
10
+ * @property wallet - An instance of {@link AccountWallet} from `aztec.js`,
11
+ * representing the user's account and signing capabilities.
12
+ * @property pxe - An instance of {@link PXE} (Private Execution Environment) client
13
+ * from `aztec.js`, used for interacting with the Aztec network.
14
+ * @property cache - An instance of {@link ContractArtifactCache} used for caching
15
+ * contract artifacts to optimize performance.
16
+ */
17
+ export interface AztecHandlerContext extends JSONRPCContext {
18
+ wallet: AccountWallet;
19
+ pxe: PXE;
20
+ cache: ContractArtifactCache;
21
+ }
22
+ /**
23
+ * Defines the generic signature for an Aztec wallet JSON-RPC method handler function.
24
+ *
25
+ * @template M - A key from {@link AztecWalletMethodMap}, representing the specific Aztec method being handled.
26
+ * @param context - The {@link AztecHandlerContext} providing access to wallet, PXE, and cache.
27
+ * @param params - The parameters for the RPC method, typed as {@link JSONRPCParams} (typically an array or object).
28
+ * The specific structure of `params` is defined by `AztecWalletMethodMap[M]['params']`.
29
+ * @returns A promise that resolves to the result of the RPC method, typed according to `AztecWalletMethodMap[M]['result']`.
30
+ */
31
+ export type AztecHandler<M extends keyof AztecWalletMethodMap> = (context: AztecHandlerContext, params: AztecWalletMethodMap[M]['params']) => Promise<AztecWalletMethodMap[M]['result']>;
32
+ /**
33
+ * Creates and aggregates all Aztec JSON-RPC method handlers.
34
+ *
35
+ * This factory function consolidates handlers from various specialized modules
36
+ * (account, transaction, contract, etc.) into a single object. This object
37
+ * maps method names (as defined in {@link AztecWalletMethodMap}) to their
38
+ * respective handler functions.
39
+ *
40
+ * The resulting map of handlers is typically registered with a {@link JSONRPCNode}
41
+ * instance on the wallet-side.
42
+ *
43
+ * @returns An object where keys are Aztec method names (e.g., "aztec_getAddress")
44
+ * and values are the corresponding handler functions. Each handler
45
+ * conforms to the {@link AztecHandler} type.
46
+ *
47
+ * @see {@link createAccountHandlers}
48
+ * @see {@link createTransactionHandlers}
49
+ * @see {@link createContractHandlers}
50
+ * @see {@link createContractInteractionHandlers}
51
+ * @see {@link createSenderHandlers}
52
+ * @see {@link createEventHandlers}
53
+ * @see {@link createNodeHandlers}
54
+ * @see {@link createAztecWalletNode} where these handlers are typically used.
55
+ */
56
+ export declare function createAztecHandlers(): {
57
+ wm_getSupportedMethods: (_ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["wm_getSupportedMethods"]["params"]) => Promise<AztecWalletMethodMap["wm_getSupportedMethods"]["result"]>;
58
+ aztec_getChainId: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getChainId"]["params"]) => Promise<AztecWalletMethodMap["aztec_getChainId"]["result"]>;
59
+ aztec_getVersion: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getVersion"]["params"]) => Promise<AztecWalletMethodMap["aztec_getVersion"]["result"]>;
60
+ aztec_getNodeInfo: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getNodeInfo"]["params"]) => Promise<AztecWalletMethodMap["aztec_getNodeInfo"]["result"]>;
61
+ aztec_getCurrentBaseFees: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getCurrentBaseFees"]["params"]) => Promise<AztecWalletMethodMap["aztec_getCurrentBaseFees"]["result"]>;
62
+ aztec_getPXEInfo: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getPXEInfo"]["params"]) => Promise<AztecWalletMethodMap["aztec_getPXEInfo"]["result"]>;
63
+ aztec_getBlock: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getBlock"]["params"]) => Promise<AztecWalletMethodMap["aztec_getBlock"]["result"]>;
64
+ aztec_getBlockNumber: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getBlockNumber"]["params"]) => Promise<AztecWalletMethodMap["aztec_getBlockNumber"]["result"]>;
65
+ aztec_getPrivateEvents: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getPrivateEvents"]["params"]) => Promise<AztecWalletMethodMap["aztec_getPrivateEvents"]["result"]>;
66
+ aztec_getPublicEvents: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getPublicEvents"]["params"]) => Promise<AztecWalletMethodMap["aztec_getPublicEvents"]["result"]>;
67
+ aztec_registerSender: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_registerSender"]["params"]) => Promise<AztecWalletMethodMap["aztec_registerSender"]["result"]>;
68
+ aztec_getSenders: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getSenders"]["params"]) => Promise<AztecWalletMethodMap["aztec_getSenders"]["result"]>;
69
+ aztec_removeSender: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_removeSender"]["params"]) => Promise<AztecWalletMethodMap["aztec_removeSender"]["result"]>;
70
+ aztec_wmExecuteTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_wmExecuteTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_wmExecuteTx"]["result"]>;
71
+ aztec_wmSimulateTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_wmSimulateTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_wmSimulateTx"]["result"]>;
72
+ aztec_wmDeployContract: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_wmDeployContract"]["params"]) => Promise<AztecWalletMethodMap["aztec_wmDeployContract"]["result"]>;
73
+ aztec_registerContract: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_registerContract"]["params"]) => Promise<AztecWalletMethodMap["aztec_registerContract"]["result"]>;
74
+ aztec_registerContractClass: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_registerContractClass"]["params"]) => Promise<AztecWalletMethodMap["aztec_registerContractClass"]["result"]>;
75
+ aztec_getContractMetadata: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getContractMetadata"]["params"]) => Promise<AztecWalletMethodMap["aztec_getContractMetadata"]["result"]>;
76
+ aztec_getContracts: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getContracts"]["params"]) => Promise<AztecWalletMethodMap["aztec_getContracts"]["result"]>;
77
+ aztec_getContractClassMetadata: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getContractClassMetadata"]["params"]) => Promise<AztecWalletMethodMap["aztec_getContractClassMetadata"]["result"]>;
78
+ aztec_proveTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_proveTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_proveTx"]["result"]>;
79
+ aztec_sendTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_sendTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_sendTx"]["result"]>;
80
+ aztec_getTxReceipt: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getTxReceipt"]["params"]) => Promise<AztecWalletMethodMap["aztec_getTxReceipt"]["result"]>;
81
+ aztec_simulateTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_simulateTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_simulateTx"]["result"]>;
82
+ aztec_profileTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_profileTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_profileTx"]["result"]>;
83
+ aztec_simulateUtility: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_simulateUtility"]["params"]) => Promise<AztecWalletMethodMap["aztec_simulateUtility"]["result"]>;
84
+ aztec_getAddress: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getAddress"]["params"]) => Promise<AztecWalletMethodMap["aztec_getAddress"]["result"]>;
85
+ aztec_getCompleteAddress: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getCompleteAddress"]["params"]) => Promise<AztecWalletMethodMap["aztec_getCompleteAddress"]["result"]>;
86
+ aztec_createAuthWit: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_createAuthWit"]["params"]) => Promise<AztecWalletMethodMap["aztec_createAuthWit"]["result"]>;
87
+ };
88
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallet/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAU3D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,oBAAoB,IAAI,CAC/D,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KACtC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB;sEAFV,8CAA+C,uBAExC,8CAEL;+DAagR,wCAAyC,uBAA2C,wCAAwC;+DAA03B,wCAAyC,uBAA2C,wCAAwC;gEAA61B,yCAA0C,uBAA2C,yCAAyC;uEAAm3B,gDAAiD,uBAA2C,gDAAgD;+DAAy3B,wCAAyC,uBAA2C,wCAAwC;4DAA6gC,sCAAuC,uBAA2B,sCAAsC;mEAA8mC,4CAA6C,uBAA2C,4CAA4C;oEApC1rN,8CAA+C,uBACrD,8CAA8C;mEAmCktB,6CAA8C,uBAA2B,6CAA6C;kEAzCv3B,4CAGT,uBAA2B,4CAErB;+DAyBsC,wCACvC,uBAA2C,wCACtD;gEASy/B,0CAA2C,uBAA2B,0CAA0C;+DAA4oF,yCAA0C,uBAA2B,yCAAyC;gEAAs4B,0CAA2C,uBAA2B,0CAA0C;oEAAyhD,8CAA+C,uBAA2B,8CAA8C;oEA3Ch+M,8CACe,uBAA2B,8CACnC;yEAyCyL,mDAAoD,uBAA2B,mDAAmD;uEAA2vC,iDAAkD,uBAA2B,iDAAiD;iEAA+9C,0CAA2C,uBAA2C,0CAA0C;4EAAuyC,sDAAuD,uBAA2B,sDAAsD;2DA5ClrJ,qCAC7B,uBACL,qCAAqC;0DA0C+kB,oCAAqC,uBAA2B,oCAAoC;gEAAmzC,0CAA2C,uBAA2B,0CAA0C;8DAAoqD,wCAAyC,uBAA2B,wCAAwC;6DAAqnE,uCAAwC,uBAA2B,uCAAuC;mEAA21D,6CAA8C,uBAA2B,6CAA6C;+DAlD1hQ,wCAAyC,uBACrE,wCAAwC;uEAqBzB,gDAAgD,uBACvC,gDAC9B;iEA0ByW,2CAA4C,uBAA2B,2CAA2C;EAD3d"}
@@ -0,0 +1,47 @@
1
+ import { createAccountHandlers } from './account.js';
2
+ import { createTransactionHandlers } from './transaction.js';
3
+ import { createContractHandlers } from './contract.js';
4
+ import { createContractInteractionHandlers } from './contract-interaction.js';
5
+ import { createEventHandlers } from './event.js';
6
+ import { createNodeHandlers } from './node.js';
7
+ import { createSenderHandlers } from './senders.js';
8
+ /**
9
+ * Creates and aggregates all Aztec JSON-RPC method handlers.
10
+ *
11
+ * This factory function consolidates handlers from various specialized modules
12
+ * (account, transaction, contract, etc.) into a single object. This object
13
+ * maps method names (as defined in {@link AztecWalletMethodMap}) to their
14
+ * respective handler functions.
15
+ *
16
+ * The resulting map of handlers is typically registered with a {@link JSONRPCNode}
17
+ * instance on the wallet-side.
18
+ *
19
+ * @returns An object where keys are Aztec method names (e.g., "aztec_getAddress")
20
+ * and values are the corresponding handler functions. Each handler
21
+ * conforms to the {@link AztecHandler} type.
22
+ *
23
+ * @see {@link createAccountHandlers}
24
+ * @see {@link createTransactionHandlers}
25
+ * @see {@link createContractHandlers}
26
+ * @see {@link createContractInteractionHandlers}
27
+ * @see {@link createSenderHandlers}
28
+ * @see {@link createEventHandlers}
29
+ * @see {@link createNodeHandlers}
30
+ * @see {@link createAztecWalletNode} where these handlers are typically used.
31
+ */
32
+ export function createAztecHandlers() {
33
+ return {
34
+ // Note: The individual createXYZHandlers() functions return objects whose methods
35
+ // might have params typed as general JSONRPCParams or a more specific tuple.
36
+ // The createAztecWalletNode function correctly casts these to the specific
37
+ // handler signatures expected by JSONRPCNode.registerMethod, using AztecWalletMethodMap.
38
+ ...createAccountHandlers(),
39
+ ...createTransactionHandlers(),
40
+ ...createContractHandlers(),
41
+ ...createContractInteractionHandlers(),
42
+ ...createSenderHandlers(),
43
+ ...createEventHandlers(),
44
+ ...createNodeHandlers(),
45
+ };
46
+ }
47
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvd2FsbGV0L2hhbmRsZXJzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLGNBQWMsQ0FBQztBQUNyRCxPQUFPLEVBQUUseUJBQXlCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUM3RCxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDdkQsT0FBTyxFQUFFLGlDQUFpQyxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUUsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sWUFBWSxDQUFDO0FBQ2pELE9BQU8sRUFBRSxrQkFBa0IsRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUMvQyxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFrQ3BEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQXVCRztBQUNILE1BQU0sVUFBVSxtQkFBbUI7SUFDakMsT0FBTztRQUNMLGtGQUFrRjtRQUNsRiw2RUFBNkU7UUFDN0UsMkVBQTJFO1FBQzNFLHlGQUF5RjtRQUN6RixHQUFHLHFCQUFxQixFQUFFO1FBQzFCLEdBQUcseUJBQXlCLEVBQUU7UUFDOUIsR0FBRyxzQkFBc0IsRUFBRTtRQUMzQixHQUFHLGlDQUFpQyxFQUFFO1FBQ3RDLEdBQUcsb0JBQW9CLEVBQUU7UUFDekIsR0FBRyxtQkFBbUIsRUFBRTtRQUN4QixHQUFHLGtCQUFrQixFQUFFO0tBQ3hCLENBQUM7QUFDSixDQUFDIn0=
@@ -0,0 +1,117 @@
1
+ import type { AztecHandlerContext } from './index.js';
2
+ import type { AztecWalletMethodMap } from '../../types.js';
3
+ /**
4
+ * Creates handlers for node and network information-related Aztec wallet JSON-RPC methods.
5
+ * These handlers provide dApps with insights into the connected Aztec node's state,
6
+ * network parameters (like chain ID, version, fees), and block information.
7
+ *
8
+ * Each handler function receives an {@link AztecHandlerContext} which provides access
9
+ * to the {@link AccountWallet} and {@link PXE} client.
10
+ *
11
+ * @returns An object where keys are node-related method names
12
+ * (e.g., "aztec_getNodeInfo", "aztec_getBlockNumber") and values are their
13
+ * corresponding handler functions.
14
+ * @see {@link AztecWalletMethodMap} for method definitions.
15
+ */
16
+ export declare function createNodeHandlers(): {
17
+ /**
18
+ * Handles the "wm_getSupportedMethods" JSON-RPC method.
19
+ * Returns a list of all JSON-RPC methods supported by this wallet implementation.
20
+ * This allows clients to discover the capabilities of the wallet.
21
+ *
22
+ * @param _ctx - The {@link AztecHandlerContext} (unused for this method).
23
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
24
+ * Defined by {@link AztecWalletMethodMap.wm_getSupportedMethods.params}.
25
+ * @returns A promise that resolves to an array of strings, where each string is a
26
+ * supported method name.
27
+ * Type defined by {@link AztecWalletMethodMap.wm_getSupportedMethods.result}.
28
+ * @see {@link SUPPORTED_AZTEC_METHODS}
29
+ */
30
+ wm_getSupportedMethods: (_ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["wm_getSupportedMethods"]["params"]) => Promise<AztecWalletMethodMap["wm_getSupportedMethods"]["result"]>;
31
+ /**
32
+ * Handles the "aztec_getChainId" JSON-RPC method.
33
+ * Retrieves the chain ID of the Aztec network to which the {@link AccountWallet}
34
+ * in the context is connected.
35
+ *
36
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
37
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
38
+ * Defined by {@link AztecWalletMethodMap.aztec_getChainId.params}.
39
+ * @returns A promise that resolves to the chain ID as an {@link Fr} (Field element).
40
+ * Type defined by {@link AztecWalletMethodMap.aztec_getChainId.result}.
41
+ */
42
+ aztec_getChainId: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getChainId"]["params"]) => Promise<AztecWalletMethodMap["aztec_getChainId"]["result"]>;
43
+ /**
44
+ * Handles the "aztec_getVersion" JSON-RPC method.
45
+ * Retrieves the version of the Aztec software stack, typically the version of the
46
+ * PXE (Private Execution Environment) or the node the wallet is interacting with.
47
+ *
48
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
49
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
50
+ * Defined by {@link AztecWalletMethodMap.aztec_getVersion.params}.
51
+ * @returns A promise that resolves to the version as an {@link Fr} (Field element).
52
+ * Type defined by {@link AztecWalletMethodMap.aztec_getVersion.result}.
53
+ */
54
+ aztec_getVersion: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getVersion"]["params"]) => Promise<AztecWalletMethodMap["aztec_getVersion"]["result"]>;
55
+ /**
56
+ * Handles the "aztec_getNodeInfo" JSON-RPC method.
57
+ * Retrieves comprehensive information about the connected Aztec node, such as
58
+ * protocol version, chain ID, and addresses of core protocol contracts.
59
+ *
60
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
61
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
62
+ * Defined by {@link AztecWalletMethodMap.aztec_getNodeInfo.params}.
63
+ * @returns A promise that resolves to a {@link NodeInfo} object.
64
+ * Type defined by {@link AztecWalletMethodMap.aztec_getNodeInfo.result}.
65
+ */
66
+ aztec_getNodeInfo: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getNodeInfo"]["params"]) => Promise<AztecWalletMethodMap["aztec_getNodeInfo"]["result"]>;
67
+ /**
68
+ * Handles the "aztec_getCurrentBaseFees" JSON-RPC method.
69
+ * Retrieves the current base gas fees applicable on the Aztec network.
70
+ * This information is essential for estimating transaction costs.
71
+ *
72
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
73
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
74
+ * Defined by {@link AztecWalletMethodMap.aztec_getCurrentBaseFees.params}.
75
+ * @returns A promise that resolves to a {@link GasFees} object.
76
+ * Type defined by {@link AztecWalletMethodMap.aztec_getCurrentBaseFees.result}.
77
+ */
78
+ aztec_getCurrentBaseFees: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getCurrentBaseFees"]["params"]) => Promise<AztecWalletMethodMap["aztec_getCurrentBaseFees"]["result"]>;
79
+ /**
80
+ * Handles the "aztec_getPXEInfo" JSON-RPC method.
81
+ * Retrieves information about the Private Execution Environment (PXE) service
82
+ * that the wallet is connected to, including its version and core contract addresses.
83
+ *
84
+ * @param ctx - The {@link AztecHandlerContext} containing the `pxe` instance.
85
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
86
+ * Defined by {@link AztecWalletMethodMap.aztec_getPXEInfo.params}.
87
+ * @returns A promise that resolves to a {@link PXEInfo} object.
88
+ * Type defined by {@link AztecWalletMethodMap.aztec_getPXEInfo.result}.
89
+ */
90
+ aztec_getPXEInfo: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getPXEInfo"]["params"]) => Promise<AztecWalletMethodMap["aztec_getPXEInfo"]["result"]>;
91
+ /**
92
+ * Handles the "aztec_getBlock" JSON-RPC method.
93
+ * Retrieves a specific L2 block by its number from the connected PXE.
94
+ *
95
+ * @param ctx - The {@link AztecHandlerContext} containing the `pxe` instance.
96
+ * @param paramsTuple - A tuple containing the block number.
97
+ * Defined by {@link AztecWalletMethodMap.aztec_getBlock.params}.
98
+ * @param paramsTuple.0 - The number of the block to retrieve.
99
+ * @returns A promise that resolves to the {@link L2Block} data, or `null` / `undefined`
100
+ * if the block is not found (behavior depends on PXE implementation, typically throws).
101
+ * Type defined by {@link AztecWalletMethodMap.aztec_getBlock.result}.
102
+ * @throws {Error} If the `blockNumber` parameter is missing or invalid, or if the block is not found.
103
+ */
104
+ aztec_getBlock: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_getBlock"]["params"]) => Promise<AztecWalletMethodMap["aztec_getBlock"]["result"]>;
105
+ /**
106
+ * Handles the "aztec_getBlockNumber" JSON-RPC method.
107
+ * Retrieves the current (latest) L2 block number from the connected PXE.
108
+ *
109
+ * @param ctx - The {@link AztecHandlerContext} containing the `pxe` instance.
110
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
111
+ * Defined by {@link AztecWalletMethodMap.aztec_getBlockNumber.params}.
112
+ * @returns A promise that resolves to the current block number (a `number`).
113
+ * Type defined by {@link AztecWalletMethodMap.aztec_getBlockNumber.result}.
114
+ */
115
+ aztec_getBlockNumber: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getBlockNumber"]["params"]) => Promise<AztecWalletMethodMap["aztec_getBlockNumber"]["result"]>;
116
+ };
117
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"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YG;0BAEI,mBAAmB,eACX,oBAAoB,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,KAC5D,OAAO,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC;IAY5D;;;;;;;;;OASG;gCAEI,mBAAmB,gBACV,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,KACnE,OAAO,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,CAAC;EAKrE"}
@@ -0,0 +1,196 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ const logger = createLogger('aztec-rpc-wallet:node');
3
+ /**
4
+ * A constant array listing all JSON-RPC methods supported by this Aztec wallet implementation.
5
+ * This list is returned by the `wm_getSupportedMethods` RPC call, allowing clients (dApps)
6
+ * to discover the capabilities of the connected wallet node.
7
+ * It should be kept in sync with the methods defined in {@link AztecWalletMethodMap}
8
+ * and implemented by the various handler creation functions.
9
+ *
10
+ * Note: `aztec_createTxExecutionRequest` is intentionally omitted as it's a client-side
11
+ * convenience method in `AztecDappWallet` rather than a direct RPC method handled here.
12
+ * The actual RPC methods for transactions are `aztec_proveTx`, `aztec_sendTx`, etc.,
13
+ * or the higher-level `aztec_wmExecuteTx`.
14
+ */
15
+ const SUPPORTED_AZTEC_METHODS = [
16
+ 'wm_getSupportedMethods',
17
+ 'aztec_getChainId',
18
+ 'aztec_getVersion',
19
+ 'aztec_getNodeInfo',
20
+ 'aztec_getCurrentBaseFees',
21
+ 'aztec_getPXEInfo',
22
+ 'aztec_getBlock',
23
+ 'aztec_getBlockNumber',
24
+ 'aztec_getAddress',
25
+ 'aztec_getCompleteAddress',
26
+ 'aztec_createAuthWit',
27
+ 'aztec_registerSender',
28
+ 'aztec_getSenders',
29
+ 'aztec_removeSender',
30
+ 'aztec_getContracts',
31
+ 'aztec_getContractMetadata',
32
+ 'aztec_getContractClassMetadata',
33
+ 'aztec_registerContract',
34
+ 'aztec_registerContractClass',
35
+ // 'aztec_createTxExecutionRequest', // This is a client-side method, not an RPC method.
36
+ 'aztec_proveTx',
37
+ 'aztec_sendTx',
38
+ 'aztec_getTxReceipt',
39
+ 'aztec_simulateTx',
40
+ 'aztec_profileTx',
41
+ 'aztec_simulateUtility',
42
+ 'aztec_getPrivateEvents',
43
+ 'aztec_getPublicEvents',
44
+ 'aztec_wmExecuteTx',
45
+ 'aztec_wmSimulateTx',
46
+ 'aztec_wmDeployContract',
47
+ ];
48
+ /**
49
+ * Creates handlers for node and network information-related Aztec wallet JSON-RPC methods.
50
+ * These handlers provide dApps with insights into the connected Aztec node's state,
51
+ * network parameters (like chain ID, version, fees), and block information.
52
+ *
53
+ * Each handler function receives an {@link AztecHandlerContext} which provides access
54
+ * to the {@link AccountWallet} and {@link PXE} client.
55
+ *
56
+ * @returns An object where keys are node-related method names
57
+ * (e.g., "aztec_getNodeInfo", "aztec_getBlockNumber") and values are their
58
+ * corresponding handler functions.
59
+ * @see {@link AztecWalletMethodMap} for method definitions.
60
+ */
61
+ export function createNodeHandlers() {
62
+ return {
63
+ /**
64
+ * Handles the "wm_getSupportedMethods" JSON-RPC method.
65
+ * Returns a list of all JSON-RPC methods supported by this wallet implementation.
66
+ * This allows clients to discover the capabilities of the wallet.
67
+ *
68
+ * @param _ctx - The {@link AztecHandlerContext} (unused for this method).
69
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
70
+ * Defined by {@link AztecWalletMethodMap.wm_getSupportedMethods.params}.
71
+ * @returns A promise that resolves to an array of strings, where each string is a
72
+ * supported method name.
73
+ * Type defined by {@link AztecWalletMethodMap.wm_getSupportedMethods.result}.
74
+ * @see {@link SUPPORTED_AZTEC_METHODS}
75
+ */
76
+ wm_getSupportedMethods: async (_ctx, _paramsTuple) => {
77
+ logger.debug('[HANDLER] wm_getSupportedMethods');
78
+ return Array.from(SUPPORTED_AZTEC_METHODS);
79
+ },
80
+ /**
81
+ * Handles the "aztec_getChainId" JSON-RPC method.
82
+ * Retrieves the chain ID of the Aztec network to which the {@link AccountWallet}
83
+ * in the context is connected.
84
+ *
85
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
86
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
87
+ * Defined by {@link AztecWalletMethodMap.aztec_getChainId.params}.
88
+ * @returns A promise that resolves to the chain ID as an {@link Fr} (Field element).
89
+ * Type defined by {@link AztecWalletMethodMap.aztec_getChainId.result}.
90
+ */
91
+ aztec_getChainId: async (ctx, _paramsTuple) => {
92
+ logger.debug('[HANDLER] aztec_getChainId');
93
+ return ctx.wallet.getChainId();
94
+ },
95
+ /**
96
+ * Handles the "aztec_getVersion" JSON-RPC method.
97
+ * Retrieves the version of the Aztec software stack, typically the version of the
98
+ * PXE (Private Execution Environment) or the node the wallet is interacting with.
99
+ *
100
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
101
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
102
+ * Defined by {@link AztecWalletMethodMap.aztec_getVersion.params}.
103
+ * @returns A promise that resolves to the version as an {@link Fr} (Field element).
104
+ * Type defined by {@link AztecWalletMethodMap.aztec_getVersion.result}.
105
+ */
106
+ aztec_getVersion: async (ctx, _paramsTuple) => {
107
+ logger.debug('[HANDLER] aztec_getVersion');
108
+ return ctx.wallet.getVersion();
109
+ },
110
+ /**
111
+ * Handles the "aztec_getNodeInfo" JSON-RPC method.
112
+ * Retrieves comprehensive information about the connected Aztec node, such as
113
+ * protocol version, chain ID, and addresses of core protocol contracts.
114
+ *
115
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
116
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
117
+ * Defined by {@link AztecWalletMethodMap.aztec_getNodeInfo.params}.
118
+ * @returns A promise that resolves to a {@link NodeInfo} object.
119
+ * Type defined by {@link AztecWalletMethodMap.aztec_getNodeInfo.result}.
120
+ */
121
+ aztec_getNodeInfo: async (ctx, _paramsTuple) => {
122
+ logger.debug('[HANDLER] aztec_getNodeInfo');
123
+ return await ctx.wallet.getNodeInfo();
124
+ },
125
+ /**
126
+ * Handles the "aztec_getCurrentBaseFees" JSON-RPC method.
127
+ * Retrieves the current base gas fees applicable on the Aztec network.
128
+ * This information is essential for estimating transaction costs.
129
+ *
130
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
131
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
132
+ * Defined by {@link AztecWalletMethodMap.aztec_getCurrentBaseFees.params}.
133
+ * @returns A promise that resolves to a {@link GasFees} object.
134
+ * Type defined by {@link AztecWalletMethodMap.aztec_getCurrentBaseFees.result}.
135
+ */
136
+ aztec_getCurrentBaseFees: async (ctx, _paramsTuple) => {
137
+ logger.debug('[HANDLER] aztec_getCurrentBaseFees');
138
+ return await ctx.wallet.getCurrentBaseFees();
139
+ },
140
+ /**
141
+ * Handles the "aztec_getPXEInfo" JSON-RPC method.
142
+ * Retrieves information about the Private Execution Environment (PXE) service
143
+ * that the wallet is connected to, including its version and core contract addresses.
144
+ *
145
+ * @param ctx - The {@link AztecHandlerContext} containing the `pxe` instance.
146
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
147
+ * Defined by {@link AztecWalletMethodMap.aztec_getPXEInfo.params}.
148
+ * @returns A promise that resolves to a {@link PXEInfo} object.
149
+ * Type defined by {@link AztecWalletMethodMap.aztec_getPXEInfo.result}.
150
+ */
151
+ aztec_getPXEInfo: async (ctx, _paramsTuple) => {
152
+ logger.debug('[HANDLER] aztec_getPXEInfo');
153
+ return await ctx.pxe.getPXEInfo();
154
+ },
155
+ /**
156
+ * Handles the "aztec_getBlock" JSON-RPC method.
157
+ * Retrieves a specific L2 block by its number from the connected PXE.
158
+ *
159
+ * @param ctx - The {@link AztecHandlerContext} containing the `pxe` instance.
160
+ * @param paramsTuple - A tuple containing the block number.
161
+ * Defined by {@link AztecWalletMethodMap.aztec_getBlock.params}.
162
+ * @param paramsTuple.0 - The number of the block to retrieve.
163
+ * @returns A promise that resolves to the {@link L2Block} data, or `null` / `undefined`
164
+ * if the block is not found (behavior depends on PXE implementation, typically throws).
165
+ * Type defined by {@link AztecWalletMethodMap.aztec_getBlock.result}.
166
+ * @throws {Error} If the `blockNumber` parameter is missing or invalid, or if the block is not found.
167
+ */
168
+ aztec_getBlock: async (ctx, paramsTuple) => {
169
+ const [blockNumber] = paramsTuple;
170
+ logger.debug(`[HANDLER] aztec_getBlock: blockNumber = ${blockNumber}`);
171
+ if (blockNumber === undefined) {
172
+ // Should be caught by TS if tuple type is `[number]`
173
+ throw new Error('Missing required parameter: number');
174
+ }
175
+ const block = await ctx.pxe.getBlock(blockNumber);
176
+ if (!block)
177
+ throw new Error('Block not found');
178
+ return block;
179
+ },
180
+ /**
181
+ * Handles the "aztec_getBlockNumber" JSON-RPC method.
182
+ * Retrieves the current (latest) L2 block number from the connected PXE.
183
+ *
184
+ * @param ctx - The {@link AztecHandlerContext} containing the `pxe` instance.
185
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
186
+ * Defined by {@link AztecWalletMethodMap.aztec_getBlockNumber.params}.
187
+ * @returns A promise that resolves to the current block number (a `number`).
188
+ * Type defined by {@link AztecWalletMethodMap.aztec_getBlockNumber.result}.
189
+ */
190
+ aztec_getBlockNumber: async (ctx, _paramsTuple) => {
191
+ logger.debug('[HANDLER] aztec_getBlockNumber');
192
+ return await ctx.pxe.getBlockNumber();
193
+ },
194
+ };
195
+ }
196
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9kZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy93YWxsZXQvaGFuZGxlcnMvbm9kZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFckQsTUFBTSxNQUFNLEdBQUcsWUFBWSxDQUFDLHVCQUF1QixDQUFDLENBQU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0sR0FBRyxDQUFDLEdBQUcsQ0FBQyxVQUFVLEVBQUUsQ0FBQztRQUNwQyxDQUFDO1FBRUQ7Ozs7Ozs7Ozs7OztXQVlHO1FBQ0gsY0FBYyxFQUFFLEtBQUssRUFDbkIsR0FBd0IsRUFDeEIsV0FBNkQsRUFDRixFQUFFO1lBQzdELE1BQU0sQ0FBQyxXQUFXLENBQUMsR0FBRyxXQUFXLENBQUM7WUFDbEMsTUFBTSxDQUFDLEtBQUssQ0FBQywyQ0FBMkMsV0FBVyxFQUFFLENBQUMsQ0FBQztZQUN2RSxJQUFJLFdBQVcsS0FBSyxTQUFTLEVBQUUsQ0FBQztnQkFDOUIscURBQXFEO2dCQUNyRCxNQUFNLElBQUksS0FBSyxDQUFDLG9DQUFvQyxDQUFDLENBQUM7WUFDeEQsQ0FBQztZQUNELE1BQU0sS0FBSyxHQUFHLE1BQU0sR0FBRyxDQUFDLEdBQUcsQ0FBQyxRQUFRLENBQUMsV0FBVyxDQUFDLENBQUM7WUFDbEQsSUFBSSxDQUFDLEtBQUs7Z0JBQUUsTUFBTSxJQUFJLEtBQUssQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1lBQy9DLE9BQU8sS0FBSyxDQUFDO1FBQ2YsQ0FBQztRQUVEOzs7Ozs7Ozs7V0FTRztRQUNILG9CQUFvQixFQUFFLEtBQUssRUFDekIsR0FBd0IsRUFDeEIsWUFBb0UsRUFDSCxFQUFFO1lBQ25FLE1BQU0sQ0FBQyxLQUFLLENBQUMsZ0NBQWdDLENBQUMsQ0FBQztZQUMvQyxPQUFPLE1BQU0sR0FBRyxDQUFDLEdBQUcsQ0FBQyxjQUFjLEVBQUUsQ0FBQztRQUN4QyxDQUFDO0tBQ0YsQ0FBQztBQUNKLENBQUMifQ==
@@ -0,0 +1,70 @@
1
+ import type { AztecHandlerContext } from './index.js';
2
+ import type { AztecWalletMethodMap } from '../../types.js';
3
+ /**
4
+ * Creates handlers for managing authorized senders in an Aztec wallet via JSON-RPC.
5
+ * Authorized senders are {@link AztecAddress}es permitted to submit transactions
6
+ * on behalf of the user's account. This functionality is crucial for delegation,
7
+ * enabling other accounts or smart contracts to act for the user under controlled conditions.
8
+ *
9
+ * Each handler function receives an {@link AztecHandlerContext}, providing access to the
10
+ * {@link AccountWallet} instance necessary for sender management.
11
+ *
12
+ * @returns An object where keys are sender-related method names
13
+ * (e.g., "aztec_registerSender", "aztec_getSenders", "aztec_removeSender")
14
+ * and values are their corresponding handler functions.
15
+ * @see {@link AztecWalletMethodMap} for method definitions.
16
+ */
17
+ export declare function createSenderHandlers(): {
18
+ /**
19
+ * Handles the "aztec_registerSender" JSON-RPC method.
20
+ * Registers a new {@link AztecAddress} as an authorized sender for the account
21
+ * managed by the {@link AccountWallet} in the context.
22
+ *
23
+ * This allows the specified sender address to initiate transactions on behalf of the user.
24
+ * Common use cases include:
25
+ * - Delegating transaction submission to a different account.
26
+ * - Authorizing a smart contract to perform actions for the user.
27
+ * - Setting up automated transaction systems or relayers.
28
+ *
29
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
30
+ * @param paramsTuple - A tuple containing the sender's address to register.
31
+ * Defined by {@link AztecWalletMethodMap.aztec_registerSender.params}.
32
+ * @param paramsTuple.0 - The {@link AztecAddress} to authorize as a sender.
33
+ * @returns A promise that resolves to the registered {@link AztecAddress}.
34
+ * Type defined by {@link AztecWalletMethodMap.aztec_registerSender.result}.
35
+ * @throws {Error} If the `sender` parameter is missing or invalid, though type checking
36
+ * and serializer validation should catch this earlier.
37
+ */
38
+ aztec_registerSender: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_registerSender"]["params"]) => Promise<AztecWalletMethodMap["aztec_registerSender"]["result"]>;
39
+ /**
40
+ * Handles the "aztec_getSenders" JSON-RPC method.
41
+ * Retrieves a list of all {@link AztecAddress}es currently authorized to send
42
+ * transactions on behalf of the account managed by the {@link AccountWallet} in the context.
43
+ * This is useful for auditing and managing delegation permissions.
44
+ *
45
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
46
+ * @param _paramsTuple - Parameters for this method (expected to be an empty array).
47
+ * Defined by {@link AztecWalletMethodMap.aztec_getSenders.params}.
48
+ * @returns A promise that resolves to an array of authorized {@link AztecAddress}es.
49
+ * Type defined by {@link AztecWalletMethodMap.aztec_getSenders.result}.
50
+ */
51
+ aztec_getSenders: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getSenders"]["params"]) => Promise<AztecWalletMethodMap["aztec_getSenders"]["result"]>;
52
+ /**
53
+ * Handles the "aztec_removeSender" JSON-RPC method.
54
+ * Revokes the authorization for a previously registered sender for the account
55
+ * managed by the {@link AccountWallet} in the context.
56
+ * After successful removal, the specified address will no longer be able to
57
+ * submit transactions on behalf of this wallet.
58
+ *
59
+ * @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
60
+ * @param paramsTuple - A tuple containing the sender's address to remove.
61
+ * Defined by {@link AztecWalletMethodMap.aztec_removeSender.params}.
62
+ * @param paramsTuple.0 - The {@link AztecAddress} to remove from the list of authorized senders.
63
+ * @returns A promise that resolves to `true` if the removal was successful.
64
+ * Type defined by {@link AztecWalletMethodMap.aztec_removeSender.result}.
65
+ * @throws {Error} If the `sender` parameter is missing or invalid, though type checking
66
+ * and serializer validation should catch this earlier.
67
+ */
68
+ aztec_removeSender: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_removeSender"]["params"]) => Promise<AztecWalletMethodMap["aztec_removeSender"]["result"]>;
69
+ };
70
+ //# sourceMappingURL=senders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"senders.d.ts","sourceRoot":"","sources":["../../../src/wallet/handlers/senders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAK3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB;IAEhC;;;;;;;;;;;;;;;;;;;OAmBG;gCAEI,mBAAmB,eACX,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,KAClE,OAAO,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,CAAC;IAUlE;;;;;;;;;;;OAWG;4BAEI,mBAAmB,gBACV,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,KAC/D,OAAO,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;IAK9D;;;;;;;;;;;;;;;OAeG;8BAEI,mBAAmB,eACX,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,KAChE,OAAO,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,CAAC;EAWnE"}