@account-kit/wallet-client 4.84.0 → 4.86.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/dist/esm/client/actions/grantPermissions.d.ts +1 -1
- package/dist/esm/client/actions/grantPermissions.js +1 -5
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +4 -8
- package/dist/esm/client/actions/listAccounts.js +6 -27
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/requestAccount.d.ts +3 -6
- package/dist/esm/client/actions/requestAccount.js +5 -31
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendCalls.d.ts +1 -1
- package/dist/esm/client/actions/sendCalls.js +1 -5
- package/dist/esm/client/actions/sendCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +1 -1
- package/dist/esm/client/actions/signMessage.js +1 -1
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +1 -1
- package/dist/esm/client/actions/signPreparedCalls.js +2 -5
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +34 -9
- package/dist/esm/client/actions/signSignatureRequest.js +2 -30
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +1 -1
- package/dist/esm/client/actions/signTypedData.js +1 -1
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/decorator.js +1 -13
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +2 -8
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/internal/account.d.ts +1 -1
- package/dist/esm/internal/account.js +1 -19
- package/dist/esm/internal/account.js.map +1 -1
- package/dist/esm/utils.d.ts +0 -6
- package/dist/esm/utils.js +1 -14
- package/dist/esm/utils.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/client/actions/grantPermissions.d.ts +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +4 -8
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/requestAccount.d.ts +3 -6
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendCalls.d.ts +1 -1
- package/dist/types/client/actions/sendCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +34 -9
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +1 -1
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +2 -8
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/internal/account.d.ts +1 -1
- package/dist/types/internal/account.d.ts.map +1 -1
- package/dist/types/utils.d.ts +0 -6
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -6
- package/src/client/actions/grantPermissions.ts +1 -8
- package/src/client/actions/listAccounts.ts +7 -35
- package/src/client/actions/requestAccount.ts +8 -51
- package/src/client/actions/sendCalls.ts +1 -7
- package/src/client/actions/signMessage.ts +1 -1
- package/src/client/actions/signPreparedCalls.ts +2 -7
- package/src/client/actions/signSignatureRequest.ts +5 -75
- package/src/client/actions/signTypedData.ts +1 -1
- package/src/client/decorator.ts +1 -19
- package/src/client/index.ts +2 -9
- package/src/internal/account.ts +2 -26
- package/src/utils.ts +1 -25
- package/src/version.ts +1 -1
|
@@ -3,13 +3,7 @@ import type { AlchemyTransport } from "@account-kit/infra";
|
|
|
3
3
|
import { type Address, type Chain, type Prettify } from "viem";
|
|
4
4
|
import type { InnerWalletApiClientBase } from "../types.ts";
|
|
5
5
|
import { type SmartWalletActions } from "./decorator.js";
|
|
6
|
-
|
|
7
|
-
export type WebAuthnSigner = {
|
|
8
|
-
credential: ToWebAuthnAccountParameters["credential"];
|
|
9
|
-
getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
|
|
10
|
-
rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
|
|
11
|
-
};
|
|
12
|
-
export type SmartWalletSigner = SmartAccountSigner<any> | WebAuthnSigner;
|
|
6
|
+
export type SmartWalletSigner = SmartAccountSigner<any>;
|
|
13
7
|
export type SmartWalletClientParams<TAccount extends Address | undefined = Address | undefined> = Prettify<{
|
|
14
8
|
transport: AlchemyTransport;
|
|
15
9
|
chain: Chain;
|
|
@@ -29,7 +23,7 @@ export type SmartWalletClient<TAccount extends Address | undefined = Address | u
|
|
|
29
23
|
* @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client
|
|
30
24
|
* @param {AlchemyTransport} params.transport - The Alchemy transport to use
|
|
31
25
|
* @param {Chain} params.chain - The chain to use
|
|
32
|
-
* @param {SmartAccountSigner
|
|
26
|
+
* @param {SmartAccountSigner} params.signer - The signer to use for the smart account
|
|
33
27
|
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
34
28
|
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
35
29
|
* @returns {SmartWalletClient} - A viem-compatible client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,QAAQ,EAKd,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,QAAQ,EAKd,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AASxB,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAExD,MAAM,MAAM,uBAAuB,CACjC,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACxD,QAAQ,CACV;IACE,SAAS,EAAE,gBAAgB,CAAC;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;CAC1C,GAAG,CACA;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,KAAK,CAAA;CAAE,GACxC;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAC7C,CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAC3B,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACxD,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EAChD,MAAM,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import { type Chain, type Transport, type Address } from "viem";
|
|
3
3
|
import type { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
4
4
|
import type { SmartWalletSigner } from "../client/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/internal/account.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/internal/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOzD,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,OAAO,EAEb,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,KAAK,mBAAmB,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA0F/B"}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
|
-
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
3
|
-
import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
|
|
4
|
-
import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
5
|
-
import type { WebAuthnSigner } from "./client";
|
|
6
2
|
export type Expect<T extends true> = T;
|
|
7
3
|
export declare const assertNever: (_val: never, msg: string) => never;
|
|
8
4
|
/**
|
|
@@ -19,6 +15,4 @@ export declare const assertNever: (_val: never, msg: string) => never;
|
|
|
19
15
|
* ```
|
|
20
16
|
*/
|
|
21
17
|
export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
|
|
22
|
-
export declare function isWebAuthnSigner(signer: SmartAccountSigner | WebAuthnSigner): signer is WebAuthnSigner;
|
|
23
|
-
export declare function credentialToWebAuthnPublicKey(credential: ToWebAuthnAccountParameters["credential"]): WebAuthnPublicKey;
|
|
24
18
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAE9C,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC;AAEvC,eAAO,MAAM,WAAW,GAAI,MAAM,KAAK,EAAE,KAAK,MAAM,KAAG,KAEtD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,GAAG,KAAG,GAK/D,CAAC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.86.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/wallet-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.86.0",
|
|
4
4
|
"description": "Wallet Client for Alchemy Account Kit",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"test:e2e": "bun test ./src/**/*.e2e.test.*"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@aa-sdk/core": "^4.
|
|
48
|
-
"@account-kit/infra": "^4.
|
|
49
|
-
"@account-kit/smart-contracts": "^4.
|
|
50
|
-
"@alchemy/wallet-api-types": "0.1.0-alpha.
|
|
47
|
+
"@aa-sdk/core": "^4.86.0",
|
|
48
|
+
"@account-kit/infra": "^4.86.0",
|
|
49
|
+
"@account-kit/smart-contracts": "^4.86.0",
|
|
50
|
+
"@alchemy/wallet-api-types": "0.1.0-alpha.25",
|
|
51
51
|
"deep-equal": "^2.2.3",
|
|
52
52
|
"ox": "^0.6.12"
|
|
53
53
|
},
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
73
73
|
},
|
|
74
74
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "c25907d482458844554ad9333656fd82d1668f4f"
|
|
76
76
|
}
|
|
@@ -13,7 +13,6 @@ import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
|
|
|
13
13
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
14
14
|
import { metrics } from "../../metrics.js";
|
|
15
15
|
import type { SmartWalletSigner } from "../index.js";
|
|
16
|
-
import { isWebAuthnSigner } from "../../utils.js";
|
|
17
16
|
|
|
18
17
|
type RpcSchema = Extract<
|
|
19
18
|
WalletServerRpcSchemaType,
|
|
@@ -42,7 +41,7 @@ export type GrantPermissionsResult = {
|
|
|
42
41
|
* This allows another key to perform operations on behalf of the account.
|
|
43
42
|
*
|
|
44
43
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
45
|
-
* @param {SmartAccountSigner
|
|
44
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
46
45
|
* @param {GrantPermissionsParams} params - The parameters for granting permissions
|
|
47
46
|
* @param {Address} [params.account] - The account address (required if client was not initialized with an account)
|
|
48
47
|
* @param {number} params.expirySec - Unix timestamp when the permissions expire
|
|
@@ -108,12 +107,6 @@ export async function grantPermissions<
|
|
|
108
107
|
throw new AccountNotFoundError();
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
if (isWebAuthnSigner(signer)) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
"WebAuthn signer is not currently supported for grantPermissions",
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
110
|
const { sessionId, signatureRequest } = await client.request({
|
|
118
111
|
method: "wallet_createSession",
|
|
119
112
|
params: [
|
|
@@ -3,11 +3,6 @@ import type { InnerWalletApiClient } from "../../types.ts";
|
|
|
3
3
|
import type { Address } from "viem";
|
|
4
4
|
import { metrics } from "../../metrics.js";
|
|
5
5
|
import type { SmartWalletSigner } from "../index.js";
|
|
6
|
-
import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
|
|
7
|
-
import {
|
|
8
|
-
credentialToWebAuthnPublicKey,
|
|
9
|
-
isWebAuthnSigner,
|
|
10
|
-
} from "../../utils.js";
|
|
11
6
|
|
|
12
7
|
type RpcSchema = Extract<
|
|
13
8
|
WalletServerRpcSchemaType,
|
|
@@ -21,8 +16,7 @@ type RpcSchema = Extract<
|
|
|
21
16
|
export type ListAccountsParams = Omit<
|
|
22
17
|
RpcSchema["Request"]["params"][0],
|
|
23
18
|
"signerAddress" | "signerPublicKey"
|
|
24
|
-
> &
|
|
25
|
-
({ signerAddress: Address } | { signerPublicKey: WebAuthnPublicKey } | {});
|
|
19
|
+
> & { signerAddress?: Address };
|
|
26
20
|
|
|
27
21
|
export type ListAccountsResult = RpcSchema["ReturnType"];
|
|
28
22
|
|
|
@@ -30,10 +24,9 @@ export type ListAccountsResult = RpcSchema["ReturnType"];
|
|
|
30
24
|
* Lists all smart accounts for a given signer using the wallet API client.
|
|
31
25
|
*
|
|
32
26
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
33
|
-
* @param {SmartAccountSigner
|
|
27
|
+
* @param {SmartAccountSigner} signer - The signer for which to list accounts
|
|
34
28
|
* @param {ListAccountsParams} params - Parameters for listing accounts
|
|
35
29
|
* @param {Address} [params.signerAddress] - The address of the signer to list accounts for
|
|
36
|
-
* @param {WebAuthnPublicKey} [params.signerPublicKey] - The public key of the signer to list accounts for
|
|
37
30
|
* @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
|
|
38
31
|
* @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
|
|
39
32
|
* @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
|
|
@@ -63,37 +56,16 @@ export async function listAccounts(
|
|
|
63
56
|
name: "list_accounts",
|
|
64
57
|
});
|
|
65
58
|
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const signerArg =
|
|
71
|
-
"signerAddress" in params
|
|
72
|
-
? { signerAddress: params.signerAddress }
|
|
73
|
-
: "signerPublicKey" in params
|
|
74
|
-
? {
|
|
75
|
-
signerPublicKey: {
|
|
76
|
-
...params.signerPublicKey,
|
|
77
|
-
type: "webauthn-p256" as const,
|
|
78
|
-
},
|
|
79
|
-
}
|
|
80
|
-
: isWebAuthnSigner(signer)
|
|
81
|
-
? {
|
|
82
|
-
signerPublicKey: {
|
|
83
|
-
...credentialToWebAuthnPublicKey(signer.credential),
|
|
84
|
-
type: "webauthn-p256" as const,
|
|
85
|
-
},
|
|
86
|
-
}
|
|
87
|
-
: ({
|
|
88
|
-
signerAddress: await signer.getAddress(),
|
|
89
|
-
} satisfies RpcSchema["Request"]["params"][0]);
|
|
59
|
+
// signerAddress in params takes priority; otherwise fallback to client's attached signer
|
|
60
|
+
const signerAddress = params.signerAddress ?? (await signer.getAddress());
|
|
61
|
+
const { signerAddress: _signerAddress, ...rest } = params;
|
|
90
62
|
|
|
91
63
|
return client.request({
|
|
92
64
|
method: "wallet_listAccounts",
|
|
93
65
|
params: [
|
|
94
66
|
{
|
|
95
|
-
...
|
|
96
|
-
|
|
67
|
+
...rest,
|
|
68
|
+
signerAddress,
|
|
97
69
|
},
|
|
98
70
|
],
|
|
99
71
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Address } from "abitype";
|
|
3
3
|
import deepEqual from "deep-equal";
|
|
4
4
|
import { custom } from "viem";
|
|
@@ -6,15 +6,6 @@ import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
|
|
|
6
6
|
import type { InnerWalletApiClient } from "../../types.js";
|
|
7
7
|
import { createAccount } from "../../internal/account.js";
|
|
8
8
|
import type { SmartWalletSigner } from "../index.js";
|
|
9
|
-
import {
|
|
10
|
-
credentialToWebAuthnPublicKey,
|
|
11
|
-
isWebAuthnSigner,
|
|
12
|
-
} from "../../utils.js";
|
|
13
|
-
import type {
|
|
14
|
-
CreationOptionsByPublicKey,
|
|
15
|
-
CreationOptionsBySignerAddress,
|
|
16
|
-
WebAuthnPublicKey,
|
|
17
|
-
} from "@alchemy/wallet-api-types";
|
|
18
9
|
|
|
19
10
|
type RpcSchema = Extract<
|
|
20
11
|
WalletServerRpcSchemaType,
|
|
@@ -26,11 +17,8 @@ type RpcSchema = Extract<
|
|
|
26
17
|
>;
|
|
27
18
|
|
|
28
19
|
export type RequestAccountParams = Omit<
|
|
29
|
-
Extract<
|
|
30
|
-
|
|
31
|
-
{ signerAddress: Address } | { signerPublicKey: WebAuthnPublicKey }
|
|
32
|
-
>,
|
|
33
|
-
"signerAddress" | "signerPublicKey" | "includeCounterfactualInfo"
|
|
20
|
+
Extract<RpcSchema["Request"]["params"][0], { signerAddress: Address }>,
|
|
21
|
+
"signerAddress" | "includeCounterfactualInfo"
|
|
34
22
|
> & { accountAddress?: Address };
|
|
35
23
|
|
|
36
24
|
export type RequestAccountResult = SmartContractAccount;
|
|
@@ -41,7 +29,7 @@ export type RequestAccountResult = SmartContractAccount;
|
|
|
41
29
|
* If an account already exists, the creationHint will be ignored.
|
|
42
30
|
*
|
|
43
31
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
44
|
-
* @param {SmartAccountSigner
|
|
32
|
+
* @param {SmartAccountSigner} signer - The signer that will be associated with the account
|
|
45
33
|
* @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
|
|
46
34
|
* @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer
|
|
47
35
|
* @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
|
|
@@ -61,24 +49,6 @@ export async function requestAccount(
|
|
|
61
49
|
): Promise<RequestAccountResult> {
|
|
62
50
|
const { creationHint = {} } = params ?? {};
|
|
63
51
|
|
|
64
|
-
if (isWebAuthnSigner(signer)) {
|
|
65
|
-
if (
|
|
66
|
-
creationHint.accountType &&
|
|
67
|
-
creationHint.accountType !== "mav2-webauthn"
|
|
68
|
-
) {
|
|
69
|
-
throw new BaseError(
|
|
70
|
-
"WebAuthn signers are only supported with mav2-webauthn account type",
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
// non-webauthn signers do not support the "mav2-webauthn" account type
|
|
75
|
-
if (creationHint.accountType === "mav2-webauthn") {
|
|
76
|
-
throw new BaseError(
|
|
77
|
-
"ECDSA (secp256k1) signers are not supported with mav2-webauthn account type",
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
52
|
const args = (
|
|
83
53
|
(client.account && !params) || params?.accountAddress
|
|
84
54
|
? {
|
|
@@ -86,25 +56,12 @@ export async function requestAccount(
|
|
|
86
56
|
includeCounterfactualInfo: true,
|
|
87
57
|
}
|
|
88
58
|
: {
|
|
89
|
-
|
|
59
|
+
signerAddress: await signer.getAddress(),
|
|
60
|
+
...(creationHint
|
|
90
61
|
? {
|
|
91
|
-
|
|
92
|
-
...credentialToWebAuthnPublicKey(signer.credential),
|
|
93
|
-
type: "webauthn-p256",
|
|
94
|
-
},
|
|
95
|
-
...(creationHint
|
|
96
|
-
? { creationHint: creationHint as CreationOptionsByPublicKey }
|
|
97
|
-
: {}),
|
|
62
|
+
creationHint,
|
|
98
63
|
}
|
|
99
|
-
: {
|
|
100
|
-
signerAddress: await signer.getAddress(),
|
|
101
|
-
...(creationHint
|
|
102
|
-
? {
|
|
103
|
-
creationHint:
|
|
104
|
-
creationHint as CreationOptionsBySignerAddress,
|
|
105
|
-
}
|
|
106
|
-
: {}),
|
|
107
|
-
}),
|
|
64
|
+
: {}),
|
|
108
65
|
includeCounterfactualInfo: true,
|
|
109
66
|
}
|
|
110
67
|
) satisfies RpcSchema["Request"]["params"][0];
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from "./sendPreparedCalls.js";
|
|
10
10
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
11
11
|
import type { SmartWalletSigner } from "../index.js";
|
|
12
|
-
import { isWebAuthnSigner } from "../../utils.js";
|
|
13
12
|
import { extractCapabilitiesForSending } from "../../internal/capabilities.js";
|
|
14
13
|
|
|
15
14
|
export type SendCallsParams<
|
|
@@ -27,7 +26,7 @@ export type SendCallsResult = SendPreparedCallsResult;
|
|
|
27
26
|
* </Note>
|
|
28
27
|
*
|
|
29
28
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
30
|
-
* @param {SmartAccountSigner
|
|
29
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
31
30
|
* @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
|
|
32
31
|
* @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
|
|
33
32
|
* @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
|
|
@@ -65,11 +64,6 @@ export async function sendCalls<
|
|
|
65
64
|
let calls = await prepareCalls(client, params);
|
|
66
65
|
|
|
67
66
|
if (calls.type === "paymaster-permit") {
|
|
68
|
-
if (isWebAuthnSigner(signer)) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
"WebAuthn signer is not currently supported for signing paymaster permit signatures",
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
67
|
const signature = await signSignatureRequest(
|
|
74
68
|
signer,
|
|
75
69
|
calls.signatureRequest,
|
|
@@ -13,7 +13,7 @@ export type SignMessageResult = Hex;
|
|
|
13
13
|
* This method requests the account associated with the signer and uses it to sign the message.
|
|
14
14
|
*
|
|
15
15
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
16
|
-
* @param {SmartAccountSigner
|
|
16
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
17
17
|
* @param {SignMessageParams} params - Parameters for signing the message
|
|
18
18
|
* @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
|
|
19
19
|
* @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
PreparedCall_UserOpV070,
|
|
9
9
|
} from "@alchemy/wallet-api-types";
|
|
10
10
|
import { metrics } from "../../metrics.js";
|
|
11
|
-
import { assertNever
|
|
11
|
+
import { assertNever } from "../../utils.js";
|
|
12
12
|
import type { SmartWalletSigner } from "../index.js";
|
|
13
13
|
|
|
14
14
|
type RpcSchema = Extract<
|
|
@@ -27,7 +27,7 @@ export type SignPreparedCallsResult = RpcSchema["Request"]["params"][0];
|
|
|
27
27
|
/**
|
|
28
28
|
* Signs prepared calls using the provided signer.
|
|
29
29
|
*
|
|
30
|
-
* @param {SmartAccountSigner
|
|
30
|
+
* @param {SmartAccountSigner} signer - The signer to use
|
|
31
31
|
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
32
32
|
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
33
33
|
*/
|
|
@@ -44,11 +44,6 @@ export async function signPreparedCalls(
|
|
|
44
44
|
|
|
45
45
|
const signAuthorizationCall = async (call: PreparedCall_Authorization) => {
|
|
46
46
|
const { signatureRequest: _signatureRequest, ...rest } = call;
|
|
47
|
-
if (isWebAuthnSigner(signer)) {
|
|
48
|
-
throw new Error(
|
|
49
|
-
"WebAuthn account cannot sign EIP-7702 authorization requests",
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
47
|
const signature = await signSignatureRequest(signer, {
|
|
53
48
|
type: "eip7702Auth",
|
|
54
49
|
data: {
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
1
|
import { hexToNumber, serializeSignature } from "viem";
|
|
3
|
-
import { assertNever
|
|
2
|
+
import { assertNever } from "../../utils.js";
|
|
4
3
|
import type {
|
|
5
4
|
PersonalSignSignatureRequest,
|
|
6
5
|
TypedDataSignatureRequest,
|
|
7
6
|
AuthorizationSignatureRequest,
|
|
8
7
|
Eip7702UnsignedAuth,
|
|
9
|
-
UserOpSig,
|
|
10
8
|
EcdsaSig,
|
|
11
|
-
WebauthnSig,
|
|
12
9
|
} from "@alchemy/wallet-api-types";
|
|
13
10
|
import { vToYParity } from "ox/Signature";
|
|
14
11
|
import type { WithoutRawPayload } from "../../types.ts";
|
|
15
12
|
import { metrics } from "../../metrics.js";
|
|
16
|
-
import type { SmartWalletSigner
|
|
17
|
-
import { toWebAuthnAccount } from "viem/account-abstraction";
|
|
13
|
+
import type { SmartWalletSigner } from "../index.js";
|
|
18
14
|
|
|
19
15
|
export type SignSignatureRequestParams = WithoutRawPayload<
|
|
20
16
|
| PersonalSignSignatureRequest
|
|
@@ -24,41 +20,13 @@ export type SignSignatureRequestParams = WithoutRawPayload<
|
|
|
24
20
|
})
|
|
25
21
|
>;
|
|
26
22
|
|
|
27
|
-
export type SignSignatureRequestResult =
|
|
28
|
-
|
|
29
|
-
// Overload: Always an ECDSA signer, can sign any type of request
|
|
30
|
-
export async function signSignatureRequest(
|
|
31
|
-
signer: SmartAccountSigner,
|
|
32
|
-
params: WithoutRawPayload<
|
|
33
|
-
| PersonalSignSignatureRequest
|
|
34
|
-
| TypedDataSignatureRequest
|
|
35
|
-
| (AuthorizationSignatureRequest & {
|
|
36
|
-
data: Eip7702UnsignedAuth;
|
|
37
|
-
})
|
|
38
|
-
>,
|
|
39
|
-
): Promise<EcdsaSig["signature"]>;
|
|
40
|
-
|
|
41
|
-
// Overload: WebAuthn signer, can only sign personal_sign and eth_signTypedData_v4
|
|
42
|
-
export async function signSignatureRequest(
|
|
43
|
-
signer: WebAuthnSigner,
|
|
44
|
-
params: WithoutRawPayload<
|
|
45
|
-
PersonalSignSignatureRequest | TypedDataSignatureRequest
|
|
46
|
-
>,
|
|
47
|
-
): Promise<WebauthnSig["signature"]>;
|
|
48
|
-
|
|
49
|
-
// Overload: Union type of signer, can only sign personal_sign and eth_signTypedData_v4
|
|
50
|
-
export async function signSignatureRequest(
|
|
51
|
-
signer: SmartAccountSigner | WebAuthnSigner,
|
|
52
|
-
params: WithoutRawPayload<
|
|
53
|
-
PersonalSignSignatureRequest | TypedDataSignatureRequest
|
|
54
|
-
>,
|
|
55
|
-
): Promise<UserOpSig["signature"]>;
|
|
23
|
+
export type SignSignatureRequestResult = EcdsaSig["signature"];
|
|
56
24
|
|
|
57
25
|
/**
|
|
58
26
|
* Signs a signature request using the provided signer.
|
|
59
27
|
* This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
|
|
60
28
|
*
|
|
61
|
-
* @param {SmartAccountSigner
|
|
29
|
+
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
62
30
|
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
63
31
|
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
64
32
|
* @param {SignSignatureRequestParams["data"]} params.data - The data to sign, format depends on the signature type
|
|
@@ -84,11 +52,10 @@ export async function signSignatureRequest(
|
|
|
84
52
|
* });
|
|
85
53
|
* ```
|
|
86
54
|
*/
|
|
87
|
-
|
|
88
55
|
export async function signSignatureRequest(
|
|
89
56
|
signer: SmartWalletSigner,
|
|
90
57
|
params: SignSignatureRequestParams,
|
|
91
|
-
): Promise<
|
|
58
|
+
): Promise<EcdsaSig["signature"]> {
|
|
92
59
|
metrics.trackEvent({
|
|
93
60
|
name: "sign_signature_request",
|
|
94
61
|
data: {
|
|
@@ -98,55 +65,18 @@ export async function signSignatureRequest(
|
|
|
98
65
|
|
|
99
66
|
switch (params.type) {
|
|
100
67
|
case "personal_sign": {
|
|
101
|
-
if (isWebAuthnSigner(signer)) {
|
|
102
|
-
const webAuthnAccount = toWebAuthnAccount({ ...signer });
|
|
103
|
-
|
|
104
|
-
const { signature, webauthn: metadata } =
|
|
105
|
-
await webAuthnAccount.signMessage({
|
|
106
|
-
message: params.data,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
type: "webauthn-p256",
|
|
111
|
-
data: {
|
|
112
|
-
signature,
|
|
113
|
-
metadata,
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
68
|
return {
|
|
119
69
|
type: "secp256k1",
|
|
120
70
|
data: await signer.signMessage(params.data),
|
|
121
71
|
};
|
|
122
72
|
}
|
|
123
73
|
case "eth_signTypedData_v4": {
|
|
124
|
-
if (isWebAuthnSigner(signer)) {
|
|
125
|
-
const webAuthnAccount = toWebAuthnAccount({ ...signer });
|
|
126
|
-
|
|
127
|
-
const { signature, webauthn: metadata } =
|
|
128
|
-
await webAuthnAccount.signTypedData(params.data);
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
type: "webauthn-p256",
|
|
132
|
-
data: {
|
|
133
|
-
signature,
|
|
134
|
-
metadata,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
74
|
return {
|
|
139
75
|
type: "secp256k1",
|
|
140
76
|
data: await signer.signTypedData(params.data),
|
|
141
77
|
};
|
|
142
78
|
}
|
|
143
79
|
case "eip7702Auth": {
|
|
144
|
-
if (isWebAuthnSigner(signer)) {
|
|
145
|
-
throw new Error(
|
|
146
|
-
"WebAuthn account cannot sign EIP-7702 authorization requests",
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
80
|
if (!signer.signAuthorization) {
|
|
151
81
|
throw new Error("Signer does not implement signAuthorization");
|
|
152
82
|
}
|
|
@@ -15,7 +15,7 @@ export type SignTypedDataResult = Hex;
|
|
|
15
15
|
* This method requests the account associated with the signer and uses it to sign the typed data.
|
|
16
16
|
*
|
|
17
17
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
18
|
-
* @param {SmartAccountSigner
|
|
18
|
+
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
19
19
|
* @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format
|
|
20
20
|
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
21
21
|
*
|
package/src/client/decorator.ts
CHANGED
|
@@ -56,24 +56,6 @@ import {
|
|
|
56
56
|
type SendCallsResult,
|
|
57
57
|
} from "./actions/sendCalls.js";
|
|
58
58
|
import type { SmartWalletSigner } from "./index.js";
|
|
59
|
-
import { isWebAuthnSigner } from "../utils.js";
|
|
60
|
-
|
|
61
|
-
async function signSignatureRequestSafe(
|
|
62
|
-
signer: SmartWalletSigner,
|
|
63
|
-
params: SignSignatureRequestParams,
|
|
64
|
-
): Promise<SignSignatureRequestResult> {
|
|
65
|
-
if (params.type === "eip7702Auth") {
|
|
66
|
-
if (isWebAuthnSigner(signer)) {
|
|
67
|
-
throw new Error(
|
|
68
|
-
"WebAuthn signer cannot sign EIP-7702 authorization requests",
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
// We must split up the call to signSignatureRequest across two conditionals for the TS compiler to
|
|
72
|
-
// correctly infer which overload to use.
|
|
73
|
-
return signSignatureRequest(signer, params);
|
|
74
|
-
}
|
|
75
|
-
return signSignatureRequest(signer, params);
|
|
76
|
-
}
|
|
77
59
|
|
|
78
60
|
export type SmartWalletActions<
|
|
79
61
|
TAccount extends Address | undefined = Address | undefined,
|
|
@@ -122,7 +104,7 @@ export function smartWalletClientActions<
|
|
|
122
104
|
sendCalls: (params) => sendCalls(client, signer, params),
|
|
123
105
|
getCallsStatus: (params) => getCallsStatus(client, params),
|
|
124
106
|
waitForCallsStatus: (params) => waitForCallsStatus(client, params),
|
|
125
|
-
signSignatureRequest: (params) =>
|
|
107
|
+
signSignatureRequest: (params) => signSignatureRequest(signer, params),
|
|
126
108
|
signPreparedCalls: (params) => signPreparedCalls(signer, params),
|
|
127
109
|
signMessage: (params) => signMessage(client, signer, params),
|
|
128
110
|
signTypedData: (params) => signTypedData(client, signer, params),
|
package/src/client/index.ts
CHANGED
|
@@ -21,15 +21,8 @@ import type {
|
|
|
21
21
|
} from "@alchemy/wallet-api-types/rpc";
|
|
22
22
|
import { internalStateDecorator } from "../internal/decorator.js";
|
|
23
23
|
import { metrics } from "../metrics.js";
|
|
24
|
-
import type { ToWebAuthnAccountParameters } from "viem/account-abstraction";
|
|
25
24
|
|
|
26
|
-
export type
|
|
27
|
-
credential: ToWebAuthnAccountParameters["credential"];
|
|
28
|
-
getFn?: ToWebAuthnAccountParameters["getFn"] | undefined;
|
|
29
|
-
rpId?: ToWebAuthnAccountParameters["rpId"] | undefined;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type SmartWalletSigner = SmartAccountSigner<any> | WebAuthnSigner;
|
|
25
|
+
export type SmartWalletSigner = SmartAccountSigner<any>;
|
|
33
26
|
|
|
34
27
|
export type SmartWalletClientParams<
|
|
35
28
|
TAccount extends Address | undefined = Address | undefined,
|
|
@@ -55,7 +48,7 @@ export type SmartWalletClient<
|
|
|
55
48
|
* @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client
|
|
56
49
|
* @param {AlchemyTransport} params.transport - The Alchemy transport to use
|
|
57
50
|
* @param {Chain} params.chain - The chain to use
|
|
58
|
-
* @param {SmartAccountSigner
|
|
51
|
+
* @param {SmartAccountSigner} params.signer - The signer to use for the smart account
|
|
59
52
|
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
60
53
|
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
61
54
|
* @returns {SmartWalletClient} - A viem-compatible client
|
package/src/internal/account.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InvalidSignerTypeError,
|
|
3
|
-
type SmartContractAccount,
|
|
4
|
-
} from "@aa-sdk/core";
|
|
1
|
+
import type { SmartContractAccount } from "@aa-sdk/core";
|
|
5
2
|
import {
|
|
6
3
|
createModularAccountV2,
|
|
7
4
|
createLightAccount,
|
|
@@ -17,7 +14,7 @@ import {
|
|
|
17
14
|
} from "viem";
|
|
18
15
|
import type { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
19
16
|
import { InternalError, InvalidRequestError } from "ox/RpcResponse";
|
|
20
|
-
import { assertNever
|
|
17
|
+
import { assertNever } from "../utils.js";
|
|
21
18
|
import { metrics } from "../metrics.js";
|
|
22
19
|
import type { SmartWalletSigner } from "../client/index.js";
|
|
23
20
|
|
|
@@ -59,10 +56,6 @@ export async function createAccount(
|
|
|
59
56
|
throw new Error("7702 mode currently only supports ModularAccountV2");
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
if (isWebAuthnSigner(signer)) {
|
|
63
|
-
throw new InvalidSignerTypeError("WebAuthn");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
59
|
return createModularAccountV2({
|
|
67
60
|
...accountParams,
|
|
68
61
|
signer,
|
|
@@ -92,23 +85,6 @@ export async function createAccount(
|
|
|
92
85
|
},
|
|
93
86
|
});
|
|
94
87
|
|
|
95
|
-
// WebAuthn accounts must use a different signer type, so they are handled separately.
|
|
96
|
-
if (factoryType === "MAv2.0.0-ma-webauthn") {
|
|
97
|
-
if (!isWebAuthnSigner(signer)) {
|
|
98
|
-
throw new InvalidSignerTypeError(signer.signerType);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return createModularAccountV2({
|
|
102
|
-
...commonParams,
|
|
103
|
-
...signer,
|
|
104
|
-
mode: "webauthn",
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (isWebAuthnSigner(signer)) {
|
|
109
|
-
throw new InvalidSignerTypeError("WebAuthn");
|
|
110
|
-
}
|
|
111
|
-
|
|
112
88
|
// Return the account created based on the factory type
|
|
113
89
|
switch (factoryType) {
|
|
114
90
|
case "MAv2.0.0-sma-b":
|