@alchemy/wallet-apis 5.0.0-beta.24 → 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.
@@ -1,7 +1,7 @@
1
- import { type Hex, type Prettify, type TypedDataDefinition } from "viem";
1
+ import { type Hex, type Prettify, type TypedData, type TypedDataDefinition } 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 = Prettify<TypedDataDefinition<TypedData | Record<string, unknown>> & {
5
5
  account?: AccountParam;
6
6
  }>;
7
7
  export type SignTypedDataResult = Prettify<Hex>;
@@ -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":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAEd,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 {\n type Hex,\n type Prettify,\n type TypedData,\n type TypedDataDefinition,\n} 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<TypedData | Record<string, unknown>> & {\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"]}
@@ -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 {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
36
- * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
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 {Hex} [params.slippage] - The maximum acceptable slippage percentage
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, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap
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 {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
15
- * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
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 {Hex} [params.slippage] - The maximum acceptable slippage percentage
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, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap
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,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
+ {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names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AG,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;AASrC;;;;;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\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"]}
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"]}
@@ -1,7 +1,7 @@
1
- import { type Hex, type SignableMessage, type TypedDataDefinition } from "viem";
1
+ import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
2
2
  import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
3
3
  export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
4
4
  export declare const signableMessageToJsonSafe: (message: SignableMessage) => string | {
5
5
  raw: Hex;
6
6
  };
7
- export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition) => WalletServerTypedDataDefinition;
7
+ export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition<TypedData | Record<string, unknown>>) => WalletServerTypedDataDefinition;
@@ -1,4 +1,4 @@
1
- import { isHex, toHex, bytesToHex, getTypesForEIP712Domain, } from "viem";
1
+ import { isHex, toHex, bytesToHex, getTypesForEIP712Domain, validateTypedData, } from "viem";
2
2
  export const castToHex = (val) => {
3
3
  if (isHex(val)) {
4
4
  return val;
@@ -16,6 +16,7 @@ export const signableMessageToJsonSafe = (message) => {
16
16
  // Purposefully not using `formatTypedData` from the wallet server types pkg
17
17
  // here, since that would require typebox at runtime (which breaks RN).
18
18
  export const typedDataToJsonSafe = ({ domain, primaryType, message, types, }) => {
19
+ validateTypedData({ domain, primaryType, message, types });
19
20
  return {
20
21
  domain: {
21
22
  ...domain,
@@ -26,7 +27,7 @@ export const typedDataToJsonSafe = ({ domain, primaryType, message, types, }) =>
26
27
  types: {
27
28
  ...Object.fromEntries(Object.entries(types).map(([key, value]) => [
28
29
  key,
29
- value ? [...value] : [],
30
+ Array.isArray(value) ? [...value] : [],
30
31
  ])),
31
32
  EIP712Domain: [...getTypesForEIP712Domain({ domain })],
32
33
  },
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAGL,UAAU,EAEV,uBAAuB,GACxB,MAAM,MAAM,CAAC;AAGd,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAmC,EAAO,EAAE;IACpE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,OAAwB,EACD,EAAE;IACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,C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IP712Domain,\n} from \"viem\";\nimport type { TypedDataDefinition as WalletServerTypedDataDefinition } from \"@alchemy/wallet-api-types\";\n\nexport const castToHex = (val: string | number | bigint | Hex): Hex => {\n if (isHex(val)) {\n return val;\n }\n return toHex(val);\n};\n\nexport const signableMessageToJsonSafe = (\n message: SignableMessage,\n): string | { raw: Hex } => {\n if (typeof message === \"string\") {\n return message;\n }\n return {\n raw:\n typeof message.raw === \"string\" ? message.raw : bytesToHex(message.raw),\n };\n};\n\n// Purposefully not using `formatTypedData` from the wallet server types pkg\n// here, since that would require typebox at runtime (which breaks RN).\nexport const typedDataToJsonSafe = ({\n domain,\n primaryType,\n message,\n types,\n}: TypedDataDefinition): WalletServerTypedDataDefinition => {\n return {\n domain: {\n ...domain,\n chainId:\n typeof domain?.chainId === \"bigint\"\n ? Number(domain.chainId)\n : domain?.chainId,\n },\n types: {\n ...Object.fromEntries(\n Object.entries(types).map(([key, value]) => [\n key,\n value ? [...value] : [],\n ]),\n ),\n EIP712Domain: [...getTypesForEIP712Domain({ domain })],\n },\n primaryType,\n message: JSON.parse(\n JSON.stringify(message, (_, v) => (typeof v === \"bigint\" ? toHex(v) : v)),\n ),\n };\n};\n"]}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAGL,UAAU,EAGV,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,MAAM,CAAC;AAGd,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAmC,EAAO,EAAE;IACpE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,OAAwB,EACD,EAAE;IACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO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C,CAAC,CAAC,CAAC,CAC1E;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n isHex,\n toHex,\n type Hex,\n type SignableMessage,\n bytesToHex,\n type TypedData,\n type TypedDataDefinition,\n getTypesForEIP712Domain,\n validateTypedData,\n} from \"viem\";\nimport type { TypedDataDefinition as WalletServerTypedDataDefinition } from \"@alchemy/wallet-api-types\";\n\nexport const castToHex = (val: string | number | bigint | Hex): Hex => {\n if (isHex(val)) {\n return val;\n }\n return toHex(val);\n};\n\nexport const signableMessageToJsonSafe = (\n message: SignableMessage,\n): string | { raw: Hex } => {\n if (typeof message === \"string\") {\n return message;\n }\n return {\n raw:\n typeof message.raw === \"string\" ? message.raw : bytesToHex(message.raw),\n };\n};\n\n// Purposefully not using `formatTypedData` from the wallet server types pkg\n// here, since that would require typebox at runtime (which breaks RN).\nexport const typedDataToJsonSafe = ({\n domain,\n primaryType,\n message,\n types,\n}: TypedDataDefinition<\n TypedData | Record<string, unknown>\n>): WalletServerTypedDataDefinition => {\n validateTypedData({ domain, primaryType, message, types });\n return {\n domain: {\n ...domain,\n chainId:\n typeof domain?.chainId === \"bigint\"\n ? Number(domain.chainId)\n : domain?.chainId,\n },\n types: {\n ...Object.fromEntries(\n Object.entries(types).map(([key, value]) => [\n key,\n Array.isArray(value) ? [...value] : [],\n ]),\n ),\n EIP712Domain: [...getTypesForEIP712Domain({ domain })],\n },\n primaryType,\n message: JSON.parse(\n JSON.stringify(message, (_, v) => (typeof v === \"bigint\" ? toHex(v) : v)),\n ),\n };\n};\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "5.0.0-beta.23";
1
+ export declare const VERSION = "5.0.0-beta.25";
@@ -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 = "5.0.0-beta.23";
3
+ export const VERSION = "5.0.0-beta.25";
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,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.23\";\n"]}
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"]}
@@ -1,7 +1,7 @@
1
- import { type Hex, type Prettify, type TypedDataDefinition } from "viem";
1
+ import { type Hex, type Prettify, type TypedData, type TypedDataDefinition } 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 = Prettify<TypedDataDefinition<TypedData | Record<string, unknown>> & {
5
5
  account?: AccountParam;
6
6
  }>;
7
7
  export type SignTypedDataResult = Prettify<Hex>;
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;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,EACL,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,mBAAmB,EACzB,MAAM,MAAM,CAAC;AACd,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,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;IACzD,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"}
@@ -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 {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
36
- * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
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 {Hex} [params.slippage] - The maximum acceptable slippage percentage
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, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap
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.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,YAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
@@ -1,8 +1,8 @@
1
- import { type Hex, type SignableMessage, type TypedDataDefinition } from "viem";
1
+ import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
2
2
  import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
3
3
  export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
4
4
  export declare const signableMessageToJsonSafe: (message: SignableMessage) => string | {
5
5
  raw: Hex;
6
6
  };
7
- export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition) => WalletServerTypedDataDefinition;
7
+ export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition<TypedData | Record<string, unknown>>) => WalletServerTypedDataDefinition;
8
8
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EAEzB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,mBAAmB,IAAI,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAExG,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,GAK/D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,SAAS,eAAe,KACvB,MAAM,GAAG;IAAE,GAAG,EAAE,GAAG,CAAA;CAQrB,CAAC;AAIF,eAAO,MAAM,mBAAmB,GAAI,0CAKjC,mBAAmB,KAAG,+BAuBxB,CAAC"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,eAAe,EAEpB,KAAK,SAAS,EACd,KAAK,mBAAmB,EAGzB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,mBAAmB,IAAI,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAExG,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,GAK/D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,SAAS,eAAe,KACvB,MAAM,GAAG;IAAE,GAAG,EAAE,GAAG,CAAA;CAQrB,CAAC;AAIF,eAAO,MAAM,mBAAmB,GAAI,0CAKjC,mBAAmB,CACpB,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACpC,KAAG,+BAwBH,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.0.0-beta.23";
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.24",
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.24",
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": "f30a06d06c9601f55681307c331b690d51978af9"
79
+ "gitHead": "f250979fa0141a06cd343c36d129c3faf838a9be"
80
80
  }
