@alchemy/wallet-apis 0.0.0-alpha.21 → 0.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Alchemy Insights, Inc.
3
+ Copyright (c) 2026 Alchemy Insights, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @alchemy/wallet-apis
2
+
3
+ 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
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @alchemy/wallet-apis @alchemy/common viem
9
+ ```
10
+
11
+ ## Key Exports
12
+
13
+ - **`createSmartWalletClient`** - Factory to create a `SmartWalletClient` (viem client extended with smart wallet actions)
14
+ - **`alchemyWalletTransport`** - Alchemy transport pre-configured for the Wallet API gateway
15
+ - **`smartWalletActions`** - Client decorator attaching all wallet API actions
16
+
17
+ ### Actions
18
+
19
+ - **Signing** - `signMessage`, `signTypedData`, `prepareSign`, `signPreparedCalls`, `signSignatureRequest`
20
+ - **Transactions** - `prepareCalls`, `sendCalls`, `sendPreparedCalls`
21
+ - **Account management** - `getCapabilities`, `listAccounts`, `requestAccount`
22
+ - **Permissions** - `grantPermissions`
23
+
24
+ ### Experimental (`@alchemy/wallet-apis/experimental`)
25
+
26
+ - `requestQuoteV0`, `swapActions` - Pre-release swap functionality
27
+
28
+ ## License
29
+
30
+ MIT
@@ -10,7 +10,6 @@ export type SignTypedDataResult = Prettify<Hex>;
10
10
  * This method requests the account associated with the signer and uses it to sign the typed data.
11
11
  *
12
12
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
13
- * @param {SignerClient} signerClient - The wallet client to use for signing
14
13
  * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
15
14
  * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
16
15
  *
@@ -10,7 +10,6 @@ import { resolveAddress } from "../utils/resolve.js";
10
10
  * This method requests the account associated with the signer and uses it to sign the typed data.
11
11
  *
12
12
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
13
- * @param {SignerClient} signerClient - The wallet client to use for signing
14
13
  * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
15
14
  * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
16
15
  *
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;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 {SignerClient} signerClient - The wallet client to use for signing\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":[],"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,6 +1,6 @@
1
- import type { Prettify } from "viem";
1
+ import type { Address, Prettify } from "viem";
2
2
  import type { DistributiveOmit, InnerWalletApiClient } from "../../types.ts";
3
- import { type WithCapabilities } from "../../utils/capabilities.js";
3
+ import { type PrepareCallsCapabilities, type WithCapabilities } from "../../utils/capabilities.js";
4
4
  import { type AccountParam } from "../../utils/resolve.js";
5
5
  import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
6
6
  import { type MethodParams, type MethodResponse } from "../../utils/schema.js";
@@ -10,7 +10,20 @@ export type RequestQuoteV0Params = Prettify<WithCapabilities<DistributiveOmit<Ba
10
10
  account?: AccountParam;
11
11
  chainId?: number;
12
12
  }>>;
13
- export type RequestQuoteV0Result = RequestQuoteV0Response;
13
+ /** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
14
+ type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
15
+ type: "paymaster-permit";
16
+ }>["modifiedRequest"], "from" | "capabilities"> & {
17
+ account: Address;
18
+ capabilities?: PrepareCallsCapabilities;
19
+ }>;
20
+ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
21
+ type: "paymaster-permit";
22
+ }> | (Omit<Extract<RequestQuoteV0Response, {
23
+ type: "paymaster-permit";
24
+ }>, "modifiedRequest"> & {
25
+ modifiedRequest: ClientModifiedRequest;
26
+ });
14
27
  /**
15
28
  * Requests a quote for a token swap, returning either prepared calls for smart wallets
16
29
  * or raw calls for EOA wallets depending on the returnRawCalls parameter.
@@ -1,4 +1,4 @@
1
- import { mergeClientCapabilities, toRpcCapabilities, } from "../../utils/capabilities.js";
1
+ import { fromRpcCapabilities, mergeClientCapabilities, toRpcCapabilities, } from "../../utils/capabilities.js";
2
2
  import { resolveAddress } from "../../utils/resolve.js";
3
3
  import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
4
4
  import { methodSchema, encode, decode, } from "../../utils/schema.js";
@@ -59,6 +59,21 @@ export async function requestQuoteV0(client, params) {
59
59
  method: "wallet_requestQuote_v0",
60
60
  params: [rpcParams],
61
61
  });
62
- return decode(schema.response, rpcResp);
62
+ const decoded = decode(schema.response, rpcResp);
63
+ // Transform paymaster-permit modifiedRequest from RPC format to client format:
64
+ // - `from` (RPC) → `account` (client)
65
+ // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)
66
+ if ("type" in decoded && decoded.type === "paymaster-permit") {
67
+ const { from, capabilities, ...restModifiedRequest } = decoded.modifiedRequest;
68
+ return {
69
+ ...decoded,
70
+ modifiedRequest: {
71
+ ...restModifiedRequest,
72
+ account: from,
73
+ capabilities: fromRpcCapabilities(capabilities),
74
+ },
75
+ };
76
+ }
77
+ return decoded;
63
78
  }
64
79
  //# sourceMappingURL=requestQuoteV0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,YAAY,GAChB,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QACjD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CACrB,MAAM,EACN,cAAc,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAC3D,CAAC;IAER,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,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI;QACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,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 {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../../utils/resolve.js\";\nimport { wallet_requestQuote_v0 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 BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;\ntype RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;\n\nexport type RequestQuoteV0Params = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseRequestQuoteV0Params, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\nexport type RequestQuoteV0Result = RequestQuoteV0Response;\n\n/**\n * Requests a quote for a token swap, returning either prepared calls for smart wallets\n * or raw calls for EOA wallets depending on the returnRawCalls parameter.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote\n * @param {Address} params.fromToken - The address of the token to swap from\n * @param {Address} params.toToken - The address of the token to swap to\n * @param {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)\n * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)\n * @param {AccountParam} [params.account] - The account to execute the swap 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 {Hex} [params.slippage] - The maximum acceptable slippage percentage\n * @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap\n * @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls\n *\n * @example\n * ```ts twoslash\n * // Request a quote for smart wallet (prepared calls)\n * const quote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n, // 1 ETH\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Request a quote for EOA wallet (raw calls)\n * const rawQuote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n,\n * returnRawCalls: true\n * });\n * ```\n */\nexport async function requestQuoteV0(\n client: InnerWalletApiClient,\n params: RequestQuoteV0Params,\n): Promise<RequestQuoteV0Result> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const capabilities =\n \"returnRawCalls\" in params && params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(\n client,\n \"capabilities\" in params ? params.capabilities : undefined,\n );\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId: params.chainId ?? client.chain.id,\n from,\n ...(capabilities && { capabilities: toRpcCapabilities(capabilities) }),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [rpcParams],\n });\n\n return decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GAGlB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAoC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,YAAY,GAChB,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QACjD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CACrB,MAAM,EACN,cAAc,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAC3D,CAAC;IAER,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,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI;QACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEjD,+EAA+E;IAC/E,sCAAsC;IACtC,8EAA8E;IAC9E,IAAI,MAAM,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC7D,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 {\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_requestQuote_v0 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 BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;\ntype RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;\n\nexport type RequestQuoteV0Params = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseRequestQuoteV0Params, \"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<\n Extract<\n RequestQuoteV0Response,\n { type: \"paymaster-permit\" }\n >[\"modifiedRequest\"],\n \"from\" | \"capabilities\"\n > & {\n account: Address;\n capabilities?: PrepareCallsCapabilities;\n }\n>;\n\nexport type RequestQuoteV0Result =\n | Exclude<RequestQuoteV0Response, { type: \"paymaster-permit\" }>\n | (Omit<\n Extract<RequestQuoteV0Response, { type: \"paymaster-permit\" }>,\n \"modifiedRequest\"\n > & {\n modifiedRequest: ClientModifiedRequest;\n });\n\n/**\n * Requests a quote for a token swap, returning either prepared calls for smart wallets\n * or raw calls for EOA wallets depending on the returnRawCalls parameter.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote\n * @param {Address} params.fromToken - The address of the token to swap from\n * @param {Address} params.toToken - The address of the token to swap to\n * @param {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)\n * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)\n * @param {AccountParam} [params.account] - The account to execute the swap 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 {Hex} [params.slippage] - The maximum acceptable slippage percentage\n * @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap\n * @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls\n *\n * @example\n * ```ts twoslash\n * // Request a quote for smart wallet (prepared calls)\n * const quote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n, // 1 ETH\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Request a quote for EOA wallet (raw calls)\n * const rawQuote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n,\n * returnRawCalls: true\n * });\n * ```\n */\nexport async function requestQuoteV0(\n client: InnerWalletApiClient,\n params: RequestQuoteV0Params,\n): Promise<RequestQuoteV0Result> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const capabilities =\n \"returnRawCalls\" in params && params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(\n client,\n \"capabilities\" in params ? params.capabilities : undefined,\n );\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId: params.chainId ?? client.chain.id,\n from,\n ...(capabilities && { capabilities: toRpcCapabilities(capabilities) }),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [rpcParams],\n });\n\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 (\"type\" in decoded && 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 +1 @@
