@alchemy/wallet-apis 5.0.0-beta.3 → 5.0.0-beta.30

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 (201) hide show
  1. package/README.md +3 -1
  2. package/dist/esm/actions/prepareCalls.d.ts +8 -3
  3. package/dist/esm/actions/prepareCalls.js +8 -0
  4. package/dist/esm/actions/prepareCalls.js.map +1 -1
  5. package/dist/esm/actions/requestAccount.d.ts +4 -3
  6. package/dist/esm/actions/requestAccount.js.map +1 -1
  7. package/dist/esm/actions/sendCalls.d.ts +5 -2
  8. package/dist/esm/actions/sendCalls.js +5 -2
  9. package/dist/esm/actions/sendCalls.js.map +1 -1
  10. package/dist/esm/actions/sendPreparedCalls.d.ts +3 -1
  11. package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
  12. package/dist/esm/actions/signPreparedCalls.d.ts +2 -0
  13. package/dist/esm/actions/signPreparedCalls.js +14 -1
  14. package/dist/esm/actions/signPreparedCalls.js.map +1 -1
  15. package/dist/esm/actions/signSignatureRequest.d.ts +4 -4
  16. package/dist/esm/actions/signSignatureRequest.js +1 -1
  17. package/dist/esm/actions/signSignatureRequest.js.map +1 -1
  18. package/dist/esm/actions/signTypedData.d.ts +14 -4
  19. package/dist/esm/actions/signTypedData.js.map +1 -1
  20. package/dist/esm/actions/solana/getCallsStatus.d.ts +24 -0
  21. package/dist/esm/actions/solana/getCallsStatus.js +44 -0
  22. package/dist/esm/actions/solana/getCallsStatus.js.map +1 -0
  23. package/dist/esm/actions/solana/prepareCalls.d.ts +46 -0
  24. package/dist/esm/actions/solana/prepareCalls.js +70 -0
  25. package/dist/esm/actions/solana/prepareCalls.js.map +1 -0
  26. package/dist/esm/actions/solana/sendCalls.d.ts +34 -0
  27. package/dist/esm/actions/solana/sendCalls.js +44 -0
  28. package/dist/esm/actions/solana/sendCalls.js.map +1 -0
  29. package/dist/esm/actions/solana/sendPreparedCalls.d.ts +24 -0
  30. package/dist/esm/actions/solana/sendPreparedCalls.js +32 -0
  31. package/dist/esm/actions/solana/sendPreparedCalls.js.map +1 -0
  32. package/dist/esm/actions/solana/signPreparedCalls.d.ts +23 -0
  33. package/dist/esm/actions/solana/signPreparedCalls.js +24 -0
  34. package/dist/esm/actions/solana/signPreparedCalls.js.map +1 -0
  35. package/dist/esm/actions/solana/signSignatureRequest.d.ts +10 -0
  36. package/dist/esm/actions/solana/signSignatureRequest.js +33 -0
  37. package/dist/esm/actions/solana/signSignatureRequest.js.map +1 -0
  38. package/dist/esm/actions/solana/waitForCallsStatus.d.ts +24 -0
  39. package/dist/esm/actions/solana/waitForCallsStatus.js +46 -0
  40. package/dist/esm/actions/solana/waitForCallsStatus.js.map +1 -0
  41. package/dist/esm/actions/undelegateAccount.d.ts +37 -0
  42. package/dist/esm/actions/undelegateAccount.js +49 -0
  43. package/dist/esm/actions/undelegateAccount.js.map +1 -0
  44. package/dist/esm/adapters/SolanaSignerError.d.ts +4 -0
  45. package/dist/esm/adapters/SolanaSignerError.js +13 -0
  46. package/dist/esm/adapters/SolanaSignerError.js.map +1 -0
  47. package/dist/esm/adapters/fromKeypair.d.ts +21 -0
  48. package/dist/esm/adapters/fromKeypair.js +46 -0
  49. package/dist/esm/adapters/fromKeypair.js.map +1 -0
  50. package/dist/esm/adapters/fromKitSigner.d.ts +21 -0
  51. package/dist/esm/adapters/fromKitSigner.js +61 -0
  52. package/dist/esm/adapters/fromKitSigner.js.map +1 -0
  53. package/dist/esm/adapters/fromWalletAdapter.d.ts +26 -0
  54. package/dist/esm/adapters/fromWalletAdapter.js +45 -0
  55. package/dist/esm/adapters/fromWalletAdapter.js.map +1 -0
  56. package/dist/esm/adapters/fromWalletStandard.d.ts +31 -0
  57. package/dist/esm/adapters/fromWalletStandard.js +53 -0
  58. package/dist/esm/adapters/fromWalletStandard.js.map +1 -0
  59. package/dist/esm/adapters/resolveSignerSlot.d.ts +10 -0
  60. package/dist/esm/adapters/resolveSignerSlot.js +39 -0
  61. package/dist/esm/adapters/resolveSignerSlot.js.map +1 -0
  62. package/dist/esm/client.d.ts +29 -14
  63. package/dist/esm/client.js +63 -19
  64. package/dist/esm/client.js.map +1 -1
  65. package/dist/esm/decorators/smartWalletActions.d.ts +2 -0
  66. package/dist/esm/decorators/smartWalletActions.js +4 -2
  67. package/dist/esm/decorators/smartWalletActions.js.map +1 -1
  68. package/dist/esm/decorators/solanaSmartWalletActions.d.ts +16 -0
  69. package/dist/esm/decorators/solanaSmartWalletActions.js +16 -0
  70. package/dist/esm/decorators/solanaSmartWalletActions.js.map +1 -0
  71. package/dist/esm/experimental/actions/requestQuoteV0.d.ts +48 -11
  72. package/dist/esm/experimental/actions/requestQuoteV0.js +8 -4
  73. package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
  74. package/dist/esm/experimental/swapActionsDecorator.d.ts +3 -0
  75. package/dist/esm/experimental/swapActionsDecorator.js.map +1 -1
  76. package/dist/esm/exports/index.d.ts +5 -3
  77. package/dist/esm/exports/index.js +1 -0
  78. package/dist/esm/exports/index.js.map +1 -1
  79. package/dist/esm/exports/solana.d.ts +24 -0
  80. package/dist/esm/exports/solana.js +15 -0
  81. package/dist/esm/exports/solana.js.map +1 -0
  82. package/dist/esm/types.d.ts +28 -4
  83. package/dist/esm/types.js.map +1 -1
  84. package/dist/esm/utils/assertions.d.ts +4 -2
  85. package/dist/esm/utils/assertions.js +6 -0
  86. package/dist/esm/utils/assertions.js.map +1 -1
  87. package/dist/esm/utils/capabilities.d.ts +22 -6
  88. package/dist/esm/utils/capabilities.js +19 -2
  89. package/dist/esm/utils/capabilities.js.map +1 -1
  90. package/dist/esm/utils/format.d.ts +2 -2
  91. package/dist/esm/utils/format.js +4 -3
  92. package/dist/esm/utils/format.js.map +1 -1
  93. package/dist/esm/utils/schema.d.ts +14 -14
  94. package/dist/esm/utils/schema.js +35 -39
  95. package/dist/esm/utils/schema.js.map +1 -1
  96. package/dist/esm/version.d.ts +1 -1
  97. package/dist/esm/version.js +1 -1
  98. package/dist/esm/version.js.map +1 -1
  99. package/dist/types/actions/prepareCalls.d.ts +8 -3
  100. package/dist/types/actions/prepareCalls.d.ts.map +1 -1
  101. package/dist/types/actions/requestAccount.d.ts +4 -3
  102. package/dist/types/actions/requestAccount.d.ts.map +1 -1
  103. package/dist/types/actions/sendCalls.d.ts +5 -2
  104. package/dist/types/actions/sendCalls.d.ts.map +1 -1
  105. package/dist/types/actions/sendPreparedCalls.d.ts +3 -1
  106. package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
  107. package/dist/types/actions/signPreparedCalls.d.ts +2 -0
  108. package/dist/types/actions/signPreparedCalls.d.ts.map +1 -1
  109. package/dist/types/actions/signSignatureRequest.d.ts +4 -4
  110. package/dist/types/actions/signSignatureRequest.d.ts.map +1 -1
  111. package/dist/types/actions/signTypedData.d.ts +14 -4
  112. package/dist/types/actions/signTypedData.d.ts.map +1 -1
  113. package/dist/types/actions/solana/getCallsStatus.d.ts +25 -0
  114. package/dist/types/actions/solana/getCallsStatus.d.ts.map +1 -0
  115. package/dist/types/actions/solana/prepareCalls.d.ts +47 -0
  116. package/dist/types/actions/solana/prepareCalls.d.ts.map +1 -0
  117. package/dist/types/actions/solana/sendCalls.d.ts +35 -0
  118. package/dist/types/actions/solana/sendCalls.d.ts.map +1 -0
  119. package/dist/types/actions/solana/sendPreparedCalls.d.ts +25 -0
  120. package/dist/types/actions/solana/sendPreparedCalls.d.ts.map +1 -0
  121. package/dist/types/actions/solana/signPreparedCalls.d.ts +24 -0
  122. package/dist/types/actions/solana/signPreparedCalls.d.ts.map +1 -0
  123. package/dist/types/actions/solana/signSignatureRequest.d.ts +11 -0
  124. package/dist/types/actions/solana/signSignatureRequest.d.ts.map +1 -0
  125. package/dist/types/actions/solana/waitForCallsStatus.d.ts +25 -0
  126. package/dist/types/actions/solana/waitForCallsStatus.d.ts.map +1 -0
  127. package/dist/types/actions/undelegateAccount.d.ts +38 -0
  128. package/dist/types/actions/undelegateAccount.d.ts.map +1 -0
  129. package/dist/types/adapters/SolanaSignerError.d.ts +5 -0
  130. package/dist/types/adapters/SolanaSignerError.d.ts.map +1 -0
  131. package/dist/types/adapters/fromKeypair.d.ts +22 -0
  132. package/dist/types/adapters/fromKeypair.d.ts.map +1 -0
  133. package/dist/types/adapters/fromKitSigner.d.ts +22 -0
  134. package/dist/types/adapters/fromKitSigner.d.ts.map +1 -0
  135. package/dist/types/adapters/fromWalletAdapter.d.ts +27 -0
  136. package/dist/types/adapters/fromWalletAdapter.d.ts.map +1 -0
  137. package/dist/types/adapters/fromWalletStandard.d.ts +32 -0
  138. package/dist/types/adapters/fromWalletStandard.d.ts.map +1 -0
  139. package/dist/types/adapters/resolveSignerSlot.d.ts +11 -0
  140. package/dist/types/adapters/resolveSignerSlot.d.ts.map +1 -0
  141. package/dist/types/client.d.ts +29 -14
  142. package/dist/types/client.d.ts.map +1 -1
  143. package/dist/types/decorators/smartWalletActions.d.ts +2 -0
  144. package/dist/types/decorators/smartWalletActions.d.ts.map +1 -1
  145. package/dist/types/decorators/solanaSmartWalletActions.d.ts +17 -0
  146. package/dist/types/decorators/solanaSmartWalletActions.d.ts.map +1 -0
  147. package/dist/types/experimental/actions/requestQuoteV0.d.ts +48 -11
  148. package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
  149. package/dist/types/experimental/swapActionsDecorator.d.ts +3 -0
  150. package/dist/types/experimental/swapActionsDecorator.d.ts.map +1 -1
  151. package/dist/types/exports/index.d.ts +5 -3
  152. package/dist/types/exports/index.d.ts.map +1 -1
  153. package/dist/types/exports/solana.d.ts +25 -0
  154. package/dist/types/exports/solana.d.ts.map +1 -0
  155. package/dist/types/types.d.ts +28 -4
  156. package/dist/types/types.d.ts.map +1 -1
  157. package/dist/types/utils/assertions.d.ts +4 -2
  158. package/dist/types/utils/assertions.d.ts.map +1 -1
  159. package/dist/types/utils/capabilities.d.ts +22 -6
  160. package/dist/types/utils/capabilities.d.ts.map +1 -1
  161. package/dist/types/utils/format.d.ts +2 -2
  162. package/dist/types/utils/format.d.ts.map +1 -1
  163. package/dist/types/utils/schema.d.ts +14 -14
  164. package/dist/types/utils/schema.d.ts.map +1 -1
  165. package/dist/types/version.d.ts +1 -1
  166. package/dist/types/version.d.ts.map +1 -1
  167. package/package.json +29 -11
  168. package/src/actions/prepareCalls.ts +21 -3
  169. package/src/actions/requestAccount.ts +7 -5
  170. package/src/actions/sendCalls.ts +5 -2
  171. package/src/actions/sendPreparedCalls.ts +4 -1
  172. package/src/actions/signPreparedCalls.ts +15 -2
  173. package/src/actions/signSignatureRequest.ts +8 -8
  174. package/src/actions/signTypedData.ts +15 -7
  175. package/src/actions/solana/getCallsStatus.ts +79 -0
  176. package/src/actions/solana/prepareCalls.ts +120 -0
  177. package/src/actions/solana/sendCalls.ts +66 -0
  178. package/src/actions/solana/sendPreparedCalls.ts +65 -0
  179. package/src/actions/solana/signPreparedCalls.ts +50 -0
  180. package/src/actions/solana/signSignatureRequest.ts +63 -0
  181. package/src/actions/solana/waitForCallsStatus.ts +84 -0
  182. package/src/actions/undelegateAccount.ts +68 -0
  183. package/src/adapters/SolanaSignerError.ts +5 -0
  184. package/src/adapters/fromKeypair.ts +58 -0
  185. package/src/adapters/fromKitSigner.ts +82 -0
  186. package/src/adapters/fromWalletAdapter.ts +58 -0
  187. package/src/adapters/fromWalletStandard.ts +100 -0
  188. package/src/adapters/resolveSignerSlot.ts +46 -0
  189. package/src/client.ts +131 -18
  190. package/src/decorators/smartWalletActions.ts +11 -2
  191. package/src/decorators/solanaSmartWalletActions.ts +62 -0
  192. package/src/experimental/actions/requestQuoteV0.ts +40 -15
  193. package/src/experimental/swapActionsDecorator.ts +3 -0
  194. package/src/exports/index.ts +10 -4
  195. package/src/exports/solana.ts +36 -0
  196. package/src/types.ts +38 -7
  197. package/src/utils/assertions.ts +17 -2
  198. package/src/utils/capabilities.ts +40 -8
  199. package/src/utils/format.ts +8 -3
  200. package/src/utils/schema.ts +58 -69
  201. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # @alchemy/wallet-apis
