@account-kit/wallet-client 0.1.0-alpha.10 → 0.1.0-alpha.12

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 (146) hide show
  1. package/dist/esm/client/actions/getCallsStatus.d.ts +4 -3
  2. package/dist/esm/client/actions/getCallsStatus.js +1 -0
  3. package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
  4. package/dist/esm/client/actions/grantPermissions.d.ts +5 -4
  5. package/dist/esm/client/actions/grantPermissions.js +21 -5
  6. package/dist/esm/client/actions/grantPermissions.js.map +1 -1
  7. package/dist/esm/client/actions/prepareCalls.d.ts +4 -3
  8. package/dist/esm/client/actions/prepareCalls.js +1 -0
  9. package/dist/esm/client/actions/prepareCalls.js.map +1 -1
  10. package/dist/esm/client/actions/prepareSign.d.ts +4 -3
  11. package/dist/esm/client/actions/prepareSign.js +1 -0
  12. package/dist/esm/client/actions/prepareSign.js.map +1 -1
  13. package/dist/esm/client/actions/requestAccount.js +3 -3
  14. package/dist/esm/client/actions/requestAccount.js.map +1 -1
  15. package/dist/esm/client/actions/signSignatureRequest.d.ts +3 -3
  16. package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
  17. package/dist/esm/client/client.e2e-test.js +190 -329
  18. package/dist/esm/client/client.e2e-test.js.map +1 -1
  19. package/dist/esm/client/index.d.ts +1 -4
  20. package/dist/esm/client/index.js +13 -18
  21. package/dist/esm/client/index.js.map +1 -1
  22. package/dist/esm/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +3 -7
  23. package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +9 -33
  24. package/dist/esm/internal/account.js.map +1 -0
  25. package/dist/esm/types.d.ts +2 -8
  26. package/dist/esm/types.js.map +1 -1
  27. package/dist/types/client/actions/getCallsStatus.d.ts +4 -3
  28. package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
  29. package/dist/types/client/actions/grantPermissions.d.ts +5 -4
  30. package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
  31. package/dist/types/client/actions/prepareCalls.d.ts +4 -3
  32. package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
  33. package/dist/types/client/actions/prepareSign.d.ts +4 -3
  34. package/dist/types/client/actions/prepareSign.d.ts.map +1 -1
  35. package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
  36. package/dist/types/client/actions/signSignatureRequest.d.ts +3 -3
  37. package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
  38. package/dist/types/client/index.d.ts +1 -4
  39. package/dist/types/client/index.d.ts.map +1 -1
  40. package/dist/types/{isomorphic/utils/createAccount.d.ts → internal/account.d.ts} +4 -8
  41. package/dist/types/internal/account.d.ts.map +1 -0
  42. package/dist/types/types.d.ts +2 -8
  43. package/dist/types/types.d.ts.map +1 -1
  44. package/package.json +3 -8
  45. package/src/client/actions/getCallsStatus.ts +8 -6
  46. package/src/client/actions/grantPermissions.ts +41 -10
  47. package/src/client/actions/prepareCalls.ts +11 -6
  48. package/src/client/actions/prepareSign.ts +9 -6
  49. package/src/client/actions/requestAccount.ts +3 -3
  50. package/src/client/actions/signSignatureRequest.ts +8 -8
  51. package/src/client/client.e2e-test.ts +143 -298
  52. package/src/client/index.ts +22 -23
  53. package/src/{isomorphic/utils/createAccount.ts → internal/account.ts} +11 -51
  54. package/src/types.ts +4 -15
  55. package/dist/esm/exports/internal.d.ts +0 -4
  56. package/dist/esm/exports/internal.js +0 -3
  57. package/dist/esm/exports/internal.js.map +0 -1
  58. package/dist/esm/isomorphic/actions/createSession.d.ts +0 -13
  59. package/dist/esm/isomorphic/actions/createSession.js +0 -94
  60. package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
  61. package/dist/esm/isomorphic/actions/formatSign.d.ts +0 -8
  62. package/dist/esm/isomorphic/actions/formatSign.js +0 -42
  63. package/dist/esm/isomorphic/actions/formatSign.js.map +0 -1
  64. package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -7
  65. package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -71
  66. package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
  67. package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -7
  68. package/dist/esm/isomorphic/actions/prepareCalls.js +0 -116
  69. package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
  70. package/dist/esm/isomorphic/actions/prepareSign.d.ts +0 -7
  71. package/dist/esm/isomorphic/actions/prepareSign.js +0 -49
  72. package/dist/esm/isomorphic/actions/prepareSign.js.map +0 -1
  73. package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -7
  74. package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -156
  75. package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
  76. package/dist/esm/isomorphic/client.d.ts +0 -275
  77. package/dist/esm/isomorphic/client.js +0 -41
  78. package/dist/esm/isomorphic/client.js.map +0 -1
  79. package/dist/esm/isomorphic/utils/7702.d.ts +0 -19
  80. package/dist/esm/isomorphic/utils/7702.js +0 -70
  81. package/dist/esm/isomorphic/utils/7702.js.map +0 -1
  82. package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
  83. package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
  84. package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
  85. package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
  86. package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
  87. package/dist/esm/isomorphic/utils/decodeSignature.js +0 -15
  88. package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
  89. package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
  90. package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
  91. package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
  92. package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
  93. package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
  94. package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
  95. package/dist/esm/local/client.d.ts +0 -3
  96. package/dist/esm/local/client.js +0 -97
  97. package/dist/esm/local/client.js.map +0 -1
  98. package/dist/esm/remote/client.d.ts +0 -9
  99. package/dist/esm/remote/client.js +0 -41
  100. package/dist/esm/remote/client.js.map +0 -1
  101. package/dist/types/exports/internal.d.ts +0 -5
  102. package/dist/types/exports/internal.d.ts.map +0 -1
  103. package/dist/types/isomorphic/actions/createSession.d.ts +0 -14
  104. package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
  105. package/dist/types/isomorphic/actions/formatSign.d.ts +0 -9
  106. package/dist/types/isomorphic/actions/formatSign.d.ts.map +0 -1
  107. package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -8
  108. package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
  109. package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -8
  110. package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
  111. package/dist/types/isomorphic/actions/prepareSign.d.ts +0 -8
  112. package/dist/types/isomorphic/actions/prepareSign.d.ts.map +0 -1
  113. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
  114. package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
  115. package/dist/types/isomorphic/client.d.ts +0 -276
  116. package/dist/types/isomorphic/client.d.ts.map +0 -1
  117. package/dist/types/isomorphic/utils/7702.d.ts +0 -20
  118. package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
  119. package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
  120. package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
  121. package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
  122. package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
  123. package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
  124. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
  125. package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
  126. package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
  127. package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
  128. package/dist/types/local/client.d.ts +0 -4
  129. package/dist/types/local/client.d.ts.map +0 -1
  130. package/dist/types/remote/client.d.ts +0 -10
  131. package/dist/types/remote/client.d.ts.map +0 -1
  132. package/src/exports/internal.ts +0 -8
  133. package/src/isomorphic/actions/createSession.ts +0 -163
  134. package/src/isomorphic/actions/formatSign.ts +0 -76
  135. package/src/isomorphic/actions/getCallsStatus.ts +0 -112
  136. package/src/isomorphic/actions/prepareCalls.ts +0 -172
  137. package/src/isomorphic/actions/prepareSign.ts +0 -91
  138. package/src/isomorphic/actions/sendPreparedCalls.ts +0 -234
  139. package/src/isomorphic/client.ts +0 -102
  140. package/src/isomorphic/utils/7702.ts +0 -135
  141. package/src/isomorphic/utils/createDummySigner.ts +0 -27
  142. package/src/isomorphic/utils/decodeSignature.ts +0 -21
  143. package/src/isomorphic/utils/parsePermissionsContext.ts +0 -51
  144. package/src/isomorphic/utils/supportsFeature.ts +0 -34
  145. package/src/local/client.ts +0 -136
  146. package/src/remote/client.ts +0 -67
