@account-kit/wallet-client 0.1.0-alpha.8 → 4.50.0
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/LICENSE +21 -0
- package/dist/esm/client/actions/formatSign.d.ts +30 -0
- package/dist/esm/client/actions/formatSign.js +32 -0
- package/dist/esm/client/actions/formatSign.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +6 -3
- package/dist/esm/client/actions/getCallsStatus.js +3 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +10 -11
- package/dist/esm/client/actions/grantPermissions.js +26 -12
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +10 -3
- package/dist/esm/client/actions/listAccounts.js +14 -2
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +6 -3
- package/dist/esm/client/actions/prepareCalls.js +12 -8
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/prepareSign.d.ts +28 -0
- package/dist/esm/client/actions/prepareSign.js +31 -0
- package/dist/esm/client/actions/prepareSign.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +3 -1
- package/dist/esm/client/actions/requestAccount.js +5 -3
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/esm/client/actions/sendPreparedCalls.js +2 -0
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +5 -2
- package/dist/esm/client/actions/signMessage.js +5 -2
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +2 -2
- package/dist/esm/client/actions/signPreparedCalls.js +28 -39
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +6 -10
- package/dist/esm/client/actions/signSignatureRequest.js +4 -7
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +2 -0
- package/dist/esm/client/actions/signTypedData.js +2 -0
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +0 -2
- package/dist/esm/client/decorator.js +1 -3
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +10 -6
- package/dist/esm/client/index.js +18 -21
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +1 -5
- package/dist/esm/exports/index.js +1 -6
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/internal/account.d.ts +33 -0
- package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +33 -35
- package/dist/esm/internal/account.js.map +1 -0
- package/dist/esm/types.d.ts +5 -11
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts +14 -1
- package/dist/esm/utils.js +13 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +4 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/client/actions/formatSign.d.ts +31 -0
- package/dist/types/client/actions/formatSign.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +6 -3
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +10 -11
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +10 -3
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +6 -3
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/prepareSign.d.ts +29 -0
- package/dist/types/client/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +3 -1
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +5 -2
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +2 -2
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +6 -10
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +2 -0
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +0 -2
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +10 -6
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +1 -5
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/internal/account.d.ts +34 -0
- package/dist/types/internal/account.d.ts.map +1 -0
- package/dist/types/types.d.ts +5 -11
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +14 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +33 -28
- package/src/client/actions/formatSign.ts +55 -0
- package/src/client/actions/getCallsStatus.ts +10 -6
- package/src/client/actions/grantPermissions.ts +46 -18
- package/src/client/actions/listAccounts.ts +22 -5
- package/src/client/actions/prepareCalls.ts +22 -16
- package/src/client/actions/prepareSign.ts +51 -0
- package/src/client/actions/requestAccount.ts +6 -4
- package/src/client/actions/sendPreparedCalls.ts +3 -1
- package/src/client/actions/signMessage.ts +5 -2
- package/src/client/actions/signPreparedCalls.ts +40 -45
- package/src/client/actions/signSignatureRequest.ts +12 -15
- package/src/client/actions/signTypedData.ts +2 -0
- package/src/client/decorator.ts +1 -8
- package/src/client/index.ts +41 -33
- package/src/exports/index.ts +1 -13
- package/src/{isomorphic/utils/createAccount.ts → internal/account.ts} +37 -54
- package/src/types.ts +7 -18
- package/src/utils.ts +15 -1
- package/src/version.ts +3 -0
- package/dist/esm/capabilities/eip7702Auth.d.ts +0 -4
- package/dist/esm/capabilities/eip7702Auth.js +0 -18
- package/dist/esm/capabilities/eip7702Auth.js.map +0 -1
- package/dist/esm/capabilities/index.d.ts +0 -38
- package/dist/esm/capabilities/index.js +0 -12
- package/dist/esm/capabilities/index.js.map +0 -1
- package/dist/esm/capabilities/overrides.d.ts +0 -26
- package/dist/esm/capabilities/overrides.js +0 -14
- package/dist/esm/capabilities/overrides.js.map +0 -1
- package/dist/esm/capabilities/paymaster.d.ts +0 -3
- package/dist/esm/capabilities/paymaster.js +0 -5
- package/dist/esm/capabilities/paymaster.js.map +0 -1
- package/dist/esm/capabilities/permissions/index.d.ts +0 -145
- package/dist/esm/capabilities/permissions/index.js +0 -83
- package/dist/esm/capabilities/permissions/index.js.map +0 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +0 -36
- package/dist/esm/capabilities/permissions/mav2.js +0 -88
- package/dist/esm/capabilities/permissions/mav2.js.map +0 -1
- package/dist/esm/client/actions/createAccount.d.ts +0 -35
- package/dist/esm/client/actions/createAccount.js +0 -32
- package/dist/esm/client/actions/createAccount.js.map +0 -1
- package/dist/esm/client/client.e2e-test.d.ts +0 -1
- package/dist/esm/client/client.e2e-test.js +0 -375
- package/dist/esm/client/client.e2e-test.js.map +0 -1
- package/dist/esm/exports/internal.d.ts +0 -13
- package/dist/esm/exports/internal.js +0 -15
- package/dist/esm/exports/internal.js.map +0 -1
- package/dist/esm/isomorphic/actions/createSession.d.ts +0 -14
- package/dist/esm/isomorphic/actions/createSession.js +0 -89
- package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -21
- package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -113
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -8
- package/dist/esm/isomorphic/actions/prepareCalls.js +0 -101
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -148
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
- package/dist/esm/isomorphic/client.d.ts +0 -239
- package/dist/esm/isomorphic/client.js +0 -37
- package/dist/esm/isomorphic/client.js.map +0 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +0 -18
- package/dist/esm/isomorphic/utils/7702.js +0 -74
- package/dist/esm/isomorphic/utils/7702.js.map +0 -1
- package/dist/esm/isomorphic/utils/createAccount.d.ts +0 -23
- package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
- package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
- package/dist/esm/isomorphic/utils/decodeSignature.js +0 -13
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
- package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
- package/dist/esm/local/client.d.ts +0 -3
- package/dist/esm/local/client.js +0 -97
- package/dist/esm/local/client.js.map +0 -1
- package/dist/esm/remote/client.d.ts +0 -9
- package/dist/esm/remote/client.js +0 -41
- package/dist/esm/remote/client.js.map +0 -1
- package/dist/esm/rpc/examples.d.ts +0 -230
- package/dist/esm/rpc/examples.js +0 -314
- package/dist/esm/rpc/examples.js.map +0 -1
- package/dist/esm/rpc/request.d.ts +0 -711
- package/dist/esm/rpc/request.js +0 -213
- package/dist/esm/rpc/request.js.map +0 -1
- package/dist/esm/rpc/schema.d.ts +0 -659
- package/dist/esm/rpc/schema.js +0 -5
- package/dist/esm/rpc/schema.js.map +0 -1
- package/dist/esm/schemas.d.ts +0 -693
- package/dist/esm/schemas.js +0 -419
- package/dist/esm/schemas.js.map +0 -1
- package/dist/types/capabilities/eip7702Auth.d.ts +0 -5
- package/dist/types/capabilities/eip7702Auth.d.ts.map +0 -1
- package/dist/types/capabilities/index.d.ts +0 -39
- package/dist/types/capabilities/index.d.ts.map +0 -1
- package/dist/types/capabilities/overrides.d.ts +0 -27
- package/dist/types/capabilities/overrides.d.ts.map +0 -1
- package/dist/types/capabilities/paymaster.d.ts +0 -4
- package/dist/types/capabilities/paymaster.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/index.d.ts +0 -146
- package/dist/types/capabilities/permissions/index.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +0 -37
- package/dist/types/capabilities/permissions/mav2.d.ts.map +0 -1
- package/dist/types/client/actions/createAccount.d.ts +0 -36
- package/dist/types/client/actions/createAccount.d.ts.map +0 -1
- package/dist/types/client/client.e2e-test.d.ts +0 -2
- package/dist/types/client/client.e2e-test.d.ts.map +0 -1
- package/dist/types/exports/internal.d.ts +0 -14
- package/dist/types/exports/internal.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/createSession.d.ts +0 -15
- package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -22
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -9
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -9
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
- package/dist/types/isomorphic/client.d.ts +0 -240
- package/dist/types/isomorphic/client.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/7702.d.ts +0 -19
- package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts +0 -24
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
- package/dist/types/local/client.d.ts +0 -4
- package/dist/types/local/client.d.ts.map +0 -1
- package/dist/types/remote/client.d.ts +0 -10
- package/dist/types/remote/client.d.ts.map +0 -1
- package/dist/types/rpc/examples.d.ts +0 -231
- package/dist/types/rpc/examples.d.ts.map +0 -1
- package/dist/types/rpc/request.d.ts +0 -712
- package/dist/types/rpc/request.d.ts.map +0 -1
- package/dist/types/rpc/schema.d.ts +0 -660
- package/dist/types/rpc/schema.d.ts.map +0 -1
- package/dist/types/schemas.d.ts +0 -694
- package/dist/types/schemas.d.ts.map +0 -1
- package/src/capabilities/eip7702Auth.ts +0 -26
- package/src/capabilities/index.ts +0 -12
- package/src/capabilities/overrides.ts +0 -35
- package/src/capabilities/paymaster.ts +0 -5
- package/src/capabilities/permissions/index.ts +0 -163
- package/src/capabilities/permissions/mav2.ts +0 -138
- package/src/client/actions/createAccount.ts +0 -53
- package/src/client/client.e2e-test.ts +0 -463
- package/src/exports/internal.ts +0 -16
- package/src/isomorphic/actions/createSession.ts +0 -151
- package/src/isomorphic/actions/getCallsStatus.ts +0 -170
- package/src/isomorphic/actions/prepareCalls.ts +0 -152
- package/src/isomorphic/actions/sendPreparedCalls.ts +0 -222
- package/src/isomorphic/client.ts +0 -94
- package/src/isomorphic/utils/7702.ts +0 -132
- package/src/isomorphic/utils/createDummySigner.ts +0 -27
- package/src/isomorphic/utils/decodeSignature.ts +0 -18
- package/src/isomorphic/utils/parsePermissionsContext.ts +0 -49
- package/src/isomorphic/utils/supportsFeature.ts +0 -34
- package/src/local/client.ts +0 -136
- package/src/remote/client.ts +0 -67
- package/src/rpc/examples.ts +0 -342
- package/src/rpc/request.ts +0 -299
- package/src/rpc/schema.ts +0 -40
- package/src/schemas.ts +0 -585
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Static } from "@sinclair/typebox";
|
|
2
|
+
import type { wallet_formatSign } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
4
|
+
import { toHex, type Address, type IsUndefined } from "viem";
|
|
5
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
6
|
+
|
|
7
|
+
export type FormatSignParams<
|
|
8
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
9
|
+
> = Omit<
|
|
10
|
+
WithoutChainId<
|
|
11
|
+
Static<
|
|
12
|
+
(typeof wallet_formatSign)["properties"]["Request"]["properties"]["params"]
|
|
13
|
+
>[0]
|
|
14
|
+
>,
|
|
15
|
+
"from"
|
|
16
|
+
> &
|
|
17
|
+
(IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });
|
|
18
|
+
|
|
19
|
+
export type FormatSignResult = Static<typeof wallet_formatSign>["ReturnType"];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Formats a signature request for signing messages or transactions.
|
|
23
|
+
*
|
|
24
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
25
|
+
* @param {FormatSignParams} params - Parameters for formatting the signature
|
|
26
|
+
* @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // Formats a signature
|
|
31
|
+
* const result = await client.formatSign({
|
|
32
|
+
* from: "0x1234...",
|
|
33
|
+
* signature: {
|
|
34
|
+
* type: "ecdsa",
|
|
35
|
+
* data: "0xabcd..."
|
|
36
|
+
* },
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export async function formatSign<
|
|
41
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
42
|
+
>(
|
|
43
|
+
client: InnerWalletApiClient,
|
|
44
|
+
params: FormatSignParams<TAccount>,
|
|
45
|
+
): Promise<FormatSignResult> {
|
|
46
|
+
const from = params.from ?? client.account?.address;
|
|
47
|
+
if (!from) {
|
|
48
|
+
throw new AccountNotFoundError();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return client.request({
|
|
52
|
+
method: "wallet_formatSign",
|
|
53
|
+
params: [{ ...params, from, chainId: toHex(client.chain.id) }],
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
GetCallsStatusParams as IsomorphicGetCallsStatusParams,
|
|
3
|
-
GetCallsStatusResponse as IsomorphicGetCallsStatusResult,
|
|
4
|
-
} from "../../isomorphic/actions/getCallsStatus.ts";
|
|
5
1
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
2
|
+
import type { Static } from "@sinclair/typebox";
|
|
3
|
+
import { wallet_getCallsStatus } from "@alchemy/wallet-api-types/rpc";
|
|
6
4
|
|
|
7
|
-
export type GetCallsStatusParams =
|
|
5
|
+
export type GetCallsStatusParams = Static<
|
|
6
|
+
typeof wallet_getCallsStatus
|
|
7
|
+
>["Request"]["params"][0];
|
|
8
8
|
|
|
9
|
-
export type GetCallsStatusResult =
|
|
9
|
+
export type GetCallsStatusResult = Static<
|
|
10
|
+
typeof wallet_getCallsStatus
|
|
11
|
+
>["ReturnType"];
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Gets the status of a prepared call by its ID.
|
|
@@ -21,11 +23,13 @@ export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
|
|
|
21
23
|
* - receipts: Optional array of transaction receipts if the batch has been executed
|
|
22
24
|
*
|
|
23
25
|
* @example
|
|
26
|
+
* ```ts
|
|
24
27
|
* // After sending prepared calls
|
|
25
28
|
* const sendResult = await client.sendPreparedCalls({...});
|
|
26
29
|
*
|
|
27
30
|
* // Check the status of the first call ID
|
|
28
31
|
* const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);
|
|
32
|
+
* ```
|
|
29
33
|
*/
|
|
30
34
|
export async function getCallsStatus(
|
|
31
35
|
client: InnerWalletApiClient,
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { AccountNotFoundError, type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
toHex,
|
|
4
|
+
type Address,
|
|
5
|
+
type Hex,
|
|
6
|
+
type IsUndefined,
|
|
7
|
+
type Prettify,
|
|
8
|
+
} from "viem";
|
|
4
9
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
10
|
+
import type { Static } from "@sinclair/typebox";
|
|
11
|
+
import { wallet_createSession } from "@alchemy/wallet-api-types/rpc";
|
|
12
|
+
import { encodePermissionsContext } from "@alchemy/wallet-api-types/capabilities";
|
|
13
|
+
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
5
14
|
|
|
6
15
|
export type GrantPermissionsParams<
|
|
7
16
|
TAccount extends Address | undefined = Address | undefined,
|
|
8
|
-
> =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
> = Prettify<
|
|
18
|
+
Omit<
|
|
19
|
+
Static<
|
|
20
|
+
(typeof wallet_createSession)["properties"]["Request"]["properties"]["params"]
|
|
21
|
+
>[0],
|
|
22
|
+
"account" | "chainId"
|
|
23
|
+
> &
|
|
24
|
+
(IsUndefined<TAccount> extends true
|
|
25
|
+
? { account: Address }
|
|
26
|
+
: { account?: never })
|
|
27
|
+
>;
|
|
12
28
|
|
|
13
29
|
export type GrantPermissionsResult = {
|
|
14
30
|
context: Hex;
|
|
@@ -23,21 +39,21 @@ export type GrantPermissionsResult = {
|
|
|
23
39
|
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
24
40
|
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
25
41
|
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
26
|
-
* @param {
|
|
42
|
+
* @param {sessionKeyData} params.key - The session key information
|
|
27
43
|
* @param {string} params.key.publicKey - The public key of the session key
|
|
28
44
|
* @param {string} params.key.type - The type of the key (e.g., "secp256k1")
|
|
29
45
|
* @param {Array} params.permissions - Array of permission objects defining what the session key can do
|
|
30
46
|
* @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier
|
|
31
|
-
* @returns {Hex} result.context - A hex identifier for the granted permissions context
|
|
32
47
|
*
|
|
33
48
|
* @example
|
|
49
|
+
* ```ts
|
|
34
50
|
* // Create a session key and grant root permissions
|
|
35
51
|
* const sessionKey = LocalAccountSigner.generatePrivateKeySigner();
|
|
36
52
|
* const account = await client.requestAccount();
|
|
37
53
|
*
|
|
38
54
|
* const permissions = await client.grantPermissions({
|
|
39
55
|
* account: account.address,
|
|
40
|
-
*
|
|
56
|
+
* expirySec: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now
|
|
41
57
|
* key: {
|
|
42
58
|
* publicKey: await sessionKey.getAddress(),
|
|
43
59
|
* type: "secp256k1",
|
|
@@ -58,10 +74,7 @@ export type GrantPermissionsResult = {
|
|
|
58
74
|
* });
|
|
59
75
|
*
|
|
60
76
|
* // Sign with the session key
|
|
61
|
-
* const signedCalls = await
|
|
62
|
-
* sessionKey,
|
|
63
|
-
* preparedCalls,
|
|
64
|
-
* );
|
|
77
|
+
* const signedCalls = await signPreparedCalls(sessionKey, preparedCalls);
|
|
65
78
|
*
|
|
66
79
|
* // Send the prepared call using the session key
|
|
67
80
|
* const result = await client.sendPreparedCalls({
|
|
@@ -70,6 +83,7 @@ export type GrantPermissionsResult = {
|
|
|
70
83
|
* permissions,
|
|
71
84
|
* },
|
|
72
85
|
* });
|
|
86
|
+
* ```
|
|
73
87
|
*/
|
|
74
88
|
export async function grantPermissions<
|
|
75
89
|
TAccount extends Address | undefined = Address | undefined,
|
|
@@ -79,14 +93,28 @@ export async function grantPermissions<
|
|
|
79
93
|
params: GrantPermissionsParams<TAccount>,
|
|
80
94
|
): Promise<GrantPermissionsResult> {
|
|
81
95
|
const account = params.account ?? client.account?.address;
|
|
82
|
-
|
|
83
96
|
if (!account) {
|
|
84
97
|
throw new AccountNotFoundError();
|
|
85
98
|
}
|
|
86
99
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
const { sessionId, signatureRequest } = await client.request({
|
|
101
|
+
method: "wallet_createSession",
|
|
102
|
+
params: [
|
|
103
|
+
{
|
|
104
|
+
...params,
|
|
105
|
+
account,
|
|
106
|
+
chainId: toHex(client.chain.id),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
91
109
|
});
|
|
110
|
+
|
|
111
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
context: encodePermissionsContext({
|
|
115
|
+
contextVersion: "REMOTE_MODE_DEFERRED_ACTION",
|
|
116
|
+
sessionId,
|
|
117
|
+
signature: signature.data,
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
92
120
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
|
-
import type { wallet_listAccounts } from "
|
|
2
|
+
import type { wallet_listAccounts } from "@alchemy/wallet-api-types/rpc";
|
|
3
3
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
+
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
5
|
+
import type { Address } from "viem";
|
|
4
6
|
|
|
5
|
-
export type ListAccountsParams =
|
|
6
|
-
typeof wallet_listAccounts
|
|
7
|
-
|
|
7
|
+
export type ListAccountsParams = Omit<
|
|
8
|
+
Static<typeof wallet_listAccounts>["Request"]["params"][0],
|
|
9
|
+
"signerAddress"
|
|
10
|
+
> & { signerAddress?: Address };
|
|
8
11
|
|
|
9
12
|
export type ListAccountsResult = Static<
|
|
10
13
|
typeof wallet_listAccounts
|
|
@@ -14,6 +17,7 @@ export type ListAccountsResult = Static<
|
|
|
14
17
|
* Lists all smart accounts for a given signer using the wallet API client.
|
|
15
18
|
*
|
|
16
19
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
20
|
+
* @param {SmartAccountSigner} signer - The signer for which to list accounts
|
|
17
21
|
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
18
22
|
* @param {string} params.signerAddress - The address of the signer to list accounts for
|
|
19
23
|
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
@@ -21,6 +25,7 @@ export type ListAccountsResult = Static<
|
|
|
21
25
|
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
22
26
|
*
|
|
23
27
|
* @example
|
|
28
|
+
* ```ts
|
|
24
29
|
* // Fetch the first page of accounts
|
|
25
30
|
* const firstPage = await client.listAccounts({
|
|
26
31
|
* signerAddress: "0x123...",
|
|
@@ -33,10 +38,22 @@ export type ListAccountsResult = Static<
|
|
|
33
38
|
* limit: 10,
|
|
34
39
|
* after: firstPage.meta.after
|
|
35
40
|
* });
|
|
41
|
+
* ```
|
|
36
42
|
*/
|
|
37
43
|
export async function listAccounts(
|
|
38
44
|
client: InnerWalletApiClient,
|
|
45
|
+
signer: SmartAccountSigner,
|
|
39
46
|
params: ListAccountsParams,
|
|
40
47
|
): Promise<ListAccountsResult> {
|
|
41
|
-
|
|
48
|
+
const signerAddress = params.signerAddress ?? (await signer.getAddress());
|
|
49
|
+
|
|
50
|
+
return client.request({
|
|
51
|
+
method: "wallet_listAccounts",
|
|
52
|
+
params: [
|
|
53
|
+
{
|
|
54
|
+
...params,
|
|
55
|
+
signerAddress,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
});
|
|
42
59
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
2
2
|
import { toHex, type Address, type IsUndefined } from "viem";
|
|
3
|
-
import type {
|
|
4
|
-
PrepareCallsParams as IsomorphicPrepareCallsParams,
|
|
5
|
-
PrepareCallsResult as IsomorphicPrepareCallsResult,
|
|
6
|
-
} from "../../isomorphic/actions/prepareCalls.ts";
|
|
7
3
|
import type { InnerWalletApiClient } from "../../types.ts";
|
|
4
|
+
import type { Static } from "@sinclair/typebox";
|
|
5
|
+
import { wallet_prepareCalls } from "@alchemy/wallet-api-types/rpc";
|
|
8
6
|
|
|
9
7
|
export type GetAccountParam<TAccount> =
|
|
10
8
|
IsUndefined<TAccount> extends true
|
|
@@ -13,10 +11,17 @@ export type GetAccountParam<TAccount> =
|
|
|
13
11
|
|
|
14
12
|
export type PrepareCallsParams<
|
|
15
13
|
TAccount extends Address | undefined = Address | undefined,
|
|
16
|
-
> = Omit<
|
|
14
|
+
> = Omit<
|
|
15
|
+
Static<
|
|
16
|
+
(typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]
|
|
17
|
+
>[0],
|
|
18
|
+
"from" | "chainId"
|
|
19
|
+
> &
|
|
17
20
|
(IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });
|
|
18
21
|
|
|
19
|
-
export type PrepareCallsResult =
|
|
22
|
+
export type PrepareCallsResult = Static<
|
|
23
|
+
typeof wallet_prepareCalls
|
|
24
|
+
>["ReturnType"];
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* Prepares a set of contract calls for execution by building a user operation.
|
|
@@ -32,6 +37,7 @@ export type PrepareCallsResult = IsomorphicPrepareCallsResult;
|
|
|
32
37
|
* the user operation data and signature request
|
|
33
38
|
*
|
|
34
39
|
* @example
|
|
40
|
+
* ```ts
|
|
35
41
|
* // Prepare a sponsored user operation call
|
|
36
42
|
* const result = await client.prepareCalls({
|
|
37
43
|
* calls: [{
|
|
@@ -43,6 +49,7 @@ export type PrepareCallsResult = IsomorphicPrepareCallsResult;
|
|
|
43
49
|
* paymasterService: { policyId: "your-policy-id" }
|
|
44
50
|
* }
|
|
45
51
|
* });
|
|
52
|
+
* ```
|
|
46
53
|
*/
|
|
47
54
|
export async function prepareCalls<
|
|
48
55
|
TAccount extends Address | undefined = Address | undefined,
|
|
@@ -51,26 +58,25 @@ export async function prepareCalls<
|
|
|
51
58
|
params: PrepareCallsParams<TAccount>,
|
|
52
59
|
): Promise<PrepareCallsResult> {
|
|
53
60
|
const from = params.from ?? client.account?.address;
|
|
54
|
-
|
|
55
61
|
if (!from) {
|
|
56
62
|
throw new AccountNotFoundError();
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
if (client.
|
|
65
|
+
if (client.policyIds && !params.capabilities?.paymasterService) {
|
|
60
66
|
params.capabilities = {
|
|
61
67
|
...params.capabilities,
|
|
62
|
-
paymasterService: {
|
|
68
|
+
paymasterService: { policyIds: client.policyIds },
|
|
63
69
|
};
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
const params_ = {
|
|
67
|
-
...params,
|
|
68
|
-
chainId: toHex(client.chain.id),
|
|
69
|
-
from,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
72
|
return await client.request({
|
|
73
73
|
method: "wallet_prepareCalls",
|
|
74
|
-
params: [
|
|
74
|
+
params: [
|
|
75
|
+
{
|
|
76
|
+
...params,
|
|
77
|
+
chainId: toHex(client.chain.id),
|
|
78
|
+
from,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
75
81
|
});
|
|
76
82
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { InnerWalletApiClient } from "../../types.ts";
|
|
2
|
+
import { toHex, type Address, type IsUndefined } from "viem";
|
|
3
|
+
import { AccountNotFoundError } from "@aa-sdk/core";
|
|
4
|
+
import type { Static } from "@sinclair/typebox";
|
|
5
|
+
import { wallet_prepareSign } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
+
|
|
7
|
+
export type PrepareSignParams<
|
|
8
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
9
|
+
> = Omit<
|
|
10
|
+
Static<
|
|
11
|
+
(typeof wallet_prepareSign)["properties"]["Request"]["properties"]["params"]
|
|
12
|
+
>[0],
|
|
13
|
+
"from" | "chainId"
|
|
14
|
+
> &
|
|
15
|
+
(IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });
|
|
16
|
+
|
|
17
|
+
export type PrepareSignResult = Static<typeof wallet_prepareSign>["ReturnType"];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Prepares a signature request for signing messages or transactions.
|
|
21
|
+
*
|
|
22
|
+
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
23
|
+
* @param {PrepareSignParams} params - Parameters for preparing the signature request
|
|
24
|
+
* @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // Prepare a message to be signed
|
|
29
|
+
* const result = await client.prepareSign({
|
|
30
|
+
* from: "0x1234...",
|
|
31
|
+
* type: "personal_sign",
|
|
32
|
+
* data: "Hello, world!",
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export async function prepareSign<
|
|
37
|
+
TAccount extends Address | undefined = Address | undefined,
|
|
38
|
+
>(
|
|
39
|
+
client: InnerWalletApiClient,
|
|
40
|
+
params: PrepareSignParams<TAccount>,
|
|
41
|
+
): Promise<PrepareSignResult> {
|
|
42
|
+
const from = params.from ?? client.account?.address;
|
|
43
|
+
if (!from) {
|
|
44
|
+
throw new AccountNotFoundError();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return client.request({
|
|
48
|
+
method: "wallet_prepareSign",
|
|
49
|
+
params: [{ ...params, from, chainId: toHex(client.chain.id) }],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -7,10 +7,10 @@ import { Value } from "@sinclair/typebox/value";
|
|
|
7
7
|
import type { Address } from "abitype";
|
|
8
8
|
import deepEqual from "deep-equal";
|
|
9
9
|
import { custom } from "viem";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import { TypeSerializedInitcode } from "../../schemas.js";
|
|
10
|
+
import type { wallet_requestAccount } from "@alchemy/wallet-api-types/rpc";
|
|
11
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
13
12
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
13
|
+
import { createAccount } from "../../internal/account.js";
|
|
14
14
|
|
|
15
15
|
export type RequestAccountParams = Omit<
|
|
16
16
|
Extract<
|
|
@@ -35,9 +35,11 @@ export type RequestAccountResult = SmartContractAccount;
|
|
|
35
35
|
* @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
|
+
* ```ts
|
|
38
39
|
* // Request an account with default parameters using a local signer
|
|
39
40
|
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
40
41
|
* const account = await client.requestAccount(signer);
|
|
42
|
+
* ```
|
|
41
43
|
*/
|
|
42
44
|
export async function requestAccount(
|
|
43
45
|
client: InnerWalletApiClient,
|
|
@@ -76,7 +78,7 @@ export async function requestAccount(
|
|
|
76
78
|
const account = await createAccount({
|
|
77
79
|
accountAddress,
|
|
78
80
|
counterfactualInfo: counterfactualInfo
|
|
79
|
-
? Value.Parse(
|
|
81
|
+
? Value.Parse(SerializedInitcode, counterfactualInfo)
|
|
80
82
|
: undefined,
|
|
81
83
|
delegation,
|
|
82
84
|
chain: client.chain,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
2
|
import { toHex } from "viem";
|
|
3
|
-
import type { wallet_sendPreparedCalls } from "
|
|
3
|
+
import type { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
4
4
|
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
5
5
|
|
|
6
6
|
export type SendPreparedCallsParams = WithoutChainId<
|
|
@@ -22,6 +22,7 @@ export type SendPreparedCallsResult = Static<
|
|
|
22
22
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
23
23
|
*
|
|
24
24
|
* @example
|
|
25
|
+
* ```ts
|
|
25
26
|
* // First prepare the calls
|
|
26
27
|
* const preparedCalls = await client.prepareCalls({
|
|
27
28
|
* calls: [{
|
|
@@ -41,6 +42,7 @@ export type SendPreparedCallsResult = Static<
|
|
|
41
42
|
* const result = await client.sendPreparedCalls({
|
|
42
43
|
* signedCalls,
|
|
43
44
|
* });
|
|
45
|
+
* ```
|
|
44
46
|
*/
|
|
45
47
|
export async function sendPreparedCalls(
|
|
46
48
|
client: InnerWalletApiClient,
|
|
@@ -13,16 +13,19 @@ export type SignMessageResult = Hex;
|
|
|
13
13
|
*
|
|
14
14
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
15
15
|
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {SignMessageParams} params - Parameters for signing the message
|
|
17
|
+
* @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
|
|
18
|
+
* @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
|
|
17
19
|
* @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
|
|
18
20
|
*
|
|
19
21
|
* @example
|
|
22
|
+
* ```ts
|
|
20
23
|
* // Sign a simple text message
|
|
21
24
|
* const signature = await client.signMessage("Hello, world!");
|
|
22
25
|
*
|
|
23
|
-
* @example
|
|
24
26
|
* // Sign a raw hex message
|
|
25
27
|
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
28
|
+
* ```
|
|
26
29
|
*/
|
|
27
30
|
export async function signMessage(
|
|
28
31
|
client: InnerWalletApiClient,
|
|
@@ -2,8 +2,12 @@ import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
|
2
2
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
3
3
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
4
4
|
import type { Static } from "@sinclair/typebox";
|
|
5
|
-
import { wallet_sendPreparedCalls } from "
|
|
6
|
-
import {
|
|
5
|
+
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
+
import {
|
|
7
|
+
type PreparedCall_Authorization,
|
|
8
|
+
type PreparedCall_UserOpV060,
|
|
9
|
+
type PreparedCall_UserOpV070,
|
|
10
|
+
} from "@alchemy/wallet-api-types";
|
|
7
11
|
|
|
8
12
|
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
9
13
|
|
|
@@ -17,56 +21,47 @@ export type SignPreparedCallsResult = Static<
|
|
|
17
21
|
* @param {SmartAccountSigner} signer - The signer to use
|
|
18
22
|
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
19
23
|
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
20
|
-
|
|
24
|
+
*/
|
|
21
25
|
export async function signPreparedCalls(
|
|
22
26
|
signer: SmartAccountSigner,
|
|
23
27
|
params: SignPreparedCallsParams,
|
|
24
28
|
): Promise<SignPreparedCallsResult> {
|
|
25
|
-
|
|
26
|
-
const { signatureRequest, ...
|
|
27
|
-
const signature = await signSignatureRequest(signer,
|
|
29
|
+
const signAuthorizationCall = async (call: PreparedCall_Authorization) => {
|
|
30
|
+
const { signatureRequest: _signatureRequest, ...rest } = call;
|
|
31
|
+
const signature = await signSignatureRequest(signer, {
|
|
32
|
+
type: "eip7702Auth",
|
|
33
|
+
data: {
|
|
34
|
+
...rest.data,
|
|
35
|
+
chainId: call.chainId,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
28
38
|
return {
|
|
29
|
-
...
|
|
39
|
+
...rest,
|
|
30
40
|
signature,
|
|
31
41
|
};
|
|
32
|
-
}
|
|
42
|
+
};
|
|
33
43
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
data: {
|
|
44
|
-
...call.data,
|
|
45
|
-
chainId: call.chainId,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
...rest,
|
|
50
|
-
signature,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
case "user-operation-v060":
|
|
54
|
-
case "user-operation-v070": {
|
|
55
|
-
const { signatureRequest, ...rest } = call;
|
|
56
|
-
const signature = await signSignatureRequest(
|
|
57
|
-
signer,
|
|
58
|
-
signatureRequest,
|
|
59
|
-
);
|
|
60
|
-
return {
|
|
61
|
-
...rest,
|
|
62
|
-
signature,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
default: {
|
|
66
|
-
return assertNever(call, "Unexpected call type");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
),
|
|
44
|
+
const signUserOperationCall = async (
|
|
45
|
+
call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,
|
|
46
|
+
) => {
|
|
47
|
+
const { signatureRequest, ...rest } = call;
|
|
48
|
+
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
49
|
+
return {
|
|
50
|
+
...rest,
|
|
51
|
+
signature,
|
|
52
|
+
};
|
|
71
53
|
};
|
|
54
|
+
|
|
55
|
+
return params.type === "array"
|
|
56
|
+
? {
|
|
57
|
+
type: "array" as const,
|
|
58
|
+
data: await Promise.all(
|
|
59
|
+
params.data.map((call) =>
|
|
60
|
+
call.type === "authorization"
|
|
61
|
+
? signAuthorizationCall(call)
|
|
62
|
+
: signUserOperationCall(call),
|
|
63
|
+
),
|
|
64
|
+
),
|
|
65
|
+
}
|
|
66
|
+
: signUserOperationCall(params);
|
|
72
67
|
}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import type { Static } from "@sinclair/typebox";
|
|
3
2
|
import { type Hex, hexToNumber, serializeSignature } from "viem";
|
|
4
3
|
import { assertNever } from "../../utils.js";
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
type PersonalSignSignatureRequest,
|
|
6
|
+
type TypedDataSignatureRequest,
|
|
7
|
+
type AuthorizationSignatureRequest,
|
|
8
|
+
type Eip7702UnsignedAuth,
|
|
9
|
+
} from "@alchemy/wallet-api-types";
|
|
11
10
|
import { vToYParity } from "ox/Signature";
|
|
12
11
|
import type { WithoutRawPayload } from "../../types.ts";
|
|
13
12
|
|
|
14
13
|
export type SignSignatureRequestParams = WithoutRawPayload<
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
| (
|
|
18
|
-
data:
|
|
14
|
+
| PersonalSignSignatureRequest
|
|
15
|
+
| TypedDataSignatureRequest
|
|
16
|
+
| (AuthorizationSignatureRequest & {
|
|
17
|
+
data: Eip7702UnsignedAuth;
|
|
19
18
|
})
|
|
20
19
|
>;
|
|
21
20
|
|
|
@@ -31,20 +30,17 @@ export type SignSignatureRequestResult = {
|
|
|
31
30
|
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
32
31
|
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
33
32
|
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
34
|
-
* @param {
|
|
33
|
+
* @param {SignSignatureRequestParams["data"]} params.data - The data to sign, format depends on the signature type
|
|
35
34
|
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
36
|
-
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
37
|
-
* @returns {Hex} result.signature - The hex-encoded signature
|
|
38
|
-
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
39
35
|
*
|
|
40
36
|
* @example
|
|
37
|
+
* ```ts
|
|
41
38
|
* // Sign a personal message
|
|
42
39
|
* const result = await client.signSignatureRequest({
|
|
43
40
|
* type: 'personal_sign',
|
|
44
41
|
* data: 'Hello, world!'
|
|
45
42
|
* });
|
|
46
43
|
*
|
|
47
|
-
* @example
|
|
48
44
|
* // Sign typed data (EIP-712)
|
|
49
45
|
* const result = await client.signSignatureRequest({
|
|
50
46
|
* type: 'eth_signTypedData_v4',
|
|
@@ -55,6 +51,7 @@ export type SignSignatureRequestResult = {
|
|
|
55
51
|
* message: { ... }
|
|
56
52
|
* }
|
|
57
53
|
* });
|
|
54
|
+
* ```
|
|
58
55
|
*/
|
|
59
56
|
|
|
60
57
|
export async function signSignatureRequest(
|
|
@@ -19,6 +19,7 @@ export type SignTypedDataResult = Hex;
|
|
|
19
19
|
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
|
+
* ```ts
|
|
22
23
|
* // Sign typed data
|
|
23
24
|
* const signature = await client.signTypedData({
|
|
24
25
|
* domain: {
|
|
@@ -39,6 +40,7 @@ export type SignTypedDataResult = Hex;
|
|
|
39
40
|
* wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
|
|
40
41
|
* }
|
|
41
42
|
* });
|
|
43
|
+
* ```
|
|
42
44
|
*/
|
|
43
45
|
export async function signTypedData(
|
|
44
46
|
client: InnerWalletApiClient,
|