2
2
 
3
+ **Beta** — This package replaces `@account-kit/wallet-client`. See the [migration guide](https://www.alchemy.com/docs/wallets/resources/migration-v5).
4
+
3
5
  High-level viem-style client for Alchemy's Smart Wallet APIs. Provides EIP-7702 smart wallet support with signing, transaction preparation, and call sending.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  ```bash
8
- npm install @alchemy/wallet-apis @alchemy/common viem
10
+ npm install @alchemy/wallet-apis viem
9
11
  ```
10
12
 
11
13
  ## Key Exports
@@ -2,10 +2,15 @@ import type { Address, Prettify } from "viem";
2
2
  import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
3
3
  import { type PrepareCallsCapabilities, type WithCapabilities } from "../utils/capabilities.js";
4
4
  import { type AccountParam } from "../utils/resolve.js";
5
+ import { PrepareCallsParams as EvmPrepareCallsSchema } from "@alchemy/wallet-api-types";
6
+ import type { z } from "zod";
5
7
  import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
6
- import { type MethodParams, type MethodResponse } from "../utils/schema.js";
7
- type BasePrepareCallsParams = MethodParams<typeof MethodSchema>;
8
- type PrepareCallsResponse = MethodResponse<typeof MethodSchema>;
8
+ import { type MethodResponse } from "../utils/schema.js";
9
+ type BasePrepareCallsParams = z.output<typeof EvmPrepareCallsSchema>;
10
+ type FullPrepareCallsResponse = MethodResponse<typeof MethodSchema>;
11
+ type PrepareCallsResponse = Exclude<FullPrepareCallsResponse, {
12
+ type: "solana-transaction-v0";
13
+ }>;
9
14
  export type PrepareCallsParams = Prettify<WithCapabilities<DistributiveOmit<BasePrepareCallsParams, "from" | "chainId"> & {
10
15
  account?: AccountParam;
11
16
  chainId?: number;
@@ -1,9 +1,14 @@
1
+ import { BaseError } from "@alchemy/common";
1
2
  import { LOGGER } from "../logger.js";
2
3
  import { fromRpcCapabilities, mergeClientCapabilities, toRpcCapabilities, } from "../utils/capabilities.js";
3
4
  import { resolveAddress } from "../utils/resolve.js";
5
+ import { PrepareCallsParams as EvmPrepareCallsSchema } from "@alchemy/wallet-api-types";
4
6
  import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
5
7
  import { methodSchema, encode, decode, } from "../utils/schema.js";
6
8
  const schema = methodSchema(MethodSchema);
9
+ function isEvmResponse(response) {
10
+ return response.type !== "solana-transaction-v0";
11
+ }
7
12
  /**
8
13
  * Prepares a set of contract calls for execution by building a user operation.
9
14
  * Returns the built user operation and a signature request that needs to be signed
@@ -58,6 +63,9 @@ export async function prepareCalls(client, params) {
58
63
  });
59
64
  LOGGER.debug("prepareCalls:done");
60
65
  const decoded = decode(schema.response, rpcResp);
66
+ if (!isEvmResponse(decoded)) {
67
+ throw new BaseError(`Unexpected Solana response from EVM prepareCalls: ${decoded.type}`);
68
+ }
61
69
  // Transform paymaster-permit modifiedRequest from RPC format to client format:
62
70
  // - `from` (RPC) → `account` (client)
63
71
  // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)
@@ -1 +1 @@
1
- {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../src/actions/prepareCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AA8B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,MAAM,IAAI,GAAG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f,GAAG,mBAAmB;gBACtB,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,mBAAmB,CAAC,YAAY,CAAC;aAChD;SACF,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { Address, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n fromRpcCapabilities,\n mergeClientCapabilities,\n toRpcCapabilities,\n type PrepareCallsCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { wallet_prepareCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BasePrepareCallsParams = MethodParams<typeof MethodSchema>;\ntype PrepareCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type PrepareCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BasePrepareCallsParams, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\n/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */\ntype ClientModifiedRequest = Prettify<\n Omit<BasePrepareCallsParams, \"from\" | \"capabilities\"> & {\n account: Address;\n capabilities?: PrepareCallsCapabilities;\n }\n>;\n\nexport type PrepareCallsResult =\n | Exclude<PrepareCallsResponse, { type: \"paymaster-permit\" }>\n | (Omit<\n Extract<PrepareCallsResponse, { type: \"paymaster-permit\" }>,\n \"modifiedRequest\"\n > & {\n modifiedRequest: ClientModifiedRequest;\n });\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareCallsParams} params - Parameters for preparing calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {object} [params.capabilities] - Optional capabilities to include with the request\n * @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * ```ts\n * // Prepare a sponsored user operation call (uses signer address via EIP-7702 by default)\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n * ```\n */\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const chainId = params.chainId ?? client.chain.id;\n\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"prepareCalls:start\", {\n callsCount: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId,\n from,\n capabilities: toRpcCapabilities(capabilities),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_prepareCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"prepareCalls:done\");\n const decoded = decode(schema.response, rpcResp);\n\n // Transform paymaster-permit modifiedRequest from RPC format to client format:\n // - `from` (RPC) → `account` (client)\n // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)\n if (decoded.type === \"paymaster-permit\") {\n const { from, capabilities, ...restModifiedRequest } =\n decoded.modifiedRequest;\n return {\n ...decoded,\n modifiedRequest: {\n ...restModifiedRequest,\n account: from,\n capabilities: fromRpcCapabilities(capabilities),\n },\n };\n }\n\n return decoded;\n}\n"]}
1
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,YAAY;KACvC,CAAC,CAAC;IAEH,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,OAAO;QACP,IAAI;QACJ,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;KAC9C,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEjD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,SAAS,CACjB,qDAAqD,OAAO,CAAC,IAAI,EAAE,CACpE,CAAC;IACJ,CAAC;IAED,+EAA+E;IAC/E,sCAAsC;IACtC,8EAA8E;IAC9E,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACxC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,mBAAmB,EAAE,GAClD,OAAO,CAAC,eAAe,CAAC;QAC1B,OAAO;YACL,GAAG,OAAO;YACV,eAAe,EAAE;gBACf,GAAG,mBAAmB;gBACtB,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,mBAAmB,CAAC,YAAY,CAAC;aAChD;SACF,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { Address, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { BaseError } from \"@alchemy/common\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n fromRpcCapabilities,\n mergeClientCapabilities,\n toRpcCapabilities,\n type PrepareCallsCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { PrepareCallsParams as EvmPrepareCallsSchema } from \"@alchemy/wallet-api-types\";\nimport type { z } from \"zod\";\nimport { wallet_prepareCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BasePrepareCallsParams = z.output<typeof EvmPrepareCallsSchema>;\ntype FullPrepareCallsResponse = MethodResponse<typeof MethodSchema>;\ntype PrepareCallsResponse = Exclude<\n FullPrepareCallsResponse,\n { type: \"solana-transaction-v0\" }\n>;\n\nfunction isEvmResponse(\n response: FullPrepareCallsResponse,\n): response is PrepareCallsResponse {\n return response.type !== \"solana-transaction-v0\";\n}\n\nexport type PrepareCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BasePrepareCallsParams, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\n/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */\ntype ClientModifiedRequest = Prettify<\n Omit<BasePrepareCallsParams, \"from\" | \"capabilities\"> & {\n account: Address;\n capabilities?: PrepareCallsCapabilities;\n }\n>;\n\nexport type PrepareCallsResult =\n | Exclude<PrepareCallsResponse, { type: \"paymaster-permit\" }>\n | (Omit<\n Extract<PrepareCallsResponse, { type: \"paymaster-permit\" }>,\n \"modifiedRequest\"\n > & {\n modifiedRequest: ClientModifiedRequest;\n });\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareCallsParams} params - Parameters for preparing calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {object} [params.capabilities] - Optional capabilities to include with the request\n * @returns {Promise<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * ```ts\n * // Prepare a sponsored user operation call (uses signer address via EIP-7702 by default)\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n * ```\n */\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const chainId = params.chainId ?? client.chain.id;\n\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"prepareCalls:start\", {\n callsCount: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId,\n from,\n capabilities: toRpcCapabilities(capabilities),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_prepareCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"prepareCalls:done\");\n const decoded = decode(schema.response, rpcResp);\n\n if (!isEvmResponse(decoded)) {\n throw new BaseError(\n `Unexpected Solana response from EVM prepareCalls: ${decoded.type}`,\n );\n }\n\n // Transform paymaster-permit modifiedRequest from RPC format to client format:\n // - `from` (RPC) → `account` (client)\n // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)\n if (decoded.type === \"paymaster-permit\") {\n const { from, capabilities, ...restModifiedRequest } =\n decoded.modifiedRequest;\n return {\n ...decoded,\n modifiedRequest: {\n ...restModifiedRequest,\n account: from,\n capabilities: fromRpcCapabilities(capabilities),\n },\n };\n }\n\n return decoded;\n}\n"]}
@@ -1,12 +1,13 @@
1
1
  import type { Address } from "abitype";