@@ -1,7 +1,8 @@
1
- import type { GetCallsStatusParams as IsomorphicGetCallsStatusParams, GetCallsStatusResponse as IsomorphicGetCallsStatusResult } from "../../isomorphic/actions/getCallsStatus.ts";
2
1
  import type { InnerWalletApiClient } from "../../types.ts";
3
- export type GetCallsStatusParams = IsomorphicGetCallsStatusParams;
4
- export type GetCallsStatusResult = IsomorphicGetCallsStatusResult;
2
+ import type { Static } from "@sinclair/typebox";
3
+ import { wallet_getCallsStatus } from "@alchemy/wallet-api-types/rpc";
4
+ export type GetCallsStatusParams = Static<typeof wallet_getCallsStatus>["Request"]["params"][0];
5
+ export type GetCallsStatusResult = Static<typeof wallet_getCallsStatus>["ReturnType"];
5
6
  /**
6
7
  * Gets the status of a prepared call by its ID.
7
8
  * This method is used to check the execution status of calls sent via sendPreparedCalls.
@@ -1,3 +1,4 @@
1
+ import { wallet_getCallsStatus } from "@alchemy/wallet-api-types/rpc";
1
2
  /**
2
3
  * Gets the status of a prepared call by its ID.
3
4
  * This method is used to check the execution status of calls sent via sendPreparedCalls.
@@ -1 +1 @@
1
- {"version":3,"file":"getCallsStatus.js","sourceRoot":"","sources":["../../../../src/client/actions/getCallsStatus.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,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 {\n GetCallsStatusParams as IsomorphicGetCallsStatusParams,\n GetCallsStatusResponse as IsomorphicGetCallsStatusResult,\n} from \"../../isomorphic/actions/getCallsStatus.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GetCallsStatusParams = IsomorphicGetCallsStatusParams;\n\nexport type GetCallsStatusResult = IsomorphicGetCallsStatusResult;\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 * // 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 */\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\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":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAUtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,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\";\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 * // 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 */\nexport async function getCallsStatus(\n client: InnerWalletApiClient,\n params: GetCallsStatusParams,\n): Promise<GetCallsStatusResult> {\n return await client.request({\n method: \"wallet_getCallsStatus\",\n params: [params],\n });\n}\n"]}
@@ -1,12 +1,13 @@
1
1
  import { type SmartAccountSigner } from "@aa-sdk/core";
