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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,17 @@
1
- import type { Prettify } from "viem";
1
+ import { type Chain, 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 SendCallsResult } from "./sendCalls.js";
7
5
  export type UndelegateAccountParams = Prettify<{
8
6
  account?: AccountParam;
9
- chainId?: number;
7
+ chain?: Pick<Chain, "id">;
10
8
  capabilities?: {
11
9
  paymaster?: {
12
10
  policyId: string;
13
11
  };
14
12
  };
15
13
  }>;
16
- export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
14
+ export type UndelegateAccountResult = Prettify<SendCallsResult>;
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).
@@ -24,7 +22,7 @@ export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
24
22
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
25
23
  * @param {UndelegateAccountParams} params - Parameters for undelegating the account
26
24
  * @param {AccountParam} [params.account] - The account to undelegate. Defaults to the client's account (signer address).
27
- * @param {number} [params.chainId] - The chain ID. Defaults to the client's chain.
25
+ * @param {object} [params.chain] - The chain. Defaults to the client's chain.
28
26
  * @param {object} [params.capabilities] - Optional capabilities. If omitted, falls back to the policy ID(s) set on the client.
29
27
  * @param {object} [params.capabilities.paymaster] - Paymaster capabilities. Requires a BSO policy ID.
30
28
  * @param {string} [params.capabilities.paymaster.policyId] - The BSO policy ID to use for gas sponsorship.
@@ -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,7 @@
1
+ import { zeroAddress } from "viem";
1
2
  import { LOGGER } from "../logger.js";
2
3
  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";
6
- import { BaseError } from "@alchemy/common";
7
- import { mergeClientCapabilities } from "../utils/capabilities.js";
8
- const prepareSchema = methodSchema(PrepareMethodSchema);
9
- const sendSchema = methodSchema(SendMethodSchema);
4
+ import { sendCalls } from "./sendCalls.js";
10
5
  /**
11
6
  * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.
12
7
  * Gas is sponsored by Alchemy (requires Enterprise plan).
@@ -17,7 +12,7 @@ const sendSchema = methodSchema(SendMethodSchema);
17
12
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
18
13
  * @param {UndelegateAccountParams} params - Parameters for undelegating the account
19
14
  * @param {AccountParam} [params.account] - The account to undelegate. Defaults to the client's account (signer address).
20
- * @param {number} [params.chainId] - The chain ID. Defaults to the client's chain.
15
+ * @param {object} [params.chain] - The chain. Defaults to the client's chain.
21
16
  * @param {object} [params.capabilities] - Optional capabilities. If omitted, falls back to the policy ID(s) set on the client.
22
17
  * @param {object} [params.capabilities.paymaster] - Paymaster capabilities. Requires a BSO policy ID.
23
18
  * @param {string} [params.capabilities.paymaster.policyId] - The BSO policy ID to use for gas sponsorship.
@@ -30,52 +25,24 @@ const sendSchema = methodSchema(SendMethodSchema);
30
25
  * ```
31
26
  */
32
27
  export async function undelegateAccount(client, params) {
33
- const from = params?.account
28
+ const account = params?.account
34
29
  ? resolveAddress(params.account)
35
30
  : 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,
31
+ LOGGER.info("undelegateAccount:start", {
32
+ account,
33
+ chain: params?.chain,
34
+ });
35
+ const result = await sendCalls(client, {
36
+ calls: [],
37
+ account,
38
+ ...(params?.chain != null ? { chain: params.chain } : {}),
43
39
  capabilities: {
44
- ...capabilities,
40
+ ...params?.capabilities,
45
41
  eip7702Auth: {
46
- delegation: "0x0000000000000000000000000000000000000000",
42
+ delegation: zeroAddress,
47
43
  },
48
44
  },
49
45
  });
50
- const prepareRpcResp = await client.request({
51
- method: "wallet_prepareCalls",
52
- params: [prepareRpcParams],
53
- });
54
- const prepared = decode(prepareSchema.response, prepareRpcResp);
55
- if (prepared.type !== "authorization") {
56
- throw new BaseError(`Unexpected response type from wallet_prepareCalls: expected "authorization", got "${prepared.type}"`);
57
- }
58
- 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
- });
67
- 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],
77
- });
78
- const result = decode(sendSchema.response, sendRpcResp);
79
46
  LOGGER.info("undelegateAccount:done", { id: result.id });
