@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.
- package/dist/esm/actions/undelegateAccount.d.ts +2 -5
- package/dist/esm/actions/undelegateAccount.js +22 -38
- package/dist/esm/actions/undelegateAccount.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/undelegateAccount.d.ts +2 -5
- package/dist/types/actions/undelegateAccount.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/actions/undelegateAccount.ts +25 -53
- package/src/version.ts +1 -1
|
@@ -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 {
|
|
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<
|
|
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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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 {
|
|
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
|
|
31
|
+
const account = params?.account
|
|
34
32
|
? resolveAddress(params.account)
|
|
35
33
|
: client.account.address;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
60
|
-
const
|
|
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
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
...
|
|
72
|
-
|
|
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,
|
|
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,CAAC,IAAI,CAAC,yBAAyB,EAAE;QACrC,OAAO;QACP,OAAO,EAAE,MAAM,EAAE,OAAO;KACzB,CAAC,CAAC;IAEH,+DAA+D;IAC/D,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE;QAC1C,KAAK,EAAE,EAAE;QACT,OAAO;QACP,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,YAAY,EAAE;YACZ,GAAG,MAAM,EAAE,YAAY;YACvB,WAAW,EAAE;gBACX,UAAU,EAAE,4CAA4C;aACzD;SACF;KACF,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACtC,MAAM,IAAI,SAAS,CACjB,qFAAqF,QAAQ,CAAC,IAAI,GAAG,CACtG,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAE3C,eAAe;IACf,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE9D,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEzC,eAAe;IACf,MAAM,gBAAgB,GAAG,6BAA6B,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAE7E,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC7C,GAAG,WAAW;QACd,GAAG,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACxE,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 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"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.20";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.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 {
|
|
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<
|
|
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;
|
|
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;AAGxE,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAIhC,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,uBAAuB,CAAC,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,uBAAuB,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CA8ClC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.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.
|
|
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.
|
|
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": "
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
} from "
|
|
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 {
|
|
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<
|
|
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
|
|
52
|
+
const account = params?.account
|
|
63
53
|
? resolveAddress(params.account)
|
|
64
54
|
: client.account.address;
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 —
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
100
|
-
const
|
|
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
|
|
111
|
-
const
|
|
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
|
|
118
|
-
|
|
119
|
-
|
|
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