2
- import { type Address, type Hex, type IsUndefined } from "viem";
3
- import type { CreateSessionParams } from "../../isomorphic/actions/createSession.ts";
2
+ import { type Address, type Hex, type IsUndefined, type Prettify } from "viem";
4
3
  import type { InnerWalletApiClient } from "../../types.ts";
5
- export type GrantPermissionsParams<TAccount extends Address | undefined = Address | undefined> = Omit<CreateSessionParams, "account" | "chainId" | "entityId"> & (IsUndefined<TAccount> extends true ? {
4
+ import type { Static } from "@sinclair/typebox";
5
+ import { wallet_createSession } from "@alchemy/wallet-api-types/rpc";
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 ? {
6
7
  account: Address;
7
8
  } : {
8
9
  account?: never;
9
- });
10
+ })>;
10
11
  export type GrantPermissionsResult = {
11
12
  context: Hex;
12
13
  };
@@ -1,5 +1,8 @@
1
1
  import { AccountNotFoundError } from "@aa-sdk/core";
2
- import { toHex } from "viem";
2
+ import { toHex, } from "viem";
3
+ import { wallet_createSession } from "@alchemy/wallet-api-types/rpc";
4
+ import { encodePermissionsContext } from "@alchemy/wallet-api-types/capabilities";
5
+ import { signSignatureRequest } from "./signSignatureRequest.js";
3
6
  /**
4
7
  * Grants permissions to a smart account by creating a session.
5
8
  * This allows another key to perform operations on behalf of the account.
@@ -62,10 +65,23 @@ export async function grantPermissions(client, signer, params) {
62
65
  if (!account) {
63
66
  throw new AccountNotFoundError();
64
67
  }
65
- return client.grantPermissions(signer, {
66
- ...params,
67
- account,
68
- chainId: toHex(client.chain.id),
68
+ const { sessionId, signatureRequest } = await client.request({
69
+ method: "wallet_createSession",
70
+ params: [
71
+ {
72
+ ...params,
73
+ account,
74
+ chainId: toHex(client.chain.id),
75
+ },
76
+ ],
69
77
  });
78
+ const signature = await signSignatureRequest(signer, signatureRequest);
79
+ return {
80
+ context: encodePermissionsContext({
81
+ contextVersion: "REMOTE_MODE_DEFERRED_ACTION",
82
+ sessionId,
83
+ signature: signature.data,
84
+ }),
85
+ };
70
86
  }
71
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,EAA4C,KAAK,EAAE,MAAM,MAAM,CAAC;AAevE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAGpC,MAA4B,EAC5B,MAA0B,EAC1B,MAAwC;IAExC,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,OAAO,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE;QACrC,GAAG,MAAM;QACT,OAAO;QACP,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type IsUndefined, toHex } from \"viem\";\nimport type { CreateSessionParams } from \"../../isomorphic/actions/createSession.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\n\nexport type GrantPermissionsParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<CreateSessionParams, \"account\" | \"chainId\" | \"entityId\"> &\n (IsUndefined<TAccount> extends true\n ? { account: Address }\n : { account?: never });\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 {object} 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 * @returns {Hex} result.context - A hex identifier for the granted permissions context\n *\n * @example\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 * expiry: 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 client.signPreparedCalls(\n * sessionKey,\n * preparedCalls,\n * );\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 */\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 const account = params.account ?? client.account?.address;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n return client.grantPermissions(signer, {\n ...params,\n account,\n chainId: toHex(client.chain.id),\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,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;AAoBjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAGpC,MAA4B,EAC5B,MAA0B,EAC1B,MAAwC;IAExC,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\";\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 {object} 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 * @returns {Hex} result.context - A hex identifier for the granted permissions context\n *\n * @example\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 * expiry: 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 client.signPreparedCalls(\n * sessionKey,\n * preparedCalls,\n * );\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 */\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 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,17 +1,18 @@
1
1
  import { type Address, type IsUndefined } from "viem";
2
- import type { PrepareCallsParams as IsomorphicPrepareCallsParams, PrepareCallsResult as IsomorphicPrepareCallsResult } from "../../isomorphic/actions/prepareCalls.ts";
3
2
  import type { InnerWalletApiClient } from "../../types.ts";
3
+ import type { Static } from "@sinclair/typebox";
4
+ import { wallet_prepareCalls } from "@alchemy/wallet-api-types/rpc";
4
5
  export type GetAccountParam<TAccount> = IsUndefined<TAccount> extends true ? {
5
6
  account: Address;
6
7
  } : {
7
8
  account?: Address;
8
9
  };
9
- export type PrepareCallsParams<TAccount extends Address | undefined = Address | undefined> = Omit<IsomorphicPrepareCallsParams, "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
10
+ export type PrepareCallsParams<TAccount extends Address | undefined = Address | undefined> = Omit<Static<(typeof wallet_prepareCalls)["properties"]["Request"]["properties"]["params"]>[0], "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
10
11
  from: Address;
11
12
  } : {
12
13
  from?: never;
13
14
  });
