@account-kit/wallet-client 4.75.0 → 4.75.2

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 (89) hide show
  1. package/dist/esm/client/actions/formatSign.d.ts +1 -1
  2. package/dist/esm/client/actions/formatSign.js.map +1 -1
  3. package/dist/esm/client/actions/getCallsStatus.d.ts +2 -2
  4. package/dist/esm/client/actions/getCallsStatus.js +0 -1
  5. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  6. package/dist/esm/client/actions/grantPermissions.d.ts +2 -2
  7. package/dist/esm/client/actions/grantPermissions.js +5 -7
  8. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  9. package/dist/esm/client/actions/listAccounts.d.ts +1 -1
  10. package/dist/esm/client/actions/listAccounts.js.map +1 -1
  11. package/dist/esm/client/actions/prepareCalls.d.ts +2 -2
  12. package/dist/esm/client/actions/prepareCalls.js +0 -1
  13. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  14. package/dist/esm/client/actions/prepareSign.d.ts +2 -2
  15. package/dist/esm/client/actions/prepareSign.js +0 -1
  16. package/dist/esm/client/actions/prepareSign.js.map +1 -1
  17. package/dist/esm/client/actions/requestAccount.d.ts +1 -1
  18. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  19. package/dist/esm/client/actions/sendPreparedCalls.d.ts +1 -1
  20. package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
  21. package/dist/esm/client/actions/signPreparedCalls.d.ts +2 -2
  22. package/dist/esm/client/actions/signPreparedCalls.js +0 -2
  23. package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
  24. package/dist/esm/client/actions/signSignatureRequest.d.ts +1 -1
  25. package/dist/esm/client/actions/signSignatureRequest.js +0 -1
  26. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  27. package/dist/esm/client/index.js +4 -3
  28. package/dist/esm/client/index.js.map +1 -1
  29. package/dist/esm/experimental/actions/requestQuoteV0.d.ts +1 -1
  30. package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
  31. package/dist/esm/exports/index.d.ts +1 -1
  32. package/dist/esm/exports/index.js +0 -1
  33. package/dist/esm/exports/index.js.map +1 -1
  34. package/dist/esm/internal/account.d.ts +2 -2
  35. package/dist/esm/internal/account.js +3 -5
  36. package/dist/esm/internal/account.js.map +1 -1
  37. package/dist/esm/metrics.d.ts +2 -2
  38. package/dist/esm/metrics.js +0 -1
  39. package/dist/esm/metrics.js.map +1 -1
  40. package/dist/esm/version.d.ts +1 -1
  41. package/dist/esm/version.js +1 -1
  42. package/dist/esm/version.js.map +1 -1
  43. package/dist/types/client/actions/formatSign.d.ts +1 -1
  44. package/dist/types/client/actions/formatSign.d.ts.map +1 -1
  45. package/dist/types/client/actions/getCallsStatus.d.ts +2 -2
  46. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  47. package/dist/types/client/actions/grantPermissions.d.ts +2 -2
  48. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  49. package/dist/types/client/actions/listAccounts.d.ts +1 -1
  50. package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
  51. package/dist/types/client/actions/prepareCalls.d.ts +2 -2
  52. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  53. package/dist/types/client/actions/prepareSign.d.ts +2 -2
  54. package/dist/types/client/actions/prepareSign.d.ts.map +1 -1
  55. package/dist/types/client/actions/requestAccount.d.ts +1 -1
  56. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  57. package/dist/types/client/actions/sendPreparedCalls.d.ts +1 -1
  58. package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
  59. package/dist/types/client/actions/signPreparedCalls.d.ts +2 -2
  60. package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
  61. package/dist/types/client/actions/signSignatureRequest.d.ts +1 -1
  62. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  63. package/dist/types/client/index.d.ts.map +1 -1
  64. package/dist/types/experimental/actions/requestQuoteV0.d.ts +1 -1
  65. package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
  66. package/dist/types/exports/index.d.ts +1 -1
  67. package/dist/types/exports/index.d.ts.map +1 -1
  68. package/dist/types/internal/account.d.ts +2 -2
  69. package/dist/types/internal/account.d.ts.map +1 -1
  70. package/dist/types/metrics.d.ts +2 -2
  71. package/dist/types/metrics.d.ts.map +1 -1
  72. package/dist/types/version.d.ts +1 -1
  73. package/package.json +8 -8
  74. package/src/client/actions/formatSign.ts +1 -1
  75. package/src/client/actions/getCallsStatus.ts +2 -2
  76. package/src/client/actions/grantPermissions.ts +7 -7
  77. package/src/client/actions/listAccounts.ts +1 -1
  78. package/src/client/actions/prepareCalls.ts +2 -2
  79. package/src/client/actions/prepareSign.ts +2 -2
  80. package/src/client/actions/requestAccount.ts +1 -1
  81. package/src/client/actions/sendPreparedCalls.ts +1 -1
  82. package/src/client/actions/signPreparedCalls.ts +6 -6
  83. package/src/client/actions/signSignatureRequest.ts +5 -5
  84. package/src/client/index.ts +18 -6
  85. package/src/experimental/actions/requestQuoteV0.ts +1 -1
  86. package/src/exports/index.ts +1 -4
  87. package/src/internal/account.ts +13 -8
  88. package/src/metrics.ts +2 -2
  89. package/src/version.ts +1 -1
@@ -1,4 +1,4 @@
1
- import type { Static } from "@sinclair/typebox";
1
+ import type { Static } from "typebox";
2
2
  import type { wallet_formatSign } from "@alchemy/wallet-api-types/rpc";
3
3
  import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
4
4
  import { type Address, type IsUndefined } from "viem";