1
- export declare const VERSION = "0.0.0-alpha.20";
1
+ export declare const VERSION = "0.0.0-alpha.21";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "0.0.0-alpha.20";
3
+ export const VERSION = "0.0.0-alpha.21";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"0.0.0-alpha.20\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"0.0.0-alpha.21\";\n"]}
@@ -10,7 +10,6 @@ export type SignTypedDataResult = Prettify<Hex>;
10
10
  * This method requests the account associated with the signer and uses it to sign the typed data.
11
11
  *
12
12
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
13
- * @param {SignerClient} signerClient - The wallet client to use for signing
14
13
  * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
15
14
  * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
16
15
  *
@@ -1 +1 @@
1
- {"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,mBAAmB,GAAG;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CACF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,wBAAsB,aAAa,CACjC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA4B9B"}
1
+ {"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CACxC,mBAAmB,GAAG;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CACF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAsB,aAAa,CACjC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA4B9B"}
@@ -1,6 +1,6 @@
1
- import type { Prettify } from "viem";
1
+ import type { Address, Prettify } from "viem";
2
2
  import type { DistributiveOmit, InnerWalletApiClient } from "../../types.ts";
3
- import { type WithCapabilities } from "../../utils/capabilities.js";
3
+ import { type PrepareCallsCapabilities, type WithCapabilities } from "../../utils/capabilities.js";
4
4
  import { type AccountParam } from "../../utils/resolve.js";
