@alchemy/wallet-apis 5.0.0-beta.20 → 5.0.0-beta.21

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,9 +1,7 @@
1
1
  import type { Prettify } from "viem";
2
2
  import type { InnerWalletApiClient } from "../types.js";
3
3
  import { type AccountParam } from "../utils/resolve.js";
4
- import { wallet_sendPreparedCalls as SendMethodSchema } from "@alchemy/wallet-api-types/rpc";
5
- import { type MethodResponse } from "../utils/schema.js";
6
- type SendPreparedCallsResponse = MethodResponse<typeof SendMethodSchema>;
4
+ import { type SendPreparedCallsResult } from "./sendPreparedCalls.js";
7
5
  export type UndelegateAccountParams = Prettify<{
8
6
  account?: AccountParam;
9
7
  chainId?: number;
@@ -13,7 +11,7 @@ export type UndelegateAccountParams = Prettify<{
13
11
  };
14
12
  };
15
13
  }>;
16
- export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
14
+ export type UndelegateAccountResult = Prettify<SendPreparedCallsResult>;
17
15
  /**
18
16
  * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.
19
17
  * Gas is sponsored by Alchemy (requires Enterprise plan).
@@ -37,4 +35,3 @@ export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
37
35
  * ```
38
36
  */
39
37
  export declare function undelegateAccount(client: InnerWalletApiClient, params?: UndelegateAccountParams): Promise<UndelegateAccountResult>;
40
- export {};
@@ -1,12 +1,10 @@
1
1
  import { LOGGER } from "../logger.js";
2
2
  import { resolveAddress } from "../utils/resolve.js";
3
- import { wallet_prepareCalls as PrepareMethodSchema, wallet_sendPreparedCalls as SendMethodSchema, } from "@alchemy/wallet-api-types/rpc";
4
- import { methodSchema, encode, decode, } from "../utils/schema.js";
5
- import { signSignatureRequest } from "./signSignatureRequest.js";
3
+ import { prepareCalls } from "./prepareCalls.js";
4
+ import { signPreparedCalls } from "./signPreparedCalls.js";
5
+ import { sendPreparedCalls, } from "./sendPreparedCalls.js";
6
6
  import { BaseError } from "@alchemy/common";
7
- import { mergeClientCapabilities } from "../utils/capabilities.js";
8
- const prepareSchema = methodSchema(PrepareMethodSchema);
9
- const sendSchema = methodSchema(SendMethodSchema);
7
+ import { extractCapabilitiesForSending } from "../utils/capabilities.js";
10
8
  /**
11
9
  * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.
12
10
  * Gas is sponsored by Alchemy (requires Enterprise plan).
@@ -30,52 +28,38 @@ const sendSchema = methodSchema(SendMethodSchema);
30
28
  * ```
31
29
  */
