@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.
- package/dist/esm/actions/undelegateAccount.d.ts +5 -8
- package/dist/esm/actions/undelegateAccount.js +14 -47
- 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 +5 -8
- 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 +16 -73
- package/src/version.ts +1 -1
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type
|
|
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 {
|
|
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
|
-
|
|
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<
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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
|
|
28
|
+
const account = params?.account
|
|
34
29
|
? resolveAddress(params.account)
|
|
35
30
|
: client.account.address;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
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:
|
|
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/undelegateAccount.ts"],"names":[],"mappings":"
|
|
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"]}
|
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.21";
|
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.21\";\n"]}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type
|
|
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 {
|
|
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
|
-
|
|
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<
|
|
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 {
|
|
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;
|
|
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"}
|
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.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.
|
|
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.
|
|
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": "
|
|
79
|
+
"gitHead": "cd83c2c18bd4de73dfbf56cef2516a4e45ef31ba"
|
|
80
80
|
}
|
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
import type
|
|
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
|
-
|
|
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<
|
|
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 {
|
|
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
|
|
45
|
+
const account = params?.account
|
|
63
46
|
? resolveAddress(params.account)
|
|
64
47
|
: client.account.address;
|
|
65
48
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
LOGGER.info("undelegateAccount:start", { account: from, chainId });
|
|
49
|
+
LOGGER.info("undelegateAccount:start", {
|
|
50
|
+
account,
|
|
51
|
+
chain: params?.chain,
|
|
52
|
+
});
|
|
71
53
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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:
|
|
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