80
47
  return result;
81
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"undelegateAccount.js","sourceRoot":"","sources":["../../../src/actions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,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":"AAAA,OAAO,EAAE,WAAW,EAA6B,MAAM,MAAM,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAwB,MAAM,gBAAgB,CAAC;AAcjE;;;;;;;;;;;;;;;;;;;;;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,CAAC,IAAI,CAAC,yBAAyB,EAAE;QACrC,OAAO;QACP,KAAK,EAAE,MAAM,EAAE,KAAK;KACrB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE;QACrC,KAAK,EAAE,EAAE;QACT,OAAO;QACP,GAAG,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,YAAY,EAAE;YACZ,GAAG,MAAM,EAAE,YAAY;YACvB,WAAW,EAAE;gBACX,UAAU,EAAE,WAAW;aACxB;SACF;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { zeroAddress, type Chain, type Prettify } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { sendCalls, type SendCallsResult } from \"./sendCalls.js\";\n\nexport type UndelegateAccountParams = Prettify<{\n account?: AccountParam;\n chain?: Pick<Chain, \"id\">;\n capabilities?: {\n paymaster?: {\n policyId: string;\n };\n };\n}>;\n\nexport type UndelegateAccountResult = Prettify<SendCallsResult>;\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 {object} [params.chain] - The chain. 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 chain: params?.chain,\n });\n\n const result = await sendCalls(client, {\n calls: [],\n account,\n ...(params?.chain != null ? { chain: params.chain } : {}),\n capabilities: {\n ...params?.capabilities,\n eip7702Auth: {\n delegation: zeroAddress,\n },\n },\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.21";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "5.0.0-beta.19";
3
+ export const VERSION = "5.0.0-beta.21";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,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.21\";\n"]}
@@ -1,19 +1,17 @@
1
- import type { Prettify } from "viem";
1
+ import { type Chain, 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 SendCallsResult } from "./sendCalls.js";
7
5
  export type UndelegateAccountParams = Prettify<{
8
6
  account?: AccountParam;
9
- chainId?: number;
7
+ chain?: Pick<Chain, "id">;
10
8
  capabilities?: {
11
9
  paymaster?: {
12
10
  policyId: string;
13
11
  };
14
12
  };
15
13
  }>;
16
- export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
14
+ export type UndelegateAccountResult = Prettify<SendCallsResult>;
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).
@@ -24,7 +22,7 @@ export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
24
22
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
25
23
  * @param {UndelegateAccountParams} params - Parameters for undelegating the account
26
24
  * @param {AccountParam} [params.account] - The account to undelegate. Defaults to the client's account (signer address).
27
- * @param {number} [params.chainId] - The chain ID. Defaults to the client's chain.
25
+ * @param {object} [params.chain] - The chain. Defaults to the client's chain.
28
26
  * @param {object} [params.capabilities] - Optional capabilities. If omitted, falls back to the policy ID(s) set on the client.
29
27
  * @param {object} [params.capabilities.paymaster] - Paymaster capabilities. Requires a BSO policy ID.
30
28
  * @param {string} [params.capabilities.paymaster.policyId] - The BSO policy ID to use for gas sponsorship.
