@alchemy/wallet-apis 0.0.0-alpha.14 → 0.0.0-alpha.16

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.
Files changed (92) hide show
  1. package/dist/esm/actions/grantPermissions.js +9 -2
  2. package/dist/esm/actions/grantPermissions.js.map +1 -1
  3. package/dist/esm/actions/listAccounts.d.ts +10 -2
  4. package/dist/esm/actions/listAccounts.js +23 -2
  5. package/dist/esm/actions/listAccounts.js.map +1 -1
  6. package/dist/esm/actions/requestAccount.d.ts +10 -3
  7. package/dist/esm/actions/requestAccount.js +43 -15
  8. package/dist/esm/actions/requestAccount.js.map +1 -1
  9. package/dist/esm/actions/sendCalls.d.ts +4 -0
  10. package/dist/esm/actions/sendCalls.js +26 -4
  11. package/dist/esm/actions/sendCalls.js.map +1 -1
  12. package/dist/esm/actions/sendPreparedCalls.js +2 -0
  13. package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
  14. package/dist/esm/actions/signMessage.js +5 -1
  15. package/dist/esm/actions/signMessage.js.map +1 -1
  16. package/dist/esm/actions/signPreparedCalls.js +6 -1
  17. package/dist/esm/actions/signPreparedCalls.js.map +1 -1
  18. package/dist/esm/actions/signSignatureRequest.d.ts +10 -3
  19. package/dist/esm/actions/signSignatureRequest.js +93 -42
  20. package/dist/esm/actions/signSignatureRequest.js.map +1 -1
  21. package/dist/esm/actions/signTypedData.js +5 -1
  22. package/dist/esm/actions/signTypedData.js.map +1 -1
  23. package/dist/esm/client.d.ts +4 -4
  24. package/dist/esm/client.js +3 -13
  25. package/dist/esm/client.js.map +1 -1
  26. package/dist/esm/types.d.ts +4 -7
  27. package/dist/esm/types.js.map +1 -1
  28. package/dist/esm/utils/assertions.d.ts +6 -2
  29. package/dist/esm/utils/assertions.js +9 -0
  30. package/dist/esm/utils/assertions.js.map +1 -1
  31. package/dist/esm/utils/capabilities.d.ts +13 -4
  32. package/dist/esm/utils/capabilities.js +37 -11
  33. package/dist/esm/utils/capabilities.js.map +1 -1
  34. package/dist/esm/utils/format.d.ts +3 -1
  35. package/dist/esm/utils/format.js +11 -1
  36. package/dist/esm/utils/format.js.map +1 -1
  37. package/dist/esm/utils/signer.d.ts +10 -0
  38. package/dist/esm/utils/signer.js +28 -0
  39. package/dist/esm/utils/signer.js.map +1 -0
  40. package/dist/esm/utils/viemDecode.d.ts +1 -1
  41. package/dist/esm/utils/viemDecode.js.map +1 -1
  42. package/dist/esm/utils/viemEncode.js.map +1 -1
  43. package/dist/esm/version.d.ts +1 -1
  44. package/dist/esm/version.js +1 -1
  45. package/dist/esm/version.js.map +1 -1
  46. package/dist/types/actions/grantPermissions.d.ts.map +1 -1
  47. package/dist/types/actions/listAccounts.d.ts +10 -2
  48. package/dist/types/actions/listAccounts.d.ts.map +1 -1
  49. package/dist/types/actions/requestAccount.d.ts +10 -3
  50. package/dist/types/actions/requestAccount.d.ts.map +1 -1
  51. package/dist/types/actions/sendCalls.d.ts +4 -0
  52. package/dist/types/actions/sendCalls.d.ts.map +1 -1
  53. package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
  54. package/dist/types/actions/signMessage.d.ts.map +1 -1
  55. package/dist/types/actions/signPreparedCalls.d.ts.map +1 -1
  56. package/dist/types/actions/signSignatureRequest.d.ts +10 -3
  57. package/dist/types/actions/signSignatureRequest.d.ts.map +1 -1
  58. package/dist/types/actions/signTypedData.d.ts.map +1 -1
  59. package/dist/types/client.d.ts +4 -4
  60. package/dist/types/client.d.ts.map +1 -1
  61. package/dist/types/types.d.ts +4 -7
  62. package/dist/types/types.d.ts.map +1 -1
  63. package/dist/types/utils/assertions.d.ts +6 -2
  64. package/dist/types/utils/assertions.d.ts.map +1 -1
  65. package/dist/types/utils/capabilities.d.ts +13 -4
  66. package/dist/types/utils/capabilities.d.ts.map +1 -1
  67. package/dist/types/utils/format.d.ts +3 -1
  68. package/dist/types/utils/format.d.ts.map +1 -1
  69. package/dist/types/utils/signer.d.ts +11 -0
  70. package/dist/types/utils/signer.d.ts.map +1 -0
  71. package/dist/types/utils/viemDecode.d.ts +1 -1
  72. package/dist/types/utils/viemDecode.d.ts.map +1 -1
  73. package/dist/types/version.d.ts +1 -1
  74. package/package.json +7 -6
  75. package/src/actions/grantPermissions.ts +13 -2
  76. package/src/actions/listAccounts.ts +39 -5
  77. package/src/actions/requestAccount.ts +67 -22
  78. package/src/actions/sendCalls.ts +40 -4
  79. package/src/actions/sendPreparedCalls.ts +3 -0
  80. package/src/actions/signMessage.ts +8 -0
  81. package/src/actions/signPreparedCalls.ts +14 -1
  82. package/src/actions/signSignatureRequest.ts +165 -54
  83. package/src/actions/signTypedData.ts +8 -0
  84. package/src/client.ts +5 -23
  85. package/src/types.ts +5 -5
  86. package/src/utils/assertions.ts +21 -2
  87. package/src/utils/capabilities.ts +56 -15
  88. package/src/utils/format.ts +20 -1
  89. package/src/utils/signer.ts +36 -0
  90. package/src/utils/viemDecode.ts +1 -1
  91. package/src/utils/viemEncode.ts +1 -1
  92. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"viemDecode.d.ts","sourceRoot":"","sources":["../../../src/utils/viemDecode.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAEV,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AACpG,OAAO,KAAK,EACV,4BAA4B,EAC5B,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,uBAAuB,GAClC,cAAc,wBAAwB,KACrC,kBA2BF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,MACI,4BAA4B,GAC5B,8BAA8B,GAC9B,4BAA4B,KAE9B,uBAAuB,GACvB,uBAAuB,GACvB,mBAAmB,GACnB,0BAgBH,CAAC;AAwIF,eAAO,MAAM,sBAAsB,GACjC,cAAc,YAAY,GAAG,SAAS,KACrC,qBA6FF,CAAC"}