@@ -1 +1 @@
1
- {"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../../src/client/actions/formatSign.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAgB3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAG9B,MAA4B,EAC5B,MAAkC;IAElC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,aAAa;KACpB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport type { wallet_formatSign } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type FormatSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n WithoutChainId<\n Static<\n (typeof wallet_formatSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n >,\n \"from\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type FormatSignResult = Static<typeof wallet_formatSign>[\"ReturnType\"];\n\n/**\n * Formats a signature request for signing messages or transactions.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {FormatSignParams} params - Parameters for formatting the signature\n * @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.\n *\n * @example\n * ```ts\n * // Formats a signature\n * const result = await client.formatSign({\n * from: \"0x1234...\",\n * signature: {\n * type: \"ecdsa\",\n * data: \"0xabcd...\"\n * },\n * });\n * ```\n */\nexport async function formatSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: FormatSignParams<TAccount>,\n): Promise<FormatSignResult> {\n metrics.trackEvent({\n name: \"format_sign\",\n });\n\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n return client.request({\n method: \"wallet_formatSign\",\n params: [{ ...params, from, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
1
+ {"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../../src/client/actions/formatSign.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAgB3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAG9B,MAA4B,EAC5B,MAAkC;IAElC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,aAAa;KACpB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"typebox\";\nimport type { wallet_formatSign } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type FormatSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n WithoutChainId<\n Static<\n (typeof wallet_formatSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n >,\n \"from\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type FormatSignResult = Static<typeof wallet_formatSign>[\"ReturnType\"];\n\n/**\n * Formats a signature request for signing messages or transactions.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {FormatSignParams} params - Parameters for formatting the signature\n * @returns {Promise<FormatSignResult>} A Promise that resolves to the formatSign result containing the formatted signature.\n *\n * @example\n * ```ts\n * // Formats a signature\n * const result = await client.formatSign({\n * from: \"0x1234...\",\n * signature: {\n * type: \"ecdsa\",\n * data: \"0xabcd...\"\n * },\n * });\n * ```\n */\nexport async function formatSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: FormatSignParams<TAccount>,\n): Promise<FormatSignResult> {\n metrics.trackEvent({\n name: \"format_sign\",\n });\n\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n return client.request({\n method: \"wallet_formatSign\",\n params: [{ ...params, from, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { InnerWalletApiClient } from "../../types.ts";
2
- import type { Static } from "@sinclair/typebox";
3
- import { wallet_getCallsStatus } from "@alchemy/wallet-api-types/rpc";
2
+ import type { Static } from "typebox";
3
+ import type { wallet_getCallsStatus } from "@alchemy/wallet-api-types/rpc";
4
4
  export type GetCallsStatusParams = Static<typeof wallet_getCallsStatus>["Request"]["params"][0];
5
5
  export type GetCallsStatusResult = Static<typeof wallet_getCallsStatus>["ReturnType"];
6
6
  /**
@@ -1,4 +1,3 @@
1
- import { wallet_getCallsStatus } from "@alchemy/wallet-api-types/rpc";
2
1
  import { metrics } from "../../metrics.js";
3
2
  /**
4
3
  * Gets the status of a prepared call by its ID.
@@ -1 +1 @@
1
- {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAU3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IAEH,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_getCallsStatus } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type GetCallsStatusParams = Static<\n typeof wallet_getCallsStatus\n>[\"Request\"][\"params\"][0];\n\nexport type GetCallsStatusResult = Static<\n typeof wallet_getCallsStatus\n>[\"ReturnType\"];\n\n/**\n * Gets the status of a prepared call by its ID.\n * This method is used to check the execution status of calls sent via sendPreparedCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {GetCallsStatusParams} params - The ID of the prepared call to check\n * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:\n * - id: The hex ID of the call\n * - chainId: The chain ID in hex format\n * - status: The current status of the batch execution\n * - receipts: Optional array of transaction receipts if the batch has been executed\n *\n * @example\n * ```ts\n * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the first call ID\n * const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);\n * ```\n */\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n metrics.trackEvent({\n name: \"get_calls_status\",\n });\n\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
1
+ {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAU3C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IAEH,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,MAAM,CAAC;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Static } from \"typebox\";\nimport type { wallet_getCallsStatus } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type GetCallsStatusParams = Static<\n typeof wallet_getCallsStatus\n>[\"Request\"][\"params\"][0];\n\nexport type GetCallsStatusResult = Static<\n typeof wallet_getCallsStatus\n>[\"ReturnType\"];\n\n/**\n * Gets the status of a prepared call by its ID.\n * This method is used to check the execution status of calls sent via sendPreparedCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {GetCallsStatusParams} params - The ID of the prepared call to check\n * @returns {Promise<GetCallsStatusResult>} A Promise that resolves to the status information including:\n * - id: The hex ID of the call\n * - chainId: The chain ID in hex format\n * - status: The current status of the batch execution\n * - receipts: Optional array of transaction receipts if the batch has been executed\n *\n * @example\n * ```ts\n * // After sending prepared calls\n * const sendResult = await client.sendPreparedCalls({...});\n *\n * // Check the status of the first call ID\n * const status = await client.getCallsStatus(sendResult.preparedCallIds[0]);\n * ```\n */\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n metrics.trackEvent({\n name: \"get_calls_status\",\n });\n\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { type SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Address, type Hex, type IsUndefined, type Prettify } from "viem";
3
3
  import type { InnerWalletApiClient } from "../../types.ts";
4
- import type { Static } from "@sinclair/typebox";
5
- import { wallet_createSession } from "@alchemy/wallet-api-types/rpc";
4
+ import type { Static } from "typebox";
5
+ import type { wallet_createSession } from "@alchemy/wallet-api-types/rpc";
6
6
  export type GrantPermissionsParams<TAccount extends Address | undefined = Address | undefined> = Prettify<Omit<Static<(typeof wallet_createSession)["properties"]["Request"]["properties"]["params"]>[0], "account" | "chainId"> & (IsUndefined<TAccount> extends true ? {
7
7
  account: Address;
8
8
  } : {
@@ -1,7 +1,5 @@
1
1
  import { AccountNotFoundError } from "@aa-sdk/core";
2
- import { toHex, } from "viem";
3
- import { wallet_createSession } from "@alchemy/wallet-api-types/rpc";
4
- import { encodePermissionsContext } from "@alchemy/wallet-api-types/capabilities";
2
+ import { toHex, concatHex, } from "viem";
5
3
  import { signSignatureRequest } from "./signSignatureRequest.js";
6
4
  import { metrics } from "../../metrics.js";
7
5
  /**
@@ -79,11 +77,11 @@ export async function grantPermissions(client, signer, params) {
79
77
  });
80
78
  const signature = await signSignatureRequest(signer, signatureRequest);
81
79
  return {
82
- context: encodePermissionsContext({
83
- contextVersion: "REMOTE_MODE_DEFERRED_ACTION",
80
+ context: concatHex([
81
+ "0x00", // remote mode
84
82
  sessionId,
85
- signature: signature.data,
86
- }),
83
+ signature.data,
84
+ ]),
87
85
  };
88
86
  }
89
87
  //# sourceMappingURL=grantPermissions.js.map
@@ -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,GAKN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAoB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,wBAAwB,CAAC;YAChC,cAAc,EAAE,6BAA6B;YAC7C,SAAS;YACT,SAAS,EAAE,SAAS,CAAC,IAAI;SAC1B,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} from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_createSession } from \"@alchemy/wallet-api-types/rpc\";\nimport { encodePermissionsContext } from \"@alchemy/wallet-api-types/capabilities\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n Omit<\n Static<\n (typeof wallet_createSession)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"account\" | \"chainId\"\n > &\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: encodePermissionsContext({\n contextVersion: \"REMOTE_MODE_DEFERRED_ACTION\",\n sessionId,\n signature: 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,EAA2B,MAAM,cAAc,CAAC;AAC7E,OAAO,EACL,KAAK,EAKL,SAAS,GACV,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAoB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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 { Static } from \"typebox\";\nimport type { wallet_createSession } from \"@alchemy/wallet-api-types/rpc\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n Omit<\n Static<\n (typeof wallet_createSession)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"account\" | \"chainId\"\n > &\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,4 +1,4 @@
1
- import type { Static } from "@sinclair/typebox";
1
+ import type { Static } from "typebox";
2
2
  import type { wallet_listAccounts } from "@alchemy/wallet-api-types/rpc";
3
3
  import type { InnerWalletApiClient } from "../../types.ts";
4
4
  import type { SmartAccountSigner } from "@aa-sdk/core";
@@ -1 +1 @@
1
- {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../../src/client/actions/listAccounts.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAW3C;;;;;;;;;;;;;;;;;;;;;;;;;;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 { Static } from \"@sinclair/typebox\";\nimport type { wallet_listAccounts } 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\nexport type ListAccountsParams = Omit<\n Static<typeof wallet_listAccounts>[\"Request\"][\"params\"][0],\n \"signerAddress\"\n> & { signerAddress?: Address };\n\nexport type ListAccountsResult = Static<\n typeof wallet_listAccounts\n>[\"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":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAW3C;;;;;;;;;;;;;;;;;;;;;;;;;;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 { Static } from \"typebox\";\nimport type { wallet_listAccounts } 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\nexport type ListAccountsParams = Omit<\n Static<typeof wallet_listAccounts>[\"Request\"][\"params\"][0],\n \"signerAddress\"\n> & { signerAddress?: Address };\n\nexport type ListAccountsResult = Static<\n typeof wallet_listAccounts\n>[\"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,7 +1,7 @@
1
1
  import { type Address, type IsUndefined } from "viem";
2
2
  import type { InnerWalletApiClient } from "../../types.ts";
3
- import type { Static } from "@sinclair/typebox";
4
- import { wallet_prepareCalls } from "@alchemy/wallet-api-types/rpc";
3
+ import type { Static } from "typebox";
4
+ import type { wallet_prepareCalls } from "@alchemy/wallet-api-types/rpc";
5
5
  export type GetAccountParam<TAccount> = IsUndefined<TAccount> extends true ? {
6
6
  account: Address;
7
7
  } : {
@@ -1,6 +1,5 @@
1
1
  import { AccountNotFoundError } from "@aa-sdk/core";
2
2
  import { toHex } from "viem";
3
- import { wallet_prepareCalls } from "@alchemy/wallet-api-types/rpc";
4
3
  import { metrics } from "../../metrics.js";
5
4
  import { mergeClientCapabilities } from "../../internal/capabilities.js";
6
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAqBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,MAA4B,EAC5B,MAAoC;IAEpC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI;gBACJ,YAAY;aACb;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_prepareCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\nimport { mergeClientCapabilities } from \"../../internal/capabilities.js\";\n\nexport type GetAccountParam<TAccount> =\n IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: Address };\n\nexport type PrepareCallsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"from\" | \"chainId\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = Static<\n typeof wallet_prepareCalls\n>[\"ReturnType\"];\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request\n * @param {PrepareCallsParams<TAccount>} params - Parameters for preparing 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<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * ```ts\n * // Prepare a sponsored user operation call\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n * ```\n */\nexport async function prepareCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult> {\n metrics.trackEvent({\n name: \"prepare_calls\",\n });\n\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n capabilities,\n },\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAI7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAqBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,MAA4B,EAC5B,MAAoC;IAEpC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe;KACtB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI;gBACJ,YAAY;aACb;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport type { Static } from \"typebox\";\nimport type { wallet_prepareCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\nimport { mergeClientCapabilities } from \"../../internal/capabilities.js\";\n\nexport type GetAccountParam<TAccount> =\n IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: Address };\n\nexport type PrepareCallsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n Static<\n (typeof wallet_prepareCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"from\" | \"chainId\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = Static<\n typeof wallet_prepareCalls\n>[\"ReturnType\"];\n\n/**\n * Prepares a set of contract calls for execution by building a user operation.\n * Returns the built user operation and a signature request that needs to be signed\n * before submitting to sendPreparedCalls.\n *\n * @param {InnerWalletApiClient<TAccount>} client - The wallet API client to use for the request\n * @param {PrepareCallsParams<TAccount>} params - Parameters for preparing 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<PrepareCallsResult>} A Promise that resolves to the prepared calls result containing\n * the user operation data and signature request\n *\n * @example\n * ```ts\n * // Prepare a sponsored user operation call\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n * ```\n */\nexport async function prepareCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult> {\n metrics.trackEvent({\n name: \"prepare_calls\",\n });\n\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n capabilities,\n },\n ],\n });\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { InnerWalletApiClient } from "../../types.ts";
2
2
  import { type Address, type IsUndefined } from "viem";
3
- import type { Static } from "@sinclair/typebox";
4
- import { wallet_prepareSign } from "@alchemy/wallet-api-types/rpc";
3
+ import type { Static } from "typebox";
4
+ import type { wallet_prepareSign } from "@alchemy/wallet-api-types/rpc";
5
5
  export type PrepareSignParams<TAccount extends Address | undefined = Address | undefined> = Omit<Static<(typeof wallet_prepareSign)["properties"]["Request"]["properties"]["params"]>[0], "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
6
6
  from: Address;
7
7
  } : {
@@ -1,6 +1,5 @@
1
1
  import { toHex } from "viem";
2
2
  import { AccountNotFoundError } from "@aa-sdk/core";
3
- import { wallet_prepareSign } from "@alchemy/wallet-api-types/rpc";
4
3
  import { metrics } from "../../metrics.js";
5
4
  /**
6
5
  * Prepares a signature request for signing messages or transactions.
@@ -1 +1 @@
1
- {"version":3,"file":"prepareSign.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareSign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAc3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAG/B,MAA4B,EAC5B,MAAmC;IAEnC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,oBAAoB;QAC5B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InnerWalletApiClient } from \"../../types.ts\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_prepareSign } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type PrepareSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n Static<\n (typeof wallet_prepareSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"from\" | \"chainId\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareSignResult = Static<typeof wallet_prepareSign>[\"ReturnType\"];\n\n/**\n * Prepares a signature request for signing messages or transactions.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareSignParams} params - Parameters for preparing the signature request\n * @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request\n *\n * @example\n * ```ts\n * // Prepare a message to be signed\n * const result = await client.prepareSign({\n * from: \"0x1234...\",\n * type: \"personal_sign\",\n * data: \"Hello, world!\",\n * });\n * ```\n */\nexport async function prepareSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareSignParams<TAccount>,\n): Promise<PrepareSignResult> {\n metrics.trackEvent({\n name: \"prepare_sign\",\n });\n\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n return client.request({\n method: \"wallet_prepareSign\",\n params: [{ ...params, from, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
1
+ {"version":3,"file":"prepareSign.js","sourceRoot":"","sources":["../../../../src/client/actions/prepareSign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAkC,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAc3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAG/B,MAA4B,EAC5B,MAAmC;IAEnC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,oBAAoB;QAC5B,MAAM,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InnerWalletApiClient } from \"../../types.ts\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\nimport type { Static } from \"typebox\";\nimport type { wallet_prepareSign } from \"@alchemy/wallet-api-types/rpc\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type PrepareSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<\n Static<\n (typeof wallet_prepareSign)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"from\" | \"chainId\"\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareSignResult = Static<typeof wallet_prepareSign>[\"ReturnType\"];\n\n/**\n * Prepares a signature request for signing messages or transactions.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareSignParams} params - Parameters for preparing the signature request\n * @returns {Promise<PrepareSignResult>} A Promise that resolves to the prepare sign result containing a signature request\n *\n * @example\n * ```ts\n * // Prepare a message to be signed\n * const result = await client.prepareSign({\n * from: \"0x1234...\",\n * type: \"personal_sign\",\n * data: \"Hello, world!\",\n * });\n * ```\n */\nexport async function prepareSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareSignParams<TAccount>,\n): Promise<PrepareSignResult> {\n metrics.trackEvent({\n name: \"prepare_sign\",\n });\n\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n return client.request({\n method: \"wallet_prepareSign\",\n params: [{ ...params, from, chainId: toHex(client.chain.id) }],\n });\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type SmartAccountSigner, type SmartContractAccount } from "@aa-sdk/core";
2
- import type { Static } from "@sinclair/typebox";
2
+ import type { Static } from "typebox";
3
3
  import type { Address } from "abitype";
4
4
  import type { wallet_requestAccount } from "@alchemy/wallet-api-types/rpc";
5
5
  import type { InnerWalletApiClient } from "../../types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAGtB,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAY1D;;;;;;;;;;;;;;;;;;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 { Static } from \"@sinclair/typebox\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport type { wallet_requestAccount } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { createAccount } from \"../../internal/account.js\";\n\nexport type RequestAccountParams = Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\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,EAGN,MAAM,cAAc,CAAC;AAGtB,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAY1D;;;;;;;;;;;;;;;;;;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 { Static } from \"typebox\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport type { wallet_requestAccount } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { createAccount } from \"../../internal/account.js\";\n\nexport type RequestAccountParams = Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\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,4 +1,4 @@
1
- import type { Static } from "@sinclair/typebox";
1
+ import type { Static } from "typebox";
2
2
  import type { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
3
3
  import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
4
4
  export type SendPreparedCallsParams = WithoutChainId<Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0]>;
@@ -1 +1 @@
1
- {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAY3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,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,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type SendPreparedCallsParams = WithoutChainId<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs\n *\n * @example\n * ```ts\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n * ```\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n metrics.trackEvent({\n name: \"send_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [\n params.type === \"array\"\n ? params\n : {\n ...params,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAY3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,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,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type SendPreparedCallsParams = WithoutChainId<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs\n *\n * @example\n * ```ts\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n * ```\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n metrics.trackEvent({\n name: \"send_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [\n params.type === \"array\"\n ? params\n : {\n ...params,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { PrepareCallsResult } from "./prepareCalls.ts";
2
2
  import { type SmartAccountSigner } from "@aa-sdk/core";
3
- import type { Static } from "@sinclair/typebox";
4
- import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
3
+ import type { Static } from "typebox";
4
+ import type { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
5
5
  export type SignPreparedCallsParams = PrepareCallsResult;
6
6
  export type SignPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0];
7
7
  /**
@@ -1,7 +1,5 @@
1
1
  import { BaseError } from "@aa-sdk/core";
2
2
  import { signSignatureRequest } from "./signSignatureRequest.js";
3
- import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
4
- import {} from "@alchemy/wallet-api-types";
5
3
  import { metrics } from "../../metrics.js";
6
4
  import { assertNever } from "../../utils.js";
7
5
  /**
@@ -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;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAIN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C;;;;;;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,CAAC;QAC9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAC;QACH,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,EACjC,IAAuD,EACvD,EAAE;QACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAE3C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,SAAS,CACjB,wIAAwI,CACzI,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO;YACL,IAAI,EAAE,OAAgB;YACtB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACvB,IAAI,CAAC,IAAI,KAAK,eAAe;gBAC3B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAChC,CACF;SACF,CAAC;IACJ,CAAC;SAAM,IACL,MAAM,CAAC,IAAI,KAAK,qBAAqB;QACrC,MAAM,CAAC,IAAI,KAAK,qBAAqB,EACrC,CAAC;QACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC9C,MAAM,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, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_sendPreparedCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n type PreparedCall_Authorization,\n type PreparedCall_UserOpV060,\n type PreparedCall_UserOpV070,\n} from \"@alchemy/wallet-api-types\";\nimport { metrics } from \"../../metrics.js\";\nimport { assertNever } from \"../../utils.js\";\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[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,EAA2B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAQjE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C;;;;;;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,CAAC;QAC9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAC;QACH,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,EACjC,IAAuD,EACvD,EAAE;QACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAE3C,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,IAAI,SAAS,CACjB,wIAAwI,CACzI,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO;YACL,IAAI,EAAE,OAAgB;YACtB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACvB,IAAI,CAAC,IAAI,KAAK,eAAe;gBAC3B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAChC,CACF;SACF,CAAC;IACJ,CAAC;SAAM,IACL,MAAM,CAAC,IAAI,KAAK,qBAAqB;QACrC,MAAM,CAAC,IAAI,KAAK,qBAAqB,EACrC,CAAC;QACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC9C,MAAM,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, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { Static } from \"typebox\";\nimport type { wallet_sendPreparedCalls } 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\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[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,6 +1,6 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Hex } from "viem";
3
- import { type PersonalSignSignatureRequest, type TypedDataSignatureRequest, type AuthorizationSignatureRequest, type Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
3
+ import type { PersonalSignSignatureRequest, TypedDataSignatureRequest, AuthorizationSignatureRequest, Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
4
4
  import type { WithoutRawPayload } from "../../types.ts";
5
5
  export type SignSignatureRequestParams = WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
6
6
  data: Eip7702UnsignedAuth;
@@ -1,6 +1,5 @@
1
1
  import { hexToNumber, serializeSignature } from "viem";
2
2
  import { assertNever } from "../../utils.js";
3
- import {} from "@alchemy/wallet-api-types";
4
3
  import { vToYParity } from "ox/Signature";
5
4
  import { metrics } from "../../metrics.js";
6
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAKN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAe3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IAEH,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,EACJ,CAAC,EACD,CAAC,EACD,CAAC,EACD,OAAO,EAAE,QAAQ,GAClB,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBACjC,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACtC,CAAC,CAAC;YACH,MAAM,OAAO,GACX,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAE9D,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO;iBACR,CAAC;aACH,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Hex, hexToNumber, serializeSignature } from \"viem\";\nimport { assertNever } from \"../../utils.js\";\nimport {\n type PersonalSignSignatureRequest,\n type TypedDataSignatureRequest,\n type AuthorizationSignatureRequest,\n type Eip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type { WithoutRawPayload } from \"../../types.ts\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type SignSignatureRequestParams = WithoutRawPayload<\n | PersonalSignSignatureRequest\n | TypedDataSignatureRequest\n | (AuthorizationSignatureRequest & {\n data: Eip7702UnsignedAuth;\n })\n>;\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: Hex;\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.\n *\n * @param {SmartAccountSigner} signer - The signer to use for signing the request\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {SignSignatureRequestParams[\"data\"]} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n *\n * @example\n * ```ts\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n * ```\n */\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n metrics.trackEvent({\n name: \"sign_signature_request\",\n data: {\n type: params.type,\n },\n });\n\n switch (params.type) {\n case \"personal_sign\": {\n return {\n type: \"secp256k1\",\n data: await signer.signMessage(params.data),\n };\n }\n case \"eth_signTypedData_v4\": {\n return {\n type: \"secp256k1\",\n data: await signer.signTypedData(params.data),\n };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new Error(\"Signer does not implement signAuthorization\");\n }\n const {\n r,\n s,\n v,\n yParity: _yParity,\n } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n const yParity =\n _yParity != null ? Number(_yParity) : vToYParity(Number(v));\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity,\n }),\n };\n }\n default:\n return assertNever(params, `Unexpected signature request type.`);\n }\n}\n"]}
1
+ {"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAO7C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAe3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB;KACF,CAAC,CAAC;IAEH,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,EACJ,CAAC,EACD,CAAC,EACD,CAAC,EACD,OAAO,EAAE,QAAQ,GAClB,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBACjC,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACtC,CAAC,CAAC;YACH,MAAM,OAAO,GACX,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAE9D,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO;iBACR,CAAC;aACH,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Hex, hexToNumber, serializeSignature } from \"viem\";\nimport { assertNever } from \"../../utils.js\";\nimport type {\n PersonalSignSignatureRequest,\n TypedDataSignatureRequest,\n AuthorizationSignatureRequest,\n Eip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type { WithoutRawPayload } from \"../../types.ts\";\nimport { metrics } from \"../../metrics.js\";\n\nexport type SignSignatureRequestParams = WithoutRawPayload<\n | PersonalSignSignatureRequest\n | TypedDataSignatureRequest\n | (AuthorizationSignatureRequest & {\n data: Eip7702UnsignedAuth;\n })\n>;\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: Hex;\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.\n *\n * @param {SmartAccountSigner} signer - The signer to use for signing the request\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {SignSignatureRequestParams[\"data\"]} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n *\n * @example\n * ```ts\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n * ```\n */\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n metrics.trackEvent({\n name: \"sign_signature_request\",\n data: {\n type: params.type,\n },\n });\n\n switch (params.type) {\n case \"personal_sign\": {\n return {\n type: \"secp256k1\",\n data: await signer.signMessage(params.data),\n };\n }\n case \"eth_signTypedData_v4\": {\n return {\n type: \"secp256k1\",\n data: await signer.signTypedData(params.data),\n };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new Error(\"Signer does not implement signAuthorization\");\n }\n const {\n r,\n s,\n v,\n yParity: _yParity,\n } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n const yParity =\n _yParity != null ? Number(_yParity) : vToYParity(Number(v));\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity,\n }),\n };\n }\n default:\n return assertNever(params, `Unexpected signature request type.`);\n }\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import { createClient, custom, } from "viem";
2
2
  import { smartWalletClientActions, } from "./decorator.js";
3
- import { Provider } from "ox";
4
- import { WalletServerRpcSchema } from "@alchemy/wallet-api-types/rpc";
3
+ import { Provider, RpcSchema } from "ox";
5
4
  import { internalStateDecorator } from "../internal/decorator.js";
6
5
  import { metrics } from "../metrics.js";
7
6
  export function createSmartWalletClient(params) {
@@ -12,7 +11,9 @@ export function createSmartWalletClient(params) {
12
11
  ? params.policyIds
13
12
  : undefined;
14
13
  const innerClient = createClient({
15
- transport: (opts) => custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(opts),
14
+ transport: (opts) => custom(Provider.from(transport(opts), {
15
+ schema: RpcSchema.from(),
16
+ }))(opts),
16
17
  chain,
17
18
  account,
18
19
  }).extend(() => ({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,YAAY,EACZ,MAAM,GACP,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAqDxC,MAAM,UAAU,uBAAuB,CACrC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAErD,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ;QAC/B,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACnB,CAAC,CAAC,MAAM,CAAC,SAAS;YAChB,CAAC,CAAC,MAAM,CAAC,SAAS;YAClB,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,WAAW,GAAG,YAAY,CAAC;QAC/B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC,CACvE,IAAI,CACL;QACH,KAAK;QACL,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,SAAS;QACT,QAAQ,EAAE,sBAAsB,EAAE;KACnC,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;SACzB;KACF,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACnC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,yDAAyD;AACzD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,MAAM;AAEN,gEAAgE;AAEhE,sDAAsD;AACtD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,0BAA0B;AAC1B,MAAM;AAEN,6DAA6D","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { AlchemyTransport } from \"@account-kit/infra\";\nimport {\n type Address,\n type Chain,\n type Prettify,\n createClient,\n custom,\n} from \"viem\";\nimport type { InnerWalletApiClientBase } from \"../types.ts\";\nimport {\n smartWalletClientActions,\n type SmartWalletActions,\n} from \"./decorator.js\";\nimport { Provider } from \"ox\";\nimport { WalletServerRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { internalStateDecorator } from \"../internal/decorator.js\";\nimport { metrics } from \"../metrics.js\";\n\nexport type SmartWalletClientParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n {\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n account?: TAccount | Address | undefined;\n } & (\n | { policyId?: string; policyIds?: never }\n | { policyIds?: string[]; policyId?: never }\n )\n>;\n\nexport type SmartWalletClient<\n TAccount extends Address | undefined = Address | undefined,\n> = InnerWalletApiClientBase<SmartWalletActions<TAccount>>;\n\n/**\n * Creates a smart wallet client that can be used to interact with a smart account.\n *\n * @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client\n * @param {AlchemyTransport} params.transport - The Alchemy transport to use\n * @param {Chain} params.chain - The chain to use\n * @param {SmartAccountSigner} params.signer - The signer to use for the smart account\n * @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)\n * @param {Address} [params.account] - The smart account address to use (optional)\n * @returns {SmartWalletClient} - A viem-compatible client\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\n * import { generatePrivateKey } from \"viem/accounts\";\n * import { createSmartWalletClient } from \"@account-kit/wallet-client\";\n *\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());\n * const transport = alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * });\n * const client = createSmartWalletClient({\n * transport,\n * chain: arbitrumSepolia,\n * signer,\n * });\n * ```\n */\nexport function createSmartWalletClient<\n TAccount extends Address | undefined = undefined,\n>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;\n\nexport function createSmartWalletClient(\n params: SmartWalletClientParams,\n): SmartWalletClient {\n const { transport, chain, account, signer } = params;\n\n const policyIds = params.policyId\n ? [params.policyId]\n : params.policyIds\n ? params.policyIds\n : undefined;\n\n const innerClient = createClient({\n transport: (opts) =>\n custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(\n opts,\n ),\n chain,\n account,\n }).extend(() => ({\n policyIds,\n internal: internalStateDecorator(),\n }));\n\n metrics.trackEvent({\n name: \"client_created\",\n data: {\n chainId: params.chain.id,\n },\n });\n\n return innerClient.extend((client) =>\n smartWalletClientActions(client, signer),\n );\n}\n\n// Example usage:\n// const clientWithoutAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// });\n\n// const account1 = await clientWithoutAccount.requestAccount();\n\n// const clientWithAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// account: zeroAddress,\n// });\n\n// const account2 = await clientWithAccount.requestAccount();\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,YAAY,EACZ,MAAM,GAEP,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAKzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAqDxC,MAAM,UAAU,uBAAuB,CACrC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAErD,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ;QAC/B,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACnB,CAAC,CAAC,MAAM,CAAC,SAAS;YAChB,CAAC,CAAC,MAAM,CAAC,SAAS;YAClB,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,WAAW,GAAG,YAAY,CAK9B;QACA,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,MAAM,CACJ,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YAC7B,MAAM,EAAE,SAAS,CAAC,IAAI,EAA6B;SACpD,CAAC,CACH,CAAC,IAAI,CAAC;QACT,KAAK;QACL,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,SAAS;QACT,QAAQ,EAAE,sBAAsB,EAAE;KACnC,CAAC,CAAC,CAAC;IAEJ,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;SACzB;KACF,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACnC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,yDAAyD;AACzD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,MAAM;AAEN,gEAAgE;AAEhE,sDAAsD;AACtD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,0BAA0B;AAC1B,MAAM;AAEN,6DAA6D","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { AlchemyTransport } from \"@account-kit/infra\";\nimport {\n type Address,\n type Chain,\n type Prettify,\n type Transport,\n createClient,\n custom,\n type JsonRpcAccount,\n} from \"viem\";\nimport type { InnerWalletApiClientBase } from \"../types.ts\";\nimport {\n smartWalletClientActions,\n type SmartWalletActions,\n} from \"./decorator.js\";\nimport { Provider, RpcSchema } from \"ox\";\nimport type {\n WalletServerRpcSchemaType,\n WalletServerViemRpcSchema,\n} from \"@alchemy/wallet-api-types/rpc\";\nimport { internalStateDecorator } from \"../internal/decorator.js\";\nimport { metrics } from \"../metrics.js\";\n\nexport type SmartWalletClientParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n {\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n account?: TAccount | Address | undefined;\n } & (\n | { policyId?: string; policyIds?: never }\n | { policyIds?: string[]; policyId?: never }\n )\n>;\n\nexport type SmartWalletClient<\n TAccount extends Address | undefined = Address | undefined,\n> = InnerWalletApiClientBase<SmartWalletActions<TAccount>>;\n\n/**\n * Creates a smart wallet client that can be used to interact with a smart account.\n *\n * @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client\n * @param {AlchemyTransport} params.transport - The Alchemy transport to use\n * @param {Chain} params.chain - The chain to use\n * @param {SmartAccountSigner} params.signer - The signer to use for the smart account\n * @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)\n * @param {Address} [params.account] - The smart account address to use (optional)\n * @returns {SmartWalletClient} - A viem-compatible client\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\n * import { generatePrivateKey } from \"viem/accounts\";\n * import { createSmartWalletClient } from \"@account-kit/wallet-client\";\n *\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());\n * const transport = alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * });\n * const client = createSmartWalletClient({\n * transport,\n * chain: arbitrumSepolia,\n * signer,\n * });\n * ```\n */\nexport function createSmartWalletClient<\n TAccount extends Address | undefined = undefined,\n>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;\n\nexport function createSmartWalletClient(\n params: SmartWalletClientParams,\n): SmartWalletClient {\n const { transport, chain, account, signer } = params;\n\n const policyIds = params.policyId\n ? [params.policyId]\n : params.policyIds\n ? params.policyIds\n : undefined;\n\n const innerClient = createClient<\n Transport,\n Chain,\n JsonRpcAccount<Address> | undefined,\n WalletServerViemRpcSchema\n >({\n transport: (opts) =>\n custom(\n Provider.from(transport(opts), {\n schema: RpcSchema.from<WalletServerRpcSchemaType>(),\n }),\n )(opts),\n chain,\n account,\n }).extend(() => ({\n policyIds,\n internal: internalStateDecorator(),\n }));\n\n metrics.trackEvent({\n name: \"client_created\",\n data: {\n chainId: params.chain.id,\n },\n });\n\n return innerClient.extend((client) =>\n smartWalletClientActions(client, signer),\n );\n}\n\n// Example usage:\n// const clientWithoutAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// });\n\n// const account1 = await clientWithoutAccount.requestAccount();\n\n// const clientWithAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// account: zeroAddress,\n// });\n\n// const account2 = await clientWithAccount.requestAccount();\n"]}
@@ -1,4 +1,4 @@
1
- import type { Static } from "@sinclair/typebox";
1
+ import type { Static } from "typebox";
2
2
  import { type Address, type IsUndefined, type Prettify, type UnionOmit } from "viem";
3
3
  import type { wallet_requestQuote_v0 } from "@alchemy/wallet-api-types/rpc";
4
4
  import type { InnerWalletApiClientBase } from "../../types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,GAKN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAkBzE,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC,MAAgC,EAChC,MAAsC;IAEtC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc;QACxC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAEzD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI;gBACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,CAAC;aACtC;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport {\n toHex,\n type Address,\n type IsUndefined,\n type Prettify,\n type UnionOmit,\n} from \"viem\";\nimport type { wallet_requestQuote_v0 } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClientBase } from \"../../types.js\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { mergeClientCapabilities } from \"../../internal/capabilities.js\";\n\nexport type RequestQuoteV0Params<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n UnionOmit<\n Static<\n (typeof wallet_requestQuote_v0)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"from\" | \"chainId\"\n >\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type RequestQuoteV0Result = Prettify<\n Static<typeof wallet_requestQuote_v0>[\"ReturnType\"]\n>;\n\nexport async function requestQuoteV0<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClientBase,\n params: RequestQuoteV0Params<TAccount>,\n): Promise<RequestQuoteV0Result> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n const capabilities = params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(client, params.capabilities);\n\n return await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n ...(capabilities && { capabilities }),\n },\n ],\n });\n}\n"]}
1
+ {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,GAKN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAkBzE,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC,MAAgC,EAChC,MAAsC;IAEtC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,cAAc;QACxC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAEzD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC;QAC1B,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE;YACN;gBACE,GAAG,MAAM;gBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,IAAI;gBACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,CAAC;aACtC;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"typebox\";\nimport {\n toHex,\n type Address,\n type IsUndefined,\n type Prettify,\n type UnionOmit,\n} from \"viem\";\nimport type { wallet_requestQuote_v0 } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClientBase } from \"../../types.js\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { mergeClientCapabilities } from \"../../internal/capabilities.js\";\n\nexport type RequestQuoteV0Params<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n UnionOmit<\n Static<\n (typeof wallet_requestQuote_v0)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0],\n \"from\" | \"chainId\"\n >\n> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type RequestQuoteV0Result = Prettify<\n Static<typeof wallet_requestQuote_v0>[\"ReturnType\"]\n>;\n\nexport async function requestQuoteV0<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClientBase,\n params: RequestQuoteV0Params<TAccount>,\n): Promise<RequestQuoteV0Result> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n const capabilities = params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(client, params.capabilities);\n\n return await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n ...(capabilities && { capabilities }),\n },\n ],\n });\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export { createSmartWalletClient, type SmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
2
- export { WalletServerRpcSchema, type WalletServerRpcSchemaType, } from "@alchemy/wallet-api-types/rpc";
2
+ export type { WalletServerRpcSchemaType } from "@alchemy/wallet-api-types/rpc";
3
3
  export type * from "../client/actions/getCallsStatus.js";
4
4
  export { getCallsStatus } from "../client/actions/getCallsStatus.js";
5
5
  export type * from "../client/actions/grantPermissions.js";
@@ -1,7 +1,6 @@
1
1
  // TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories
2
2
  // and we shouldn't export * for the sake of tree-shaking
3
3
  export { createSmartWalletClient, } from "../client/index.js";
4
- export { WalletServerRpcSchema, } from "@alchemy/wallet-api-types/rpc";
5
4
  export { getCallsStatus } from "../client/actions/getCallsStatus.js";
6
5
  export { grantPermissions } from "../client/actions/grantPermissions.js";
7
6
  export { listAccounts } from "../client/actions/listAccounts.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAGxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,qBAAqB,GAEtB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["// TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories\n// and we shouldn't export * for the sake of tree-shaking\nexport {\n createSmartWalletClient,\n type SmartWalletClient,\n type SmartWalletClientParams,\n} from \"../client/index.js\";\n\nexport {\n WalletServerRpcSchema,\n type WalletServerRpcSchemaType,\n} from \"@alchemy/wallet-api-types/rpc\";\n\n// client actions\nexport type * from \"../client/actions/getCallsStatus.js\";\nexport { getCallsStatus } from \"../client/actions/getCallsStatus.js\";\nexport type * from \"../client/actions/grantPermissions.js\";\nexport { grantPermissions } from \"../client/actions/grantPermissions.js\";\nexport type * from \"../client/actions/listAccounts.js\";\nexport { listAccounts } from \"../client/actions/listAccounts.js\";\nexport type * from \"../client/actions/prepareCalls.js\";\nexport { prepareCalls } from \"../client/actions/prepareCalls.js\";\nexport type * from \"../client/actions/requestAccount.js\";\nexport { requestAccount } from \"../client/actions/requestAccount.js\";\nexport type * from \"../client/actions/signSignatureRequest.js\";\nexport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nexport type * from \"../client/actions/signPreparedCalls.js\";\nexport { signPreparedCalls } from \"../client/actions/signPreparedCalls.js\";\nexport type * from \"../client/actions/signMessage.js\";\nexport { signMessage } from \"../client/actions/signMessage.js\";\nexport type * from \"../client/actions/signTypedData.js\";\nexport { signTypedData } from \"../client/actions/signTypedData.js\";\nexport type * from \"../client/actions/sendPreparedCalls.js\";\nexport { sendPreparedCalls } from \"../client/actions/sendPreparedCalls.js\";\nexport type * from \"../client/actions/sendCalls.js\";\nexport { sendCalls } from \"../client/actions/sendCalls.js\";\nexport type * from \"../client/actions/waitForCallsStatus.js\";\nexport { waitForCallsStatus } from \"../client/actions/waitForCallsStatus.js\";\nexport type * from \"../client/actions/prepareSign.js\";\nexport { prepareSign } from \"../client/actions/prepareSign.js\";\nexport type * from \"../client/actions/formatSign.js\";\nexport { formatSign } from \"../client/actions/formatSign.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,yDAAyD;AACzD,OAAO,EACL,uBAAuB,GAGxB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["// TODO: anything that we want to expose publicly should be exported from `index.ts` files in the subdirectories\n// and we shouldn't export * for the sake of tree-shaking\nexport {\n createSmartWalletClient,\n type SmartWalletClient,\n type SmartWalletClientParams,\n} from \"../client/index.js\";\n\nexport type { WalletServerRpcSchemaType } from \"@alchemy/wallet-api-types/rpc\";\n\n// client actions\nexport type * from \"../client/actions/getCallsStatus.js\";\nexport { getCallsStatus } from \"../client/actions/getCallsStatus.js\";\nexport type * from \"../client/actions/grantPermissions.js\";\nexport { grantPermissions } from \"../client/actions/grantPermissions.js\";\nexport type * from \"../client/actions/listAccounts.js\";\nexport { listAccounts } from \"../client/actions/listAccounts.js\";\nexport type * from \"../client/actions/prepareCalls.js\";\nexport { prepareCalls } from \"../client/actions/prepareCalls.js\";\nexport type * from \"../client/actions/requestAccount.js\";\nexport { requestAccount } from \"../client/actions/requestAccount.js\";\nexport type * from \"../client/actions/signSignatureRequest.js\";\nexport { signSignatureRequest } from \"../client/actions/signSignatureRequest.js\";\nexport type * from \"../client/actions/signPreparedCalls.js\";\nexport { signPreparedCalls } from \"../client/actions/signPreparedCalls.js\";\nexport type * from \"../client/actions/signMessage.js\";\nexport { signMessage } from \"../client/actions/signMessage.js\";\nexport type * from \"../client/actions/signTypedData.js\";\nexport { signTypedData } from \"../client/actions/signTypedData.js\";\nexport type * from \"../client/actions/sendPreparedCalls.js\";\nexport { sendPreparedCalls } from \"../client/actions/sendPreparedCalls.js\";\nexport type * from \"../client/actions/sendCalls.js\";\nexport { sendCalls } from \"../client/actions/sendCalls.js\";\nexport type * from \"../client/actions/waitForCallsStatus.js\";\nexport { waitForCallsStatus } from \"../client/actions/waitForCallsStatus.js\";\nexport type * from \"../client/actions/prepareSign.js\";\nexport { prepareSign } from \"../client/actions/prepareSign.js\";\nexport type * from \"../client/actions/formatSign.js\";\nexport { formatSign } from \"../client/actions/formatSign.js\";\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { SmartAccountSigner, SmartContractAccount } from "@aa-sdk/core";
2
2
  import { type Chain, type Transport, type Address } from "viem";
3
- import type { StaticDecode } from "@sinclair/typebox";
4
- import { SerializedInitcode } from "@alchemy/wallet-api-types";
3
+ import type { StaticDecode } from "typebox";
4
+ import type { SerializedInitcode } from "@alchemy/wallet-api-types";
5
5
  type CreateAccountParams = {
6
6
  chain: Chain;
7
7
  transport: Transport;
@@ -1,9 +1,7 @@
1
1
  import { createModularAccountV2, createLightAccount, createMultiOwnerLightAccount, createMultiOwnerModularAccount, } from "@account-kit/smart-contracts";
2
- import { concatHex } from "viem";
3
- import { SerializedInitcode } from "@alchemy/wallet-api-types";
2
+ import { concatHex, isAddressEqual, } from "viem";
4
3
  import { InternalError, InvalidRequestError } from "ox/RpcResponse";
5
4
  import { assertNever } from "../utils.js";
6
- import { getAccountTypeForDelegationAddress7702 } from "@alchemy/wallet-api-types/capabilities";
7
5
  import { metrics } from "../metrics.js";
8
6
  /**
9
7
  * Creates a smart account instance from the given parameters.
@@ -27,8 +25,7 @@ import { metrics } from "../metrics.js";
27
25
  export async function createAccount(params) {
28
26
  const { counterfactualInfo: ci, ...accountParams } = params;
29
27
  if (params.delegation) {
30
- const accountType = getAccountTypeForDelegationAddress7702(params.delegation);
31
- if (accountType !== "ModularAccountV2") {
28
+ if (!isAddressEqual(params.delegation, MAV2_7702_DELEGATION_ADDRESS)) {
32
29
  throw new Error("7702 mode currently only supports ModularAccountV2");
33
30
  }
34
31
  return createModularAccountV2({
@@ -103,4 +100,5 @@ export async function createAccount(params) {
103
100
  return assertNever(factoryType, "Unsupported factory type");
104
101
  }
105
102
  }
103
+ const MAV2_7702_DELEGATION_ADDRESS = "0x69007702764179f14F51cdce752f4f775d74E139";
106
104
  //# sourceMappingURL=account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/internal/account.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAA4C,MAAM,MAAM,CAAC;AAE3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,sCAAsC,EAAE,MAAM,wCAAwC,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWxC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA2B;IAE3B,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC;IAE5D,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,WAAW,GAAG,sCAAsC,CACxD,MAAM,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,WAAW,KAAK,kBAAkB,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,sBAAsB,CAAC;YAC5B,GAAG,aAAa;YAChB,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,aAAa,CAAC;YACtB,OAAO,EAAE,+BAA+B;SACzC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;IACnC,MAAM,YAAY,GAAG;QACnB,GAAG,aAAa;QAChB,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;KACzD,CAAC;IAEF,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,EAAE,MAAM,CAAC,UAAU;gBACxB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,EAAE,WAAW,IAAI,SAAS,CAAC;SAC1D;KACF,CAAC,CAAC;IAEH,uDAAuD;IACvD,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,gBAAgB;YACnB,OAAO,sBAAsB,CAAC;gBAC5B,GAAG,YAAY;gBACf,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,qBAAqB;YACxB,OAAO,8BAA8B,CAAC;gBACpC,GAAG,YAAY;aAChB,CAAC,CAAC;QACL,KAAK,+BAA+B;YAClC,OAAO,4BAA4B,CAAC;gBAClC,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,mBAAmB,CAAC;QACzB,KAAK,iBAAiB,CAAC;QACvB,KAAK,sBAAsB,CAAC;QAC5B,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACZ,MAAM,IAAI,mBAAmB,CAAC;gBAC5B,OAAO,EAAE,uCAAuC,WAAW,EAAE;aAC9D,CAAC,CAAC;QACL;YACE,OAAO,WAAW,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["import type { SmartAccountSigner, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n createModularAccountV2,\n createLightAccount,\n createMultiOwnerLightAccount,\n createMultiOwnerModularAccount,\n} from \"@account-kit/smart-contracts\";\nimport { concatHex, type Chain, type Transport, type Address } from \"viem\";\nimport type { StaticDecode } from \"@sinclair/typebox\";\nimport { SerializedInitcode } from \"@alchemy/wallet-api-types\";\nimport { InternalError, InvalidRequestError } from \"ox/RpcResponse\";\nimport { assertNever } from \"../utils.js\";\nimport { getAccountTypeForDelegationAddress7702 } from \"@alchemy/wallet-api-types/capabilities\";\nimport { metrics } from \"../metrics.js\";\n\ntype CreateAccountParams = {\n chain: Chain;\n transport: Transport;\n signer: SmartAccountSigner;\n accountAddress: Address;\n counterfactualInfo?: StaticDecode<typeof SerializedInitcode>; // undefined for 7702 accounts\n delegation?: Address; // for 7702 accounts\n};\n\n/**\n * Creates a smart account instance from the given parameters.\n *\n * @param {CreateAccountParams} params - The parameters for creating a smart account.\n * @returns {Promise<SmartContractAccount>} A promise that resolves to the created smart account.\n *\n * @example\n * ```ts\n * // Create a smart account\n * const account = await createAccount({\n * chain: arbitrumSepolia,\n * transport: alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * }),\n * signer: signer,\n * accountAddress: \"0x1234...\",\n * });\n * ```\n */\nexport async function createAccount(\n params: CreateAccountParams,\n): Promise<SmartContractAccount> {\n const { counterfactualInfo: ci, ...accountParams } = params;\n\n if (params.delegation) {\n const accountType = getAccountTypeForDelegationAddress7702(\n params.delegation,\n );\n if (accountType !== \"ModularAccountV2\") {\n throw new Error(\"7702 mode currently only supports ModularAccountV2\");\n }\n return createModularAccountV2({\n ...accountParams,\n mode: \"7702\",\n });\n }\n\n if (!ci) {\n throw new InternalError({\n message: \"Counterfactual info not found\",\n });\n }\n\n const factoryType = ci.factoryType;\n const commonParams = {\n ...accountParams,\n initCode: concatHex([ci.factoryAddress, ci.factoryData]),\n };\n\n metrics.trackEvent({\n name: \"account_initialized\",\n data: {\n chainId: params.chain.id,\n factory: params.delegation\n ? \"7702\"\n : (params.counterfactualInfo?.factoryType ?? \"unknown\"),\n },\n });\n\n // Return the account created based on the factory type\n switch (factoryType) {\n case \"MAv2.0.0-sma-b\":\n return createModularAccountV2({\n ...commonParams,\n mode: \"default\",\n });\n case \"LightAccountV2.0.0\":\n return createLightAccount({\n ...commonParams,\n version: \"v2.0.0\",\n });\n case \"LightAccountV1.0.1\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.0.1\",\n });\n case \"LightAccountV1.0.2\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.0.2\",\n });\n case \"LightAccountV1.1.0\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.1.0\",\n });\n case \"MAv1.0.0-MultiOwner\":\n return createMultiOwnerModularAccount({\n ...commonParams,\n });\n case \"LightAccountV2.0.0-MultiOwner\":\n return createMultiOwnerLightAccount({\n ...commonParams,\n version: \"v2.0.0\",\n });\n case \"MAv1.0.0-MultiSig\":\n case \"MAv2.0.0-ma-ssv\":\n case \"MAv2.0.0-ma-webauthn\":\n case \"unknown\":\n case undefined:\n throw new InvalidRequestError({\n message: `Account type currently unsupported: ${factoryType}`,\n });\n default:\n return assertNever(factoryType, \"Unsupported factory type\");\n }\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/internal/account.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,SAAS,EAIT,cAAc,GACf,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWxC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA2B;IAE3B,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,CAAC;IAE5D,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,4BAA4B,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,sBAAsB,CAAC;YAC5B,GAAG,aAAa;YAChB,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,aAAa,CAAC;YACtB,OAAO,EAAE,+BAA+B;SACzC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC;IACnC,MAAM,YAAY,GAAG;QACnB,GAAG,aAAa;QAChB,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;KACzD,CAAC;IAEF,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,EAAE,MAAM,CAAC,UAAU;gBACxB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,EAAE,WAAW,IAAI,SAAS,CAAC;SAC1D;KACF,CAAC,CAAC;IAEH,uDAAuD;IACvD,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,gBAAgB;YACnB,OAAO,sBAAsB,CAAC;gBAC5B,GAAG,YAAY;gBACf,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC;gBACxB,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,qBAAqB;YACxB,OAAO,8BAA8B,CAAC;gBACpC,GAAG,YAAY;aAChB,CAAC,CAAC;QACL,KAAK,+BAA+B;YAClC,OAAO,4BAA4B,CAAC;gBAClC,GAAG,YAAY;gBACf,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;QACL,KAAK,mBAAmB,CAAC;QACzB,KAAK,iBAAiB,CAAC;QACvB,KAAK,sBAAsB,CAAC;QAC5B,KAAK,SAAS,CAAC;QACf,KAAK,SAAS;YACZ,MAAM,IAAI,mBAAmB,CAAC;gBAC5B,OAAO,EAAE,uCAAuC,WAAW,EAAE;aAC9D,CAAC,CAAC;QACL;YACE,OAAO,WAAW,CAAC,WAAW,EAAE,0BAA0B,CAAC,CAAC;IAChE,CAAC;AACH,CAAC;AAED,MAAM,4BAA4B,GAChC,4CAA4C,CAAC","sourcesContent":["import type { SmartAccountSigner, SmartContractAccount } from \"@aa-sdk/core\";\nimport {\n createModularAccountV2,\n createLightAccount,\n createMultiOwnerLightAccount,\n createMultiOwnerModularAccount,\n} from \"@account-kit/smart-contracts\";\nimport {\n concatHex,\n type Chain,\n type Transport,\n type Address,\n isAddressEqual,\n} from \"viem\";\nimport type { StaticDecode } from \"typebox\";\nimport type { SerializedInitcode } from \"@alchemy/wallet-api-types\";\nimport { InternalError, InvalidRequestError } from \"ox/RpcResponse\";\nimport { assertNever } from \"../utils.js\";\nimport { metrics } from \"../metrics.js\";\n\ntype CreateAccountParams = {\n chain: Chain;\n transport: Transport;\n signer: SmartAccountSigner;\n accountAddress: Address;\n counterfactualInfo?: StaticDecode<typeof SerializedInitcode>; // undefined for 7702 accounts\n delegation?: Address; // for 7702 accounts\n};\n\n/**\n * Creates a smart account instance from the given parameters.\n *\n * @param {CreateAccountParams} params - The parameters for creating a smart account.\n * @returns {Promise<SmartContractAccount>} A promise that resolves to the created smart account.\n *\n * @example\n * ```ts\n * // Create a smart account\n * const account = await createAccount({\n * chain: arbitrumSepolia,\n * transport: alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * }),\n * signer: signer,\n * accountAddress: \"0x1234...\",\n * });\n * ```\n */\nexport async function createAccount(\n params: CreateAccountParams,\n): Promise<SmartContractAccount> {\n const { counterfactualInfo: ci, ...accountParams } = params;\n\n if (params.delegation) {\n if (!isAddressEqual(params.delegation, MAV2_7702_DELEGATION_ADDRESS)) {\n throw new Error(\"7702 mode currently only supports ModularAccountV2\");\n }\n return createModularAccountV2({\n ...accountParams,\n mode: \"7702\",\n });\n }\n\n if (!ci) {\n throw new InternalError({\n message: \"Counterfactual info not found\",\n });\n }\n\n const factoryType = ci.factoryType;\n const commonParams = {\n ...accountParams,\n initCode: concatHex([ci.factoryAddress, ci.factoryData]),\n };\n\n metrics.trackEvent({\n name: \"account_initialized\",\n data: {\n chainId: params.chain.id,\n factory: params.delegation\n ? \"7702\"\n : (params.counterfactualInfo?.factoryType ?? \"unknown\"),\n },\n });\n\n // Return the account created based on the factory type\n switch (factoryType) {\n case \"MAv2.0.0-sma-b\":\n return createModularAccountV2({\n ...commonParams,\n mode: \"default\",\n });\n case \"LightAccountV2.0.0\":\n return createLightAccount({\n ...commonParams,\n version: \"v2.0.0\",\n });\n case \"LightAccountV1.0.1\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.0.1\",\n });\n case \"LightAccountV1.0.2\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.0.2\",\n });\n case \"LightAccountV1.1.0\":\n return createLightAccount({\n ...commonParams,\n version: \"v1.1.0\",\n });\n case \"MAv1.0.0-MultiOwner\":\n return createMultiOwnerModularAccount({\n ...commonParams,\n });\n case \"LightAccountV2.0.0-MultiOwner\":\n return createMultiOwnerLightAccount({\n ...commonParams,\n version: \"v2.0.0\",\n });\n case \"MAv1.0.0-MultiSig\":\n case \"MAv2.0.0-ma-ssv\":\n case \"MAv2.0.0-ma-webauthn\":\n case \"unknown\":\n case undefined:\n throw new InvalidRequestError({\n message: `Account type currently unsupported: ${factoryType}`,\n });\n default:\n return assertNever(factoryType, \"Unsupported factory type\");\n }\n}\n\nconst MAV2_7702_DELEGATION_ADDRESS =\n \"0x69007702764179f14F51cdce752f4f775d74E139\";\n"]}
@@ -1,5 +1,5 @@
1
- import type { StaticDecode } from "@sinclair/typebox";
2
- import { SerializedInitcode } from "@alchemy/wallet-api-types";
1
+ import type { StaticDecode } from "typebox";
2
+ import type { SerializedInitcode } from "@alchemy/wallet-api-types";
3
3
  export type CoreEventsSchema = [
4
4
  {
5
5
  EventName: "client_created";