@account-kit/wallet-client 4.76.0 → 4.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/esm/client/actions/grantPermissions.d.ts +3 -3
  2. package/dist/esm/client/actions/grantPermissions.js +28 -3
  3. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  4. package/dist/esm/client/actions/listAccounts.d.ts +11 -7
  5. package/dist/esm/client/actions/listAccounts.js +27 -4
  6. package/dist/esm/client/actions/listAccounts.js.map +1 -1
  7. package/dist/esm/client/actions/requestAccount.d.ts +8 -4
  8. package/dist/esm/client/actions/requestAccount.js +38 -6
  9. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  10. package/dist/esm/client/actions/sendCalls.d.ts +3 -3
  11. package/dist/esm/client/actions/sendCalls.js +5 -2
  12. package/dist/esm/client/actions/sendCalls.js.map +1 -1
  13. package/dist/esm/client/actions/signMessage.d.ts +3 -3
  14. package/dist/esm/client/actions/signMessage.js +1 -2
  15. package/dist/esm/client/actions/signMessage.js.map +1 -1
  16. package/dist/esm/client/actions/signPreparedCalls.d.ts +3 -3
  17. package/dist/esm/client/actions/signPreparedCalls.js +5 -2
  18. package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
  19. package/dist/esm/client/actions/signSignatureRequest.d.ts +8 -37
  20. package/dist/esm/client/actions/signSignatureRequest.js +30 -2
  21. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  22. package/dist/esm/client/actions/signTypedData.d.ts +3 -3
  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/actions/waitForCallsStatus.d.ts +1 -1
  26. package/dist/esm/client/decorator.d.ts +2 -2
  27. package/dist/esm/client/decorator.js +13 -1
  28. package/dist/esm/client/decorator.js.map +1 -1
  29. package/dist/esm/client/index.d.ts +9 -2
  30. package/dist/esm/client/index.js.map +1 -1
  31. package/dist/esm/internal/account.d.ts +3 -2
  32. package/dist/esm/internal/account.js +28 -3
  33. package/dist/esm/internal/account.js.map +1 -1
  34. package/dist/esm/utils.d.ts +6 -0
  35. package/dist/esm/utils.js +14 -1
  36. package/dist/esm/utils.js.map +1 -1
  37. package/dist/esm/version.d.ts +1 -1
  38. package/dist/esm/version.js +1 -1
  39. package/dist/esm/version.js.map +1 -1
  40. package/dist/types/client/actions/grantPermissions.d.ts +3 -3
  41. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  42. package/dist/types/client/actions/listAccounts.d.ts +11 -7
  43. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  44. package/dist/types/client/actions/requestAccount.d.ts +8 -4
  45. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  46. package/dist/types/client/actions/sendCalls.d.ts +3 -3
  47. package/dist/types/client/actions/sendCalls.d.ts.map +1 -1
  48. package/dist/types/client/actions/signMessage.d.ts +3 -3
  49. package/dist/types/client/actions/signMessage.d.ts.map +1 -1
  50. package/dist/types/client/actions/signPreparedCalls.d.ts +3 -3
  51. package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
  52. package/dist/types/client/actions/signSignatureRequest.d.ts +8 -37
  53. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  54. package/dist/types/client/actions/signTypedData.d.ts +3 -3
  55. package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
  56. package/dist/types/client/actions/waitForCallsStatus.d.ts +1 -1
  57. package/dist/types/client/decorator.d.ts +2 -2
  58. package/dist/types/client/decorator.d.ts.map +1 -1
  59. package/dist/types/client/index.d.ts +9 -2
  60. package/dist/types/client/index.d.ts.map +1 -1
  61. package/dist/types/internal/account.d.ts +3 -2
  62. package/dist/types/internal/account.d.ts.map +1 -1
  63. package/dist/types/utils.d.ts +6 -0
  64. package/dist/types/utils.d.ts.map +1 -1
  65. package/dist/types/version.d.ts +1 -1
  66. package/package.json +5 -5
  67. package/src/client/actions/grantPermissions.ts +33 -4
  68. package/src/client/actions/listAccounts.ts +38 -8
  69. package/src/client/actions/requestAccount.ts +59 -12
  70. package/src/client/actions/sendCalls.ts +9 -3
  71. package/src/client/actions/signMessage.ts +3 -3
  72. package/src/client/actions/signPreparedCalls.ts +10 -4
  73. package/src/client/actions/signSignatureRequest.ts +75 -8
  74. package/src/client/actions/signTypedData.ts +3 -3
  75. package/src/client/decorator.ts +21 -3
  76. package/src/client/index.ts +11 -2
  77. package/src/internal/account.ts +38 -5
  78. package/src/utils.ts +25 -1
  79. package/src/version.ts +1 -1