1
+ {"version":3,"file":"viemDecode.d.ts","sourceRoot":"","sources":["../../../src/utils/viemDecode.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAEV,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,wBAAwB,IAAI,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAChH,OAAO,KAAK,EACV,4BAA4B,EAC5B,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,uBAAuB,GAClC,cAAc,wBAAwB,KACrC,kBA2BF,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,MACI,4BAA4B,GAC5B,8BAA8B,GAC9B,4BAA4B,KAE9B,uBAAuB,GACvB,uBAAuB,GACvB,mBAAmB,GACnB,0BAgBH,CAAC;AAwIF,eAAO,MAAM,sBAAsB,GACjC,cAAc,YAAY,GAAG,SAAS,KACrC,qBA6FF,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.0.0-alpha.13";
1
+ export declare const VERSION = "0.0.0-alpha.15";
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": "0.0.0-alpha.14",
3
+ "version": "0.0.0-alpha.16",
4
4
  "description": "Alchemy Wallet APIs",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -54,11 +54,12 @@
54
54
  "typescript-template": "*"
55
55
  },
56
56
  "dependencies": {
57
- "@alchemy/common": "^0.0.0-alpha.14",
58
- "@alchemy/wallet-api-types": "^0.1.0-alpha.18",
57
+ "@alchemy/common": "^0.0.0-alpha.16",
58
+ "@alchemy/wallet-api-types": "^0.1.0-alpha.22",
59
59
  "deep-equal": "^2.2.3",
60
- "ox": "^0.6.12",
61
- "viem": "^2.32.0"
60
+ "ox": "^0.11.1",
61
+ "viem": "^2.44.2",
62
+ "webauthn-p256": "^0.0.10"
62
63
  },
63
64
  "publishConfig": {
64
65
  "access": "public",
@@ -72,5 +73,5 @@
72
73
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
73
74
  },
74
75
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
75
- "gitHead": "11e8a88c8ff02396f2e46d47f183eae43b4eb43c"
76
+ "gitHead": "299dbbeffbba1ee90b8cc4f5f0931cad3645add0"
76
77
  }