@@ -1,4 +1,9 @@
1
- import { type Hex, type Prettify, type TypedDataDefinition } from "viem";
1
+ import {
2
+ type Hex,
3
+ type Prettify,
4
+ type TypedData,
5
+ type TypedDataDefinition,
6
+ } from "viem";
2
7
  import type { InnerWalletApiClient } from "../types.ts";
3
8
  import { prepareSign } from "./prepareSign.js";
4
9
  import { signSignatureRequest } from "./signSignatureRequest.js";
@@ -8,7 +13,7 @@ import { LOGGER } from "../logger.js";
8
13
  import { resolveAddress, type AccountParam } from "../utils/resolve.js";
9
14
 
10
15
  export type SignTypedDataParams = Prettify<
11
- TypedDataDefinition & {
16
+ TypedDataDefinition<TypedData | Record<string, unknown>> & {
12
17
  account?: AccountParam;
13
18
  }
14
19
  >;
@@ -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 {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)
65
- * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)
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 {Hex} [params.slippage] - The maximum acceptable slippage percentage
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, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap
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,
@@ -4,8 +4,10 @@ import {
4
4
  type Hex,
5
5
  type SignableMessage,
6
6
  bytesToHex,
7
+ type TypedData,
7
8
  type TypedDataDefinition,
8
9
  getTypesForEIP712Domain,
10
+ validateTypedData,
9
11
  } from "viem";
10
12
  import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
11
13
 
@@ -35,7 +37,10 @@ export const typedDataToJsonSafe = ({
35
37
  primaryType,
36
38
  message,
37
39
  types,
38
- }: TypedDataDefinition): WalletServerTypedDataDefinition => {
40
+ }: TypedDataDefinition<
41
+ TypedData | Record<string, unknown>
42
+ >): WalletServerTypedDataDefinition => {
43
+ validateTypedData({ domain, primaryType, message, types });
39
44
  return {
40
45
  domain: {
41
46
  ...domain,
@@ -48,7 +53,7 @@ export const typedDataToJsonSafe = ({
48
53
  ...Object.fromEntries(
49
54
  Object.entries(types).map(([key, value]) => [
50
55
  key,
51
- value ? [...value] : [],
56
+ Array.isArray(value) ? [...value] : [],
52
57
  ]),
53
58
  ),
54
59
  EIP712Domain: [...getTypesForEIP712Domain({ domain })],
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 = "5.0.0-beta.24";
3
+ export const VERSION = "5.0.0-beta.26";