@@ -1,7 +1,7 @@
1
- import { type SmartAccountSigner } from "@aa-sdk/core";
2
1
  import { type Address, type Hex, type IsUndefined, type Prettify } from "viem";
3
2
  import type { InnerWalletApiClient } from "../../types.ts";
4
3
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
4
+ import type { SmartWalletSigner } from "../index.js";
5
5
  type RpcSchema = Extract<WalletServerRpcSchemaType, {
6
6
  Request: {
7
7
  method: "wallet_createSession";
@@ -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} signer - The signer of the smart account
23
+ * @param {SmartAccountSigner | WebAuthnSigner} 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
@@ -70,5 +70,5 @@ export type GrantPermissionsResult = {
70
70
  * });
71
71
  * ```
72
72
  */
73
- export declare function grantPermissions<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartAccountSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
73
+ export declare function grantPermissions<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartWalletSigner, params: GrantPermissionsParams<TAccount>): Promise<GrantPermissionsResult>;
74
74
  export {};
@@ -1,13 +1,14 @@
1
1
  import { AccountNotFoundError } from "@aa-sdk/core";
2
- import { toHex, concatHex, } from "viem";
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";
5
6
  /**
6
7
  * Grants permissions to a smart account by creating a session.
7
8
  * This allows another key to perform operations on behalf of the account.
8
9
  *
9
10
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
10
- * @param {SmartAccountSigner} signer - The signer of the smart account
11
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account
11
12
  * @param {GrantPermissionsParams} params - The parameters for granting permissions
12
13
  * @param {Address} [params.account] - The account address (required if client was not initialized with an account)
13
14
  * @param {number} params.expirySec - Unix timestamp when the permissions expire
@@ -65,6 +66,9 @@ export async function grantPermissions(client, signer, params) {
65
66
  if (!account) {
66
67
  throw new AccountNotFoundError();
67
68
  }
69
+ if (isWebAuthnSigner(signer)) {
70
+ throw new Error("WebAuthn signer is not currently supported for grantPermissions");
71
+ }
68
72
  const { sessionId, signatureRequest } = await client.request({
69
73
  method: "wallet_createSession",
70
74
  params: [
@@ -76,11 +80,32 @@ export async function grantPermissions(client, signer, params) {
76
80
  ],
77
81
  });
78
82
  const signature = await signSignatureRequest(signer, signatureRequest);
83
+ let signatureHex;
84
+ if (typeof signature.data === "string") {
85
+ signatureHex = signature.data;
86
+ }
87
+ else {
88
+ const sigData = signature.data;
89
+ if ("yParity" in sigData) {
90
+ signatureHex = serializeSignature({
91
+ r: sigData.r,
92
+ s: sigData.s,
93
+ yParity: Number(sigData.yParity),
94
+ });
95
+ }
96
+ else {
97
+ signatureHex = serializeSignature({
98
+ r: sigData.r,
99
+ s: sigData.s,
100
+ v: BigInt(sigData.v),
101
+ });
102
+ }
103
+ }
79
104
  return {
80
105
  context: concatHex([
81
106
  "0x00", // remote mode
82
107
  sessionId,
83
- signature.data,
108
+ signatureHex,
84
109
  ]),
85
110
  };
86
111
  }
@@ -1 +1 @@
1
- {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../../src/client/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,KAAK,EAKL,SAAS,GACV,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAwB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAGpC,MAA4B,EAC5B,MAA0B,EAC1B,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,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QAC3D,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,OAAO;gBACP,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;aAChC;SACF;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAEvE,OAAO;QACL,OAAO,EAAE,SAAS,CAAC;YACjB,MAAM,EAAE,cAAc;YACtB,SAAS;YACT,SAAS,CAAC,IAAI;SACf,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { AccountNotFoundError, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n toHex,\n type Address,\n type Hex,\n type IsUndefined,\n type Prettify,\n concatHex,\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\";\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: SmartAccountSigner,\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 return {\n context: concatHex([\n \"0x00\", // remote mode\n sessionId,\n signature.data,\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;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAwBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,MAAM,CAAC,KAAK,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,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,23 +1,27 @@
1
1
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
2
2
  import type { InnerWalletApiClient } from "../../types.ts";
3
- import type { SmartAccountSigner } from "@aa-sdk/core";
4
3
  import type { Address } from "viem";
4
+ import type { SmartWalletSigner } from "../index.js";
5
+ import type { WebAuthnPublicKey } from "@alchemy/wallet-api-types";
5
6
  type RpcSchema = Extract<WalletServerRpcSchemaType, {
6
7
  Request: {
7
8
  method: "wallet_listAccounts";
8
9
  };
9
10
  }>;
10
- export type ListAccountsParams = Omit<RpcSchema["Request"]["params"][0], "signerAddress"> & {
11
- signerAddress?: Address;
12
- };
11
+ export type ListAccountsParams = Omit<RpcSchema["Request"]["params"][0], "signerAddress" | "signerPublicKey"> & ({
12
+ signerAddress: Address;
13
+ } | {
14
+ signerPublicKey: WebAuthnPublicKey;
15
+ } | {});
13
16
  export type ListAccountsResult = RpcSchema["ReturnType"];
14
17
  /**
15
18
  * Lists all smart accounts for a given signer using the wallet API client.
16
19
  *
17
20
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
18
- * @param {SmartAccountSigner} signer - The signer for which to list accounts
21
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer for which to list accounts
19
22
  * @param {ListAccountsParams} params - Parameters for listing accounts
20
- * @param {string} params.signerAddress - The address of the signer to list accounts for
23
+ * @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
21
25
  * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
22
26
  * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
23
27
  * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
@@ -38,5 +42,5 @@ export type ListAccountsResult = RpcSchema["ReturnType"];
38
42
  * });
39
43
  * ```