@@ -9,9 +9,10 @@ import {
9
9
  import type { InnerWalletApiClient } from "../types.ts";
10
10
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
11
11
  import { signSignatureRequest } from "./signSignatureRequest.js";
12
- import { AccountNotFoundError } from "@alchemy/common";
12
+ import { AccountNotFoundError, BaseError } from "@alchemy/common";
13
13
  import { LOGGER } from "../logger.js";
14
14
  import type { OptionalChainId } from "../types.ts";
15
+ import { isWebAuthnAccount } from "../utils/assertions.js";
15
16
 
16
17
  type RpcSchema = Extract<
17
18
  WalletServerRpcSchemaType,
@@ -100,6 +101,13 @@ export async function grantPermissions<
100
101
  LOGGER.warn("grantPermissions:no-account");
101
102
  throw new AccountNotFoundError();
102
103
  }
104
+ if (isWebAuthnAccount(client.owner)) {
105
+ LOGGER.warn("grantPermissions:unsupported-account");
106
+ throw new BaseError(
107
+ "WebAuthn signer is not currently supported for grantPermissions",
108
+ );
109
+ }
110
+
103
111
  LOGGER.debug("grantPermissions:start", { expirySec: params.expirySec });
104
112
  const { sessionId, signatureRequest } = await client.request({
105
113
  method: "wallet_createSession",
@@ -113,11 +121,14 @@ export async function grantPermissions<
113
121
  });
114
122
 
115
123
  const signature = await signSignatureRequest(client, signatureRequest);
124
+
116
125
  const res = {
117
126
  context: concatHex([
118
127
  "0x00", // Remote mode.
119
128
  sessionId,
120
- signature.data,
129
+ signature.type === "webauthn-p256"
130
+ ? signature.data.signature
131
+ : signature.data,
121
132
  ]),
122
133
  } as const;
123
134
  LOGGER.debug("grantPermissions:done");
@@ -2,6 +2,8 @@ import type { InnerWalletApiClient } from "../types.ts";
2
2
  import { LOGGER } from "../logger.js";
3
3
  import type { Address, Prettify } from "viem";
4
4
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
5
+ import { getSignerAddressOrPublicKey } from "../utils/signer.js";
6
+ import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
5
7
 
6
8
  type RpcSchema = Extract<
7
9
  WalletServerRpcSchemaType,
@@ -13,9 +15,18 @@ type RpcSchema = Extract<
13
15
  >;
14
16
 
15
17
  export type ListAccountsParams = Prettify<
16
- Omit<RpcSchema["Request"]["params"][0], "signerAddress"> & {
17
- signerAddress?: Address;
18
- }
18
+ Omit<RpcSchema["Request"]["params"][0], "signerAddress"> &
19
+ (
20
+ | {
21
+ signerAddress?: Address;
22
+ signerPublicKey?: never;
23
+ }
24
+ | { signerPublicKey: WebAuthnPublicKey; signerAddress?: never }
25
+ | {
26
+ signerAddress?: never;
27
+ signerPublicKey?: never;
28
+ }
29
+ )
19
30
  >;
20
31
 
21
32
  export type ListAccountsResult = Prettify<RpcSchema["ReturnType"]>;