2
2
  import { type JsonRpcAccount, type Prettify } from "viem";
3
3
  import { wallet_requestAccount as MethodSchema } from "@alchemy/wallet-api-types/rpc";
4
- import type { DistributiveOmit, InnerWalletApiClient } from "../types";
4
+ import type { InnerWalletApiClient } from "../types";
5
5
  import { type MethodParams } from "../utils/schema.js";
6
6
  type BaseRequestAccountParams = MethodParams<typeof MethodSchema>;
7
- export type RequestAccountParams = Prettify<DistributiveOmit<Extract<BaseRequestAccountParams, {
7
+ type SignerAddressParams = Extract<BaseRequestAccountParams, {
8
8
  signerAddress: Address;
9
- }>, "signerAddress" | "includeCounterfactualInfo"> & ({
9
+ }>;
10
+ export type RequestAccountParams = Prettify<Pick<SignerAddressParams, "id" | "creationHint"> & ({
10
11
  signerAddress?: Address;
11
12
  accountAddress?: never;
12
13
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAsC,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAEP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA6B;IAE7B,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;QACnC,SAAS,EAAE,CAAC,CAA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AAC,OAAO,CAAC;QACnC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE9C,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { Address } from \"abitype\";\nimport { isAddressEqual, type JsonRpcAccount, type Prettify } from \"viem\";\nimport { wallet_requestAccount as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport deepEqual from \"deep-equal\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types\";\nimport { LOGGER } from \"../logger.js\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestAccountParams = MethodParams<typeof MethodSchema>;\n\nexport type RequestAccountParams = Prettify<\n DistributiveOmit<\n Extract<BaseRequestAccountParams, { signerAddress: Address }>,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n > &\n (\n | { signerAddress?: Address; accountAddress?: never }\n | { signerAddress?: never; accountAddress: Address }\n )\n>;\n\nexport type RequestAccountResult = JsonRpcAccount<Address>;\n\n/**\n * Requests a smart account address for the provided signer using the wallet API client.\n *\n * Note: This is only needed for non-EIP-7702 accounts. The client defaults to using\n * EIP-7702 with the signer's address, so you can call `prepareCalls` or `sendCalls`\n * directly without first calling `requestAccount`.\n *\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to an object containing a smart account address\n *\n * @example\n * ```ts\n * // Request a non-7702 smart account\n * const account = await client.requestAccount();\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n LOGGER.debug(\"requestAccount:start\", {\n hasParams: !!params,\n hasAccountOnClient: !!client.account,\n });\n\n const signerAddress =\n (params && \"signerAddress\" in params ? params.signerAddress : undefined) ??\n (isLocalAccount(client.owner)\n ? client.owner.address\n : client.owner.account.address);\n\n const args =\n params && \"accountAddress\" in params && params.accountAddress\n ? {\n accountAddress: params.accountAddress,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress,\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal?.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n isAddressEqual(cachedAccount.address, args.accountAddress)) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n LOGGER.debug(\"requestAccount:cache-hit\", {\n address: cachedAccount.address,\n });\n return {\n address: cachedAccount.address,\n type: \"json-rpc\",\n };\n }\n\n const rpcParams = encode(schema.request, args);\n\n const rpcResp = await client.request({\n method: \"wallet_requestAccount\",\n params: [rpcParams],\n });\n\n const resp = decode(schema.response, rpcResp);\n\n client.internal?.setAccount({\n address: resp.accountAddress,\n requestParams: args,\n });\n\n LOGGER.debug(\"requestAccount:done\", { address: resp.accountAddress });\n\n return {\n address: resp.accountAddress,\n type: \"json-rpc\",\n };\n}\n"]}
1
+ {"version":3,"file":"requestAccount.js","s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AM,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEpD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,cAAc,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YAC3D,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE;YACvC,OAAO,EAAE,aAAa,CAAC,OAAO;SAC/B,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,IAAI,EAAE,UAAU;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE9C,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { Address } from \"abitype\";\nimport { isAddressEqual, type JsonRpcAccount, type Prettify } from \"viem\";\nimport { wallet_requestAccount as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport deepEqual from \"deep-equal\";\nimport type { InnerWalletApiClient } from \"../types\";\nimport { LOGGER } from \"../logger.js\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestAccountParams = MethodParams<typeof MethodSchema>;\n\ntype SignerAddressParams = Extract<\n BaseRequestAccountParams,\n { signerAddress: Address }\n>;\n\nexport type RequestAccountParams = Prettify<\n Pick<SignerAddressParams, \"id\" | \"creationHint\"> &\n (\n | { signerAddress?: Address; accountAddress?: never }\n | { signerAddress?: never; accountAddress: Address }\n )\n>;\n\nexport type RequestAccountResult = JsonRpcAccount<Address>;\n\n/**\n * Requests a smart account address for the provided signer using the wallet API client.\n *\n * Note: This is only needed for non-EIP-7702 accounts. The client defaults to using\n * EIP-7702 with the signer's address, so you can call `prepareCalls` or `sendCalls`\n * directly without first calling `requestAccount`.\n *\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to an object containing a smart account address\n *\n * @example\n * ```ts\n * // Request a non-7702 smart account\n * const account = await client.requestAccount();\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n LOGGER.debug(\"requestAccount:start\", {\n hasParams: !!params,\n hasAccountOnClient: !!client.account,\n });\n\n const signerAddress =\n (params && \"signerAddress\" in params ? params.signerAddress : undefined) ??\n (isLocalAccount(client.owner)\n ? client.owner.address\n : client.owner.account.address);\n\n const args =\n params && \"accountAddress\" in params && params.accountAddress\n ? {\n accountAddress: params.accountAddress,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress,\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal?.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n isAddressEqual(cachedAccount.address, args.accountAddress)) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n LOGGER.debug(\"requestAccount:cache-hit\", {\n address: cachedAccount.address,\n });\n return {\n address: cachedAccount.address,\n type: \"json-rpc\",\n };\n }\n\n const rpcParams = encode(schema.request, args);\n\n const rpcResp = await client.request({\n method: \"wallet_requestAccount\",\n params: [rpcParams],\n });\n\n const resp = decode(schema.response, rpcResp);\n\n client.internal?.setAccount({\n address: resp.accountAddress,\n requestParams: args,\n });\n\n LOGGER.debug(\"requestAccount:done\", { address: resp.accountAddress });\n\n return {\n address: resp.accountAddress,\n type: \"json-rpc\",\n };\n}\n"]}
@@ -33,8 +33,11 @@ export type SendCallsResult = Prettify<SendPreparedCallsResult>;
33
33
  * }