40
44
  */
41
- export declare function listAccounts(client: InnerWalletApiClient, signer: SmartAccountSigner, params: ListAccountsParams): Promise<ListAccountsResult>;
45
+ export declare function listAccounts(client: InnerWalletApiClient, signer: SmartWalletSigner, params: ListAccountsParams): Promise<ListAccountsResult>;
42
46
  export {};
@@ -1,11 +1,13 @@
1
1
  import { metrics } from "../../metrics.js";
2
+ import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js";
2
3
  /**
3
4
  * Lists all smart accounts for a given signer using the wallet API client.
4
5
  *
5
6
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
6
- * @param {SmartAccountSigner} signer - The signer for which to list accounts
7
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer for which to list accounts
7
8
  * @param {ListAccountsParams} params - Parameters for listing accounts
8
- * @param {string} params.signerAddress - The address of the signer to list accounts for
9
+ * @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
9
11
  * @param {number} [params.limit] - Optional maximum number of accounts to return (default: 100, max: 100)
10
12
  * @param {string} [params.after] - Optional pagination cursor for fetching subsequent pages
11
13
  * @returns {Promise<ListAccountsResult>} A Promise that resolves to the list of accounts and pagination metadata
@@ -30,13 +32,34 @@ export async function listAccounts(client, signer, params) {
30
32
  metrics.trackEvent({
31
33
  name: "list_accounts",
32
34
  });
33
- const signerAddress = params.signerAddress ?? (await signer.getAddress());
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
+ };
34
57
  return client.request({
35
58
  method: "wallet_listAccounts",
36
59
  params: [
37
60
  {
38
61
  ...params,
39
- signerAddress,
62
+ ...signerArg,
40
63
  },
41
64
  ],
42
65
  });
@@ -1 +1 @@
1
- {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAkB3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B,EAC1B,MAA0B;IAE1B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAE1E,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,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 { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Address } from \"viem\";\nimport { metrics } from \"../../metrics.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\"\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 {string} 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: SmartAccountSigner,\n params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n metrics.trackEvent({\n name: \"list_accounts\",\n });\n\n const signerAddress = params.signerAddress ?? (await signer.getAddress());\n\n return client.request({\n method: \"wallet_listAccounts\",\n params: [\n {\n ...params,\n signerAddress,\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;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,7 +1,9 @@
1
- import { type SmartAccountSigner, 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
+ import type { SmartWalletSigner } from "../index.js";
6
+ import { type WebAuthnPublicKey } from "@alchemy/wallet-api-types";
5
7
  type RpcSchema = Extract<WalletServerRpcSchemaType, {
6
8
  Request: {
7
9
  method: "wallet_requestAccount";
@@ -9,7 +11,9 @@ type RpcSchema = Extract<WalletServerRpcSchemaType, {
9
11
  }>;
10
12
  export type RequestAccountParams = Omit<Extract<RpcSchema["Request"]["params"][0], {
11
13
  signerAddress: Address;
12
- }>, "signerAddress" | "includeCounterfactualInfo"> & {
14
+ } | {
15
+ signerPublicKey: WebAuthnPublicKey;
16
+ }>, "signerAddress" | "signerPublicKey" | "includeCounterfactualInfo"> & {
13
17
  accountAddress?: Address;
14
18
  };
15
19
  export type RequestAccountResult = SmartContractAccount;
@@ -19,7 +23,7 @@ export type RequestAccountResult = SmartContractAccount;
19
23
  * If an account already exists, the creationHint will be ignored.
20
24
  *
21
25
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
22
- * @param {SmartAccountSigner} signer - The signer that will be associated with the account
26
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer that will be associated with the account
23
27
  * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
24
28
  * @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
25
29
  * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
@@ -32,5 +36,5 @@ export type RequestAccountResult = SmartContractAccount;
32
36
  * const account = await client.requestAccount(signer);
33
37
  * ```
34
38
  */
