@account-kit/wallet-client 4.84.0 → 4.84.1

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 (72) hide show
  1. package/dist/esm/client/actions/grantPermissions.d.ts +1 -1
  2. package/dist/esm/client/actions/grantPermissions.js +1 -5
  3. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  4. package/dist/esm/client/actions/listAccounts.d.ts +4 -8
  5. package/dist/esm/client/actions/listAccounts.js +6 -27
  6. package/dist/esm/client/actions/listAccounts.js.map +1 -1
  7. package/dist/esm/client/actions/requestAccount.d.ts +3 -6
  8. package/dist/esm/client/actions/requestAccount.js +5 -31
  9. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  10. package/dist/esm/client/actions/sendCalls.d.ts +1 -1
  11. package/dist/esm/client/actions/sendCalls.js +1 -5
  12. package/dist/esm/client/actions/sendCalls.js.map +1 -1
  13. package/dist/esm/client/actions/signMessage.d.ts +1 -1
  14. package/dist/esm/client/actions/signMessage.js +1 -1
  15. package/dist/esm/client/actions/signMessage.js.map +1 -1
  16. package/dist/esm/client/actions/signPreparedCalls.d.ts +1 -1
  17. package/dist/esm/client/actions/signPreparedCalls.js +2 -5
  18. package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
  19. package/dist/esm/client/actions/signSignatureRequest.d.ts +34 -9
  20. package/dist/esm/client/actions/signSignatureRequest.js +2 -30
  21. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  22. package/dist/esm/client/actions/signTypedData.d.ts +1 -1
  23. package/dist/esm/client/actions/signTypedData.js +1 -1
  24. package/dist/esm/client/actions/signTypedData.js.map +1 -1
  25. package/dist/esm/client/decorator.js +1 -13
  26. package/dist/esm/client/decorator.js.map +1 -1
  27. package/dist/esm/client/index.d.ts +2 -8
  28. package/dist/esm/client/index.js.map +1 -1
  29. package/dist/esm/internal/account.d.ts +1 -1
  30. package/dist/esm/internal/account.js +1 -19
  31. package/dist/esm/internal/account.js.map +1 -1
  32. package/dist/esm/utils.d.ts +0 -6
  33. package/dist/esm/utils.js +1 -14
  34. package/dist/esm/utils.js.map +1 -1
  35. package/dist/esm/version.d.ts +1 -1
  36. package/dist/esm/version.js +1 -1
  37. package/dist/esm/version.js.map +1 -1
  38. package/dist/types/client/actions/grantPermissions.d.ts +1 -1
  39. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  40. package/dist/types/client/actions/listAccounts.d.ts +4 -8
  41. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  42. package/dist/types/client/actions/requestAccount.d.ts +3 -6
  43. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  44. package/dist/types/client/actions/sendCalls.d.ts +1 -1
  45. package/dist/types/client/actions/sendCalls.d.ts.map +1 -1
  46. package/dist/types/client/actions/signMessage.d.ts +1 -1
  47. package/dist/types/client/actions/signPreparedCalls.d.ts +1 -1
  48. package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
  49. package/dist/types/client/actions/signSignatureRequest.d.ts +34 -9
  50. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  51. package/dist/types/client/actions/signTypedData.d.ts +1 -1
  52. package/dist/types/client/decorator.d.ts.map +1 -1
  53. package/dist/types/client/index.d.ts +2 -8
  54. package/dist/types/client/index.d.ts.map +1 -1
  55. package/dist/types/internal/account.d.ts +1 -1
  56. package/dist/types/internal/account.d.ts.map +1 -1
  57. package/dist/types/utils.d.ts +0 -6
  58. package/dist/types/utils.d.ts.map +1 -1
  59. package/dist/types/version.d.ts +1 -1
  60. package/package.json +6 -6
  61. package/src/client/actions/grantPermissions.ts +1 -8
  62. package/src/client/actions/listAccounts.ts +7 -35
  63. package/src/client/actions/requestAccount.ts +8 -51
  64. package/src/client/actions/sendCalls.ts +1 -7
  65. package/src/client/actions/signMessage.ts +1 -1
  66. package/src/client/actions/signPreparedCalls.ts +2 -7
  67. package/src/client/actions/signSignatureRequest.ts +5 -75
  68. package/src/client/actions/signTypedData.ts +1 -1
  69. package/src/client/decorator.ts +1 -19
  70. package/src/client/index.ts +2 -9
  71. package/src/internal/account.ts +2 -26
  72. package/src/utils.ts +1 -25