@@ -50,17 +61,40 @@ export async function listAccounts(
50
61
  client: InnerWalletApiClient,
51
62
  params: ListAccountsParams,
52
63
  ): Promise<ListAccountsResult> {
53
- const signerAddress = params.signerAddress ?? client.owner.account.address;
64
+ const owner = getSignerAddressOrPublicKey(client.owner);
65
+
66
+ // Coalesce:
67
+ // signerAddress or signerPublicKey in params takes priority.
68
+ // if not present, then fallback to client's attached signer.
69
+ const signerParam: RpcSchema["Request"]["params"][0] = params.signerAddress
70
+ ? { signerAddress: params.signerAddress }
71
+ : params.signerPublicKey
72
+ ? {
73
+ signerPublicKey: {
74
+ type: "webauthn-p256",
75
+ ...params.signerPublicKey,
76
+ },
77
+ }
78
+ : owner.type === "webauthn-p256"
79
+ ? {
80
+ signerPublicKey: {
81
+ type: "webauthn-p256",
82
+ ...owner.publicKey,
83
+ },
84
+ }
85
+ : { signerAddress: owner.address };
86
+
54
87
  LOGGER.debug("listAccounts:start", { hasAfter: !!params.after });
55
88
  const res = await client.request({
56
89
  method: "wallet_listAccounts",
57
90
  params: [
58
91
  {
59
92
  ...params,
60
- signerAddress,
93
+ ...signerParam,
61
94
  },
62
95
  ],
63
96
  });
64
97
  LOGGER.debug("listAccounts:done", { count: res.accounts.length });
98
+
65
99
  return res;
66
100
  }
@@ -1,9 +1,16 @@
1
1
  import type { Address } from "abitype";
2
- import type { Prettify, UnionOmit } from "viem";
2
+ import { BaseError, type Prettify } from "viem";
3
3
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
4
4
  import deepEqual from "deep-equal";
5
- import type { InnerWalletApiClient, OptionalSignerAddress } from "../types";
5
+ import type { InnerWalletApiClient } from "../types";
6
6
  import { LOGGER } from "../logger.js";
7
+ import type {
8
+ CreationOptionsByPublicKey,
9
+ CreationOptionsBySignerAddress,
10
+ WebAuthnPublicKey,
11
+ } from "@alchemy/wallet-api-types";
12
+ import { isWebAuthnAccount } from "../utils/assertions.js";
13
+ import { getSignerAddressOrPublicKey } from "../utils/signer.js";
7
14
 
8
15
  type RpcSchema = Extract<
9
16
  WalletServerRpcSchemaType,
@@ -15,9 +22,13 @@ type RpcSchema = Extract<
15
22
  >;
16
23
 
17
24
  export type RequestAccountParams = Prettify<
18
- OptionalSignerAddress<
19
- UnionOmit<RpcSchema["Request"]["params"][0], "includeCounterfactualInfo">
20
- >
25
+ Omit<
26
+ Extract<
27
+ RpcSchema["Request"]["params"][0],
28
+ { signerAddress: Address } | { signerPublicKey: WebAuthnPublicKey }
29
+ >,
30
+ "signerAddress" | "signerPublicKey" | "includeCounterfactualInfo"
31
+ > & { accountAddress?: Address }
21
32
  >;
22
33
 
23
34
  export type RequestAccountResult = Prettify<{ address: Address }>;
@@ -48,31 +59,65 @@ export async function requestAccount(
48
59
  hasParams: !!params,
49
60
  hasAccountOnClient: !!client.account,
50
61
  });
51
- const args =
52
- client.account && !params
62
+
63
+ const { creationHint = {} } = params ?? {};
64
+
65
+ if (isWebAuthnAccount(client.owner)) {
66
+ if (
67
+ creationHint.accountType &&
68
+ creationHint.accountType !== "mav2-webauthn"
69
+ ) {
70
+ throw new BaseError(
71
+ "WebAuthn signers are only supported with mav2-webauthn account type",
72
+ );
73
+ }
74
+ } else {
75
+ // Non-webauthn signers do not support the "mav2-webauthn" account type.
76
+ if (creationHint.accountType === "mav2-webauthn") {
77
+ throw new BaseError(
78
+ "ECDSA (secp256k1) signers are not supported with mav2-webauthn account type",
79
+ );
80
+ }
81
+ }
82
+
83
+ const owner = getSignerAddressOrPublicKey(client.owner);
84
+
85
+ const args: RpcSchema["Request"]["params"][0] =
86
+ (client.account && !params) || params?.accountAddress
53
87
  ? {
54
- accountAddress: client.account.address,
88
+ accountAddress: params?.accountAddress ?? client.account!.address,
55
89
  includeCounterfactualInfo: true,
56
90
  }