35
- export declare function requestAccount(client: InnerWalletApiClient, signer: SmartAccountSigner, params?: RequestAccountParams): Promise<RequestAccountResult>;
39
+ export declare function requestAccount(client: InnerWalletApiClient, signer: SmartWalletSigner, params?: RequestAccountParams): Promise<RequestAccountResult>;
36
40
  export {};
@@ -1,14 +1,16 @@
1
- import {} from "@aa-sdk/core";
1
+ import { BaseError } from "@aa-sdk/core";
2
2
  import deepEqual from "deep-equal";
3
3
  import { custom } from "viem";
4
4
  import { createAccount } from "../../internal/account.js";
5
+ import { credentialToWebAuthnPublicKey, isWebAuthnSigner, } from "../../utils.js";
6
+ import { CreationOptionsByPublicKey, CreationOptionsBySignerAddress, } from "@alchemy/wallet-api-types";
5
7
  /**
6
8
  * Requests an account for the provided signer using the wallet API client.
7
9
  * If an account already exists for the signer, it will always return that account unless a new ID is specified.
8
10
  * If an account already exists, the creationHint will be ignored.
9
11
  *
10
12
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
11
- * @param {SmartAccountSigner} signer - The signer that will be associated with the account
13
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer that will be associated with the account
12
14
  * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account
13
15
  * @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
14
16
  * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists
@@ -22,16 +24,46 @@ import { createAccount } from "../../internal/account.js";
22
24
  * ```
23
25
  */