@@ -20,7 +20,7 @@ export type GrantPermissionsResult = {
20
20
  * This allows another key to perform operations on behalf of the account.
21
21
  *
22
22
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
23
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account
23
+ * @param {SmartAccountSigner} signer - The signer of the smart account
24
24
  * @param {GrantPermissionsParams} params - The parameters for granting permissions
25
25
  * @param {Address} [params.account] - The account address (required if client was not initialized with an account)
26
26
  * @param {number} params.expirySec - Unix timestamp when the permissions expire
@@ -2,13 +2,12 @@ import { AccountNotFoundError } from "@aa-sdk/core";
2
2
  import { toHex, concatHex, serializeSignature, } from "viem";
3
3
  import { signSignatureRequest } from "./signSignatureRequest.js";
4
4
  import { metrics } from "../../metrics.js";
5
- import { isWebAuthnSigner } from "../../utils.js";
6
5
  /**
7
6
  * Grants permissions to a smart account by creating a session.
8
7
  * This allows another key to perform operations on behalf of the account.
9
8
  *
10
9
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
11
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account
10
+ * @param {SmartAccountSigner} signer - The signer of the smart account
12
11
  * @param {GrantPermissionsParams} params - The parameters for granting permissions
13
12
  * @param {Address} [params.account] - The account address (required if client was not initialized with an account)
14
13
  * @param {number} params.expirySec - Unix timestamp when the permissions expire
@@ -66,9 +65,6 @@ export async function grantPermissions(client, signer, params) {
66
65
  if (!account) {
67
66
  throw new AccountNotFoundError();
68
67
  }
69
- if (isWebAuthnSigner(signer)) {
70
- throw new Error("WebAuthn signer is not currently supported for grantPermissions");
71
- }
72
68
  const { sessionId, signatureRequest } = await client.request({
73
69
  method: "wallet_createSession",
74
70
  params: [
@@ -1 +1 @@
1
- {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":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,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC;IAChC,CAAC;SAAM,CAAC;QACN,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC;QAC/B,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;YACzB,YAAY,GAAG,kBAAkB,CAAC;gBAChC,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;aACjC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,kBAAkB,CAAC;gBAChC,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,CAAC,EAAE,OAAO,CAAC,CAAC;gBACZ,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,SAAS,CAAC;YACjB,MAAM,EAAE,cAAc;YACtB,SAAS;YACT,YAAY;SACb,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport {\n toHex,\n type Address,\n type Hex,\n type IsUndefined,\n type Prettify,\n concatHex,\n serializeSignature,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\nimport { isWebAuthnSigner } from \"../../utils.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_createSession\";\n };\n }\n>;\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n Omit<RpcSchema[\"Request\"][\"params\"][0], \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never })\n>;\n\nexport type GrantPermissionsResult = {\n context: Hex;\n};\n\n/**\n * Grants permissions to a smart account by creating a session.\n * This allows another key to perform operations on behalf of the account.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account\n * @param {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {Address} [params.account] - The account address (required if client was not initialized with an account)\n * @param {number} params.expirySec - Unix timestamp when the permissions expire\n * @param {sessionKeyData} params.key - The session key information\n * @param {string} params.key.publicKey - The public key of the session key\n * @param {string} params.key.type - The type of the key (e.g., \"secp256k1\")\n * @param {Array} params.permissions - Array of permission objects defining what the session key can do\n * @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier\n *\n * @example\n * ```ts\n * // Create a session key and grant root permissions\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount();\n *\n * const permissions = await client.grantPermissions({\n * account: account.address,\n * expirySec: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now\n * key: {\n * publicKey: await sessionKey.getAddress(),\n * type: \"secp256k1\",\n * },\n * permissions: [{ type: \"root\" }],\n * });\n *\n * // Use the permissions to prepare a call\n * const preparedCalls = await client.prepareCalls({\n * calls: [{ to: zeroAddress, value: \"0x0\" }],\n * from: account.address,\n * capabilities: {\n * paymasterService: {\n * policyId: \"your-paymaster-policy-id\",\n * },\n * permissions,\n * },\n * });\n *\n * // Sign with the session key\n * const signedCalls = await signPreparedCalls(sessionKey, preparedCalls);\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...signedCalls,\n * capabilities: {\n * permissions,\n * },\n * });\n * ```\n */\nexport async function grantPermissions<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult> {\n metrics.trackEvent({\n name: \"grant_permissions\",\n });\n\n const account = params.account ?? client.account?.address;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (isWebAuthnSigner(signer)) {\n throw new Error(\n \"WebAuthn signer is not currently supported for grantPermissions\",\n );\n }\n\n const { sessionId, signatureRequest } = await client.request({\n method: \"wallet_createSession\",\n params: [\n {\n ...params,\n account,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n\n let signatureHex: Hex;\n if (typeof signature.data === \"string\") {\n signatureHex = signature.data;\n } else {\n const sigData = signature.data;\n if (\"yParity\" in sigData) {\n signatureHex = serializeSignature({\n r: sigData.r,\n s: sigData.s,\n yParity: Number(sigData.yParity),\n });\n } else {\n signatureHex = serializeSignature({\n r: sigData.r,\n s: sigData.s,\n v: BigInt(sigData.v),\n });\n }\n }\n\n return {\n context: concatHex([\n \"0x00\", // remote mode\n sessionId,\n signatureHex,\n ]),\n };\n}\n"]}
1
+ {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,KAAK,EAKL,SAAS,EACT,kBAAkB,GACnB,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAyB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAGpC,MAA4B,EAC5B,MAAyB,EACzB,MAAwC;IAExC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,mBAAmB;KAC1B,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1D,IAAI,CAAC,OAAO,EAAE,C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ndefined,\n type Prettify,\n concatHex,\n serializeSignature,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_createSession\";\n };\n }\n>;\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n Omit<RpcSchema[\"Request\"][\"params\"][0], \"account\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never })\n>;\n\nexport type GrantPermissionsResult = {\n context: Hex;\n};\n\n/**\n * Grants permissions to a smart account by creating a session.\n * This allows another key to perform operations on behalf of the account.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {Address} [params.account] - The account address (required if client was not initialized with an account)\n * @param {number} params.expirySec - Unix timestamp when the permissions expire\n * @param {sessionKeyData} params.key - The session key information\n * @param {string} params.key.publicKey - The public key of the session key\n * @param {string} params.key.type - The type of the key (e.g., \"secp256k1\")\n * @param {Array} params.permissions - Array of permission objects defining what the session key can do\n * @returns {Promise<GrantPermissionsResult>} A Promise that resolves to the result containing a context identifier\n *\n * @example\n * ```ts\n * // Create a session key and grant root permissions\n * const sessionKey = LocalAccountSigner.generatePrivateKeySigner();\n * const account = await client.requestAccount();\n *\n * const permissions = await client.grantPermissions({\n * account: account.address,\n * expirySec: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour from now\n * key: {\n * publicKey: await sessionKey.getAddress(),\n * type: \"secp256k1\",\n * },\n * permissions: [{ type: \"root\" }],\n * });\n *\n * // Use the permissions to prepare a call\n * const preparedCalls = await client.prepareCalls({\n * calls: [{ to: zeroAddress, value: \"0x0\" }],\n * from: account.address,\n * capabilities: {\n * paymasterService: {\n * policyId: \"your-paymaster-policy-id\",\n * },\n * permissions,\n * },\n * });\n *\n * // Sign with the session key\n * const signedCalls = await signPreparedCalls(sessionKey, preparedCalls);\n *\n * // Send the prepared call using the session key\n * const result = await client.sendPreparedCalls({\n * ...signedCalls,\n * capabilities: {\n * permissions,\n * },\n * });\n * ```\n */\nexport async function grantPermissions<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: GrantPermissionsParams<TAccount>,\n): Promise<GrantPermissionsResult> {\n metrics.trackEvent({\n name: \"grant_permissions\",\n });\n\n const account = params.account ?? client.account?.address;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n const { sessionId, signatureRequest } = await client.request({\n method: \"wallet_createSession\",\n params: [\n {\n ...params,\n account,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n\n let signatureHex: Hex;\n if (typeof signature.data === \"string\") {\n signatureHex = signature.data;\n } else {\n const sigData = signature.data;\n if (\"yParity\" in sigData) {\n signatureHex = serializeSignature({\n r: sigData.r,\n s: sigData.s,\n yParity: Number(sigData.yParity),\n });\n } else {\n signatureHex = serializeSignature({\n r: sigData.r,\n s: sigData.s,\n v: BigInt(sigData.v),\n });\n }\n }\n\n return {\n context: concatHex([\n \"0x00\", // remote mode\n sessionId,\n signatureHex,\n ]),\n };\n}\n"]}
@@ -2,26 +2,22 @@ import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
2
2
  import type { InnerWalletApiClient } from "../../types.ts";
3
3
  import type { Address } from "viem";
4
4
  import type { SmartWalletSigner } from "../index.js";
5
- import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
6
5
  type RpcSchema = Extract<WalletServerRpcSchemaType, {
7
6
  Request: {
8
7
  method: "wallet_listAccounts";
9
8
  };
10
9
  }>;
11
- export type ListAccountsParams = Omit<RpcSchema["Request"]["params"][0], "signerAddress" | "signerPublicKey"> & ({
12
- signerAddress: Address;
13
- } | {
14
- signerPublicKey: WebAuthnPublicKey;
15
- } | {});
10
+ export type ListAccountsParams = Omit<RpcSchema["Request"]["params"][0], "signerAddress" | "signerPublicKey"> & {
11
+ signerAddress?: Address;
12
+ };
16
13
  export type ListAccountsResult = RpcSchema["ReturnType"];
17
14
  /**
18
15
  * Lists all smart accounts for a given signer using the wallet API client.
19
16
  *
20
17
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
21
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer for which to list accounts
18
+ * @param {SmartAccountSigner} signer - The signer for which to list accounts
22
19
  * @param {ListAccountsParams} params - Parameters for listing accounts
23
20
  * @param {Address} [params.signerAddress] - The address of the signer to list accounts for
24
- * @param {WebAuthnPublicKey} [params.signerPublicKey] - The public key of the signer to list accounts for
25
21
  * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
26
22
  * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
27
23
  * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
@@ -1,13 +1,11 @@
1
1
  import { metrics } from "../../metrics.js";
2
- import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js";
3
2
  /**
4
3
  * Lists all smart accounts for a given signer using the wallet API client.
5
4
  *
6
5
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
7
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer for which to list accounts
6
+ * @param {SmartAccountSigner} signer - The signer for which to list accounts
8
7
  * @param {ListAccountsParams} params - Parameters for listing accounts
9
8
  * @param {Address} [params.signerAddress] - The address of the signer to list accounts for
10
- * @param {WebAuthnPublicKey} [params.signerPublicKey] - The public key of the signer to list accounts for
11
9
  * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
12
10
  * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
13
11
  * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
@@ -32,34 +30,15 @@ export async function listAccounts(client, signer, params) {
32
30
  metrics.trackEvent({
33
31
  name: "list_accounts",
34
32
  });
35
- // Coalesce:
36
- // signerAddress or signerPublicKey in params takes priority
37
- // if not present, then fallback to client's attached signer
38
- const signerArg = "signerAddress" in params
39
- ? { signerAddress: params.signerAddress }
40
- : "signerPublicKey" in params
41
- ? {
42
- signerPublicKey: {
43
- ...params.signerPublicKey,
44
- type: "webauthn-p256",
45
- },
46
- }
47
- : isWebAuthnSigner(signer)
48
- ? {
49
- signerPublicKey: {
50
- ...credentialToWebAuthnPublicKey(signer.credential),
51
- type: "webauthn-p256",
52
- },
53
- }
54
- : {
55
- signerAddress: await signer.getAddress(),
56
- };
33
+ // signerAddress in params takes priority; otherwise fallback to client's attached signer
34
+ const signerAddress = params.signerAddress ?? (await signer.getAddress());
35
+ const { signerAddress: _signerAddress, ...rest } = params;
57
36
  return client.request({
58
37
  method: "wallet_listAccounts",
59
38
  params: [
60
39
  {
61
- ...params,
62
- ...signerArg,
40
+ ...rest,
41
+ signerAddress,
63
42
  },
64
43
  ],
65
44
  });
@@ -1 +1 @@
1
- {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAmBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAAyB,EACzB,MAA0B;IAE1B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IAEH,YAAY;IACZ,4DAA4D;IAC5D,4DAA4D;IAE5D,MAAM,SAAS,GACb,eAAe,IAAI,MAAM;QACvB,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE;QACzC,CAAC,CAAC,iBAAiB,IAAI,MAAM;YAC3B,CAAC,CAAC;gBACE,eAAe,EAAE;oBACf,GAAG,MAAM,CAAC,eAAe;oBACzB,IAAI,EAAE,eAAwB;iBAC/B;aACF;YACH,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;gBACxB,CAAC,CAAC;oBACE,eAAe,EAAE;wBACf,GAAG,6BAA6B,CAAC,MAAM,CAAC,UAAU,CAAC;wBACnD,IAAI,EAAE,eAAwB;qBAC/B;iBACF;gBACH,CAAC,CAAE;oBACC,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;iBACI,CAAC;IAEzD,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,GAAG,SAAS;aACb;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Address } from \"viem\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\nimport type { WebAuthnPublicKey } from \"@alchemy/wallet-api-types\";\nimport {\n credentialToWebAuthnPublicKey,\n isWebAuthnSigner,\n} from \"../../utils.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_listAccounts\";\n };\n }\n>;\n\nexport type ListAccountsParams = Omit<\n RpcSchema[\"Request\"][\"params\"][0],\n \"signerAddress\" | \"signerPublicKey\"\n> &\n ({ signerAddress: Address } | { signerPublicKey: WebAuthnPublicKey } | {});\n\nexport type ListAccountsResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Lists all smart accounts for a given signer using the wallet API client.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer for which to list accounts\n * @param {ListAccountsParams} params - Parameters for listing accounts\n * @param {Address} [params.signerAddress] - The address of the signer to list accounts for\n * @param {WebAuthnPublicKey} [params.signerPublicKey] - The public key of the signer to list accounts for\n * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)\n * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages\n * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata\n *\n * @example\n * ```ts\n * // Fetch the first page of accounts\n * const firstPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10\n * });\n *\n * // If an 'after' cursor exists, use it to fetch the next page\n * const nextPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10,\n * after: firstPage.meta.after\n * });\n * ```\n */\nexport async function listAccounts(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n metrics.trackEvent({\n name: \"list_accounts\",\n });\n\n // Coalesce:\n // signerAddress or signerPublicKey in params takes priority\n // if not present, then fallback to client's attached signer\n\n const signerArg =\n \"signerAddress\" in params\n ? { signerAddress: params.signerAddress }\n : \"signerPublicKey\" in params\n ? {\n signerPublicKey: {\n ...params.signerPublicKey,\n type: \"webauthn-p256\" as const,\n },\n }\n : isWebAuthnSigner(signer)\n ? {\n signerPublicKey: {\n ...credentialToWebAuthnPublicKey(signer.credential),\n type: \"webauthn-p256\" as const,\n },\n }\n : ({\n signerAddress: await signer.getAddress(),\n } satisfies RpcSchema[\"Request\"][\"params\"][0]);\n\n return client.request({\n method: \"wallet_listAccounts\",\n params: [\n {\n ...params,\n ...signerArg,\n },\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAmB3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAAyB,EACzB,MAA0B;IAE1B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IAEH,yFAAyF;IACzF,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1E,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAE1D,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,IAAI;gBACP,aAAa;aACd;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Address } from \"viem\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_listAccounts\";\n };\n }\n>;\n\nexport type ListAccountsParams = Omit<\n RpcSchema[\"Request\"][\"params\"][0],\n \"signerAddress\" | \"signerPublicKey\"\n> & { signerAddress?: Address };\n\nexport type ListAccountsResult = RpcSchema[\"ReturnType\"];\n\n/**\n * Lists all smart accounts for a given signer using the wallet API client.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer for which to list accounts\n * @param {ListAccountsParams} params - Parameters for listing accounts\n * @param {Address} [params.signerAddress] - The address of the signer to list accounts for\n * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)\n * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages\n * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata\n *\n * @example\n * ```ts\n * // Fetch the first page of accounts\n * const firstPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10\n * });\n *\n * // If an 'after' cursor exists, use it to fetch the next page\n * const nextPage = await client.listAccounts({\n * signerAddress: \"0x123...\",\n * limit: 10,\n * after: firstPage.meta.after\n * });\n * ```\n */\nexport async function listAccounts(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n metrics.trackEvent({\n name: \"list_accounts\",\n });\n\n // signerAddress in params takes priority; otherwise fallback to client's attached signer\n const signerAddress = params.signerAddress ?? (await signer.getAddress());\n const { signerAddress: _signerAddress, ...rest } = params;\n\n return client.request({\n method: \"wallet_listAccounts\",\n params: [\n {\n ...rest,\n signerAddress,\n },\n ],\n });\n}\n"]}
@@ -1,9 +1,8 @@
1
- import { type SmartContractAccount } from "@aa-sdk/core";
1
+ import type { SmartContractAccount } from "@aa-sdk/core";
2
2
  import type { Address } from "abitype";
3
3
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
4
4
  import type { InnerWalletApiClient } from "../../types.js";
5
5
  import type { SmartWalletSigner } from "../index.js";
6
- import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
7
6
  type RpcSchema = Extract<WalletServerRpcSchemaType, {
8
7
  Request: {
9
8
  method: "wallet_requestAccount";
@@ -11,9 +10,7 @@ type RpcSchema = Extract<WalletServerRpcSchemaType, {
11
10
  }>;
12
11
  export type RequestAccountParams = Omit<Extract<RpcSchema["Request"]["params"][0], {
13
12
  signerAddress: Address;
14
- } | {
15
- signerPublicKey: WebAuthnPublicKey;
16
- }>, "signerAddress" | "signerPublicKey" | "includeCounterfactualInfo"> & {
13
+ }>, "signerAddress" | "includeCounterfactualInfo"> & {
17
14
  accountAddress?: Address;
18
15
  };
19
16
  export type RequestAccountResult = SmartContractAccount;
@@ -23,7 +20,7 @@ export type RequestAccountResult = SmartContractAccount;
23
20
  * If an account already exists, the creationHint will be ignored.
24
21
  *
25
22
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
26
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer that will be associated with the account
23
+ * @param {SmartAccountSigner} signer - The signer that will be associated with the account
27
24
  * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
28
25
  * @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
29
26
  * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
@@ -1,15 +1,13 @@
1
- import { BaseError } from "@aa-sdk/core";
2
1
  import deepEqual from "deep-equal";
3
2
  import { custom } from "viem";
4
3
  import { createAccount } from "../../internal/account.js";
5
- import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js";
6
4
  /**
7
5
  * Requests an account for the provided signer using the wallet API client.
8
6
  * If an account already exists for the signer, it will always return that account unless a new ID is specified.
9
7
  * If an account already exists, the creationHint will be ignored.
10
8
  *
11
9
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
12
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer that will be associated with the account
10
+ * @param {SmartAccountSigner} signer - The signer that will be associated with the account
13
11
  * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
14
12
  * @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
15
13
  * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
@@ -24,42 +22,18 @@ import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js
24
22
  */
25
23
  export async function requestAccount(client, signer, params) {
26
24
  const { creationHint = {} } = params ?? {};
27
- if (isWebAuthnSigner(signer)) {
28
- if (creationHint.accountType &&
29
- creationHint.accountType !== "mav2-webauthn") {
30
- throw new BaseError("WebAuthn signers are only supported with mav2-webauthn account type");
31
- }
32
- }
33
- else {
34
- // non-webauthn signers do not support the "mav2-webauthn" account type
35
- if (creationHint.accountType === "mav2-webauthn") {
36
- throw new BaseError("ECDSA (secp256k1) signers are not supported with mav2-webauthn account type");
37
- }
38
- }
39
25
  const args = ((client.account && !params) || params?.accountAddress
40
26
  ? {
41
27
  accountAddress: params?.accountAddress ?? client.account.address,
42
28
  includeCounterfactualInfo: true,
43
29
  }
44
30
  : {
45
- ...(isWebAuthnSigner(signer)
31
+ signerAddress: await signer.getAddress(),
32
+ ...(creationHint
46
33
  ? {
47
- signerPublicKey: {
48
- ...credentialToWebAuthnPublicKey(signer.credential),
49
- type: "webauthn-p256",
50
- },
51
- ...(creationHint
52
- ? { creationHint: creationHint }
53
- : {}),
34
+ creationHint,
54
35
  }
55
- : {
56
- signerAddress: await signer.getAddress(),
57
- ...(creationHint
58
- ? {
59
- creationHint: creationHint,
60
- }
61
- : {}),
62
- }),
36
+ : {}),
63
37
  includeCounterfactualInfo: true,
64
38
  });
65
39
  const cachedAccount = client.internal.getAccount();
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,cAAc,CAAC;AAEpE,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AA0BxB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAAyB,EACzB,MAA6B;IAE7B,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IAE3C,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,IACE,YAAY,CAAC,WAAW;YACxB,YAAY,CAAC,WAAW,KAAK,eAAe,EAC5C,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,qEA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QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,GACtD,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc;QACd,kBAAkB;QAClB,UAAU;QACV,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { BaseError, type SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { createAccount } from \"../../internal/account.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\nimport {\n credentialToWebAuthnPublicKey,\n isWebAuthnSigner,\n} from \"../../utils.js\";\nimport type {\n CreationOptionsByPublicKey,\n CreationOptionsBySignerAddress,\n WebAuthnPublicKey,\n} from \"@alchemy/wallet-api-types\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_requestAccount\";\n };\n }\n>;\n\nexport type RequestAccountParams = Omit<\n Extract<\n RpcSchema[\"Request\"][\"params\"][0],\n { signerAddress: Address } | { signerPublicKey: WebAuthnPublicKey }\n >,\n \"signerAddress\" | \"signerPublicKey\" | \"includeCounterfactualInfo\"\n> & { accountAddress?: Address };\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @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\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * ```ts\n * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const { creationHint = {} } = params ?? {};\n\n if (isWebAuthnSigner(signer)) {\n if (\n creationHint.accountType &&\n creationHint.accountType !== \"mav2-webauthn\"\n ) {\n throw new BaseError(\n \"WebAuthn signers are only supported with mav2-webauthn account type\",\n );\n }\n } else {\n // non-webauthn signers do not support the \"mav2-webauthn\" account type\n if (creationHint.accountType === \"mav2-webauthn\") {\n throw new BaseError(\n \"ECDSA (secp256k1) signers are not supported with mav2-webauthn account type\",\n );\n }\n }\n\n const args = (\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...(isWebAuthnSigner(signer)\n ? {\n signerPublicKey: {\n ...credentialToWebAuthnPublicKey(signer.credential),\n type: \"webauthn-p256\",\n },\n ...(creationHint\n ? { creationHint: creationHint as CreationOptionsByPublicKey }\n : {}),\n }\n : {\n signerAddress: await signer.getAddress(),\n ...(creationHint\n ? {\n creationHint:\n creationHint as CreationOptionsBySignerAddress,\n }\n : {}),\n }),\n includeCounterfactualInfo: true,\n }\n ) satisfies RpcSchema[\"Request\"][\"params\"][0];\n\n const cachedAccount = client.internal.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { accountAddress, counterfactualInfo, delegation } =\n await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo,\n delegation,\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
1
+ {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAmB1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAAyB,EACzB,MAA6B;IAE7B,MAAM,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IAE3C,MAAM,IAAI,GAAG,CACX,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,cAAc;QACnD,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,EAAE,cAAc,IAAI,MAAM,CAAC,OAAQ,CAAC,OAAO;YACjE,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,GAAG,CAAC,YAAY;gBACd,CAAC,CAAC;oBACE,YAAY;iBACb;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,yBAAyB,EAAE,IAAI;SAChC,CACsC,CAAC;IAE9C,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEnD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,aAAa,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC;YACtD,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,GACtD,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc;QACd,kBAAkB;QAClB,UAAU;QACV,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { createAccount } from \"../../internal/account.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_requestAccount\";\n };\n }\n>;\n\nexport type RequestAccountParams = Omit<\n Extract<RpcSchema[\"Request\"][\"params\"][0], { signerAddress: Address }>,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n> & { accountAddress?: Address };\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @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\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * ```ts\n * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const { creationHint = {} } = params ?? {};\n\n const args = (\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n signerAddress: await signer.getAddress(),\n ...(creationHint\n ? {\n creationHint,\n }\n : {}),\n includeCounterfactualInfo: true,\n }\n ) satisfies RpcSchema[\"Request\"][\"params\"][0];\n\n const cachedAccount = client.internal.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { accountAddress, counterfactualInfo, delegation } =\n await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo,\n delegation,\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
@@ -14,7 +14,7 @@ export type SendCallsResult = SendPreparedCallsResult;
14
14
  * </Note>
15
15
  *
16
16
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
17
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use
17
+ * @param {SmartAccountSigner} signer - The signer to use
18
18
  * @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
19
19
  * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
20
20
  * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
@@ -3,7 +3,6 @@ import { metrics } from "../../metrics.js";
3
3
  import { signPreparedCalls } from "./signPreparedCalls.js";
4
4
  import { sendPreparedCalls, } from "./sendPreparedCalls.js";
5
5
  import { signSignatureRequest } from "./signSignatureRequest.js";
6
- import { isWebAuthnSigner } from "../../utils.js";
7
6
  import { extractCapabilitiesForSending } from "../../internal/capabilities.js";
8
7
  /**
9
8
  * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
@@ -14,7 +13,7 @@ import { extractCapabilitiesForSending } from "../../internal/capabilities.js";
14
13
  * </Note>
15
14
  *
16
15
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
17
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use
16
+ * @param {SmartAccountSigner} signer - The signer to use
18
17
  * @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
19
18
  * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
20
19
  * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
@@ -44,9 +43,6 @@ export async function sendCalls(client, signer, params) {
44
43
  });
45
44
  let calls = await prepareCalls(client, params);
46
45
  if (calls.type === "paymaster-permit") {
47
- if (isWebAuthnSigner(signer)) {
48
- throw new Error("WebAuthn signer is not currently supported for signing paymaster permit signatures");
49
- }
50
46
  const signature = await signSignatureRequest(signer, calls.signatureRequest);
51
47
  const secondCallParams = {
52
48
  from: calls.modifiedRequest.from,
@@ -1 +1 @@
1
- {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAG7B,MAA4B,EAC5B,MAAyB,EACzB,MAAiC;IAEjC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,YAAY;KACnB,CAAC,CAAC;IAEH,IAAI,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/C,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtC,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;QACJ,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,KAAK,CAAC,gBAAgB,CACvB,CAAC;QAEF,MAAM,gBAAgB,GAAG;YACvB,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI;YAChC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,KAAK;YAClC,YAAY,EAAE,KAAK,CAAC,eAAe,CAAC,YAAY;YAChD,wBAAwB,EAAE,SAAS;SACpC,CAAC;QAEF,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,MAAM,YAAY,GAAG,6BAA6B,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAExE,OAAO,MAAM,iBAAiB,CAAC,MAAM,EAAE;QACrC,GAAG,WAAW;QACd,GAAG,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Address } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { metrics } from \"../../metrics.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\nimport { isWebAuthnSigner } from \"../../utils.js\";\nimport { extractCapabilitiesForSending } from \"../../internal/capabilities.js\";\n\nexport type SendCallsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = PrepareCallsParams<TAccount>;\n\nexport type SendCallsResult = SendPreparedCallsResult;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use\n * @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute\n * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request. See [API documentation](/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls#request.body.prepareCallsRequest.capabilities) for details.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // The result contains the call ID\n * console.log(result.id);\n * ```\n */\nexport async function sendCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: SendCallsParams<TAccount>,\n): Promise<SendCallsResult> {\n metrics.trackEvent({\n name: \"send_calls\",\n });\n\n let calls = await prepareCalls(client, params);\n\n if (calls.type === \"paymaster-permit\") {\n if (isWebAuthnSigner(signer)) {\n throw new Error(\n \"WebAuthn signer is not currently supported for signing paymaster permit signatures\",\n );\n }\n const signature = await signSignatureRequest(\n signer,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n from: calls.modifiedRequest.from,\n calls: calls.modifiedRequest.calls,\n capabilities: calls.modifiedRequest.capabilities,\n paymasterPermitSignature: signature,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(signer, calls);\n\n const capabilities = extractCapabilitiesForSending(params.capabilities);\n\n return await sendPreparedCalls(client, {\n ...signedCalls,\n ...(capabilities != null ? { capabilities } : {}),\n });\n}\n"]}
1
+ {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAA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YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Address } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { metrics } from \"../../metrics.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\nimport { extractCapabilitiesForSending } from \"../../internal/capabilities.js\";\n\nexport type SendCallsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = PrepareCallsParams<TAccount>;\n\nexport type SendCallsResult = SendPreparedCallsResult;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute\n * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request. See [API documentation](/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls#request.body.prepareCallsRequest.capabilities) for details.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // The result contains the call ID\n * console.log(result.id);\n * ```\n */\nexport async function sendCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: SendCallsParams<TAccount>,\n): Promise<SendCallsResult> {\n metrics.trackEvent({\n name: \"send_calls\",\n });\n\n let calls = await prepareCalls(client, params);\n\n if (calls.type === \"paymaster-permit\") {\n const signature = await signSignatureRequest(\n signer,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n from: calls.modifiedRequest.from,\n calls: calls.modifiedRequest.calls,\n capabilities: calls.modifiedRequest.capabilities,\n paymasterPermitSignature: signature,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(signer, calls);\n\n const capabilities = extractCapabilitiesForSending(params.capabilities);\n\n return await sendPreparedCalls(client, {\n ...signedCalls,\n ...(capabilities != null ? { capabilities } : {}),\n });\n}\n"]}
@@ -11,7 +11,7 @@ export type SignMessageResult = Hex;
11
11
  * This method requests the account associated with the signer and uses it to sign the message.
12
12
  *
13
13
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
14
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account
14
+ * @param {SmartAccountSigner} signer - The signer of the smart account
15
15
  * @param {SignMessageParams} params - Parameters for signing the message
16
16
  * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
17
17
  * @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
@@ -5,7 +5,7 @@ import { metrics } from "../../metrics.js";
5
5
  * This method requests the account associated with the signer and uses it to sign the message.
6
6
  *
7
7
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
8
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account
8
+ * @param {SmartAccountSigner} signer - The signer of the smart account
9
9
  * @param {SignMessageParams} params - Parameters for signing the message
10
10
  * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
11
11
  * @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
@@ -1 +1 @@
1
- {"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAAyB,EACzB,MAAyB;IAEzB,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { Address, Hex, SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account\n * @param {SignMessageParams} params - Parameters for signing the message\n * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.\n * @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * ```ts\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n * ```\n */\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n metrics.trackEvent({\n name: \"sign_message\",\n });\n\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
1
+ {"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAAyB,EACzB,MAAyB;IAEzB,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import type { Address, Hex, SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\nimport { metrics } from \"../../metrics.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {SignMessageParams} params - Parameters for signing the message\n * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.\n * @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * ```ts\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n * ```\n */\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartWalletSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n metrics.trackEvent({\n name: \"sign_message\",\n });\n\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
@@ -11,7 +11,7 @@ export type SignPreparedCallsResult = RpcSchema["Request"]["params"][0];
11
11
  /**
12
12
  * Signs prepared calls using the provided signer.
13
13
  *
14
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use
14
+ * @param {SmartAccountSigner} signer - The signer to use
15
15
  * @param {SignPreparedCallsParams} params - The prepared calls with signature requests
16
16
  * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
17
17
  */
@@ -1,11 +1,11 @@
1
1
  import { BaseError } from "@aa-sdk/core";
2
2
  import { signSignatureRequest } from "./signSignatureRequest.js";
3
3
  import { metrics } from "../../metrics.js";
4
- import { assertNever, isWebAuthnSigner } from "../../utils.js";
4
+ import { assertNever } from "../../utils.js";
5
5
  /**
6
6
  * Signs prepared calls using the provided signer.
7
7
  *
8
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use
8
+ * @param {SmartAccountSigner} signer - The signer to use
9
9
  * @param {SignPreparedCallsParams} params - The prepared calls with signature requests
10
10
  * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
11
11
  */
@@ -18,9 +18,6 @@ export async function signPreparedCalls(signer, params) {
18
18
  });
19
19
  const signAuthorizationCall = async (call) => {
20
20
  const { signatureRequest: _signatureRequest, ...rest } = call;
21
- if (isWebAuthnSigner(signer)) {
22
- throw new Error("WebAuthn account cannot sign EIP-7702 authorization requests");
23
- }
24
21
  const signature = await signSignatureRequest(signer, {
25
22
  type: "eip7702Auth",
26
23
  data: {
@@ -1 +1 @@
1
- {"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAgB/D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAyB,EACzB,MAA+B;IAE/B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IAEH,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAgC,EAAE,EAAE;QACvE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC9D,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;QACJ,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAA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AC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport { BaseError } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type {\n PreparedCall_Authorization,\n PreparedCall_UserOpV060,\n PreparedCall_UserOpV070,\n} from \"@alchemy/wallet-api-types\";\nimport { metrics } from \"../../metrics.js\";\nimport { assertNever, isWebAuthnSigner } from \"../../utils.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_sendPreparedCalls\";\n };\n }\n>;\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = RpcSchema[\"Request\"][\"params\"][0];\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n */\nexport async function signPreparedCalls(\n signer: SmartWalletSigner,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n metrics.trackEvent({\n name: \"sign_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n const signAuthorizationCall = async (call: PreparedCall_Authorization) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n if (isWebAuthnSigner(signer)) {\n throw new Error(\n \"WebAuthn account cannot sign EIP-7702 authorization requests\",\n );\n }\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (\n call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,\n ) => {\n const { signatureRequest, ...rest } = call;\n\n if (!signatureRequest) {\n throw new BaseError(\n \"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.\",\n );\n }\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...rest,\n signature,\n };\n };\n\n if (params.type === \"array\") {\n return {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n };\n } else if (\n params.type === \"user-operation-v060\" ||\n params.type === \"user-operation-v070\"\n ) {\n return signUserOperationCall(params);\n } else if (params.type === \"paymaster-permit\") {\n throw new BaseError(\n `Invalid call type ${params.type} for signing prepared calls`,\n );\n } else {\n return assertNever(\n params,\n `Unexpected call type in ${params} for signing prepared calls`,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAgB7C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAyB,EACzB,MAA+B;IAE/B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IAEH,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAgC,EAAE,EAAE;QACvE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAA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M,6BAA6B,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport { BaseError } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\nimport type {\n PreparedCall_Authorization,\n PreparedCall_UserOpV060,\n PreparedCall_UserOpV070,\n} from \"@alchemy/wallet-api-types\";\nimport { metrics } from \"../../metrics.js\";\nimport { assertNever } from \"../../utils.js\";\nimport type { SmartWalletSigner } from \"../index.js\";\n\ntype RpcSchema = Extract<\n WalletServerRpcSchemaType,\n {\n Request: {\n method: \"wallet_sendPreparedCalls\";\n };\n }\n>;\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = RpcSchema[\"Request\"][\"params\"][0];\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n */\nexport async function signPreparedCalls(\n signer: SmartWalletSigner,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n metrics.trackEvent({\n name: \"sign_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n const signAuthorizationCall = async (call: PreparedCall_Authorization) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (\n call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,\n ) => {\n const { signatureRequest, ...rest } = call;\n\n if (!signatureRequest) {\n throw new BaseError(\n \"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.\",\n );\n }\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...rest,\n signature,\n };\n };\n\n if (params.type === \"array\") {\n return {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n };\n } else if (\n params.type === \"user-operation-v060\" ||\n params.type === \"user-operation-v070\"\n ) {\n return signUserOperationCall(params);\n } else if (params.type === \"paymaster-permit\") {\n throw new BaseError(\n `Invalid call type ${params.type} for signing prepared calls`,\n );\n } else {\n return assertNever(\n params,\n `Unexpected call type in ${params} for signing prepared calls`,\n );\n }\n}\n"]}
@@ -1,13 +1,38 @@
1
- import type { SmartAccountSigner } from "@aa-sdk/core";
2
- import type { PersonalSignSignatureRequest, TypedDataSignatureRequest, AuthorizationSignatureRequest, Eip7702UnsignedAuth, UserOpSig, EcdsaSig, WebauthnSig } from "@alchemy/wallet-api-types";
1
+ import type { PersonalSignSignatureRequest, TypedDataSignatureRequest, AuthorizationSignatureRequest, Eip7702UnsignedAuth, EcdsaSig } from "@alchemy/wallet-api-types";
3
2
  import type { WithoutRawPayload } from "../../types.ts";
4
- import type { WebAuthnSigner } from "../index.js";
3
+ import type { SmartWalletSigner } from "../index.js";
5
4
  export type SignSignatureRequestParams = WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
6
5
  data: Eip7702UnsignedAuth;
7
6
  })>;
8
- export type SignSignatureRequestResult = UserOpSig["signature"];
9
- export declare function signSignatureRequest(signer: SmartAccountSigner, params: WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
10
- data: Eip7702UnsignedAuth;
11
- })>): Promise<EcdsaSig["signature"]>;
12
- export declare function signSignatureRequest(signer: WebAuthnSigner, params: WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest>): Promise<WebauthnSig["signature"]>;
13
- export declare function signSignatureRequest(signer: SmartAccountSigner | WebAuthnSigner, params: WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest>): Promise<UserOpSig["signature"]>;
7
+ export type SignSignatureRequestResult = EcdsaSig["signature"];
8
+ /**
9
+ * Signs a signature request using the provided signer.
10
+ * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
11
+ *
12
+ * @param {SmartAccountSigner} signer - The signer to use for signing the request
13
+ * @param {SignSignatureRequestParams} params - The signature request parameters
14
+ * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
15
+ * @param {SignSignatureRequestParams["data"]} params.data - The data to sign, format depends on the signature type
16
+ * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // Sign a personal message
21
+ * const result = await client.signSignatureRequest({
22
+ * type: 'personal_sign',
23
+ * data: 'Hello, world!'
24
+ * });
25
+ *
26
+ * // Sign typed data (EIP-712)
27
+ * const result = await client.signSignatureRequest({
28
+ * type: 'eth_signTypedData_v4',
29
+ * data: {
30
+ * domain: { ... },
31
+ * types: { ... },
32
+ * primaryType: '...',
33
+ * message: { ... }
34
+ * }
35
+ * });
36
+ * ```
37
+ */
38
+ export declare function signSignatureRequest(signer: SmartWalletSigner, params: SignSignatureRequestParams): Promise<EcdsaSig["signature"]>;
@@ -1,13 +1,12 @@
1
1
  import { hexToNumber, serializeSignature } from "viem";
2
- import { assertNever, isWebAuthnSigner } from "../../utils.js";
2
+ import { assertNever } from "../../utils.js";
3
3
  import { vToYParity } from "ox/Signature";
4
4
  import { metrics } from "../../metrics.js";
5
- import { toWebAuthnAccount } from "viem/account-abstraction";
6
5
  /**
7
6
  * Signs a signature request using the provided signer.
8
7
  * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.
9
8
  *
10
- * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use for signing the request
9
+ * @param {SmartAccountSigner} signer - The signer to use for signing the request
11
10
  * @param {SignSignatureRequestParams} params - The signature request parameters
12
11
  * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
13
12
  * @param {SignSignatureRequestParams["data"]} params.data - The data to sign, format depends on the signature type
@@ -42,45 +41,18 @@ export async function signSignatureRequest(signer, params) {
42
41
  });
43
42
  switch (params.type) {
44
43
  case "personal_sign": {
45
- if (isWebAuthnSigner(signer)) {
46
- const webAuthnAccount = toWebAuthnAccount({ ...signer });
47
- const { signature, webauthn: metadata } = await webAuthnAccount.signMessage({
48
- message: params.data,
49
- });
50
- return {
51
- type: "webauthn-p256",
52
- data: {
53
- signature,
54
- metadata,
55
- },
56
- };
57
- }
58
44
  return {
59
45
  type: "secp256k1",
60
46
  data: await signer.signMessage(params.data),
61
47
  };
62
48
  }
63
49
  case "eth_signTypedData_v4": {
64
- if (isWebAuthnSigner(signer)) {
65
- const webAuthnAccount = toWebAuthnAccount({ ...signer });
66
- const { signature, webauthn: metadata } = await webAuthnAccount.signTypedData(params.data);
67
- return {
68
- type: "webauthn-p256",
69
- data: {
70
- signature,
71
- metadata,
72
- },
73
- };
74
- }
75
50
  return {
76
51
  type: "secp256k1",
77
52
  data: await signer.signTypedData(params.data),
78
53
  };
79
54
  }
80
55
  case "eip7702Auth": {
81
- if (isWebAuthnSigner(signer)) {
82
- throw new Error("WebAuthn account cannot sign EIP-7702 authorization requests");
83
- }
84
56
  if (!signer.signAuthorization) {
85
57
  throw new Error("Signer does not implement signAuthorization");
86
58
  }