14
- export type PrepareCallsResult = IsomorphicPrepareCallsResult;
15
+ export type PrepareCallsResult = Static<typeof wallet_prepareCalls>["ReturnType"];
15
16
  /**
16
17
  * Prepares a set of contract calls for execution by building a user operation.
17
18
  * Returns the built user operation and a signature request that needs to be signed
@@ -1,5 +1,6 @@
1
1
  import { AccountNotFoundError } from "@aa-sdk/core";
2
2
  import { toHex } from "viem";
3
+ import { wallet_prepareCalls } from "@alchemy/wallet-api-types/rpc";
3
4
  /**
4
5
  * Prepares a set of contract calls for execution by building a user operation.
5
6
  * Returns the built user operation and a signature request that needs to be signed
@@ -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;AAmB7D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,MAA4B,EAC5B,MAAoC;IAEpC,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,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,CAAC;QAC9D,MAAM,CAAC,YAAY,GAAG;YACpB,GAAG,MAAM,CAAC,YAAY;YACtB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,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;aACL;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { AccountNotFoundError } from \"@aa-sdk/core\";\nimport { toHex, type Address, type IsUndefined } from \"viem\";\nimport type {\n PrepareCallsParams as IsomorphicPrepareCallsParams,\n PrepareCallsResult as IsomorphicPrepareCallsResult,\n} from \"../../isomorphic/actions/prepareCalls.ts\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\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<IsomorphicPrepareCallsParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareCallsResult = IsomorphicPrepareCallsResult;\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\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 * // 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 */\nexport async function prepareCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\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;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAqBpE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAGhC,MAA4B,EAC5B,MAAoC;IAEpC,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,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,EAAE,CAAC;QAC9D,MAAM,CAAC,YAAY,GAAG;YACpB,GAAG,MAAM,CAAC,YAAY;YACtB,gBAAgB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,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;aACL;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\";\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\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 * // 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 */\nexport async function prepareCalls<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareCallsParams<TAccount>,\n): Promise<PrepareCallsResult> {\n const from = params.from ?? client.account?.address;\n if (!from) {\n throw new AccountNotFoundError();\n }\n\n if (client.policyId && !params.capabilities?.paymasterService) {\n params.capabilities = {\n ...params.capabilities,\n paymasterService: { policyId: client.policyId },\n };\n }\n\n return await client.request({\n method: \"wallet_prepareCalls\",\n params: [\n {\n ...params,\n chainId: toHex(client.chain.id),\n from,\n },\n ],\n });\n}\n"]}
@@ -1,12 +1,13 @@
1
1
  import type { InnerWalletApiClient } from "../../types.ts";