5
5
  import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
6
6
  import { type MethodParams, type MethodResponse } from "../../utils/schema.js";
@@ -10,7 +10,20 @@ export type RequestQuoteV0Params = Prettify<WithCapabilities<DistributiveOmit<Ba
10
10
  account?: AccountParam;
11
11
  chainId?: number;
12
12
  }>>;
13
- export type RequestQuoteV0Result = RequestQuoteV0Response;
13
+ /** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
14
+ type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
15
+ type: "paymaster-permit";
16
+ }>["modifiedRequest"], "from" | "capabilities"> & {
17
+ account: Address;
18
+ capabilities?: PrepareCallsCapabilities;
19
+ }>;
20
+ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
21
+ type: "paymaster-permit";
22
+ }> | (Omit<Extract<RequestQuoteV0Response, {
23
+ type: "paymaster-permit";
24
+ }>, "modifiedRequest"> & {
25
+ modifiedRequest: ClientModifiedRequest;
26
+ });
14
27
  /**
15
28
  * Requests a quote for a token swap, returning either prepared calls for smart wallets
16
29
  * or raw calls for EOA wallets depending on the returnRawCalls parameter.
@@ -1 +1 @@
1
- {"version":3,"file":"requestQuoteV0.d.ts","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,KAAK,wBAAwB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAClE,KAAK,sBAAsB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,gBAAgB,CACd,gBAAgB,CAAC,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IAC/D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CACF,CACF,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CA2B/B"}
1
+ {"version":3,"file":"requestQuoteV0.d.ts","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAIL,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,KAAK,wBAAwB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAClE,KAAK,sBAAsB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,gBAAgB,CACd,gBAAgB,CAAC,wBAAwB,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IAC/D,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CACF,CACF,CAAC;AAEF,2FAA2F;AAC3F,KAAK,qBAAqB,GAAG,QAAQ,CACnC,IAAI,CACF,OAAO,CACL,sBAAsB,EACtB;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAC7B,CAAC,iBAAiB,CAAC,EACpB,MAAM,GAAG,cAAc,CACxB,GAAG;IACF,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,wBAAwB,CAAC;CACzC,CACF,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC,GAC7D,CAAC,IAAI,CACH,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAC7D,iBAAiB,CAClB,GAAG;IACF,eAAe,EAAE,qBAAqB,CAAC;CACxC,CAAC,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CA6C/B"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.0.0-alpha.20";
1
+ export declare const VERSION = "0.0.0-alpha.21";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy/wallet-apis",
3
- "version": "0.0.0-alpha.21",
3
+ "version": "0.0.0-alpha.22",
4
4
  "description": "Alchemy Wallet APIs",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  "typescript-template": "*"
54
54
  },
55
55
  "dependencies": {
56
- "@alchemy/common": "^0.0.0-alpha.21",
56
+ "@alchemy/common": "^0.0.0-alpha.22",
57
57
  "@alchemy/wallet-api-types": "0.1.0-alpha.25",
58
58
  "deep-equal": "^2.2.3",
59
59
  "ox": "^0.11.1",
@@ -72,5 +72,5 @@
72
72
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
73
73
  },
74
74
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
75
- "gitHead": "b253d0ee34fcb723a72d594d56b484188ac6867b"
75
+ "gitHead": "10e989504f15718c4c6b66e6856e509dfb3e6cfe"
76
76
  }
@@ -20,7 +20,6 @@ export type SignTypedDataResult = Prettify<Hex>;
20
20
  * This method requests the account associated with the signer and uses it to sign the typed data.
21
21
  *
22
22
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
23
- * @param {SignerClient} signerClient - The wallet client to use for signing
24
23
  * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
25
24
  * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
26
25
  *
@@ -1,8 +1,10 @@
1
- import type { Prettify } from "viem";
1
+ import type { Address, Prettify } from "viem";
2
2
  import type { DistributiveOmit, InnerWalletApiClient } from "../../types.ts";
3
3
  import {
4
+ fromRpcCapabilities,
4
5
  mergeClientCapabilities,
5
6
  toRpcCapabilities,
7
+ type PrepareCallsCapabilities,
6
8
  type WithCapabilities,
7
9
  } from "../../utils/capabilities.js";
8
10
  import { resolveAddress, type AccountParam } from "../../utils/resolve.js";
@@ -28,7 +30,28 @@ export type RequestQuoteV0Params = Prettify<
28
30
  >
29
31
  >;
30
32
 
31
- export type RequestQuoteV0Result = RequestQuoteV0Response;
33
+ /** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
34
+ type ClientModifiedRequest = Prettify<
35
+ Omit<
36
+ Extract<
37
+ RequestQuoteV0Response,
38
+ { type: "paymaster-permit" }
39
+ >["modifiedRequest"],
40
+ "from" | "capabilities"
41
+ > & {
42
+ account: Address;
43
+ capabilities?: PrepareCallsCapabilities;
44
+ }
45
+ >;
46
+
47
+ export type RequestQuoteV0Result =
48
+ | Exclude<RequestQuoteV0Response, { type: "paymaster-permit" }>
49
+ | (Omit<
50
+ Extract<RequestQuoteV0Response, { type: "paymaster-permit" }>,
51
+ "modifiedRequest"
52
+ > & {
53
+ modifiedRequest: ClientModifiedRequest;
54
+ });
32
55
 
33
56
  /**
34
57
  * Requests a quote for a token swap, returning either prepared calls for smart wallets
@@ -97,5 +120,23 @@ export async function requestQuoteV0(
97
120
  params: [rpcParams],
98
121
  });
99
122
 
100
- return decode(schema.response, rpcResp);
123
+ const decoded = decode(schema.response, rpcResp);
124
+
125
+ // Transform paymaster-permit modifiedRequest from RPC format to client format:
126
+ // - `from` (RPC) → `account` (client)
127
+ // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)
128
+ if ("type" in decoded && decoded.type === "paymaster-permit") {
129
+ const { from, capabilities, ...restModifiedRequest } =
130
+ decoded.modifiedRequest;
131
+ return {
132
+ ...decoded,
133
+ modifiedRequest: {
134
+ ...restModifiedRequest,
135
+ account: from,
136
+ capabilities: fromRpcCapabilities(capabilities),
137
+ },
138
+ };
139
+ }
140
+
141
+ return decoded;
101
142
  }
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "0.0.0-alpha.21";
3
+ export const VERSION = "0.0.0-alpha.22";