34
34
  * });
35
35
  *
36
- * // The result contains the call ID
37
- * console.log(result.id);
36
+ * // Wait for the calls to be mined and confirmed.
37
+ * // Polls getCallsStatus until the bundle succeeds, fails, or times out (default 60s).
38
+ * // See: https://viem.sh/docs/actions/wallet/waitForCallsStatus
39
+ * const status = await client.waitForCallsStatus({ id: result.id });
40
+ * console.log(status.status); // "success" | "failure"
38
41
  * ```
39
42
  * <Note>
40
43
  * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden
@@ -31,8 +31,11 @@ import { extractCapabilitiesForSending } from "../utils/capabilities.js";
31
31
  * }
32
32
  * });
33
33
  *
34
- * // The result contains the call ID
35
- * console.log(result.id);
34
+ * // Wait for the calls to be mined and confirmed.
35
+ * // Polls getCallsStatus until the bundle succeeds, fails, or times out (default 60s).
36
+ * // See: https://viem.sh/docs/actions/wallet/waitForCallsStatus
37
+ * const status = await client.waitForCallsStatus({ id: result.id });
38
+ * console.log(status.status); // "success" | "failure"
36
39
  * ```
37
40
  * <Note>
38
41
  * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden
@@ -1 +1 @@
1
- {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../src/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAUzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA4B,EAC5B,MAAuB;IAEvB,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM;QAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY;KACvC,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAChD,IAAI,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE;QACrC,GAAG,kBAAkB;QACrB,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,KAAK,CAAC,gBAAgB,CACvB,CAAC;QAEF,MAAM,gBAAgB,GAAG;YACvB,GAAG,KAAK,CAAC,eAAe;YACxB,8EAA8E;YAC9E,wBAAwB,EAAE,SAGzB;SACF,CAAC;QAEF,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,MAAM,6BAA6B,GAAG,6BAA6B,CACjE,MAAM,CAAC,YAAY,CACpB,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC1C,GAAG,WAAW;QACd,GAAG,CAAC,6BAA6B,IAAI,IAAI;YACvC,CAAC,CAAC,EAAE,YAAY,EAAE,6BAA6B,EAAE;YACjD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { Chain, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { extractCapabilitiesForSending } from \"../utils/capabilities.js\";\n\nexport type SendCallsParams = Prettify<\n DistributiveOmit<PrepareCallsParams, \"chainId\"> & {\n chain?: Pick<Chain, \"id\">;\n }\n>;\n\nexport type SendCallsResult = Prettify<SendPreparedCallsResult>;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendCallsParams} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {object} [params.capabilities] - Optional capabilities to include with the request.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * // Send calls (uses signer address via EIP-7702 by default)\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // The result contains the call ID\n * console.log(result.id);\n * ```\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n */\nexport async function sendCalls(\n client: InnerWalletApiClient,\n params: SendCallsParams,\n): Promise<SendCallsResult> {\n LOGGER.info(\"sendCalls:start\", {\n calls: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n const { chain, ...prepareCallsParams } = params;\n let calls = await prepareCalls(client, {\n ...prepareCallsParams,\n ...(chain != null ? { chainId: chain.id } : {}),\n });\n\n if (calls.type === \"paymaster-permit\") {\n const signature = await signSignatureRequest(\n client,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n ...calls.modifiedRequest,\n // WebAuthn signatures are not supported for paymaster permits (throws above).\n paymasterPermitSignature: signature as Exclude<\n typeof signature,\n { type: \"webauthn-p256\" }\n >,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(client, calls);\n\n const sendPreparedCallsCapabilities = extractCapabilitiesForSending(\n params.capabilities,\n );\n\n const res = await sendPreparedCalls(client, {\n ...signedCalls,\n ...(sendPreparedCallsCapabilities != null\n ? { capabilities: sendPreparedCallsCapabilities }\n : {}),\n });\n LOGGER.info(\"sendCalls:done\");\n return res;\n}\n"]}
1
+ {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../src/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAUzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA4B,EAC5B,MAAuB;IAEvB,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM;QAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY;KACvC,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAChD,IAAI,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE;QACrC,GAAG,kBAAkB;QACrB,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,KAAK,CAAC,gBAAgB,CACvB,CAAC;QAEF,MAAM,gBAAgB,GAAG;YACvB,GAAG,KAAK,CAAC,eAAe;YACxB,8EAA8E;YAC9E,wBAAwB,EAAE,SAGzB;SACF,CAAC;QAEF,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,MAAM,6BAA6B,GAAG,6BAA6B,CACjE,MAAM,CAAC,YAAY,CACpB,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC1C,GAAG,WAAW;QACd,GAAG,CAAC,6BAA6B,IAAI,IAAI;YACvC,CAAC,CAAC,EAAE,YAAY,EAAE,6BAA6B,EAAE;YACjD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { Chain, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { extractCapabilitiesForSending } from \"../utils/capabilities.js\";\n\nexport type SendCallsParams = Prettify<\n DistributiveOmit<PrepareCallsParams, \"chainId\"> & {\n chain?: Pick<Chain, \"id\">;\n }\n>;\n\nexport type SendCallsResult = Prettify<SendPreparedCallsResult>;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendCallsParams} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {object} [params.capabilities] - Optional capabilities to include with the request.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * // Send calls (uses signer address via EIP-7702 by default)\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Wait for the calls to be mined and confirmed.\n * // Polls getCallsStatus until the bundle succeeds, fails, or times out (default 60s).\n * // See: https://viem.sh/docs/actions/wallet/waitForCallsStatus\n * const status = await client.waitForCallsStatus({ id: result.id });\n * console.log(status.status); // \"success\" | \"failure\"\n * ```\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n */\nexport async function sendCalls(\n client: InnerWalletApiClient,\n params: SendCallsParams,\n): Promise<SendCallsResult> {\n LOGGER.info(\"sendCalls:start\", {\n calls: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n const { chain, ...prepareCallsParams } = params;\n let calls = await prepareCalls(client, {\n ...prepareCallsParams,\n ...(chain != null ? { chainId: chain.id } : {}),\n });\n\n if (calls.type === \"paymaster-permit\") {\n const signature = await signSignatureRequest(\n client,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n ...calls.modifiedRequest,\n // WebAuthn signatures are not supported for paymaster permits (throws above).\n paymasterPermitSignature: signature as Exclude<\n typeof signature,\n { type: \"webauthn-p256\" }\n >,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(client, calls);\n\n const sendPreparedCallsCapabilities = extractCapabilitiesForSending(\n params.capabilities,\n );\n\n const res = await sendPreparedCalls(client, {\n ...signedCalls,\n ...(sendPreparedCallsCapabilities != null\n ? { capabilities: sendPreparedCallsCapabilities }\n : {}),\n });\n LOGGER.info(\"sendCalls:done\");\n return res;\n}\n"]}
@@ -3,7 +3,9 @@ import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
3
3
  import { type WithCapabilities } from "../utils/capabilities.js";