24
26
  export async function requestAccount(client, signer, params) {
25
- const args = (client.account && !params) || params?.accountAddress
27
+ const { creationHint = {} } = params ?? {};
28
+ if (isWebAuthnSigner(signer)) {
29
+ if (creationHint.accountType !== "mav2-webauthn") {
30
+ // todo: validate error details
31
+ throw new BaseError("WebAuthn signers are only supported with mav2-webauthn account type");
32
+ }
33
+ }
34
+ else {
35
+ // non-webauthn signers do not support the "mav2-webauthn" account type
36
+ if (creationHint.accountType === "mav2-webauthn") {
37
+ throw new BaseError("ECDSA (secp256k1) signers are not supported with mav2-webauthn account type");
38
+ }
39
+ }
40
+ const args = ((client.account && !params) || params?.accountAddress
26
41
  ? {
27
42
  accountAddress: params?.accountAddress ?? client.account.address,
28
43
  includeCounterfactualInfo: true,
29
44
  }
30
45
  : {
31
- ...params,
32
- signerAddress: await signer.getAddress(),
46
+ ...(isWebAuthnSigner(signer)
47
+ ? {
48
+ signerPublicKey: {
49
+ ...credentialToWebAuthnPublicKey(signer.credential),
50
+ type: "webauthn-p256",
51
+ },
52
+ // todo: re-enable after fixing type assertions above
53
+ ...(creationHint
54
+ ? { creationHint: creationHint }
55
+ : {}),
56
+ }
57
+ : {
58
+ signerAddress: await signer.getAddress(),
59
+ ...(creationHint
60
+ ? {
61
+ creationHint: creationHint,
62
+ }
63
+ : {}),
64
+ }),
33
65
  includeCounterfactualInfo: true,
34
- };
66
+ });
35
67
  const cachedAccount = client.internal.getAccount();