2
2
  import { type Address, type IsUndefined } from "viem";
3
- import type { PrepareSignParams as IsomorphicPrepareSignParams, PrepareSignResult as IsomorphicPrepareSignResult } from "../../isomorphic/actions/prepareSign.ts";
4
- export type PrepareSignParams<TAccount extends Address | undefined = Address | undefined> = Omit<IsomorphicPrepareSignParams, "from" | "chainId"> & (IsUndefined<TAccount> extends true ? {
3
+ import type { Static } from "@sinclair/typebox";
4
+ import { wallet_prepareSign } from "@alchemy/wallet-api-types/rpc";
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 ? {
5
6
  from: Address;
6
7
  } : {
7
8
  from?: never;
8
9
  });
9
- export type PrepareSignResult = IsomorphicPrepareSignResult;
10
+ export type PrepareSignResult = Static<typeof wallet_prepareSign>["ReturnType"];
10
11
  /**
11
12
  * Prepares a signature request for signing messages or transactions.
12
13
  *
@@ -1,5 +1,6 @@
1
1
  import { toHex } from "viem";
2
2
  import { AccountNotFoundError } from "@aa-sdk/core";
3
+ import { wallet_prepareSign } from "@alchemy/wallet-api-types/rpc";
3
4
  /**
4
5
  * Prepares a signature request for signing messages or transactions.
5
6
  *
@@ -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;AAK7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AASpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAG/B,MAA4B,EAC5B,MAAmC;IAEnC,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 type {\n PrepareSignParams as IsomorphicPrepareSignParams,\n PrepareSignResult as IsomorphicPrepareSignResult,\n} from \"../../isomorphic/actions/prepareSign.ts\";\nimport { AccountNotFoundError } from \"@aa-sdk/core\";\n\nexport type PrepareSignParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Omit<IsomorphicPrepareSignParams, \"from\" | \"chainId\"> &\n (IsUndefined<TAccount> extends true ? { from: Address } : { from?: never });\n\nexport type PrepareSignResult = IsomorphicPrepareSignResult;\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 * // 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 */\nexport async function prepareSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareSignParams<TAccount>,\n): Promise<PrepareSignResult> {\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;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAcnE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAG/B,MAA4B,EAC5B,MAAmC;IAEnC,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\";\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 * // 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 */\nexport async function prepareSign<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n params: PrepareSignParams<TAccount>,\n): Promise<PrepareSignResult> {\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"]}
@@ -2,8 +2,8 @@ import {} from "@aa-sdk/core";
2
2
  import { Value } from "@sinclair/typebox/value";
3
3
  import deepEqual from "deep-equal";
4
4
  import { custom } from "viem";