@@ -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,EAIL,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAQ5B,KAAK,yBAAyB,GAAG,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzE,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE;YACV,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC,yBAAyB,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,uBAAuB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAgElC"}
1
+ {"version":3,"file":"undelegateAccount.d.ts","sourceRoot":"","sources":["../../../src/actions/undelegateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1B,YAAY,CAAC,EAAE;QACb,SAAS,CAAC,EAAE;YACV,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,uBAAuB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAwBlC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.0.0-beta.19";
1
+ export declare const VERSION = "5.0.0-beta.21";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy/wallet-apis",
3
- "version": "5.0.0-beta.20",
3
+ "version": "5.0.0-beta.22",
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.22",
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": "cd83c2c18bd4de73dfbf56cef2516a4e45ef31ba"
80
80
  }
@@ -1,29 +1,12 @@
1
- import type { Prettify } from "viem";
1
+ import { zeroAddress, type Chain, 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 {
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";
16
- 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>;
5
+ import { sendCalls, type SendCallsResult } from "./sendCalls.js";
23
6
 
24
7
  export type UndelegateAccountParams = Prettify<{
25
8
  account?: AccountParam;
26
- chainId?: number;
9
+ chain?: Pick<Chain, "id">;
27
10
  capabilities?: {
28
11
  paymaster?: {
29
12
  policyId: string;
@@ -31,7 +14,7 @@ export type UndelegateAccountParams = Prettify<{
31
14
  };
32
15
  }>;
33
16
 
34
- export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
17
+ export type UndelegateAccountResult = Prettify<SendCallsResult>;
35
18
 
36
19
  /**
37
20
  * Prepares, signs, and sends an EIP-7702 undelegation to remove delegation from an EOA.
@@ -43,7 +26,7 @@ export type UndelegateAccountResult = Prettify<SendPreparedCallsResponse>;
43
26
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
44
27
  * @param {UndelegateAccountParams} params - Parameters for undelegating the account
45
28
  * @param {AccountParam} [params.account] - The account to undelegate. Defaults to the client's account (signer address).
46
- * @param {number} [params.chainId] - The chain ID. Defaults to the client's chain.
29
+ * @param {object} [params.chain] - The chain. Defaults to the client's chain.
47
30
  * @param {object} [params.capabilities] - Optional capabilities. If omitted, falls back to the policy ID(s) set on the client.
48
31
  * @param {object} [params.capabilities.paymaster] - Paymaster capabilities. Requires a BSO policy ID.
49
32
  * @param {string} [params.capabilities.paymaster.policyId] - The BSO policy ID to use for gas sponsorship.
@@ -59,67 +42,27 @@ export async function undelegateAccount(
59
42
  client: InnerWalletApiClient,
60
43
  params?: UndelegateAccountParams,
61
44
  ): Promise<UndelegateAccountResult> {
62
- const from = params?.account
45
+ const account = params?.account
63
46
  ? resolveAddress(params.account)
64
47
  : client.account.address;
65
48
 
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 });
49
+ LOGGER.info("undelegateAccount:start", {
50
+ account,
51
+ chain: params?.chain,
52
+ });
71
53
 
72
- // Step 1: Prepare — wallet_prepareCalls with zero-address delegation, no calls
73
- const prepareRpcParams = encode(prepareSchema.request, {
74
- from,
75
- chainId,
54
+ const result = await sendCalls(client, {
55
+ calls: [],
56
+ account,
57
+ ...(params?.chain != null ? { chain: params.chain } : {}),
76
58
  capabilities: {
77
- ...capabilities,
59
+ ...params?.capabilities,
78
60
  eip7702Auth: {
79
- delegation: "0x0000000000000000000000000000000000000000",
61
+ delegation: zeroAddress,
80
62
  },
81
63
  },
82
64
  });
83
65
 
84
- const prepareRpcResp = await client.request({
85
- method: "wallet_prepareCalls",
86
- params: [prepareRpcParams],
87
- });
88
-
89
- const prepared = decode(prepareSchema.response, prepareRpcResp);
90
-
91
- if (prepared.type !== "authorization") {
92
- throw new BaseError(
93
- `Unexpected response type from wallet_prepareCalls: expected "authorization", got "${prepared.type}"`,
94
- );
95
- }
96
-
97
- LOGGER.debug("undelegateAccount:prepared");
98
-
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
- });
107
-
108
- LOGGER.debug("undelegateAccount:signed");
109
-
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
- });
116
-
117
- const sendRpcResp = await client.request({
118
- method: "wallet_sendPreparedCalls",
119
- params: [sendRpcParams],
120
- });
121
-
122
- const result = decode(sendSchema.response, sendRpcResp);
123
66
  LOGGER.info("undelegateAccount:done", { id: result.id });
124
67
  return result;
125
68
  }
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.22";