@alchemy/wallet-apis 5.0.0-beta.25 → 5.0.0-beta.26
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/dist/esm/experimental/actions/requestQuoteV0.d.ts +14 -4
- package/dist/esm/experimental/actions/requestQuoteV0.js +8 -4
- package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
- package/dist/esm/experimental/swapActionsDecorator.d.ts +3 -0
- package/dist/esm/experimental/swapActionsDecorator.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/experimental/actions/requestQuoteV0.d.ts +14 -4
- package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
- package/dist/types/experimental/swapActionsDecorator.d.ts +3 -0
- package/dist/types/experimental/swapActionsDecorator.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/experimental/actions/requestQuoteV0.ts +14 -4
- package/src/experimental/swapActionsDecorator.ts +3 -0
- package/src/version.ts +1 -1
|
@@ -6,6 +6,9 @@ import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-type
|
|
|
6
6
|
import { type MethodParams, type MethodResponse } from "../../utils/schema.js";
|
|
7
7
|
type BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;
|
|
8
8
|
type RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* Parameters accepted by the experimental `requestQuoteV0` action.
|
|
11
|
+
*/
|
|
9
12
|
export type RequestQuoteV0Params = Prettify<WithCapabilities<DistributiveOmit<BaseRequestQuoteV0Params, "from" | "chainId"> & {
|
|
10
13
|
account?: AccountParam;
|
|
11
14
|
chainId?: number;
|
|
@@ -17,6 +20,9 @@ type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
|
|
|
17
20
|
account: Address;
|
|
18
21
|
capabilities?: PrepareCallsCapabilities;
|
|
19
22
|
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Result returned by the experimental `requestQuoteV0` action.
|
|
25
|
+
*/
|
|
20
26
|
export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
21
27
|
type: "paymaster-permit";
|
|
22
28
|
}> | (Omit<Extract<RequestQuoteV0Response, {
|
|
@@ -32,13 +38,15 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
32
38
|
* @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote
|
|
33
39
|
* @param {Address} params.fromToken - The address of the token to swap from
|
|
34
40
|
* @param {Address} params.toToken - The address of the token to swap to
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
41
|
+
* @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
|
|
42
|
+
* @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
|
|
37
43
|
* @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).
|
|
38
|
-
* @param {
|
|
44
|
+
* @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.
|
|
45
|
+
* @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.
|
|
46
|
+
* @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.
|
|
39
47
|
* @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)
|
|
40
48
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)
|
|
41
|
-
* @param {Array<{to: Address
|
|
49
|
+
* @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap
|
|
42
50
|
* @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls
|
|
43
51
|
*
|
|
44
52
|
* @example
|
|
@@ -48,6 +56,7 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
48
56
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
49
57
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
50
58
|
* fromAmount: 1000000000000000000n, // 1 ETH
|
|
59
|
+
* chainId: 42161, // Arbitrum
|
|
51
60
|
* capabilities: {
|
|
52
61
|
* paymaster: { policyId: "your-policy-id" }
|
|
53
62
|
* }
|
|
@@ -58,6 +67,7 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
58
67
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
59
68
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
60
69
|
* fromAmount: 1000000000000000000n,
|
|
70
|
+
* chainId: 42161,
|
|
61
71
|
* returnRawCalls: true
|
|
62
72
|
* });
|
|
63
73
|
* ```
|
|
@@ -11,13 +11,15 @@ const schema = methodSchema(MethodSchema);
|
|
|
11
11
|
* @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote
|
|
12
12
|
* @param {Address} params.fromToken - The address of the token to swap from
|
|
13
13
|
* @param {Address} params.toToken - The address of the token to swap to
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
14
|
+
* @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
|
|
15
|
+
* @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
|
|
16
16
|
* @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).
|
|
17
|
-
* @param {
|
|
17
|
+
* @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.
|
|
18
|
+
* @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.
|
|
19
|
+
* @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.
|
|
18
20
|
* @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)
|
|
19
21
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)
|
|
20
|
-
* @param {Array<{to: Address
|
|
22
|
+
* @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap
|
|
21
23
|
* @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
@@ -27,6 +29,7 @@ const schema = methodSchema(MethodSchema);
|
|
|
27
29
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
28
30
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
29
31
|
* fromAmount: 1000000000000000000n, // 1 ETH
|
|
32
|
+
* chainId: 42161, // Arbitrum
|
|
30
33
|
* capabilities: {
|
|
31
34
|
* paymaster: { policyId: "your-policy-id" }
|
|
32
35
|
* }
|
|
@@ -37,6 +40,7 @@ const schema = methodSchema(MethodSchema);
|
|
|
37
40
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
38
41
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
39
42
|
* fromAmount: 1000000000000000000n,
|
|
43
|
+
* chainId: 42161,
|
|
40
44
|
* returnRawCalls: true
|
|
41
45
|
* });
|
|
42
46
|
* ```
|
|
@@ -1 +1 @@
|
|
|
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,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AG,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\n/**\n * Parameters accepted by the experimental `requestQuoteV0` action.\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\n/**\n * Result returned by the experimental `requestQuoteV0` action.\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 {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)\n * @param {bigint} [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 {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.\n * @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.\n * @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.\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?: bigint }>} [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 * chainId: 42161, // Arbitrum\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 * chainId: 42161,\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,5 +1,8 @@
|
|
|
1
1
|
import { type RequestQuoteV0Params, type RequestQuoteV0Result } from "./actions/requestQuoteV0.js";
|
|
2
2
|
import type { BaseWalletClient } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Experimental swap actions for wallet API clients.
|
|
5
|
+
*/
|
|
3
6
|
export type SwapActions = {
|
|
4
7
|
requestQuoteV0: (params: RequestQuoteV0Params) => Promise<RequestQuoteV0Result>;
|
|
5
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapActionsDecorator.js","sourceRoot":"","sources":["../../../src/experimental/swapActionsDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"swapActionsDecorator.js","sourceRoot":"","sources":["../../../src/experimental/swapActionsDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;AAYrC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAA8C,CACpE,MAAM,EACN,EAAE;IACF,mEAAmE;IACnE,2CAA2C;IAC3C,MAAM,OAAO,GAAG,MAA8B,CAAC;IAC/C,OAAO;QACL,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC;KAC5D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n requestQuoteV0,\n type RequestQuoteV0Params,\n type RequestQuoteV0Result,\n} from \"./actions/requestQuoteV0.js\";\nimport type { BaseWalletClient, InnerWalletApiClient } from \"../types.js\";\n\n/**\n * Experimental swap actions for wallet API clients.\n */\nexport type SwapActions = {\n requestQuoteV0: (\n params: RequestQuoteV0Params,\n ) => Promise<RequestQuoteV0Result>;\n};\n\n/**\n * This is a decorator that is used to add experimental swap actions to a client.\n *\n * @param {BaseWalletClient} client The wallet client to extend with swap functionality\n * @returns {SwapActions} An object containing swap-related actions\n */\nexport const swapActions: (client: BaseWalletClient) => SwapActions = (\n client,\n) => {\n // This is safe. It's just needed b/c we have an internal decorator\n // that we don't expose on the public type.\n const _client = client as InnerWalletApiClient;\n return {\n requestQuoteV0: (params) => requestQuoteV0(_client, params),\n };\n};\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.25";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -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,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.25\";\n"]}
|
|
@@ -6,6 +6,9 @@ import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-type
|
|
|
6
6
|
import { type MethodParams, type MethodResponse } from "../../utils/schema.js";
|
|
7
7
|
type BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;
|
|
8
8
|
type RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* Parameters accepted by the experimental `requestQuoteV0` action.
|
|
11
|
+
*/
|
|
9
12
|
export type RequestQuoteV0Params = Prettify<WithCapabilities<DistributiveOmit<BaseRequestQuoteV0Params, "from" | "chainId"> & {
|
|
10
13
|
account?: AccountParam;
|
|
11
14
|
chainId?: number;
|
|
@@ -17,6 +20,9 @@ type ClientModifiedRequest = Prettify<Omit<Extract<RequestQuoteV0Response, {
|
|
|
17
20
|
account: Address;
|
|
18
21
|
capabilities?: PrepareCallsCapabilities;
|
|
19
22
|
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Result returned by the experimental `requestQuoteV0` action.
|
|
25
|
+
*/
|
|
20
26
|
export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
21
27
|
type: "paymaster-permit";
|
|
22
28
|
}> | (Omit<Extract<RequestQuoteV0Response, {
|
|
@@ -32,13 +38,15 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
32
38
|
* @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote
|
|
33
39
|
* @param {Address} params.fromToken - The address of the token to swap from
|
|
34
40
|
* @param {Address} params.toToken - The address of the token to swap to
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
41
|
+
* @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
|
|
42
|
+
* @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
|
|
37
43
|
* @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).
|
|
38
|
-
* @param {
|
|
44
|
+
* @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.
|
|
45
|
+
* @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.
|
|
46
|
+
* @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.
|
|
39
47
|
* @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)
|
|
40
48
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)
|
|
41
|
-
* @param {Array<{to: Address
|
|
49
|
+
* @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap
|
|
42
50
|
* @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls
|
|
43
51
|
*
|
|
44
52
|
* @example
|
|
@@ -48,6 +56,7 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
48
56
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
49
57
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
50
58
|
* fromAmount: 1000000000000000000n, // 1 ETH
|
|
59
|
+
* chainId: 42161, // Arbitrum
|
|
51
60
|
* capabilities: {
|
|
52
61
|
* paymaster: { policyId: "your-policy-id" }
|
|
53
62
|
* }
|
|
@@ -58,6 +67,7 @@ export type RequestQuoteV0Result = Exclude<RequestQuoteV0Response, {
|
|
|
58
67
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
59
68
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
60
69
|
* fromAmount: 1000000000000000000n,
|
|
70
|
+
* chainId: 42161,
|
|
61
71
|
* returnRawCalls: true
|
|
62
72
|
* });
|
|
63
73
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestQuoteV0.d.ts","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.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AAwB,CAAC;CACzC,CACF,CAAC;AAEF;;GAEG;AACH,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CA6C/B"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type RequestQuoteV0Params, type RequestQuoteV0Result } from "./actions/requestQuoteV0.js";
|
|
2
2
|
import type { BaseWalletClient } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Experimental swap actions for wallet API clients.
|
|
5
|
+
*/
|
|
3
6
|
export type SwapActions = {
|
|
4
7
|
requestQuoteV0: (params: RequestQuoteV0Params) => Promise<RequestQuoteV0Result>;
|
|
5
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapActionsDecorator.d.ts","sourceRoot":"","sources":["../../../src/experimental/swapActionsDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,aAAa,CAAC;AAE1E,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,CACd,MAAM,EAAE,oBAAoB,KACzB,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,WASvD,CAAC"}
|
|
1
|
+
{"version":3,"file":"swapActionsDecorator.d.ts","sourceRoot":"","sources":["../../../src/experimental/swapActionsDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAwB,MAAM,aAAa,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,EAAE,CACd,MAAM,EAAE,oBAAoB,KACzB,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,WASvD,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.25";
|
|
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": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.26",
|
|
4
4
|
"description": "Alchemy Wallet APIs",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"viem": "^2.45.0"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@alchemy/common": "5.0.0-beta.
|
|
58
|
+
"@alchemy/common": "5.0.0-beta.26",
|
|
59
59
|
"@alchemy/wallet-api-types": "^0.1.0-alpha.27",
|
|
60
60
|
"deep-equal": "^2.2.3",
|
|
61
61
|
"ox": "^0.11.1",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
77
77
|
},
|
|
78
78
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "f250979fa0141a06cd343c36d129c3faf838a9be"
|
|
80
80
|
}
|
|
@@ -21,6 +21,9 @@ const schema = methodSchema(MethodSchema);
|
|
|
21
21
|
type BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;
|
|
22
22
|
type RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Parameters accepted by the experimental `requestQuoteV0` action.
|
|
26
|
+
*/
|
|
24
27
|
export type RequestQuoteV0Params = Prettify<
|
|
25
28
|
WithCapabilities<
|
|
26
29
|
DistributiveOmit<BaseRequestQuoteV0Params, "from" | "chainId"> & {
|
|
@@ -44,6 +47,9 @@ type ClientModifiedRequest = Prettify<
|
|
|
44
47
|
}
|
|
45
48
|
>;
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Result returned by the experimental `requestQuoteV0` action.
|
|
52
|
+
*/
|
|
47
53
|
export type RequestQuoteV0Result =
|
|
48
54
|
| Exclude<RequestQuoteV0Response, { type: "paymaster-permit" }>
|
|
49
55
|
| (Omit<
|
|
@@ -61,13 +67,15 @@ export type RequestQuoteV0Result =
|
|
|
61
67
|
* @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote
|
|
62
68
|
* @param {Address} params.fromToken - The address of the token to swap from
|
|
63
69
|
* @param {Address} params.toToken - The address of the token to swap to
|
|
64
|
-
* @param {
|
|
65
|
-
* @param {
|
|
70
|
+
* @param {bigint} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
|
|
71
|
+
* @param {bigint} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
|
|
66
72
|
* @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).
|
|
67
|
-
* @param {
|
|
73
|
+
* @param {number} [params.chainId] - The source chain ID. Defaults to the wallet client's chain.
|
|
74
|
+
* @param {number} [params.toChainId] - The destination chain ID for cross-chain swaps. Omit for same-chain swaps.
|
|
75
|
+
* @param {bigint} [params.slippage] - The maximum acceptable slippage in basis points.
|
|
68
76
|
* @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)
|
|
69
77
|
* @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)
|
|
70
|
-
* @param {Array<{to: Address
|
|
78
|
+
* @param {Array<{ to: Address; data?: Hex; value?: bigint }>} [params.postCalls] - Optional calls to execute after the swap
|
|
71
79
|
* @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls
|
|
72
80
|
*
|
|
73
81
|
* @example
|
|
@@ -77,6 +85,7 @@ export type RequestQuoteV0Result =
|
|
|
77
85
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
78
86
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
79
87
|
* fromAmount: 1000000000000000000n, // 1 ETH
|
|
88
|
+
* chainId: 42161, // Arbitrum
|
|
80
89
|
* capabilities: {
|
|
81
90
|
* paymaster: { policyId: "your-policy-id" }
|
|
82
91
|
* }
|
|
@@ -87,6 +96,7 @@ export type RequestQuoteV0Result =
|
|
|
87
96
|
* fromToken: "0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
88
97
|
* toToken: "0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E",
|
|
89
98
|
* fromAmount: 1000000000000000000n,
|
|
99
|
+
* chainId: 42161,
|
|
90
100
|
* returnRawCalls: true
|
|
91
101
|
* });
|
|
92
102
|
* ```
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
} from "./actions/requestQuoteV0.js";
|
|
6
6
|
import type { BaseWalletClient, InnerWalletApiClient } from "../types.js";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Experimental swap actions for wallet API clients.
|
|
10
|
+
*/
|
|
8
11
|
export type SwapActions = {
|
|
9
12
|
requestQuoteV0: (
|
|
10
13
|
params: RequestQuoteV0Params,
|
package/src/version.ts
CHANGED