5
- import { createAccount } from "../../isomorphic/utils/createAccount.js";
6
- import { TypeSerializedInitcode } from "@alchemy/wallet-api-types";
5
+ import { SerializedInitcode } from "@alchemy/wallet-api-types";
6
+ import { createAccount } from "../../internal/account.js";
7
7
  /**
8
8
  * Requests an account for the provided signer using the wallet API client.
9
9
  * If an account already exists for the signer, it will always return that account unless a new ID is specified.
@@ -46,7 +46,7 @@ export async function requestAccount(client, signer, params) {
46
46
  const account = await createAccount({
47
47
  accountAddress,
48
48
  counterfactualInfo: counterfactualInfo
49
- ? Value.Parse(TypeSerializedInitcode, counterfactualInfo)
49
+ ? Value.Parse(SerializedInitcode, counterfactualInfo)
50
50
  : undefined,
51
51
  delegation,
52
52
  chain: client.chain,
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAExE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAanE;;;;;;;;;;;;;;;;GAgBG;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,EAAE,kBAAkB;YACpC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,sBAAsB,EAAE,kBAAkB,CAAC;YACzD,CAAC,CAAC,SAAS;QACb,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 { Value } from \"@sinclair/typebox/value\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport { createAccount } from \"../../isomorphic/utils/createAccount.js\";\nimport type { wallet_requestAccount } from \"@alchemy/wallet-api-types/rpc\";\nimport { TypeSerializedInitcode } from \"@alchemy/wallet-api-types\";\nimport type { InnerWalletApiClient } from \"../../types.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 * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\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: counterfactualInfo\n ? Value.Parse(TypeSerializedInitcode, counterfactualInfo)\n : undefined,\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;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAY1D;;;;;;;;;;;;;;;;GAgBG;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,EAAE,kBAAkB;YACpC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;YACrD,CAAC,CAAC,SAAS;QACb,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 { Value } from \"@sinclair/typebox/value\";\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 { SerializedInitcode } from \"@alchemy/wallet-api-types\";\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 * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\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: counterfactualInfo\n ? Value.Parse(SerializedInitcode, counterfactualInfo)\n : undefined,\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,9 +1,9 @@
1
1
  import type { SmartAccountSigner } from "@aa-sdk/core";
2
2
  import { type Hex } from "viem";
3
- import { type TypePersonalSignSignatureRequest, type TypeTypedDataSignatureRequest, type TypeAuthorizationSignatureRequest, type TypeEip7702UnsignedAuth } from "@alchemy/wallet-api-types";
3
+ import { type PersonalSignSignatureRequest, type TypedDataSignatureRequest, type AuthorizationSignatureRequest, type Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
4
4
  import type { WithoutRawPayload } from "../../types.ts";
5
- export type SignSignatureRequestParams = WithoutRawPayload<TypePersonalSignSignatureRequest | TypeTypedDataSignatureRequest | (TypeAuthorizationSignatureRequest & {
6
- data: TypeEip7702UnsignedAuth;
5
+ export type SignSignatureRequestParams = WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
6
+ data: Eip7702UnsignedAuth;
7
7
  })>;
8
8
  export type SignSignatureRequestResult = {
9
9
  type: "secp256k1";
@@ -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;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,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,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBAC1D,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;YAEH,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO,EAAE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBAC1C,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 TypePersonalSignSignatureRequest,\n type TypeTypedDataSignatureRequest,\n type TypeAuthorizationSignatureRequest,\n type TypeEip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type { WithoutRawPayload } from \"../../types.ts\";\n\nexport type SignSignatureRequestParams = WithoutRawPayload<\n | TypePersonalSignSignatureRequest\n | TypeTypedDataSignatureRequest\n | (TypeAuthorizationSignatureRequest & {\n data: TypeEip7702UnsignedAuth;\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 {any} 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 * @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)\n * @returns {Hex} result.signature - The hex-encoded signature\n * @returns {Eip7702ExtendedFields[\"eip7702Auth\"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable\n *\n * @example\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * @example\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\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\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 { r, s, v, yParity } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity: yParity ?? vToYParity(Number(v)),\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;AAC7C,OAAO,EAKN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,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,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBAC1D,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;YAEH,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO,EAAE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBAC1C,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\";\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 {any} 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 * @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)\n * @returns {Hex} result.signature - The hex-encoded signature\n * @returns {Eip7702ExtendedFields[\"eip7702Auth\"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable\n *\n * @example\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * @example\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\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\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 { r, s, v, yParity } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity: yParity ?? vToYParity(Number(v)),\n }),\n };\n }\n default:\n return assertNever(params, `Unexpected signature request type.`);\n }\n}\n"]}