57
- : params != null && "accountAddress" in params
58
- ? {
59
- accountAddress: params.accountAddress,
60
- includeCounterfactualInfo: true,
61
- }
62
- : {
63
- ...params,
64
- signerAddress:
65
- (params && "signerAddress" in params
66
- ? params.signerAddress
67
- : undefined) ?? client.owner.account.address,
68
- includeCounterfactualInfo: true,
69
- };
91
+ : {
92
+ ...(owner.type === "webauthn-p256"
93
+ ? {
94
+ signerPublicKey: {
95
+ ...owner.publicKey,
96
+ type: "webauthn-p256",
97
+ },
98
+ // Casts here are safe due to our checks above.
99
+ ...(creationHint
100
+ ? { creationHint: creationHint as CreationOptionsByPublicKey }
101
+ : {}),
102
+ }
103
+ : {
104
+ signerAddress: owner.address,
105
+ ...(creationHint
106
+ ? {
107
+ creationHint:
108
+ creationHint as CreationOptionsBySignerAddress,
109
+ }
110
+ : {}),
111
+ }),
112
+ includeCounterfactualInfo: true,
113
+ };
70
114
 
71
115
  const cachedAccount = client.internal?.getAccount();
72
116
 
73
117
  if (
74
118
  cachedAccount &&
75
- ((args.accountAddress && cachedAccount.address === args.accountAddress) ||
119
+ ((params?.accountAddress &&
120
+ cachedAccount.address === params.accountAddress) ||
76
121
  deepEqual(cachedAccount.requestParams, args, { strict: true }))
77
122
  ) {
78
123
  LOGGER.debug("requestAccount:cache-hit", {
@@ -7,6 +7,10 @@ import {
7
7
  type SendPreparedCallsResult,
8
8
  } from "./sendPreparedCalls.js";
9
9
  import { LOGGER } from "../logger.js";
10
+ import { signSignatureRequest } from "./signSignatureRequest.js";
11
+ import { isWebAuthnAccount } from "../utils/assertions.js";
12
+ import { extractCapabilitiesForSending } from "../utils/capabilities.js";
13
+ import { BaseError } from "@alchemy/common";
10
14
 
11
15
  export type SendCallsParams<
12
16
  TAccount extends Address | undefined = Address | undefined,
@@ -40,6 +44,10 @@ export type SendCallsResult = Prettify<SendPreparedCallsResult>;
40
44
  * // The result contains the prepared call IDs
41
45
  * console.log(result.preparedCallIds);
42
46
  * ```
47
+ * <Note>
48
+ * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden
49
+ * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.
50
+ * </Note>
43
51
  */
44
52
  export async function sendCalls<
45
53
  TAccount extends Address | undefined = Address | undefined,
@@ -51,15 +59,43 @@ export async function sendCalls<
51
59
  calls: params.calls?.length,
52
60
  hasCapabilities: !!params.capabilities,
53
61
  });
54
- const calls = await prepareCalls(client, params);
62
+ let calls = await prepareCalls(client, params);
63
+
64
+ if (calls.type === "paymaster-permit") {
65
+ if (isWebAuthnAccount(client.owner)) {
66
+ throw new BaseError(
67
+ "WebAuthn signer is not currently supported for signing paymaster permit signatures",
68
+ );
69
+ }
70
+ const signature = await signSignatureRequest(
71
+ client,
72
+ calls.signatureRequest,
73
+ );
74
+
75
+ const secondCallParams = {
76
+ from: calls.modifiedRequest.from,
77
+ calls: calls.modifiedRequest.calls,
78
+ capabilities: calls.modifiedRequest.capabilities,
79
+ // WebAuthn signatures are not supported for paymaster permits (throws above).
80
+ paymasterPermitSignature: signature as Exclude<
81
+ typeof signature,
82
+ { type: "webauthn-p256" }
83
+ >,
84
+ };
85
+
86
+ calls = await prepareCalls(client, secondCallParams);
87
+ }
55
88
 
56
89
  const signedCalls = await signPreparedCalls(client, calls);
57
90
 
91
+ const sendPreparedCallsCapabilities = extractCapabilitiesForSending(
92
+ params.capabilities,
93
+ );
94
+
58
95
  const res = await sendPreparedCalls(client, {
59
96
  ...signedCalls,
60
- // The only capability that is supported in sendPreparedCalls is permissions.
61
- ...(params.capabilities?.permissions != null
62
- ? { capabilities: { permissions: params.capabilities.permissions } }
97
+ ...(sendPreparedCallsCapabilities != null
98
+ ? { capabilities: sendPreparedCallsCapabilities }
63
99
  : {}),
64
100
  });
65
101
  LOGGER.info("sendCalls:done");
@@ -2,6 +2,7 @@ import { toHex, type Prettify } from "viem";
2
2
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
3
3
  import type { InnerWalletApiClient, OptionalChainId } from "../types.ts";
4
4
  import { LOGGER } from "../logger.js";
5
+ import { mergeClientCapabilities } from "../utils/capabilities.js";
5
6
 
6
7
  type RpcSchema = Extract<
7
8
  WalletServerRpcSchemaType,
@@ -53,6 +54,8 @@ export async function sendPreparedCalls(
53
54
  client: InnerWalletApiClient,
54
55
  params: SendPreparedCallsParams,
55
56
  ): Promise<SendPreparedCallsResult> {
57
+ params.capabilities = mergeClientCapabilities(client, params.capabilities);
58
+
56
59
  LOGGER.debug("sendPreparedCalls:start", { type: params.type });
57
60
  const res = await client.request({
58
61
  method: "wallet_sendPreparedCalls",
@@ -3,6 +3,7 @@ import {
3
3
  type Hex,
4
4
  type Prettify,
5
5
  type SignableMessage,
6
+ BaseError,
6
7
  } from "viem";
7
8
  import type { InnerWalletApiClient } from "../types.js";
8
9
  import { requestAccount } from "./requestAccount.js";
@@ -62,6 +63,13 @@ export async function signMessage(
62
63
 
63
64
  const signed = await signSignatureRequest(client, prepared.signatureRequest);
64
65
 
66
+ // TODO: Wallet server needs to be updated to support webauthn here.
67
+ if (signed.type === "webauthn-p256") {
68
+ throw new BaseError(
69
+ "WebAuthn account is currently unsupported by wallet_formatSign",
70
+ );
71
+ }
72
+
65
73
  const formatted = await formatSign(client, {
66
74
  from: account.address,
67
75
  signature: {
@@ -10,6 +10,7 @@ import type {
10
10
  import type { InnerWalletApiClient } from "../types.js";
11
11
  import { LOGGER } from "../logger.js";
12
12
  import type { SendPreparedCallsParams } from "./sendPreparedCalls.js";
13
+ import { isWebAuthnAccount } from "../utils/assertions.js";
13
14
 
14
15
  export type SignPreparedCallsParams = Prettify<PrepareCallsResult>;
15
16
 
@@ -45,8 +46,16 @@ export async function signPreparedCalls(
45
46
  params: SignPreparedCallsParams,
46
47
  ): Promise<SignPreparedCallsResult> {
47
48
  LOGGER.debug("signPreparedCalls:start", { type: params.type });
49
+
48
50
  const signAuthorizationCall = async (call: PreparedCall_Authorization) => {
49
51
  const { signatureRequest: _signatureRequest, ...rest } = call;
52
+
53
+ if (isWebAuthnAccount(client.owner)) {
54
+ throw new BaseError(
55
+ "WebAuthn account cannot sign EIP-7702 authorization requests",
56
+ );
57
+ }
58
+
50
59
  const signature = await signSignatureRequest(client, {
51
60
  type: "eip7702Auth",
52
61
  data: {
@@ -54,9 +63,13 @@ export async function signPreparedCalls(
54
63
  chainId: call.chainId,
55
64
  },
56
65
  });
66
+ // Authorization signatures are never webauthn-256 (throws above).
57
67
  return {
58
68
  ...rest,
59
- signature,
69
+ signature: signature as Exclude<
70
+ typeof signature,
71
+ { type: "webauthn-p256" }
72
+ >,
60
73
  };
61
74
  };
62
75