4
4
  import { wallet_sendPreparedCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
5
5
  import { type MethodParams, type MethodResponse } from "../utils/schema.js";
6
- type BaseSendPreparedCallsParams = MethodParams<typeof MethodSchema>;
6
+ type BaseSendPreparedCallsParams = Exclude<MethodParams<typeof MethodSchema>, {
7
+ type: "solana-transaction-v0";
8
+ }>;
7
9
  type SendPreparedCallsResponse = MethodResponse<typeof MethodSchema>;
8
10
  export type SendPreparedCallsParams = Prettify<WithCapabilities<DistributiveOmit<BaseSendPreparedCallsParams, "chainId"> & {
9
11
  chainId?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE/D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAE9C,MAAM,UAAU,GACd,UAAU,CAAC,IAAI,KAAK,OAAO;QACzB,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE;QAClE,CAAC,CAAC;YACE,GAAG,UAAU;YACb,OAAO;YACP,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;SAC9C,CAAC;IAER,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { wallet_sendPreparedCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseSendPreparedCallsParams = MethodParams<typeof MethodSchema>;\ntype SendPreparedCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type SendPreparedCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseSendPreparedCallsParams, \"chainId\"> & {\n chainId?: number;\n }\n >\n>;\n\nexport type SendPreparedCallsResult = SendPreparedCallsResponse;\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID\n *\n * @example\n * ```ts\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n * ```\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"sendPreparedCalls:start\", { type: params.type });\n\n const { chainId: rawChainId, ...restParams } = params;\n const chainId = rawChainId ?? client.chain.id;\n\n const fullParams =\n restParams.type === \"array\"\n ? { ...restParams, capabilities: toRpcCapabilities(capabilities) }\n : {\n ...restParams,\n chainId,\n capabilities: toRpcCapabilities(capabilities),\n };\n\n const rpcParams = encode(schema.request, fullParams);\n\n const rpcResp = await client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"sendPreparedCalls:done\");\n return decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,M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vC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { wallet_sendPreparedCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseSendPreparedCallsParams = Exclude<\n MethodParams<typeof MethodSchema>,\n { type: \"solana-transaction-v0\" }\n>;\ntype SendPreparedCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type SendPreparedCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseSendPreparedCallsParams, \"chainId\"> & {\n chainId?: number;\n }\n >\n>;\n\nexport type SendPreparedCallsResult = SendPreparedCallsResponse;\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID\n *\n * @example\n * ```ts\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n * ```\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"sendPreparedCalls:start\", { type: params.type });\n\n const { chainId: rawChainId, ...restParams } = params;\n const chainId = rawChainId ?? client.chain.id;\n\n const fullParams =\n restParams.type === \"array\"\n ? { ...restParams, capabilities: toRpcCapabilities(capabilities) }\n : {\n ...restParams,\n chainId,\n capabilities: toRpcCapabilities(capabilities),\n };\n\n const rpcParams = encode(schema.request, fullParams);\n\n const rpcResp = await client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"sendPreparedCalls:done\");\n return decode(schema.response, rpcResp);\n}\n"]}
@@ -18,6 +18,8 @@ export type SignPreparedCallsResult = {
18
18
  type: "user-operation-v060";
19
19
  }>> | Signed<Extract<PrepareCallsResult, {
20
20
  type: "user-operation-v070";
21
+ }>> | Signed<Extract<PrepareCallsResult, {
22
+ type: "authorization";
21
23
  }>>;
22
24
  /**
23
25
  * Signs prepared calls using the provided signer.
@@ -43,7 +43,7 @@ export async function signPreparedCalls(client, params) {
43
43
  };
44
44
  };
45
45
  const signUserOperationCall = async (call) => {
46
- const { signatureRequest, ...rest } = call;
46
+ const { signatureRequest, feePayment: _feePayment, ...rest } = call;
47
47
  if (!signatureRequest) {
48
48
  LOGGER.warn("signPreparedCalls:missing-signatureRequest", {
49
49
  type: call.type,
@@ -74,6 +74,19 @@ export async function signPreparedCalls(client, params) {
74
74
  LOGGER.debug("signPreparedCalls:single-userOp:ok");
75
75
  return res;
76
76
  }
77
+ else if (params.type === "authorization") {
78
+ const { signatureRequest: _signatureRequest, ...rest } = params;
79
+ const signature = await signSignatureRequest(client, {
80
+ type: "eip7702Auth",
81
+ data: {
82
+ ...rest.data,
83
+ chainId: params.chainId,
84
+ },
85
+ });
86
+ const res = { ...rest, signature };
87
+ LOGGER.debug("signPreparedCalls:single-authorization:ok");
88
+ return res;
89
+ }
77
90
  else if (params.type === "paymaster-permit") {
78
91
  LOGGER.warn("signPreparedCalls:invalid-call-type", { type: params.type });
79
92
  throw new BaseError(`Invalid call type ${params.type} for signing prepared calls`);
@@ -1 +1 @@
1
- {"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../src/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EACL,oBAAoB,GAErB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA+BtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE/D,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAuB,EAAE,EAAE;QAC9D,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAE9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAC;QACH,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAgB,EAAE,EAAE;QACvD,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAE3C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,4CAA4C,EAAE;gBACxD,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC;YACH,MAAM,IAAI,SAAS,CACjB,wIA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C9D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE;YACpD,IAAI,EAAG,MAA6B,CAAC,IAAI;SAC1C,CAAC,CAAC;QACH,OAAO,WAAW,CAChB,MAAM,EACN,2BAA2B,MAAM,6BAA6B,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { assertNever, BaseError } from \"@alchemy/common\";\nimport type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport {\n signSignatureRequest,\n type SignSignatureRequestResult,\n} from \"./signSignatureRequest.js\";\nimport type { Prettify } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.js\";\nimport { LOGGER } from \"../logger.js\";\n\nexport type SignPreparedCallsParams = Prettify<PrepareCallsResult>;\n\n/** Replace signatureRequest/feePayment with the actual signature produced by signPreparedCalls. */\ntype Signed<T> = T extends { signatureRequest?: unknown }\n ? Prettify<\n Omit<T, \"signatureRequest\" | \"feePayment\"> & {\n signature: SignSignatureRequestResult;\n }\n >\n : never;\n\nexport type SignPreparedCallsResult =\n | {\n type: \"array\";\n data: Signed<\n Extract<PrepareCallsResult, { type: \"array\" }>[\"data\"][number]\n >[];\n }\n | Signed<Extract<PrepareCallsResult, { type: \"user-operation-v060\" }>>\n | Signed<Extract<PrepareCallsResult, { type: \"user-operation-v070\" }>>;\n\n// Decoded types derived from PrepareCallsResult (numbers/bigints, not hex strings)\ntype ArrayCallData = Extract<\n PrepareCallsResult,\n { type: \"array\" }\n>[\"data\"][number];\ntype AuthorizationCall = Extract<ArrayCallData, { type: \"authorization\" }>;\ntype UserOpCall = Exclude<ArrayCallData, { type: \"authorization\" }>;\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {InnerWalletApiClient} client - The wallet client to use for signing\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n *\n * @example\n * ```ts\n * // Prepare a user operation call.\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * });\n *\n * // Sign the prepared calls.\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Send the signed calls.\n * const result = await client.sendPreparedCalls(signedCalls);\n * ```\n */\nexport async function signPreparedCalls(\n client: InnerWalletApiClient,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n LOGGER.debug(\"signPreparedCalls:start\", { type: params.type });\n\n const signAuthorizationCall = async (call: AuthorizationCall) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n\n const signature = await signSignatureRequest(client, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (call: UserOpCall) => {\n const { signatureRequest, ...rest } = call;\n\n if (!signatureRequest) {\n LOGGER.warn(\"signPreparedCalls:missing-signatureRequest\", {\n type: call.type,\n });\n throw new BaseError(\n \"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.\",\n );\n }\n\n const signature = await signSignatureRequest(client, signatureRequest);\n const res = {\n ...rest,\n signature,\n } as const;\n LOGGER.debug(\"signPreparedCalls:userOp:ok\");\n return res;\n };\n\n if (params.type === \"array\") {\n const res = {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n };\n LOGGER.debug(\"signPreparedCalls:array:ok\", { count: res.data.length });\n return res;\n } else if (\n params.type === \"user-operation-v060\" ||\n params.type === \"user-operation-v070\"\n ) {\n const res = await signUserOperationCall(params);\n LOGGER.debug(\"signPreparedCalls:single-userOp:ok\");\n return res;\n } else if (params.type === \"paymaster-permit\") {\n LOGGER.warn(\"signPreparedCalls:invalid-call-type\", { type: params.type });\n throw new BaseError(\n `Invalid call type ${params.type} for signing prepared calls`,\n );\n } else {\n LOGGER.warn(\"signPreparedCalls:unexpected-call-type\", {\n type: (params as { type?: unknown }).type,\n });\n return assertNever(\n params,\n `Unexpected call type in ${params} for signing prepared calls`,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../src/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EACL,oBAAoB,GAErB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAgCtC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE/D,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAuB,EAAE,EAAE;QAC9D,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAE9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAC;QACH,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAgB,EAAE,EAAE;QACvD,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAEpE,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,CAAC,IAAI,CAAC,4CAA4C,EAAE;gBACxD,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MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB;SACF,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAC1D,OAAO,GAAG,CAAC;IACb,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC9C,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1E,MAAM,IAAI,SAAS,CACjB,qBAAqB,MAAM,CAAC,IAAI,6BAA6B,CAC9D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE;YACpD,IAAI,EAAG,MAA6B,CAAC,IAAI;SAC1C,CAAC,CAAC;QACH,OAAO,WAAW,CAChB,MAAM,EACN,2BAA2B,MAAM,6BAA6B,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { assertNever, BaseError } from \"@alchemy/common\";\nimport type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport {\n signSignatureRequest,\n type SignSignatureRequestResult,\n} from \"./signSignatureRequest.js\";\nimport type { Prettify } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.js\";\nimport { LOGGER } from \"../logger.js\";\n\nexport type SignPreparedCallsParams = Prettify<PrepareCallsResult>;\n\n/** Replace signatureRequest/feePayment with the actual signature produced by signPreparedCalls. */\ntype Signed<T> = T extends { signatureRequest?: unknown }\n ? Prettify<\n Omit<T, \"signatureRequest\" | \"feePayment\"> & {\n signature: SignSignatureRequestResult;\n }\n >\n : never;\n\nexport type SignPreparedCallsResult =\n | {\n type: \"array\";\n data: Signed<\n Extract<PrepareCallsResult, { type: \"array\" }>[\"data\"][number]\n >[];\n }\n | Signed<Extract<PrepareCallsResult, { type: \"user-operation-v060\" }>>\n | Signed<Extract<PrepareCallsResult, { type: \"user-operation-v070\" }>>\n | Signed<Extract<PrepareCallsResult, { type: \"authorization\" }>>;\n\n// Decoded types derived from PrepareCallsResult (numbers/bigints, not hex strings)\ntype ArrayCallData = Extract<\n PrepareCallsResult,\n { type: \"array\" }\n>[\"data\"][number];\ntype AuthorizationCall = Extract<ArrayCallData, { type: \"authorization\" }>;\ntype UserOpCall = Exclude<ArrayCallData, { type: \"authorization\" }>;\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {InnerWalletApiClient} client - The wallet client to use for signing\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n *\n * @example\n * ```ts\n * // Prepare a user operation call.\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * });\n *\n * // Sign the prepared calls.\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Send the signed calls.\n * const result = await client.sendPreparedCalls(signedCalls);\n * ```\n */\nexport async function signPreparedCalls(\n client: InnerWalletApiClient,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n LOGGER.debug(\"signPreparedCalls:start\", { type: params.type });\n\n const signAuthorizationCall = async (call: AuthorizationCall) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n\n const signature = await signSignatureRequest(client, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (call: UserOpCall) => {\n const { signatureRequest, feePayment: _feePayment, ...rest } = call;\n\n if (!signatureRequest) {\n LOGGER.warn(\"signPreparedCalls:missing-signatureRequest\", {\n type: call.type,\n });\n throw new BaseError(\n \"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.\",\n );\n }\n\n const signature = await signSignatureRequest(client, signatureRequest);\n const res = {\n ...rest,\n signature,\n } as const;\n LOGGER.debug(\"signPreparedCalls:userOp:ok\");\n return res;\n };\n\n if (params.type === \"array\") {\n const res = {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n };\n LOGGER.debug(\"signPreparedCalls:array:ok\", { count: res.data.length });\n return res;\n } else if (\n params.type === \"user-operation-v060\" ||\n params.type === \"user-operation-v070\"\n ) {\n const res = await signUserOperationCall(params);\n LOGGER.debug(\"signPreparedCalls:single-userOp:ok\");\n return res;\n } else if (params.type === \"authorization\") {\n const { signatureRequest: _signatureRequest, ...rest } = params;\n const signature = await signSignatureRequest(client, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: params.chainId,\n },\n });\n const res = { ...rest, signature };\n LOGGER.debug(\"signPreparedCalls:single-authorization:ok\");\n return res;\n } else if (params.type === \"paymaster-permit\") {\n LOGGER.warn(\"signPreparedCalls:invalid-call-type\", { type: params.type });\n throw new BaseError(\n `Invalid call type ${params.type} for signing prepared calls`,\n );\n } else {\n LOGGER.warn(\"signPreparedCalls:unexpected-call-type\", {\n type: (params as { type?: unknown }).type,\n });\n return assertNever(\n params,\n `Unexpected call type in ${params} for signing prepared calls`,\n );\n }\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { type Hex, type Prettify } from "viem";
2
- import { type PersonalSignSignatureRequest, type TypedDataSignatureRequest, type AuthorizationSignatureRequest, Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
2
+ import { PersonalSignSignatureRequest, TypedDataSignatureRequest, AuthorizationSignatureRequest, Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
3
3
  import type { InnerWalletApiClient, WithoutRawPayload } from "../types";
4
- import type { StaticDecode } from "typebox";
5
- export type SignSignatureRequestParams = Prettify<WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
6
- data: StaticDecode<typeof Eip7702UnsignedAuth>;
4
+ import type { z } from "zod";
5
+ export type SignSignatureRequestParams = Prettify<WithoutRawPayload<z.output<typeof PersonalSignSignatureRequest> | z.output<typeof TypedDataSignatureRequest> | (z.output<typeof AuthorizationSignatureRequest> & {
6
+ data: z.output<typeof Eip7702UnsignedAuth>;
7
7
  })>>;
8
8
  export type SignSignatureRequestResult = {
9
9
  type: "secp256k1";
@@ -1,5 +1,5 @@
1
1
  import { serializeSignature } from "viem";
2
- import { Eip7702UnsignedAuth, } from "@alchemy/wallet-api-types";
2
+ import { PersonalSignSignatureRequest, TypedDataSignatureRequest, AuthorizationSignatureRequest, Eip7702UnsignedAuth, } from "@alchemy/wallet-api-types";
3
3
  import { vToYParity } from "ox/Signature";
4
4
  import { assertNever, BaseError } from "@alchemy/common";
5
5
  import { LOGGER } from "../logger.js";
@@ -1 +1 @@
1
- {"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../src/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACnE,OAAO,EAIL,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmB7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH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AAG,MAAM,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YACvE,MAAM,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;YAC1E,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QACrC,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,EACJ,CAAC,EACD,CAAC,EACD,CAAC,EACD,OAAO,EAAE,QAAQ,GAClB,GAAG,MAAM,MAAM,CAAC;gBACf,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;YACH,MAAM,OAAO,GACX,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACjE,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD;YACE,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE;gBAC/C,IAAI,EAAG,MAA6B,CAAC,IAAI;aAC1C,CAAC,CAAC;YACH,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { type Hex, type Prettify, serializeSignature } from \"viem\";\nimport {\n type PersonalSignSignatureRequest,\n type TypedDataSignatureRequest,\n type AuthorizationSignatureRequest,\n Eip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type {\n InnerWalletApiClient,\n SignerClient,\n WithoutRawPayload,\n} from \"../types\";\nimport { assertNever, BaseError } from \"@alchemy/common\";\nimport { LOGGER } from \"../logger.js\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport { getAction } from \"viem/utils\";\nimport { signAuthorization, signMessage, signTypedData } from \"viem/actions\";\nimport type { LocalAccount } from \"viem\";\nimport type { StaticDecode } from \"typebox\";\n\nexport type SignSignatureRequestParams = Prettify<\n WithoutRawPayload<\n | PersonalSignSignatureRequest\n | TypedDataSignatureRequest\n | (AuthorizationSignatureRequest & {\n data: StaticDecode<typeof Eip7702UnsignedAuth>;\n })\n >\n>;\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: Hex;\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.\n *\n * @param {InnerWalletApiClient} client - The wallet client to use for signing\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {SignSignatureRequestParams[\"data\"]} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n *\n * @example\n * ```ts\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n * ```\n */\n\nexport async function signSignatureRequest(\n client: InnerWalletApiClient,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n LOGGER.debug(\"signSignatureRequest:start\", { type: params.type });\n\n if (isLocalAccount(client.owner)) {\n return signWithLocalAccount(client.owner, params);\n }\n\n return signWithSignerClient(client.owner, params);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LocalAccount signer\n// ─────────────────────────────────────────────────────────────────────────────\n\ntype Secp256k1Result = Extract<\n SignSignatureRequestResult,\n { type: \"secp256k1\" }\n>;\n\nasync function signWithLocalAccount(\n signer: LocalAccount,\n params: SignSignatureRequestParams,\n): Promise<Secp256k1Result> {\n switch (params.type) {\n case \"personal_sign\": {\n const data = await signer.signMessage({ message: params.data });\n LOGGER.debug(\"signSignatureRequest:localAccount:personal_sign:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eth_signTypedData_v4\": {\n const data = await signer.signTypedData(params.data);\n LOGGER.debug(\"signSignatureRequest:localAccount:eth_signTypedData_v4:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new BaseError(\n \"Current signer does not support signing authorization requests\",\n );\n }\n const {\n r,\n s,\n v,\n yParity: _yParity,\n } = await signer.signAuthorization(params.data);\n const yParity =\n _yParity != null ? Number(_yParity) : vToYParity(Number(v));\n LOGGER.debug(\"signSignatureRequest:localAccount:eip7702Auth:ok\");\n return {\n type: \"secp256k1\",\n data: serializeSignature({ r, s, yParity }),\n };\n }\n default:\n LOGGER.warn(\"signSignatureRequest:unknown-type\", {\n type: (params as { type?: unknown }).type,\n });\n return assertNever(params, \"Unexpected signature request type.\");\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// SignerClient (WalletClient)\n// ─────────────────────────────────────────────────────────────────────────────\n\nasync function signWithSignerClient(\n signer: SignerClient,\n params: SignSignatureRequestParams,\n): Promise<Secp256k1Result> {\n switch (params.type) {\n case \"personal_sign\": {\n const action = getAction(signer, signMessage, \"signMessage\");\n const data = await action({\n message: params.data,\n account: signer.account,\n });\n LOGGER.debug(\"signSignatureRequest:signerClient:personal_sign:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eth_signTypedData_v4\": {\n const action = getAction(signer, signTypedData, \"signTypedData\");\n const data = await action({ ...params.data, account: signer.account });\n LOGGER.debug(\"signSignatureRequest:signerClient:eth_signTypedData_v4:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eip7702Auth\": {\n const action = getAction(signer, signAuthorization, \"signAuthorization\");\n const {\n r,\n s,\n v,\n yParity: _yParity,\n } = await action({\n ...params.data,\n account: signer.account,\n });\n const yParity =\n _yParity != null ? Number(_yParity) : vToYParity(Number(v));\n LOGGER.debug(\"signSignatureRequest:signerClient:eip7702Auth:ok\");\n return {\n type: \"secp256k1\",\n data: serializeSignature({ r, s, yParity }),\n };\n }\n default:\n LOGGER.warn(\"signSignatureRequest:unknown-type\", {\n type: (params as { type?: unknown }).type,\n });\n return assertNever(params, \"Unexpected signature request type.\");\n }\n}\n"]}
1
+ {"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../src/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmB7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA4B,EAC5B,MAAkC;IAElC,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAElE,IAAI,cAAc,CAAC,MA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E,WAAW,EAAE,IAAI,EAAE,CAAC;QACrC,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;YACzE,MAAM,EACJ,CAAC,EACD,CAAC,EACD,CAAC,EACD,OAAO,EAAE,QAAQ,GAClB,GAAG,MAAM,MAAM,CAAC;gBACf,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CAAC,CAAC;YACH,MAAM,OAAO,GACX,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;YACjE,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD;YACE,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE;gBAC/C,IAAI,EAAG,MAA6B,CAAC,IAAI;aAC1C,CAAC,CAAC;YACH,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { type Hex, type Prettify, serializeSignature } from \"viem\";\nimport {\n PersonalSignSignatureRequest,\n TypedDataSignatureRequest,\n AuthorizationSignatureRequest,\n Eip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type {\n InnerWalletApiClient,\n SignerClient,\n WithoutRawPayload,\n} from \"../types\";\nimport { assertNever, BaseError } from \"@alchemy/common\";\nimport { LOGGER } from \"../logger.js\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport { getAction } from \"viem/utils\";\nimport { signAuthorization, signMessage, signTypedData } from \"viem/actions\";\nimport type { LocalAccount } from \"viem\";\nimport type { z } from \"zod\";\n\nexport type SignSignatureRequestParams = Prettify<\n WithoutRawPayload<\n | z.output<typeof PersonalSignSignatureRequest>\n | z.output<typeof TypedDataSignatureRequest>\n | (z.output<typeof AuthorizationSignatureRequest> & {\n data: z.output<typeof Eip7702UnsignedAuth>;\n })\n >\n>;\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: Hex;\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.\n *\n * @param {InnerWalletApiClient} client - The wallet client to use for signing\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {SignSignatureRequestParams[\"data\"]} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n *\n * @example\n * ```ts\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n * ```\n */\n\nexport async function signSignatureRequest(\n client: InnerWalletApiClient,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n LOGGER.debug(\"signSignatureRequest:start\", { type: params.type });\n\n if (isLocalAccount(client.owner)) {\n return signWithLocalAccount(client.owner, params);\n }\n\n return signWithSignerClient(client.owner, params);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LocalAccount signer\n// ─────────────────────────────────────────────────────────────────────────────\n\ntype Secp256k1Result = Extract<\n SignSignatureRequestResult,\n { type: \"secp256k1\" }\n>;\n\nasync function signWithLocalAccount(\n signer: LocalAccount,\n params: SignSignatureRequestParams,\n): Promise<Secp256k1Result> {\n switch (params.type) {\n case \"personal_sign\": {\n const data = await signer.signMessage({ message: params.data });\n LOGGER.debug(\"signSignatureRequest:localAccount:personal_sign:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eth_signTypedData_v4\": {\n const data = await signer.signTypedData(params.data);\n LOGGER.debug(\"signSignatureRequest:localAccount:eth_signTypedData_v4:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new BaseError(\n \"Current signer does not support signing authorization requests\",\n );\n }\n const {\n r,\n s,\n v,\n yParity: _yParity,\n } = await signer.signAuthorization(params.data);\n const yParity =\n _yParity != null ? Number(_yParity) : vToYParity(Number(v));\n LOGGER.debug(\"signSignatureRequest:localAccount:eip7702Auth:ok\");\n return {\n type: \"secp256k1\",\n data: serializeSignature({ r, s, yParity }),\n };\n }\n default:\n LOGGER.warn(\"signSignatureRequest:unknown-type\", {\n type: (params as { type?: unknown }).type,\n });\n return assertNever(params, \"Unexpected signature request type.\");\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// SignerClient (WalletClient)\n// ─────────────────────────────────────────────────────────────────────────────\n\nasync function signWithSignerClient(\n signer: SignerClient,\n params: SignSignatureRequestParams,\n): Promise<Secp256k1Result> {\n switch (params.type) {\n case \"personal_sign\": {\n const action = getAction(signer, signMessage, \"signMessage\");\n const data = await action({\n message: params.data,\n account: signer.account,\n });\n LOGGER.debug(\"signSignatureRequest:signerClient:personal_sign:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eth_signTypedData_v4\": {\n const action = getAction(signer, signTypedData, \"signTypedData\");\n const data = await action({ ...params.data, account: signer.account });\n LOGGER.debug(\"signSignatureRequest:signerClient:eth_signTypedData_v4:ok\");\n return { type: \"secp256k1\", data };\n }\n case \"eip7702Auth\": {\n const action = getAction(signer, signAuthorization, \"signAuthorization\");\n const {\n r,\n s,\n v,\n yParity: _yParity,\n } = await action({\n ...params.data,\n account: signer.account,\n });\n const yParity =\n _yParity != null ? Number(_yParity) : vToYParity(Number(v));\n LOGGER.debug(\"signSignatureRequest:signerClient:eip7702Auth:ok\");\n return {\n type: \"secp256k1\",\n data: serializeSignature({ r, s, yParity }),\n };\n }\n default:\n LOGGER.warn(\"signSignatureRequest:unknown-type\", {\n type: (params as { type?: unknown }).type,\n });\n return assertNever(params, \"Unexpected signature request type.\");\n }\n}\n"]}
@@ -1,10 +1,20 @@
1
- import { type Hex, type Prettify, type TypedDataDefinition } from "viem";
1
+ import { type Address as ViemAddress, type Hex, type TypedData } from "viem";
2
2
  import type { InnerWalletApiClient } from "../types.ts";
3
3
  import { type AccountParam } from "../utils/resolve.js";
4
- export type SignTypedDataParams = Prettify<TypedDataDefinition & {
4
+ export type SignTypedDataParams = {
5
+ domain?: {
6
+ name?: string;
7
+ version?: string;
8
+ chainId?: number | bigint;
9
+ verifyingContract?: ViemAddress;
10
+ salt?: Hex;
11
+ };
12
+ types: TypedData | Record<string, unknown>;
13
+ primaryType: string;
14
+ message: Record<string, unknown>;
5
15
  account?: AccountParam;
6
- }>;
7
- export type SignTypedDataResult = Prettify<Hex>;
16
+ };
17
+ export type SignTypedDataResult = Hex;
8
18
  /**
9
19
  * Signs typed data (EIP-712) using the smart account.
10
20
  * This method requests the account associated with the signer and uses it to sign the typed data.
@@ -1 +1 @@
1
- {"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,MAAM,MAAM,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAUxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA2B;IAE3B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE;QAClC,kBAAkB,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI;QAC1C,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO;QACnC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE;QACzC,OAAO,EAAE,cAAc;QACvB,gBAAgB,EAAE;YAChB,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC;SAClC;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAE7E,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,MAAM,EAAE;QACzC,OAAO,EAAE,cAAc;QACvB,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IACH,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC,SAAS,CAAC;AAC7B,CAAC","sourcesContent":["import { type Hex, type Prettify, type TypedDataDefinition } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport { prepareSign } from \"./prepareSign.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { formatSign } from \"./formatSign.js\";\nimport { typedDataToJsonSafe } from \"../utils/format.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\n\nexport type SignTypedDataParams = Prettify<\n TypedDataDefinition & {\n account?: AccountParam;\n }\n>;\n\nexport type SignTypedDataResult = Prettify<Hex>;\n\n/**\n * Signs typed data (EIP-712) using the smart account.\n * This method requests the account associated with the signer and uses it to sign the typed data.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format\n * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string\n *\n * @example\n * ```ts\n * // Sign typed data\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Example DApp',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' }\n * ]\n * },\n * primaryType: 'Person',\n * message: {\n * name: 'John Doe',\n * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'\n * }\n * });\n * ```\n */\n\nexport async function signTypedData(\n client: InnerWalletApiClient,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n LOGGER.debug(\"signTypedData:start\", {\n hasExplicitAccount: params.account != null,\n primaryType: params.primaryType,\n });\n const accountAddress = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const prepared = await prepareSign(client, {\n account: accountAddress,\n signatureRequest: {\n type: \"eth_signTypedData_v4\",\n data: typedDataToJsonSafe(params),\n },\n });\n\n const signed = await signSignatureRequest(client, prepared.signatureRequest);\n\n const formatted = await formatSign(client, {\n account: accountAddress,\n signature: {\n type: \"ecdsa\",\n data: signed.data,\n },\n });\n LOGGER.debug(\"signTypedData:done\", { from: accountAddress });\n return formatted.signature;\n}\n"]}
1
+ {"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[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AAC;IACH,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC,SAAS,CAAC;AAC7B,CAAC","sourcesContent":["import { type Address as ViemAddress, type Hex, type TypedData } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport { prepareSign } from \"./prepareSign.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { formatSign } from \"./formatSign.js\";\nimport { typedDataToJsonSafe } from \"../utils/format.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\n\nexport type SignTypedDataParams = {\n domain?: {\n name?: string;\n version?: string;\n chainId?: number | bigint;\n verifyingContract?: ViemAddress;\n salt?: Hex;\n };\n types: TypedData | Record<string, unknown>;\n primaryType: string;\n message: Record<string, unknown>;\n account?: AccountParam;\n};\n\nexport type SignTypedDataResult = Hex;\n\n/**\n * Signs typed data (EIP-712) using the smart account.\n * This method requests the account associated with the signer and uses it to sign the typed data.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format\n * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string\n *\n * @example\n * ```ts\n * // Sign typed data\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Example DApp',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' }\n * ]\n * },\n * primaryType: 'Person',\n * message: {\n * name: 'John Doe',\n * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'\n * }\n * });\n * ```\n */\n\nexport async function signTypedData(\n client: InnerWalletApiClient,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n LOGGER.debug(\"signTypedData:start\", {\n hasExplicitAccount: params.account != null,\n primaryType: params.primaryType,\n });\n const accountAddress = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const prepared = await prepareSign(client, {\n account: accountAddress,\n signatureRequest: {\n type: \"eth_signTypedData_v4\",\n data: typedDataToJsonSafe(params),\n },\n });\n\n const signed = await signSignatureRequest(client, prepared.signatureRequest);\n\n const formatted = await formatSign(client, {\n account: accountAddress,\n signature: {\n type: \"ecdsa\",\n data: signed.data,\n },\n });\n LOGGER.debug(\"signTypedData:done\", { from: accountAddress });\n return formatted.signature;\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import type { Hex } from "viem";
2
+ import type { InnerSolanaWalletApiClient } from "../../types.js";
3
+ import { wallet_getCallsStatus as MethodSchema } from "@alchemy/wallet-api-types/rpc";
4
+ import { type MethodResponse } from "../../utils/schema.js";
5
+ type GetCallsStatusResponse = MethodResponse<typeof MethodSchema>;
6
+ type SolanaGetCallsStatusResponse = Extract<GetCallsStatusResponse, {
7
+ chainId: `solana:${string}`;
8
+ }>;
9
+ export type SolanaGetCallsStatusParams = {
10
+ id: Hex;
11
+ };
12
+ export type SolanaGetCallsStatusResult = Omit<SolanaGetCallsStatusResponse, "status"> & {
13
+ status: "pending" | "success" | "failure";
14
+ statusCode: number;
15
+ };
16
+ /**
17
+ * Gets the status of a Solana call bundle.
18
+ *
19
+ * @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
20
+ * @param {SolanaGetCallsStatusParams} params - The call ID to check
21
+ * @returns {Promise<SolanaGetCallsStatusResult>} The status of the call
22
+ */
23
+ export declare function getCallsStatus(client: InnerSolanaWalletApiClient, params: SolanaGetCallsStatusParams): Promise<SolanaGetCallsStatusResult>;
24
+ export {};
@@ -0,0 +1,44 @@
1
+ import { BaseError } from "@alchemy/common";
2
+ import { LOGGER } from "../../logger.js";
3
+ import { wallet_getCallsStatus as MethodSchema } from "@alchemy/wallet-api-types/rpc";
4
+ import { methodSchema, decode, } from "../../utils/schema.js";
5
+ const schema = methodSchema(MethodSchema);
6
+ function isSolanaResponse(response) {
7
+ return (typeof response.chainId === "string" &&
8
+ response.chainId.startsWith("solana:"));
9
+ }
10
+ /**
11
+ * Gets the status of a Solana call bundle.
12
+ *
13
+ * @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
14
+ * @param {SolanaGetCallsStatusParams} params - The call ID to check
15
+ * @returns {Promise<SolanaGetCallsStatusResult>} The status of the call
16
+ */
17
+ export async function getCallsStatus(client, params) {
18
+ LOGGER.debug("solana:getCallsStatus:start", { id: params.id });
19
+ const rpcResp = await client.request({
20
+ method: "wallet_getCallsStatus",
21
+ params: [params.id],
22
+ });
23
+ const decoded = decode(schema.response, rpcResp);
24
+ if (!isSolanaResponse(decoded)) {
25
+ throw new BaseError(`Unexpected EVM response from Solana getCallsStatus`);
26
+ }
27
+ const statusCode = decoded.status;
28
+ const status = (() => {
29
+ if (statusCode >= 100 && statusCode < 200)
30
+ return "pending";
31
+ if (statusCode >= 200 && statusCode < 300)
32
+ return "success";
33
+ if (statusCode >= 300 && statusCode < 700)
34
+ return "failure";
35
+ throw new BaseError(`Unknown Solana call status code: ${statusCode}`);
36
+ })();
37
+ LOGGER.debug("solana:getCallsStatus:done", { status, statusCode });
38
+ return {
39
+ ...decoded,
40
+ status,
41
+ statusCode,
42
+ };
43
+ }
44
+ //# sourceMappingURL=getCallsStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/actions/solana/getCallsStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EACL,YAAY,EACZ,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,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;QACL,GAAG,OAAO;QACV,MAAM;QACN,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import type { Hex } from \"viem\";\nimport { BaseError } from \"@alchemy/common\";\nimport type { InnerSolanaWalletApiClient } from \"../../types.js\";\nimport { LOGGER } from \"../../logger.js\";\nimport { wallet_getCallsStatus as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n decode,\n type MethodResponse,\n} from \"../../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype GetCallsStatusResponse = MethodResponse<typeof MethodSchema>;\n\ntype SolanaGetCallsStatusResponse = Extract<\n GetCallsStatusResponse,\n { chainId: `solana:${string}` }\n>;\n\nfunction isSolanaResponse(\n response: GetCallsStatusResponse,\n): response is SolanaGetCallsStatusResponse {\n return (\n typeof response.chainId === \"string\" &&\n response.chainId.startsWith(\"solana:\")\n );\n}\n\nexport type SolanaGetCallsStatusParams = {\n id: Hex;\n};\n\nexport type SolanaGetCallsStatusResult = Omit<\n SolanaGetCallsStatusResponse,\n \"status\"\n> & {\n status: \"pending\" | \"success\" | \"failure\";\n statusCode: number;\n};\n\n/**\n * Gets the status of a Solana call bundle.\n *\n * @param {InnerSolanaWalletApiClient} client - The Solana wallet API client\n * @param {SolanaGetCallsStatusParams} params - The call ID to check\n * @returns {Promise<SolanaGetCallsStatusResult>} The status of the call\n */\nexport async function getCallsStatus(\n client: InnerSolanaWalletApiClient,\n params: SolanaGetCallsStatusParams,\n): Promise<SolanaGetCallsStatusResult> {\n LOGGER.debug(\"solana:getCallsStatus:start\", { id: params.id });\n\n const rpcResp = await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params.id],\n });\n\n const decoded = decode(schema.response, rpcResp);\n\n if (!isSolanaResponse(decoded)) {\n throw new BaseError(`Unexpected EVM response from Solana getCallsStatus`);\n }\n const statusCode = decoded.status;\n const status = (() => {\n if (statusCode >= 100 && statusCode < 200) return \"pending\" as const;\n if (statusCode >= 200 && statusCode < 300) return \"success\" as const;\n if (statusCode >= 300 && statusCode < 700) return \"failure\" as const;\n throw new BaseError(`Unknown Solana call status code: ${statusCode}`);\n })();\n\n LOGGER.debug(\"solana:getCallsStatus:done\", { status, statusCode });\n\n return {\n ...decoded,\n status,\n statusCode,\n };\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import type { Prettify } from "viem";
2
+ import type { DistributiveOmit, InnerSolanaWalletApiClient } from "../../types.js";
3
+ import type { SolanaChainId } from "@alchemy/wallet-api-types";
4
+ import { SolanaPrepareCallsParams as SolanaPrepareCallsSchema } from "@alchemy/wallet-api-types";
5
+ import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
6
+ import type { z } from "zod";
7
+ import { type WithCapabilities } from "../../utils/capabilities.js";
8
+ import { type MethodResponse } from "../../utils/schema.js";
9
+ type PrepareCallsResponse = MethodResponse<typeof MethodSchema>;
10
+ type BaseSolanaPrepareCallsParams = z.output<typeof SolanaPrepareCallsSchema>;
11
+ export type SolanaPrepareCallsParams = Prettify<WithCapabilities<DistributiveOmit<BaseSolanaPrepareCallsParams, "from" | "chainId"> & {
12
+ account?: string;
13
+ chainId?: SolanaChainId;
14
+ }>>;
15
+ type SolanaPrepareCallsResponse = Extract<PrepareCallsResponse, {
16
+ type: "solana-transaction-v0";
17
+ }>;
18
+ export type SolanaPrepareCallsResult = SolanaPrepareCallsResponse;
19
+ /**
20
+ * Prepares Solana instructions for execution by building a versioned transaction.
21
+ * Returns the compiled transaction and a signature request that needs to be signed
22
+ * before submitting to sendPreparedCalls.
23
+ *
24
+ * @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
25
+ * @param {SolanaPrepareCallsParams} params - Parameters for preparing Solana calls
26
+ * @param {Array<{programId: string, accounts?: Array, data: Hex}>} params.calls - Array of Solana instructions
27
+ * @param {string} [params.account] - The Solana address to execute from. Defaults to the signer's address.
28
+ * @param {SolanaChainId} [params.chainId] - The Solana chain ID. Defaults to the client's chain.
29
+ * @param {object} [params.capabilities] - Optional capabilities (e.g. paymaster sponsorship)
30
+ * @returns {Promise<SolanaPrepareCallsResult>} The prepared Solana transaction with signature request
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const result = await client.prepareCalls({
35
+ * calls: [{
36
+ * programId: "11111111111111111111111111111111",
37
+ * data: "0x...",
38
+ * }],
39
+ * capabilities: {
40
+ * paymaster: { policyId: "your-policy-id" }
41
+ * }
42
+ * });
43
+ * ```
44
+ */
45
+ export declare function prepareCalls(client: InnerSolanaWalletApiClient, params: SolanaPrepareCallsParams): Promise<SolanaPrepareCallsResult>;
46
+ export {};