36
68
  if (cachedAccount &&
37
69
  ((args.accountAddress &&
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAkB1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA0B,EAC1B,MAA6B;IAE7B,MAAM,IAAI,GACR,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,GAAG,MAAM;YACT,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,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 {\n type SmartAccountSigner,\n type SmartContractAccount,\n} 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\";\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: SmartAccountSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const args =\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress: await signer.getAddress(),\n includeCounterfactualInfo: true,\n };\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":"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,aA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R;gBACH,CAAC,CAAC;oBACE,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;oBACxC,GAAG,CAAC,YAAY;wBACd,CAAC,CAAC;4BACE,YAAY,EACV,YAA8C;yBACjD;wBACH,CAAC,CAAC,EAAE,CAAC;iBACR,CAAC;YACN,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 { 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 {\n CreationOptionsByPublicKey,\n CreationOptionsBySignerAddress,\n type 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 (creationHint.accountType !== \"mav2-webauthn\") {\n // todo: validate error details\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 // todo: re-enable after fixing type assertions above\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,8 +1,8 @@
1
1
  import type { Address } from "viem";
2
2
  import type { InnerWalletApiClient } from "../../types.js";
3
3
  import { type PrepareCallsParams } from "./prepareCalls.js";
4
- import { type SmartAccountSigner } from "@aa-sdk/core";
5
4
  import { type SendPreparedCallsResult } from "./sendPreparedCalls.js";
5
+ import type { SmartWalletSigner } from "../index.js";
6
6
  export type SendCallsParams<TAccount extends Address | undefined = Address | undefined> = PrepareCallsParams<TAccount>;
7
7
  export type SendCallsResult = SendPreparedCallsResult;
8
8
  /**
@@ -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} signer - The signer to use
17
+ * @param {SmartAccountSigner | WebAuthnSigner} 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)
@@ -38,4 +38,4 @@ export type SendCallsResult = SendPreparedCallsResult;
38
38
  * console.log(result.preparedCallIds);
39
39
  * ```
40
40
  */
41
- export declare function sendCalls<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SendCallsParams<TAccount>): Promise<SendCallsResult>;
41
+ export declare function sendCalls<TAccount extends Address | undefined = Address | undefined>(client: InnerWalletApiClient, signer: SmartWalletSigner, params: SendCallsParams<TAccount>): Promise<SendCallsResult>;
@@ -1,9 +1,9 @@
1
1
  import { prepareCalls } from "./prepareCalls.js";
2
2
  import { metrics } from "../../metrics.js";
3
3
  import { signPreparedCalls } from "./signPreparedCalls.js";
4
- import {} from "@aa-sdk/core";
5
4
  import { sendPreparedCalls, } from "./sendPreparedCalls.js";
6
5
  import { signSignatureRequest } from "./signSignatureRequest.js";
6
+ import { isWebAuthnSigner } from "../../utils.js";
7
7
  /**
8
8
  * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
9
9
  *
@@ -13,7 +13,7 @@ import { signSignatureRequest } from "./signSignatureRequest.js";
13
13
  * </Note>
14
14
  *
15
15
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
16
- * @param {SmartAccountSigner} signer - The signer to use
16
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer to use
17
17
  * @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
18
18
  * @param {Array<{to: Address, data?: Hex, value?: Hex}>} params.calls - Array of contract calls to execute
19
19
  * @param {Address} [params.from] - The address to execute the calls from (required if the client wasn't initialized with an account)
@@ -43,6 +43,9 @@ export async function sendCalls(client, signer, params) {
43
43
  });
44
44
  let calls = await prepareCalls(client, params);
45
45
  if (calls.type === "paymaster-permit") {
46
+ if (isWebAuthnSigner(signer)) {
47
+ throw new Error("WebAuthn signer is not currently supported for signing paymaster permit signatures");
48
+ }
46
49
  const signature = await signSignatureRequest(signer, calls.signatureRequest);
47
50
  const secondCallParams = {
48
51
  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,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAQjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAG7B,MAA4B,EAC5B,MAA0B,EAC1B,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,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,OAAO,MAAM,iBAAiB,CAAC,MAAM,EAAE;QACrC,GAAG,WAAW;QACd,6EAA6E;QAC7E,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,IAAI,IAAI;YAC1C,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE;YACpE,CAAC,CAAC,EAAE,CAAC;KACR,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 { type SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.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 prepared call IDs.\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 prepared call IDs\n * console.log(result.preparedCallIds);\n * ```\n */\nexport async function sendCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\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 return await sendPreparedCalls(client, {\n ...signedCalls,\n // The only capability that is supported in sendPreparedCalls is permissions.\n ...(params.capabilities?.permissions != null\n ? { capabilities: { permissions: params.capabilities.permissions } }\n : {}),\n });\n}\n"]}
1
+ {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../../src/client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CAAC,CAAC;IAE3D,OAAO,MAAM,iBAAiB,CAAC,MAAM,EAAE;QACrC,GAAG,WAAW;QACd,6EAA6E;QAC7E,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,IAAI,IAAI;YAC1C,CAAC,CAAC,EAAE,YAAY,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE;YACpE,CAAC,CAAC,EAAE,CAAC;KACR,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\";\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 prepared call IDs.\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 prepared call IDs\n * console.log(result.preparedCallIds);\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 return await sendPreparedCalls(client, {\n ...signedCalls,\n // The only capability that is supported in sendPreparedCalls is permissions.\n ...(params.capabilities?.permissions != null\n ? { capabilities: { permissions: params.capabilities.permissions } }\n : {}),\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { type SmartAccountSigner } from "@aa-sdk/core";
2
1
  import { type Address, type Hex, type SignableMessage } from "viem";
3
2
  import type { InnerWalletApiClient } from "../../types.ts";
3
+ import type { SmartWalletSigner } from "../index.js";
4
4
  export type SignMessageParams = {
5
5
  message: SignableMessage;
6
6
  account?: Address;
@@ -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} signer - The signer of the smart account
14
+ * @param {SmartAccountSigner | WebAuthnSigner} 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.
@@ -26,4 +26,4 @@ export type SignMessageResult = Hex;
26
26
  * const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
27
27
  * ```
28
28
  */
29
- export declare function signMessage(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignMessageParams): Promise<SignMessageResult>;
29
+ export declare function signMessage(client: InnerWalletApiClient, signer: SmartWalletSigner, params: SignMessageParams): Promise<SignMessageResult>;
@@ -1,4 +1,3 @@
1
- import {} from "@aa-sdk/core";
2
1
  import {} from "viem";
3
2
  import { requestAccount } from "./requestAccount.js";
4
3
  import { metrics } from "../../metrics.js";
@@ -7,7 +6,7 @@ import { metrics } from "../../metrics.js";
7
6
  * This method requests the account associated with the signer and uses it to sign the message.
8
7
  *
9
8
  * @param {InnerWalletApiClient} client - The wallet API client to use for the request
10
- * @param {SmartAccountSigner} signer - The signer of the smart account
9
+ * @param {SmartAccountSigner | WebAuthnSigner} signer - The signer of the smart account
11
10
  * @param {SignMessageParams} params - Parameters for signing the message
12
11
  * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
13
12
  * @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":"AAAA,OAAO,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EAAgD,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAA0B,EAC1B,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 SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\nimport { metrics } from \"../../metrics.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: SmartAccountSigner,\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":"AAAA,OAAO,EAAgD,MAAM,MAAM,CAAC;AAEpE,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, type Hex, type 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,6 +1,6 @@
1
1
  import type { PrepareCallsResult } from "./prepareCalls.ts";
2
- import { type SmartAccountSigner } from "@aa-sdk/core";
3
2
  import type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
3
+ import type { SmartWalletSigner } from "../index.js";
4
4
  type RpcSchema = Extract<WalletServerRpcSchemaType, {
5
5
  Request: {
6
6
  method: "wallet_sendPreparedCalls";
@@ -11,9 +11,9 @@ export type SignPreparedCallsResult = RpcSchema["Request"]["params"][0];
11
11
  /**
12
12
  * Signs prepared calls using the provided signer.
13
13
  *
14
- * @param {SmartAccountSigner} signer - The signer to use
14
+ * @param {SmartAccountSigner | WebAuthnSigner} 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
  */
18
- export declare function signPreparedCalls(signer: SmartAccountSigner, params: SignPreparedCallsParams): Promise<SignPreparedCallsResult>;
18
+ export declare function signPreparedCalls(signer: SmartWalletSigner, params: SignPreparedCallsParams): Promise<SignPreparedCallsResult>;
19
19
  export {};
@@ -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 } from "../../utils.js";
4
+ import { assertNever, isWebAuthnSigner } from "../../utils.js";
5
5
  /**
6
6
  * Signs prepared calls using the provided signer.
7
7
  *
8
- * @param {SmartAccountSigner} signer - The signer to use
8
+ * @param {SmartAccountSigner | WebAuthnSigner} 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,6 +18,9 @@ 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
+ }
21
24
  const signature = await signSignatureRequest(signer, {
22
25
  type: "eip7702Auth",
23
26
  data: {
@@ -1 +1 @@
1
- {"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA2B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAe7C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA0B,EAC1B,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,CAA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,qBAAqB,MAAM,CAAC,IAAI,6BAA6B,CAC9D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAChB,MAAM,EACN,2BAA2B,MAAM,6BAA6B,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport { BaseError, type SmartAccountSigner } 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\";\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: SmartAccountSigner,\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
+ {"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,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AM,IAAI,SAAS,CACjB,qBAAqB,MAAM,CAAC,IAAI,6BAA6B,CAC9D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAChB,MAAM,EACN,2BAA2B,MAAM,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, 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"]}