32
30
  export async function undelegateAccount(client, params) {
33
- const from = params?.account
31
+ const account = params?.account
34
32
  ? resolveAddress(params.account)
35
33
  : client.account.address;
36
- const chainId = params?.chainId ?? client.chain.id;
37
- const capabilities = mergeClientCapabilities(client, params?.capabilities);
38
- LOGGER.info("undelegateAccount:start", { account: from, chainId });
39
- // Step 1: Prepare — wallet_prepareCalls with zero-address delegation, no calls
40
- const prepareRpcParams = encode(prepareSchema.request, {
41
- from,
42
- chainId,
34
+ LOGGER.info("undelegateAccount:start", {
35
+ account,
36
+ chainId: params?.chainId,
37
+ });
38
+ // Step 1: Prepare — zero-address delegation means "undelegate"
39
+ const prepared = await prepareCalls(client, {
40
+ calls: [],
41
+ account,
42
+ ...(params?.chainId != null ? { chainId: params.chainId } : {}),
43
43
  capabilities: {
44
- ...capabilities,
44
+ ...params?.capabilities,
45
45
  eip7702Auth: {
46
46
  delegation: "0x0000000000000000000000000000000000000000",
47
47
  },
48
48
  },
49
49
  });
50
- const prepareRpcResp = await client.request({
51
- method: "wallet_prepareCalls",
52
- params: [prepareRpcParams],
53
- });
54
- const prepared = decode(prepareSchema.response, prepareRpcResp);
55
50
  if (prepared.type !== "authorization") {
56
51
  throw new BaseError(`Unexpected response type from wallet_prepareCalls: expected "authorization", got "${prepared.type}"`);
57
52
  }
58
53
  LOGGER.debug("undelegateAccount:prepared");
59
- // Step 2: Sign the authorization
60
- const signature = await signSignatureRequest(client, {
61
- type: "eip7702Auth",
62
- data: {
63
- ...prepared.data,
64
- chainId: prepared.chainId,
65
- },
66
- });
54
+ // Step 2: Sign
55
+ const signedCalls = await signPreparedCalls(client, prepared);
67
56
  LOGGER.debug("undelegateAccount:signed");
68
- // Step 3: Send — wallet_sendPreparedCalls with the signed authorization
69
- const { signatureRequest: _, ...rest } = prepared;
70
- const sendRpcParams = encode(sendSchema.request, {
71
- ...rest,
72
- signature,
73
- });
74
- const sendRpcResp = await client.request({
75
- method: "wallet_sendPreparedCalls",
76
- params: [sendRpcParams],
57
+ // Step 3: Send
58
+ const sendCapabilities = extractCapabilitiesForSending(params?.capabilities);
59
+ const result = await sendPreparedCalls(client, {
60
+ ...signedCalls,
61
+ ...(sendCapabilities != null ? { capabilities: sendCapabilities } : {}),
77
62
  });
78
- const result = decode(sendSchema.response, sendRpcResp);
79
63
  LOGGER.info("undelegateAccount:done", { id: result.id });
80
64
  return result;
81
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"undelegateAccount.js","sourceRoot":"","sources":["../../../src/actions/undelegateAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,mBAAmB,IAAI,mBAAmB,EAC1C,wBAAwB,IAAI,gBAAgB,GAC7C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAEP,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,aAAa,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AACxD,MAAM,UAAU,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAgBlD;;;;;;;;;;;;;;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,EAAE;YACJ,GAAG,QAAQ,CAAC,IAAI;YAChB,OAAO,EAAE,QAAQ,CAAC,OAAO;SAC1B;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEzC,wEAAwE;IACxE,MAAM,EAAE,gBAAgB,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,CAAC;IAClD,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE;QAC/C,GAAG,IAAI;QACP,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACvC,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,aAAa,CAAC;KACxB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACxD,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport {\n wallet_prepareCalls as PrepareMethodSchema,\n wallet_sendPreparedCalls as SendMethodSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodResponse,\n} from \"../utils/schema.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { BaseError } from \"@alchemy/common\";\nimport { mergeClientCapabilities } from \"../utils/capabilities.js\";\n\nconst prepareSchema = methodSchema(PrepareMethodSchema);\nconst sendSchema = methodSchema(SendMethodSchema);\n\ntype SendPreparedCallsResponse = MethodResponse<typeof SendMethodSchema>;\n\nexport type UndelegateAccountParams = Prettify<{\n account?: AccountParam;\n chainId?: number;\n capabilities?: {\n paymaster?: {\n policyId: string;\n };\n };\n}>;\n\nexport type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;\n\n/**\n * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.\n * Gas is sponsored by Alchemy (requires Enterprise plan).\n *\n * A BSO (Bundler Sponsorship Override) policy ID must be provided either via\n * `params.capabilities.paymaster.policyId` or pre-configured on the client via `policyIds`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {UndelegateAccountParams} params - Parameters for undelegating the account\n * @param {AccountParam} [params.account] - The account to undelegate. Defaults to the client's account (signer address).\n * @param {number} [params.chainId] - The chain ID. Defaults to the client's chain.\n * @param {object} [params.capabilities] - Optional capabilities. If omitted, falls back to the policy ID(s) set on the client.\n * @param {object} [params.capabilities.paymaster] - Paymaster capabilities. Requires a BSO policy ID.\n * @param {string} [params.capabilities.paymaster.policyId] - The BSO policy ID to use for gas sponsorship.\n * @returns {Promise<UndelegateAccountResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * const result = await client.undelegateAccount();\n * const status = await client.waitForCallsStatus({ id: result.id });\n * ```\n */\nexport async function undelegateAccount(\n client: InnerWalletApiClient,\n params?: UndelegateAccountParams,\n): Promise<UndelegateAccountResult> {\n const from = params?.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const chainId = params?.chainId ?? client.chain.id;\n\n const capabilities = mergeClientCapabilities(client, params?.capabilities);\n\n LOGGER.info(\"undelegateAccount:start\", { account: from, chainId });\n\n // Step 1: Prepare — wallet_prepareCalls with zero-address delegation, no calls\n const prepareRpcParams = encode(prepareSchema.request, {\n from,\n chainId,\n capabilities: {\n ...capabilities,\n eip7702Auth: {\n delegation: \"0x0000000000000000000000000000000000000000\",\n },\n },\n });\n\n const prepareRpcResp = await client.request({\n method: \"wallet_prepareCalls\",\n params: [prepareRpcParams],\n });\n\n const prepared = decode(prepareSchema.response, prepareRpcResp);\n\n if (prepared.type !== \"authorization\") {\n throw new BaseError(\n `Unexpected response type from wallet_prepareCalls: expected \"authorization\", got \"${prepared.type}\"`,\n );\n }\n\n LOGGER.debug(\"undelegateAccount:prepared\");\n\n // Step 2: Sign the authorization\n const signature = await signSignatureRequest(client, {\n type: \"eip7702Auth\",\n data: {\n ...prepared.data,\n chainId: prepared.chainId,\n },\n });\n\n LOGGER.debug(\"undelegateAccount:signed\");\n\n // Step 3: Send — wallet_sendPreparedCalls with the signed authorization\n const { signatureRequest: _, ...rest } = prepared;\n const sendRpcParams = encode(sendSchema.request, {\n ...rest,\n signature,\n });\n\n const sendRpcResp = await client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [sendRpcParams],\n });\n\n const result = decode(sendSchema.response, sendRpcResp);\n LOGGER.info(\"undelegateAccount:done\", { id: result.id });\n return result;\n}\n"]}
1
+ {"version":3,"file":"undelegateAccount.js","sourceRoot":"","sources":["../../../src/actions/undelegateAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAczE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAAgC;IAEhC,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO;QAC7B,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,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ent":["import type { Prettify } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { prepareCalls } from \"./prepareCalls.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { BaseError } from \"@alchemy/common\";\nimport { extractCapabilitiesForSending } from \"../utils/capabilities.js\";\n\nexport type UndelegateAccountParams = Prettify<{\n account?: AccountParam;\n chainId?: number;\n capabilities?: {\n paymaster?: {\n policyId: string;\n };\n };\n}>;\n\nexport type UndelegateAccountResult = Prettify<SendPreparedCallsResult>;\n\n/**\n * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.\n * Gas is sponsored by Alchemy (requires Enterprise plan).\n *\n * A BSO (Bundler Sponsorship Override) policy ID must be provided either via\n * `params.capabilities.paymaster.policyId` or pre-configured on the client via `policyIds`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {UndelegateAccountParams} params - Parameters for undelegating the account\n * @param {AccountParam} [params.account] - The account to undelegate. Defaults to the client's account (signer address).\n * @param {number} [params.chainId] - The chain ID. Defaults to the client's chain.\n * @param {object} [params.capabilities] - Optional capabilities. If omitted, falls back to the policy ID(s) set on the client.\n * @param {object} [params.capabilities.paymaster] - Paymaster capabilities. Requires a BSO policy ID.\n * @param {string} [params.capabilities.paymaster.policyId] - The BSO policy ID to use for gas sponsorship.\n * @returns {Promise<UndelegateAccountResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * const result = await client.undelegateAccount();\n * const status = await client.waitForCallsStatus({ id: result.id });\n * ```\n */\nexport async function undelegateAccount(\n client: InnerWalletApiClient,\n params?: UndelegateAccountParams,\n): Promise<UndelegateAccountResult> {\n const account = params?.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.info(\"undelegateAccount:start\", {\n account,\n chainId: params?.chainId,\n });\n\n // Step 1: Prepare — zero-address delegation means \"undelegate\"\n const prepared = await prepareCalls(client, {\n calls: [],\n account,\n ...(params?.chainId != null ? { chainId: params.chainId } : {}),\n capabilities: {\n ...params?.capabilities,\n eip7702Auth: {\n delegation: \"0x0000000000000000000000000000000000000000\",\n },\n },\n });\n\n if (prepared.type !== \"authorization\") {\n throw new BaseError(\n `Unexpected response type from wallet_prepareCalls: expected \"authorization\", got \"${prepared.type}\"`,\n );\n }\n\n LOGGER.debug(\"undelegateAccount:prepared\");\n\n // Step 2: Sign\n const signedCalls = await signPreparedCalls(client, prepared);\n\n LOGGER.debug(\"undelegateAccount:signed\");\n\n // Step 3: Send\n const sendCapabilities = extractCapabilitiesForSending(params?.capabilities);\n\n const result = await sendPreparedCalls(client, {\n ...signedCalls,\n ...(sendCapabilities != null ? { capabilities: sendCapabilities } : {}),\n });\n\n LOGGER.info(\"undelegateAccount:done\", { id: result.id });\n return result;\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "5.0.0-beta.19";
1
+ export declare const VERSION = "5.0.0-beta.20";
@@ -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.19";
3
+ export const VERSION = "5.0.0-beta.20";
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.19\";\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.20\";\n"]}
@@ -1,9 +1,7 @@
1
1
  import type { Prettify } from "viem";
2
2
  import type { InnerWalletApiClient } from "../types.js";
3
3
  import { type AccountParam } from "../utils/resolve.js";
4
- import { wallet_sendPreparedCalls as SendMethodSchema } from "@alchemy/wallet-api-types/rpc";
5
- import { type MethodResponse } from "../utils/schema.js";
6
- type SendPreparedCallsResponse = MethodResponse<typeof SendMethodSchema>;
4
+ import { type SendPreparedCallsResult } from "./sendPreparedCalls.js";
7
5
  export type UndelegateAccountParams = Prettify<{
8
6
  account?: AccountParam;
9
7
  chainId?: number;
@@ -13,7 +11,7 @@ export type UndelegateAccountParams = Prettify<{
13
11
  };
14
12
  };
15
13
  }>;
16
- export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
14
+ export type UndelegateAccountResult = Prettify<SendPreparedCallsResult>;
17
15
  /**
18
16
  * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.
19
17
  * Gas is sponsored by Alchemy (requires Enterprise plan).
@@ -37,5 +35,4 @@ export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
37
35
  * ```
38
36
  */
39
37
  export declare function undelegateAccount(client: InnerWalletApiClient, params?: UndelegateAccountParams): Promise<UndelegateAccountResult>;
40
- export {};
41
38
  //# sourceMappingURL=undelegateAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"undelegateAccount.d.ts","sourceRoot":"","sources":["../../../src/actions/undelegateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAEL,wBAAwB,IAAI,gBAAgB,EAC7C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EA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;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,uBAAuB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CA8ClC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.0.0-beta.19";
1
+ export declare const VERSION = "5.0.0-beta.20";
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.20",
3
+ "version": "5.0.0-beta.21",
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.20",
58
+ "@alchemy/common": "5.0.0-beta.21",
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": "e8b35b489e1f129877c618752b35b4fb05149a55"
79
+ "gitHead": "f7b6c8132c10a86488ea3ebbe73dce14965fe669"
80
80
  }
@@ -2,24 +2,14 @@ import type { Prettify } from "viem";
2
2
  import type { InnerWalletApiClient } from "../types.js";
3
3
  import { LOGGER } from "../logger.js";
4
4
  import { resolveAddress, type AccountParam } from "../utils/resolve.js";
5
+ import { prepareCalls } from "./prepareCalls.js";
6
+ import { signPreparedCalls } from "./signPreparedCalls.js";
5
7
  import {
6
- wallet_prepareCalls as PrepareMethodSchema,
7
- wallet_sendPreparedCalls as SendMethodSchema,
8
- } from "@alchemy/wallet-api-types/rpc";
9
- import {
10
- methodSchema,
11
- encode,
12
- decode,
13
- type MethodResponse,
14
- } from "../utils/schema.js";
15
- import { signSignatureRequest } from "./signSignatureRequest.js";
8
+ sendPreparedCalls,
9
+ type SendPreparedCallsResult,
10
+ } from "./sendPreparedCalls.js";
16
11
  import { BaseError } from "@alchemy/common";
17
- import { mergeClientCapabilities } from "../utils/capabilities.js";
18
-
19
- const prepareSchema = methodSchema(PrepareMethodSchema);
20
- const sendSchema = methodSchema(SendMethodSchema);
21
-
22
- type SendPreparedCallsResponse = MethodResponse<typeof SendMethodSchema>;
12
+ import { extractCapabilitiesForSending } from "../utils/capabilities.js";
23
13
 
24
14
  export type UndelegateAccountParams = Prettify<{
25
15
  account?: AccountParam;
@@ -31,7 +21,7 @@ export type UndelegateAccountParams = Prettify<{
31
21
  };
32
22
  }>;
33
23
 
34
- export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
24
+ export type UndelegateAccountResult = Prettify<SendPreparedCallsResult>;
35
25
 
36
26
  /**
37
27
  * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.
@@ -59,35 +49,28 @@ export async function undelegateAccount(
59
49
  client: InnerWalletApiClient,
60
50
  params?: UndelegateAccountParams,
61
51
  ): Promise<UndelegateAccountResult> {
62
- const from = params?.account
52
+ const account = params?.account
63
53
  ? resolveAddress(params.account)
64
54
  : client.account.address;
65
55
 
66
- const chainId = params?.chainId ?? client.chain.id;
67
-
68
- const capabilities = mergeClientCapabilities(client, params?.capabilities);
69
-
70
- LOGGER.info("undelegateAccount:start", { account: from, chainId });
56
+ LOGGER.info("undelegateAccount:start", {
57
+ account,
58
+ chainId: params?.chainId,
59
+ });
71
60
 
72
- // Step 1: Prepare — wallet_prepareCalls with zero-address delegation, no calls
73
- const prepareRpcParams = encode(prepareSchema.request, {
74
- from,
75
- chainId,
61
+ // Step 1: Prepare — zero-address delegation means "undelegate"
62
+ const prepared = await prepareCalls(client, {
63
+ calls: [],
64
+ account,
65
+ ...(params?.chainId != null ? { chainId: params.chainId } : {}),
76
66
  capabilities: {
77
- ...capabilities,
67
+ ...params?.capabilities,
78
68
  eip7702Auth: {
79
69
  delegation: "0x0000000000000000000000000000000000000000",
80
70
  },
81
71
  },
82
72
  });
83
73
 
84
- const prepareRpcResp = await client.request({
85
- method: "wallet_prepareCalls",
86
- params: [prepareRpcParams],
87
- });
88
-
89
- const prepared = decode(prepareSchema.response, prepareRpcResp);
90
-
91
74
  if (prepared.type !== "authorization") {
92
75
  throw new BaseError(
93
76
  `Unexpected response type from wallet_prepareCalls: expected "authorization", got "${prepared.type}"`,
@@ -96,30 +79,19 @@ export async function undelegateAccount(
96
79
 
97
80
  LOGGER.debug("undelegateAccount:prepared");
98
81
 
99
- // Step 2: Sign the authorization
100
- const signature = await signSignatureRequest(client, {
101
- type: "eip7702Auth",
102
- data: {
103
- ...prepared.data,
104
- chainId: prepared.chainId,
105
- },
106
- });
82
+ // Step 2: Sign
83
+ const signedCalls = await signPreparedCalls(client, prepared);
107
84
 
108
85
  LOGGER.debug("undelegateAccount:signed");
109
86
 
110
- // Step 3: Send — wallet_sendPreparedCalls with the signed authorization
111
- const { signatureRequest: _, ...rest } = prepared;
112
- const sendRpcParams = encode(sendSchema.request, {
113
- ...rest,
114
- signature,
115
- });
87
+ // Step 3: Send
88
+ const sendCapabilities = extractCapabilitiesForSending(params?.capabilities);
116
89
 
117
- const sendRpcResp = await client.request({
118
- method: "wallet_sendPreparedCalls",
119
- params: [sendRpcParams],
90
+ const result = await sendPreparedCalls(client, {
91
+ ...signedCalls,
92
+ ...(sendCapabilities != null ? { capabilities: sendCapabilities } : {}),
120
93
  });
121
94
 
122
- const result = decode(sendSchema.response, sendRpcResp);
123
95
  LOGGER.info("undelegateAccount:done", { id: result.id });
124
96
  return result;
125
97
  }
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.20";
3
+ export const VERSION = "5.0.0-beta.21";