@alchemy/wallet-apis 0.0.0-alpha.19 → 0.0.0-alpha.21

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 (56) hide show
  1. package/dist/esm/actions/formatSign.js +3 -4
  2. package/dist/esm/actions/formatSign.js.map +1 -1
  3. package/dist/esm/actions/grantPermissions.js +3 -4
  4. package/dist/esm/actions/grantPermissions.js.map +1 -1
  5. package/dist/esm/actions/listAccounts.js +3 -4
  6. package/dist/esm/actions/listAccounts.js.map +1 -1
  7. package/dist/esm/actions/prepareCalls.d.ts +14 -3
  8. package/dist/esm/actions/prepareCalls.js +19 -5
  9. package/dist/esm/actions/prepareCalls.js.map +1 -1
  10. package/dist/esm/actions/prepareSign.js +3 -4
  11. package/dist/esm/actions/prepareSign.js.map +1 -1
  12. package/dist/esm/actions/requestAccount.js +3 -4
  13. package/dist/esm/actions/requestAccount.js.map +1 -1
  14. package/dist/esm/actions/sendCalls.js +2 -5
  15. package/dist/esm/actions/sendCalls.js.map +1 -1
  16. package/dist/esm/actions/sendPreparedCalls.js +3 -4
  17. package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
  18. package/dist/esm/experimental/actions/requestQuoteV0.js +3 -4
  19. package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
  20. package/dist/esm/utils/capabilities.d.ts +14 -7
  21. package/dist/esm/utils/capabilities.js +3 -2
  22. package/dist/esm/utils/capabilities.js.map +1 -1
  23. package/dist/esm/utils/schema.d.ts +3 -1
  24. package/dist/esm/utils/schema.js +58 -0
  25. package/dist/esm/utils/schema.js.map +1 -1
  26. package/dist/esm/version.d.ts +1 -1
  27. package/dist/esm/version.js +1 -1
  28. package/dist/esm/version.js.map +1 -1
  29. package/dist/types/actions/formatSign.d.ts.map +1 -1
  30. package/dist/types/actions/grantPermissions.d.ts.map +1 -1
  31. package/dist/types/actions/listAccounts.d.ts.map +1 -1
  32. package/dist/types/actions/prepareCalls.d.ts +14 -3
  33. package/dist/types/actions/prepareCalls.d.ts.map +1 -1
  34. package/dist/types/actions/prepareSign.d.ts.map +1 -1
  35. package/dist/types/actions/requestAccount.d.ts.map +1 -1
  36. package/dist/types/actions/sendCalls.d.ts.map +1 -1
  37. package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
  38. package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
  39. package/dist/types/utils/capabilities.d.ts +14 -7
  40. package/dist/types/utils/capabilities.d.ts.map +1 -1
  41. package/dist/types/utils/schema.d.ts +3 -1
  42. package/dist/types/utils/schema.d.ts.map +1 -1
  43. package/dist/types/version.d.ts +1 -1
  44. package/package.json +4 -4
  45. package/src/actions/formatSign.ts +5 -4
  46. package/src/actions/grantPermissions.ts +9 -11
  47. package/src/actions/listAccounts.ts +5 -7
  48. package/src/actions/prepareCalls.ts +42 -6
  49. package/src/actions/prepareSign.ts +5 -4
  50. package/src/actions/requestAccount.ts +8 -7
  51. package/src/actions/sendCalls.ts +2 -8
  52. package/src/actions/sendPreparedCalls.ts +4 -6
  53. package/src/experimental/actions/requestQuoteV0.ts +5 -4
  54. package/src/utils/capabilities.ts +23 -11
  55. package/src/utils/schema.ts +79 -1
  56. package/src/version.ts +1 -1
@@ -1,8 +1,7 @@
1
1
  import { wallet_formatSign as MethodSchema } from "@alchemy/wallet-api-types/rpc";
2
2
  import { LOGGER } from "../logger.js";
3
3
  import { resolveAddress } from "../utils/resolve.js";
4
- import { Value } from "typebox/value";
5
- import { methodSchema, } from "../utils/schema.js";
4
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
6
5
  const schema = methodSchema(MethodSchema);
7
6
  /**
8
7
  * Formats a signature request for signing messages or transactions.
@@ -29,7 +28,7 @@ export async function formatSign(client, params) {
29
28
  : client.account.address;
30
29
  LOGGER.debug("formatSign:start");
31
30
  const { account: _, chainId: __, ...rest } = params;
32
- const rpcParams = Value.Encode(schema.request, {
31
+ const rpcParams = encode(schema.request, {
33
32
  ...rest,
34
33
  from,
35
34
  chainId: params.chainId ?? client.chain.id,
@@ -39,6 +38,6 @@ export async function formatSign(client, params) {
39
38
  params: [rpcParams],
40
39
  });
41
40
  LOGGER.debug("formatSign:done");
42
- return Value.Decode(schema.response, rpcResp);
41
+ return decode(schema.response, rpcResp);
43
42
  }
44
43
  //# sourceMappingURL=formatSign.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../src/actions/formatSign.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAa1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAA4B,EAC5B,MAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAEjC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC7C,GAAG,IAAI;QACP,IAAI;QACJ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;KACZ,CAAC,CAAC;IAElC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { wallet_formatSign as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { Value } from \"typebox/value\";\nimport {\n methodSchema,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseFormatSignParams = MethodParams<typeof MethodSchema>;\ntype FormatSignResponse = MethodResponse<typeof MethodSchema>;\n\nexport type FormatSignParams = Prettify<\n DistributiveOmit<BaseFormatSignParams, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n>;\n\nexport type FormatSignResult = FormatSignResponse;\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 * account: \"0x1234...\",\n * signature: {\n * type: \"ecdsa\",\n * data: \"0xabcd...\"\n * },\n * });\n * ```\n */\nexport async function formatSign(\n client: InnerWalletApiClient,\n params: FormatSignParams,\n): Promise<FormatSignResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.debug(\"formatSign:start\");\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = Value.Encode(schema.request, {\n ...rest,\n from,\n chainId: params.chainId ?? client.chain.id,\n } satisfies BaseFormatSignParams);\n\n const rpcResp = await client.request({\n method: \"wallet_formatSign\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"formatSign:done\");\n return Value.Decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"formatSign.js","sourceRoot":"","sources":["../../../src/actions/formatSign.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAa1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAA4B,EAC5B,MAAwB;IAExB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAEjC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,IAAI;QACJ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;KAC3C,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { wallet_formatSign as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseFormatSignParams = MethodParams<typeof MethodSchema>;\ntype FormatSignResponse = MethodResponse<typeof MethodSchema>;\n\nexport type FormatSignParams = Prettify<\n DistributiveOmit<BaseFormatSignParams, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n>;\n\nexport type FormatSignResult = FormatSignResponse;\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 * account: \"0x1234...\",\n * signature: {\n * type: \"ecdsa\",\n * data: \"0xabcd...\"\n * },\n * });\n * ```\n */\nexport async function formatSign(\n client: InnerWalletApiClient,\n params: FormatSignParams,\n): Promise<FormatSignResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.debug(\"formatSign:start\");\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n from,\n chainId: params.chainId ?? client.chain.id,\n });\n\n const rpcResp = await client.request({\n method: \"wallet_formatSign\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"formatSign:done\");\n return decode(schema.response, rpcResp);\n}\n"]}
@@ -2,9 +2,8 @@ import { concatHex } from "viem";
2
2
  import { wallet_createSession as MethodSchema } from "@alchemy/wallet-api-types/rpc";
3
3
  import { signSignatureRequest } from "./signSignatureRequest.js";
4
4
  import { LOGGER } from "../logger.js";
5
- import { Value } from "typebox/value";
6
5
  import { resolveAddress } from "../utils/resolve.js";
7
- import { methodSchema } from "../utils/schema.js";
6
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
8
7
  const schema = methodSchema(MethodSchema);
9
8
  /**
10
9
  * Grants permissions to a smart account by creating a session.
@@ -67,7 +66,7 @@ export async function grantPermissions(client, params) {
67
66
  LOGGER.debug("grantPermissions:start", { expirySec: params.expirySec });
68
67
  const chainId = params.chainId ?? client.chain.id;
69
68
  const { account: _, chainId: __, ...rest } = params;
70
- const rpcParams = Value.Encode(schema.request, {
69
+ const rpcParams = encode(schema.request, {
71
70
  ...rest,
72
71
  account,
73
72
  chainId,
@@ -76,7 +75,7 @@ export async function grantPermissions(client, params) {
76
75
  method: "wallet_createSession",
77
76
  params: [rpcParams],
78
77
  });
79
- const { sessionId, signatureRequest } = Value.Decode(schema.response, rpcResp);
78
+ const { sessionId, signatureRequest } = decode(schema.response, rpcResp);
80
79
  const signature = await signSignatureRequest(client, signatureRequest);
81
80
  const res = {
82
81
  context: concatHex([
@@ -1 +1 @@
1
- {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../src/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAErE,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,MAA8B;IAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;QAC5B,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAExE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAElD,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC7C,GAAG,IAAI;QACP,OAAO;QACP,OAAO;KAC0B,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC,MAAM,CAClD,MAAM,CAAC,QAAQ,EACf,OAAO,CAIR,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAEvE,MAAM,GAAG,GAAG;QACV,OAAO,EAAE,SAAS,CAAC;YACjB,MAAM,EAAE,eAAe;YACvB,SAAS;YACT,SAAS,CAAC,IAAI;SACf,CAAC;KACM,CAAC;IACX,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { type Hex, type Prettify, concatHex } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { wallet_createSession as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { Value } from \"typebox/value\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { methodSchema, type MethodParams } from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseCreateSessionParams = MethodParams<typeof MethodSchema>;\n\nexport type GrantPermissionsParams = Prettify<\n DistributiveOmit<BaseCreateSessionParams, \"account\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n>;\n\nexport type GrantPermissionsResult = Prettify<{\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 {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {AccountParam} [params.account] - The account (required if client was not initialized with an account). Can be an address string or an object with an `address` property.\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: 0n }],\n * from: account.address,\n * capabilities: {\n * paymaster: {\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 client: InnerWalletApiClient,\n params: GrantPermissionsParams,\n): Promise<GrantPermissionsResult> {\n const account = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.debug(\"grantPermissions:start\", { expirySec: params.expirySec });\n\n const chainId = params.chainId ?? client.chain.id;\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = Value.Encode(schema.request, {\n ...rest,\n account,\n chainId,\n } satisfies BaseCreateSessionParams);\n\n const rpcResp = await client.request({\n method: \"wallet_createSession\",\n params: [rpcParams],\n });\n\n const { sessionId, signatureRequest } = Value.Decode(\n schema.response,\n rpcResp,\n ) satisfies {\n sessionId: Hex;\n signatureRequest: Parameters<typeof signSignatureRequest>[1];\n };\n\n const signature = await signSignatureRequest(client, signatureRequest);\n\n const res = {\n context: concatHex([\n \"0x00\", // Remote mode.\n sessionId,\n signature.data,\n ]),\n } as const;\n LOGGER.debug(\"grantPermissions:done\");\n return res;\n}\n"]}
1
+ {"version":3,"file":"grantPermissions.js","sourceRoot":"","sources":["../../../src/actions/grantPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,EAAE,oBAAoB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAEP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA4B,EAC5B,MAA8B;IAE9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;QAC5B,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAExE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAElD,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,OAAO;QACP,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEzE,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAEvE,MAAM,GAAG,GAAG;QACV,OAAO,EAAE,SAAS,CAAC;YACjB,MAAM,EAAE,eAAe;YACvB,SAAS;YACT,SAAS,CAAC,IAAI;SACf,CAAC;KACM,CAAC;IACX,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { type Hex, type Prettify, concatHex } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { wallet_createSession as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseCreateSessionParams = MethodParams<typeof MethodSchema>;\n\nexport type GrantPermissionsParams = Prettify<\n DistributiveOmit<BaseCreateSessionParams, \"account\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n>;\n\nexport type GrantPermissionsResult = Prettify<{\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 {GrantPermissionsParams} params - The parameters for granting permissions\n * @param {AccountParam} [params.account] - The account (required if client was not initialized with an account). Can be an address string or an object with an `address` property.\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: 0n }],\n * from: account.address,\n * capabilities: {\n * paymaster: {\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 client: InnerWalletApiClient,\n params: GrantPermissionsParams,\n): Promise<GrantPermissionsResult> {\n const account = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.debug(\"grantPermissions:start\", { expirySec: params.expirySec });\n\n const chainId = params.chainId ?? client.chain.id;\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n account,\n chainId,\n });\n\n const rpcResp = await client.request({\n method: \"wallet_createSession\",\n params: [rpcParams],\n });\n\n const { sessionId, signatureRequest } = decode(schema.response, rpcResp);\n\n const signature = await signSignatureRequest(client, signatureRequest);\n\n const res = {\n context: concatHex([\n \"0x00\", // Remote mode.\n sessionId,\n signature.data,\n ]),\n } as const;\n LOGGER.debug(\"grantPermissions:done\");\n return res;\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import { LOGGER } from "../logger.js";
2
2
  import { wallet_listAccounts as MethodSchema } from "@alchemy/wallet-api-types/rpc";
3
3
  import { isLocalAccount } from "../utils/assertions.js";
4
- import { Value } from "typebox/value";
5
- import { methodSchema, } from "../utils/schema.js";
4
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
6
5
  const schema = methodSchema(MethodSchema);
7
6
  /**
8
7
  * Lists all smart accounts for a given signer using the wallet API client.
@@ -36,7 +35,7 @@ export async function listAccounts(client, params) {
36
35
  ? client.owner.address
37
36
  : client.owner.account.address);
38
37
  LOGGER.debug("listAccounts:start", { hasAfter: !!params.after });
39
- const rpcParams = Value.Encode(schema.request, {
38
+ const rpcParams = encode(schema.request, {
40
39
  ...params,
41
40
  signerAddress,
42
41
  });
@@ -44,7 +43,7 @@ export async function listAccounts(client, params) {
44
43
  method: "wallet_listAccounts",
45
44
  params: [rpcParams],
46
45
  });
47
- const res = Value.Decode(schema.response, rpcResp);
46
+ const res = decode(schema.response, rpcResp);
48
47
  LOGGER.debug("listAccounts:done", { count: res.accounts.length });
49
48
  return res;
50
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../src/actions/listAccounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,MAAM,aAAa,GACjB,MAAM,CAAC,aAAa;QACpB,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO;YACtB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAEjE,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC7C,GAAG,MAAM;QACT,aAAa;KACmB,CAAC,CAAC;IAEpC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CACtB,MAAM,CAAC,QAAQ,EACf,OAAO,CACqB,CAAC;IAC/B,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAElE,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport type { Address, Prettify } from \"viem\";\nimport { wallet_listAccounts as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport { Value } from \"typebox/value\";\nimport {\n methodSchema,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseListAccountsParams = MethodParams<typeof MethodSchema>;\ntype ListAccountsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type ListAccountsParams = Prettify<\n DistributiveOmit<\n BaseListAccountsParams,\n \"signerAddress\" | \"signerPublicKey\"\n > & {\n signerAddress?: Address;\n signerPublicKey?: never;\n }\n>;\n\nexport type ListAccountsResult = ListAccountsResponse;\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 {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 params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n const signerAddress =\n params.signerAddress ??\n (isLocalAccount(client.owner)\n ? client.owner.address\n : client.owner.account.address);\n\n LOGGER.debug(\"listAccounts:start\", { hasAfter: !!params.after });\n\n const rpcParams = Value.Encode(schema.request, {\n ...params,\n signerAddress,\n } satisfies BaseListAccountsParams);\n\n const rpcResp = await client.request({\n method: \"wallet_listAccounts\",\n params: [rpcParams],\n });\n\n const res = Value.Decode(\n schema.response,\n rpcResp,\n ) satisfies ListAccountsResult;\n LOGGER.debug(\"listAccounts:done\", { count: res.accounts.length });\n\n return res;\n}\n"]}
1
+ {"version":3,"file":"listAccounts.js","sourceRoot":"","sources":["../../../src/actions/listAccounts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,MAAM,aAAa,GACjB,MAAM,CAAC,aAAa;QACpB,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO;YACtB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAEjE,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,MAAM;QACT,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAElE,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport type { Address, Prettify } from \"viem\";\nimport { wallet_listAccounts as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseListAccountsParams = MethodParams<typeof MethodSchema>;\ntype ListAccountsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type ListAccountsParams = Prettify<\n DistributiveOmit<\n BaseListAccountsParams,\n \"signerAddress\" | \"signerPublicKey\"\n > & {\n signerAddress?: Address;\n signerPublicKey?: never;\n }\n>;\n\nexport type ListAccountsResult = ListAccountsResponse;\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 {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 params: ListAccountsParams,\n): Promise<ListAccountsResult> {\n const signerAddress =\n params.signerAddress ??\n (isLocalAccount(client.owner)\n ? client.owner.address\n : client.owner.account.address);\n\n LOGGER.debug(\"listAccounts:start\", { hasAfter: !!params.after });\n\n const rpcParams = encode(schema.request, {\n ...params,\n signerAddress,\n });\n\n const rpcResp = await client.request({\n method: \"wallet_listAccounts\",\n params: [rpcParams],\n });\n\n const res = decode(schema.response, rpcResp);\n LOGGER.debug(\"listAccounts:done\", { count: res.accounts.length });\n\n return res;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import type { Prettify } from "viem";
1
+ import type { Address, Prettify } from "viem";
2
2
  import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
3
- import { type WithCapabilities } from "../utils/capabilities.js";
3
+ import { type PrepareCallsCapabilities, type WithCapabilities } from "../utils/capabilities.js";
4
4
  import { type AccountParam } from "../utils/resolve.js";
5
5
  import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
6
6
  import { type MethodParams, type MethodResponse } from "../utils/schema.js";
@@ -10,7 +10,18 @@ export type PrepareCallsParams = Prettify<WithCapabilities<DistributiveOmit<Base
10
10
  account?: AccountParam;
11
11
  chainId?: number;
12
12
  }>>;
13
- export type PrepareCallsResult = PrepareCallsResponse;
13
+ /** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */
14
+ type ClientModifiedRequest = Prettify<Omit<BasePrepareCallsParams, "from" | "capabilities"> & {
15
+ account: Address;
16
+ capabilities?: PrepareCallsCapabilities;
17
+ }>;
18
+ export type PrepareCallsResult = Exclude<PrepareCallsResponse, {
19
+ type: "paymaster-permit";
20
+ }> | (Omit<Extract<PrepareCallsResponse, {
21
+ type: "paymaster-permit";
22
+ }>, "modifiedRequest"> & {
23
+ modifiedRequest: ClientModifiedRequest;
24
+ });
14
25
  /**
15
26
  * Prepares a set of contract calls for execution by building a user operation.
16
27
  * Returns the built user operation and a signature request that needs to be signed
@@ -1,9 +1,8 @@
1
1
  import { LOGGER } from "../logger.js";
2
- import { mergeClientCapabilities, toRpcCapabilities, } from "../utils/capabilities.js";
2
+ import { fromRpcCapabilities, mergeClientCapabilities, toRpcCapabilities, } from "../utils/capabilities.js";
3
3
  import { resolveAddress } from "../utils/resolve.js";
4
4
  import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
5
- import { Value } from "typebox/value";
6
- import { methodSchema, } from "../utils/schema.js";
5
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
7
6
  const schema = methodSchema(MethodSchema);
8
7
  /**
9
8
  * Prepares a set of contract calls for execution by building a user operation.
@@ -47,7 +46,7 @@ export async function prepareCalls(client, params) {
47
46
  hasCapabilities: !!params.capabilities,
48
47
  });
49
48
  const { account: _, chainId: __, ...rest } = params;
50
- const rpcParams = Value.Encode(schema.request, {
49
+ const rpcParams = encode(schema.request, {
51
50
  ...rest,
52
51
  chainId,
53
52
  from,
@@ -58,6 +57,21 @@ export async function prepareCalls(client, params) {
58
57
  params: [rpcParams],
59
58
  });
60
59
  LOGGER.debug("prepareCalls:done");
61
- return Value.Decode(schema.response, rpcResp);
60
+ const decoded = decode(schema.response, rpcResp);
61
+ // Transform paymaster-permit modifiedRequest from RPC format to client format:
62
+ // - `from` (RPC) → `account` (client)
63
+ // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)
64
+ if (decoded.type === "paymaster-permit") {
65
+ const { from, capabilities, ...restModifiedRequest } = decoded.modifiedRequest;
66
+ return {
67
+ ...decoded,
68
+ modifiedRequest: {
69
+ ...restModifiedRequest,
70
+ account: from,
71
+ capabilities: fromRpcCapabilities(capabilities),
72
+ },
73
+ };
74
+ }
75
+ return decoded;
62
76
  }
63
77
  //# sourceMappingURL=prepareCalls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../src/actions/prepareCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAElD,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE;QACjC,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM;QAChC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY;KACvC,CAAC,CAAC;IAEH,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC7C,GAAG,IAAI;QACP,OAAO;QACP,IAAI;QACJ,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;KACb,CAAC,CAAC;IAEpC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { wallet_prepareCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { Value } from \"typebox/value\";\nimport {\n methodSchema,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BasePrepareCallsParams = MethodParams<typeof MethodSchema>;\ntype PrepareCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type PrepareCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BasePrepareCallsParams, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\nexport type PrepareCallsResult = PrepareCallsResponse;\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 * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareCallsParams} params - Parameters for preparing calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\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 * ```ts\n * // Prepare a sponsored user operation call (uses signer address via EIP-7702 by default)\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n * ```\n */\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const chainId = params.chainId ?? client.chain.id;\n\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"prepareCalls:start\", {\n callsCount: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = Value.Encode(schema.request, {\n ...rest,\n chainId,\n from,\n capabilities: toRpcCapabilities(capabilities),\n } satisfies BasePrepareCallsParams);\n\n const rpcResp = await client.request({\n method: \"wallet_prepareCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"prepareCalls:done\");\n return Value.Decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"prepareCalls.js","sourceRoot":"","sources":["../../../src/actions/prepareCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AA8B1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAA4B,EAC5B,MAA0B;IAE1B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAElD,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE;QACjC,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM;QAChC,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY;KACvC,CAAC,CAAC;IAEH,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,OAAO;QACP,IAAI;QACJ,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;KAC9C,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEjD,+EAA+E;IAC/E,sCAAsC;IACtC,8EAA8E;IAC9E,IAAI,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACxC,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,mBAAmB,EAAE,GAClD,OAAO,CAAC,eAAe,CAAC;QAC1B,OAAO;YACL,GAAG,OAAO;YACV,eAAe,EAAE;gBACf,GAAG,mBAAmB;gBACtB,OAAO,EAAE,IAAI;gBACb,YAAY,EAAE,mBAAmB,CAAC,YAAY,CAAC;aAChD;SACF,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { Address, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n fromRpcCapabilities,\n mergeClientCapabilities,\n toRpcCapabilities,\n type PrepareCallsCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { wallet_prepareCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BasePrepareCallsParams = MethodParams<typeof MethodSchema>;\ntype PrepareCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type PrepareCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BasePrepareCallsParams, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\n/** The modifiedRequest in client format: `account` instead of `from`, SDK capabilities. */\ntype ClientModifiedRequest = Prettify<\n Omit<BasePrepareCallsParams, \"from\" | \"capabilities\"> & {\n account: Address;\n capabilities?: PrepareCallsCapabilities;\n }\n>;\n\nexport type PrepareCallsResult =\n | Exclude<PrepareCallsResponse, { type: \"paymaster-permit\" }>\n | (Omit<\n Extract<PrepareCallsResponse, { type: \"paymaster-permit\" }>,\n \"modifiedRequest\"\n > & {\n modifiedRequest: ClientModifiedRequest;\n });\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 * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {PrepareCallsParams} params - Parameters for preparing calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\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 * ```ts\n * // Prepare a sponsored user operation call (uses signer address via EIP-7702 by default)\n * const result = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n * ```\n */\nexport async function prepareCalls(\n client: InnerWalletApiClient,\n params: PrepareCallsParams,\n): Promise<PrepareCallsResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const chainId = params.chainId ?? client.chain.id;\n\n const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"prepareCalls:start\", {\n callsCount: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId,\n from,\n capabilities: toRpcCapabilities(capabilities),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_prepareCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"prepareCalls:done\");\n const decoded = decode(schema.response, rpcResp);\n\n // Transform paymaster-permit modifiedRequest from RPC format to client format:\n // - `from` (RPC) → `account` (client)\n // - `capabilities.paymasterService` (RPC) → `capabilities.paymaster` (client)\n if (decoded.type === \"paymaster-permit\") {\n const { from, capabilities, ...restModifiedRequest } =\n decoded.modifiedRequest;\n return {\n ...decoded,\n modifiedRequest: {\n ...restModifiedRequest,\n account: from,\n capabilities: fromRpcCapabilities(capabilities),\n },\n };\n }\n\n return decoded;\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import { wallet_prepareSign as MethodSchema } from "@alchemy/wallet-api-types/rpc";
2
2
  import { LOGGER } from "../logger.js";
3
3
  import { resolveAddress } from "../utils/resolve.js";
4
- import { Value } from "typebox/value";
5
- import { methodSchema, } from "../utils/schema.js";
4
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
6
5
  const schema = methodSchema(MethodSchema);
7
6
  /**
8
7
  * Prepares a signature request for signing messages or transactions.
@@ -27,7 +26,7 @@ export async function prepareSign(client, params) {
27
26
  : client.account.address;
28
27
  LOGGER.debug("prepareSign:start", { type: params.signatureRequest.type });
29
28
  const { account: _, chainId: __, ...rest } = params;
30
- const rpcParams = Value.Encode(schema.request, {
29
+ const rpcParams = encode(schema.request, {
31
30
  ...rest,
32
31
  from,
33
32
  chainId: params.chainId ?? client.chain.id,
@@ -37,6 +36,6 @@ export async function prepareSign(client, params) {
37
36
  params: [rpcParams],
38
37
  });
39
38
  LOGGER.debug("prepareSign:done");
40
- return Value.Decode(schema.response, rpcResp);
39
+ return decode(schema.response, rpcResp);
41
40
  }
42
41
  //# sourceMappingURL=prepareSign.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepareSign.js","sourceRoot":"","sources":["../../../src/actions/prepareSign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAAyB;IAEzB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAE1E,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC7C,GAAG,IAAI;QACP,IAAI;QACJ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;KACX,CAAC,CAAC;IAEnC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,oBAAoB;QAC5B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { wallet_prepareSign as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport { Value } from \"typebox/value\";\nimport {\n methodSchema,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BasePrepareSignParams = MethodParams<typeof MethodSchema>;\ntype PrepareSignResponse = MethodResponse<typeof MethodSchema>;\n\nexport type PrepareSignParams = DistributiveOmit<\n BasePrepareSignParams,\n \"from\" | \"chainId\"\n> & {\n account?: AccountParam;\n chainId?: number;\n};\n\nexport type PrepareSignResult = PrepareSignResponse;\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 * account: \"0x1234...\",\n * type: \"personal_sign\",\n * data: \"Hello, world!\",\n * });\n * ```\n */\nexport async function prepareSign(\n client: InnerWalletApiClient,\n params: PrepareSignParams,\n): Promise<PrepareSignResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.debug(\"prepareSign:start\", { type: params.signatureRequest.type });\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = Value.Encode(schema.request, {\n ...rest,\n from,\n chainId: params.chainId ?? client.chain.id,\n } satisfies BasePrepareSignParams);\n\n const rpcResp = await client.request({\n method: \"wallet_prepareSign\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"prepareSign:done\");\n return Value.Decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"prepareSign.js","sourceRoot":"","sources":["../../../src/actions/prepareSign.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAAyB;IAEzB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAE1E,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,IAAI;QACJ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;KAC3C,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,oBAAoB;QAC5B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { wallet_prepareSign as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { LOGGER } from \"../logger.js\";\nimport { resolveAddress, type AccountParam } from \"../utils/resolve.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BasePrepareSignParams = MethodParams<typeof MethodSchema>;\ntype PrepareSignResponse = MethodResponse<typeof MethodSchema>;\n\nexport type PrepareSignParams = DistributiveOmit<\n BasePrepareSignParams,\n \"from\" | \"chainId\"\n> & {\n account?: AccountParam;\n chainId?: number;\n};\n\nexport type PrepareSignResult = PrepareSignResponse;\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 * account: \"0x1234...\",\n * type: \"personal_sign\",\n * data: \"Hello, world!\",\n * });\n * ```\n */\nexport async function prepareSign(\n client: InnerWalletApiClient,\n params: PrepareSignParams,\n): Promise<PrepareSignResult> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n LOGGER.debug(\"prepareSign:start\", { type: params.signatureRequest.type });\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n from,\n chainId: params.chainId ?? client.chain.id,\n });\n\n const rpcResp = await client.request({\n method: \"wallet_prepareSign\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"prepareSign:done\");\n return decode(schema.response, rpcResp);\n}\n"]}
@@ -3,8 +3,7 @@ import { wallet_requestAccount as MethodSchema } from "@alchemy/wallet-api-types
3
3
  import deepEqual from "deep-equal";
4
4
  import { LOGGER } from "../logger.js";
5
5
  import { isLocalAccount } from "../utils/assertions.js";
6
- import { Value } from "typebox/value";
7
- import { methodSchema } from "../utils/schema.js";
6
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
8
7
  const schema = methodSchema(MethodSchema);
9
8
  /**
10
9
  * Requests a smart account address for the provided signer using the wallet API client.
@@ -60,12 +59,12 @@ export async function requestAccount(client, params) {
60
59
  type: "json-rpc",
61
60
  };
62
61
  }
63
- const rpcParams = Value.Encode(schema.request, args);
62
+ const rpcParams = encode(schema.request, args);
64
63
  const rpcResp = await client.request({
65
64
  method: "wallet_requestAccount",
66
65
  params: [rpcParams],
67
66
  });
68
- const resp = Value.Decode(schema.response, rpcResp);
67
+ const resp = decode(schema.response, rpcResp);
69
68
  client.internal?.setAccount({
70
69
  address: resp.accountAddress,
71
70
  requestParams: args,
@@ -1 +1 @@
1
- {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAsC,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAErE,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA6B;IAE7B,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;QACnC,SAAS,EAAE,CAAC,CAAC,MAAM;QACnB,kBAAkB,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO;KACrC,CAAC,CAAC;IAEH,MAAM,aAAa,GACjB,CAAC,MAAM,IAAI,eAAe,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO;YACtB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC,MAAM,IAAI,GACR,MAAM,IAAI,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QAC3D,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa;YACb,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEpD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,cAAc,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YAC3D,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE;YACvC,OAAO,EAAE,aAAa,CAAC,OAAO;SAC/B,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,IAAI,EAAE,UAAU;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAC5B,MAAM,CAAC,OAAO,EACd,IAAuC,CACxC,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEpD,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { Address } from \"abitype\";\nimport { isAddressEqual, type JsonRpcAccount, type Prettify } from \"viem\";\nimport { wallet_requestAccount as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport deepEqual from \"deep-equal\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types\";\nimport { LOGGER } from \"../logger.js\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport { Value } from \"typebox/value\";\nimport { methodSchema, type MethodParams } from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestAccountParams = MethodParams<typeof MethodSchema>;\n\nexport type RequestAccountParams = Prettify<\n DistributiveOmit<\n Extract<BaseRequestAccountParams, { signerAddress: Address }>,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n > &\n (\n | { signerAddress?: Address; accountAddress?: never }\n | { signerAddress?: never; accountAddress: Address }\n )\n>;\n\nexport type RequestAccountResult = JsonRpcAccount<Address>;\n\n/**\n * Requests a smart account address for the provided signer using the wallet API client.\n *\n * Note: This is only needed for non-EIP-7702 accounts. The client defaults to using\n * EIP-7702 with the signer's address, so you can call `prepareCalls` or `sendCalls`\n * directly without first calling `requestAccount`.\n *\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 {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 an object containing a smart account address\n *\n * @example\n * ```ts\n * // Request a non-7702 smart account\n * const account = await client.requestAccount();\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n LOGGER.debug(\"requestAccount:start\", {\n hasParams: !!params,\n hasAccountOnClient: !!client.account,\n });\n\n const signerAddress =\n (params && \"signerAddress\" in params ? params.signerAddress : undefined) ??\n (isLocalAccount(client.owner)\n ? client.owner.address\n : client.owner.account.address);\n\n const args =\n params && \"accountAddress\" in params && params.accountAddress\n ? {\n accountAddress: params.accountAddress,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress,\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal?.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n isAddressEqual(cachedAccount.address, args.accountAddress)) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n LOGGER.debug(\"requestAccount:cache-hit\", {\n address: cachedAccount.address,\n });\n return {\n address: cachedAccount.address,\n type: \"json-rpc\",\n };\n }\n\n const rpcParams = Value.Encode(\n schema.request,\n args satisfies BaseRequestAccountParams,\n );\n\n const rpcResp = await client.request({\n method: \"wallet_requestAccount\",\n params: [rpcParams],\n });\n\n const resp = Value.Decode(schema.response, rpcResp);\n\n client.internal?.setAccount({\n address: resp.accountAddress,\n requestParams: args,\n });\n\n LOGGER.debug(\"requestAccount:done\", { address: resp.accountAddress });\n\n return {\n address: resp.accountAddress,\n type: \"json-rpc\",\n };\n}\n"]}
1
+ {"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAsC,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAEP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA6B;IAE7B,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;QACnC,SAAS,EAAE,CAAC,CAAC,MAAM;QACnB,kBAAkB,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO;KACrC,CAAC,CAAC;IAEH,MAAM,aAAa,GACjB,CAAC,MAAM,IAAI,eAAe,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO;YACtB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpC,MAAM,IAAI,GACR,MAAM,IAAI,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QAC3D,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa;YACb,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEpD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,cAAc,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;YAC3D,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE;YACvC,OAAO,EAAE,aAAa,CAAC,OAAO;SAC/B,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,IAAI,EAAE,UAAU;SACjB,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE9C,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,cAAc;QAC5B,IAAI,EAAE,UAAU;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { Address } from \"abitype\";\nimport { isAddressEqual, type JsonRpcAccount, type Prettify } from \"viem\";\nimport { wallet_requestAccount as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport deepEqual from \"deep-equal\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types\";\nimport { LOGGER } from \"../logger.js\";\nimport { isLocalAccount } from \"../utils/assertions.js\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestAccountParams = MethodParams<typeof MethodSchema>;\n\nexport type RequestAccountParams = Prettify<\n DistributiveOmit<\n Extract<BaseRequestAccountParams, { signerAddress: Address }>,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n > &\n (\n | { signerAddress?: Address; accountAddress?: never }\n | { signerAddress?: never; accountAddress: Address }\n )\n>;\n\nexport type RequestAccountResult = JsonRpcAccount<Address>;\n\n/**\n * Requests a smart account address for the provided signer using the wallet API client.\n *\n * Note: This is only needed for non-EIP-7702 accounts. The client defaults to using\n * EIP-7702 with the signer's address, so you can call `prepareCalls` or `sendCalls`\n * directly without first calling `requestAccount`.\n *\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 {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 an object containing a smart account address\n *\n * @example\n * ```ts\n * // Request a non-7702 smart account\n * const account = await client.requestAccount();\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n LOGGER.debug(\"requestAccount:start\", {\n hasParams: !!params,\n hasAccountOnClient: !!client.account,\n });\n\n const signerAddress =\n (params && \"signerAddress\" in params ? params.signerAddress : undefined) ??\n (isLocalAccount(client.owner)\n ? client.owner.address\n : client.owner.account.address);\n\n const args =\n params && \"accountAddress\" in params && params.accountAddress\n ? {\n accountAddress: params.accountAddress,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress,\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal?.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n isAddressEqual(cachedAccount.address, args.accountAddress)) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n LOGGER.debug(\"requestAccount:cache-hit\", {\n address: cachedAccount.address,\n });\n return {\n address: cachedAccount.address,\n type: \"json-rpc\",\n };\n }\n\n const rpcParams = encode(schema.request, args);\n\n const rpcResp = await client.request({\n method: \"wallet_requestAccount\",\n params: [rpcParams],\n });\n\n const resp = decode(schema.response, rpcResp);\n\n client.internal?.setAccount({\n address: resp.accountAddress,\n requestParams: args,\n });\n\n LOGGER.debug(\"requestAccount:done\", { address: resp.accountAddress });\n\n return {\n address: resp.accountAddress,\n type: \"json-rpc\",\n };\n}\n"]}
@@ -3,7 +3,7 @@ import { signPreparedCalls } from "./signPreparedCalls.js";
3
3
  import { sendPreparedCalls, } from "./sendPreparedCalls.js";
4
4
  import { LOGGER } from "../logger.js";
5
5
  import { signSignatureRequest } from "./signSignatureRequest.js";
6
- import { extractCapabilitiesForSending, fromRpcCapabilities, } from "../utils/capabilities.js";
6
+ import { extractCapabilitiesForSending } from "../utils/capabilities.js";
7
7
  /**
8
8
  * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
9
9
  *
@@ -52,10 +52,7 @@ export async function sendCalls(client, params) {
52
52
  if (calls.type === "paymaster-permit") {
53
53
  const signature = await signSignatureRequest(client, calls.signatureRequest);
54
54
  const secondCallParams = {
55
- account: calls.modifiedRequest.from,
56
- calls: calls.modifiedRequest.calls,
57
- chainId: calls.modifiedRequest.chainId,
58
- capabilities: fromRpcCapabilities(calls.modifiedRequest.capabilities),
55
+ ...calls.modifiedRequest,
59
56
  // WebAuthn signatures are not supported for paymaster permits (throws above).
60
57
  paymasterPermitSignature: signature,
61
58
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../src/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAUlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA4B,EAC5B,MAAuB;IAEvB,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM;QAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY;KACvC,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAChD,IAAI,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE;QACrC,GAAG,kBAAkB;QACrB,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,KAAK,CAAC,gBAAgB,CACvB,CAAC;QAEF,MAAM,gBAAgB,GAAG;YACvB,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI;YACnC,KAAK,EAAE,KAAK,CAAC,eAAe,CAAC,KAAK;YAClC,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,OAAO;YACtC,YAAY,EAAE,mBAAmB,CAAC,KAAK,CAAC,eAAe,CAAC,YAAY,CAAC;YACrE,8EAA8E;YAC9E,wBAAwB,EAAE,SAGzB;SACF,CAAC;QAEF,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,MAAM,6BAA6B,GAAG,6BAA6B,CACjE,MAAM,CAAC,YAAY,CACpB,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC1C,GAAG,WAAW;QACd,GAAG,CAAC,6BAA6B,IAAI,IAAI;YACvC,CAAC,CAAC,EAAE,YAAY,EAAE,6BAA6B,EAAE;YACjD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { Chain, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport {\n extractCapabilitiesForSending,\n fromRpcCapabilities,\n} from \"../utils/capabilities.js\";\n\nexport type SendCallsParams = Prettify<\n DistributiveOmit<PrepareCallsParams, \"chainId\"> & {\n chain?: Pick<Chain, \"id\">;\n }\n>;\n\nexport type SendCallsResult = Prettify<SendPreparedCallsResult>;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendCallsParams} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {object} [params.capabilities] - Optional capabilities to include with the request.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * // Send calls (uses signer address via EIP-7702 by default)\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // The result contains the call ID\n * console.log(result.id);\n * ```\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n */\nexport async function sendCalls(\n client: InnerWalletApiClient,\n params: SendCallsParams,\n): Promise<SendCallsResult> {\n LOGGER.info(\"sendCalls:start\", {\n calls: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n const { chain, ...prepareCallsParams } = params;\n let calls = await prepareCalls(client, {\n ...prepareCallsParams,\n ...(chain != null ? { chainId: chain.id } : {}),\n });\n\n if (calls.type === \"paymaster-permit\") {\n const signature = await signSignatureRequest(\n client,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n account: calls.modifiedRequest.from,\n calls: calls.modifiedRequest.calls,\n chainId: calls.modifiedRequest.chainId,\n capabilities: fromRpcCapabilities(calls.modifiedRequest.capabilities),\n // WebAuthn signatures are not supported for paymaster permits (throws above).\n paymasterPermitSignature: signature as Exclude<\n typeof signature,\n { type: \"webauthn-p256\" }\n >,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(client, calls);\n\n const sendPreparedCallsCapabilities = extractCapabilitiesForSending(\n params.capabilities,\n );\n\n const res = await sendPreparedCalls(client, {\n ...signedCalls,\n ...(sendPreparedCallsCapabilities != null\n ? { capabilities: sendPreparedCallsCapabilities }\n : {}),\n });\n LOGGER.info(\"sendCalls:done\");\n return res;\n}\n"]}
1
+ {"version":3,"file":"sendCalls.js","sourceRoot":"","sources":["../../../src/actions/sendCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA2B,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,iBAAiB,GAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AAUzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAA4B,EAC5B,MAAuB;IAEvB,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC7B,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM;QAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY;KACvC,CAAC,CAAC;IACH,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,CAAC;IAChD,IAAI,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE;QACrC,GAAG,kBAAkB;QACrB,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACtC,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAC1C,MAAM,EACN,KAAK,CAAC,gBAAgB,CACvB,CAAC;QAEF,MAAM,gBAAgB,GAAG;YACvB,GAAG,KAAK,CAAC,eAAe;YACxB,8EAA8E;YAC9E,wBAAwB,EAAE,SAGzB;SACF,CAAC;QAEF,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE3D,MAAM,6BAA6B,GAAG,6BAA6B,CACjE,MAAM,CAAC,YAAY,CACpB,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC1C,GAAG,WAAW;QACd,GAAG,CAAC,6BAA6B,IAAI,IAAI;YACvC,CAAC,CAAC,EAAE,YAAY,EAAE,6BAA6B,EAAE;YACjD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC9B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import type { Chain, Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.js\";\nimport { prepareCalls, type PrepareCallsParams } from \"./prepareCalls.js\";\nimport { signPreparedCalls } from \"./signPreparedCalls.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsResult,\n} from \"./sendPreparedCalls.js\";\nimport { LOGGER } from \"../logger.js\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport { extractCapabilitiesForSending } from \"../utils/capabilities.js\";\n\nexport type SendCallsParams = Prettify<\n DistributiveOmit<PrepareCallsParams, \"chainId\"> & {\n chain?: Pick<Chain, \"id\">;\n }\n>;\n\nexport type SendCallsResult = Prettify<SendPreparedCallsResult>;\n\n/**\n * Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.\n *\n * The client defaults to using EIP-7702 with the signer's address, so you can call\n * this directly without first calling `requestAccount`.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendCallsParams} params - Parameters for sending calls\n * @param {Array<{to: Address, data?: Hex, value?: bigint}>} params.calls - Array of contract calls to execute\n * @param {AccountParam} [params.account] - The account to execute the calls from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {object} [params.capabilities] - Optional capabilities to include with the request.\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the call ID.\n *\n * @example\n * ```ts\n * // Send calls (uses signer address via EIP-7702 by default)\n * const result = await client.sendCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: 0n\n * }],\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // The result contains the call ID\n * console.log(result.id);\n * ```\n * <Note>\n * If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden\n * from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.\n * </Note>\n */\nexport async function sendCalls(\n client: InnerWalletApiClient,\n params: SendCallsParams,\n): Promise<SendCallsResult> {\n LOGGER.info(\"sendCalls:start\", {\n calls: params.calls?.length,\n hasCapabilities: !!params.capabilities,\n });\n const { chain, ...prepareCallsParams } = params;\n let calls = await prepareCalls(client, {\n ...prepareCallsParams,\n ...(chain != null ? { chainId: chain.id } : {}),\n });\n\n if (calls.type === \"paymaster-permit\") {\n const signature = await signSignatureRequest(\n client,\n calls.signatureRequest,\n );\n\n const secondCallParams = {\n ...calls.modifiedRequest,\n // WebAuthn signatures are not supported for paymaster permits (throws above).\n paymasterPermitSignature: signature as Exclude<\n typeof signature,\n { type: \"webauthn-p256\" }\n >,\n };\n\n calls = await prepareCalls(client, secondCallParams);\n }\n\n const signedCalls = await signPreparedCalls(client, calls);\n\n const sendPreparedCallsCapabilities = extractCapabilitiesForSending(\n params.capabilities,\n );\n\n const res = await sendPreparedCalls(client, {\n ...signedCalls,\n ...(sendPreparedCallsCapabilities != null\n ? { capabilities: sendPreparedCallsCapabilities }\n : {}),\n });\n LOGGER.info(\"sendCalls:done\");\n return res;\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import { LOGGER } from "../logger.js";
2
2
  import { mergeClientCapabilities, toRpcCapabilities, } from "../utils/capabilities.js";
3
3
  import { wallet_sendPreparedCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
4
- import { Value } from "typebox/value";
5
- import { methodSchema, } from "../utils/schema.js";
4
+ import { methodSchema, encode, decode, } from "../utils/schema.js";
6
5
  const schema = methodSchema(MethodSchema);
7
6
  /**
8
7
  * Sends prepared calls by submitting a signed user operation.
@@ -47,12 +46,12 @@ export async function sendPreparedCalls(client, params) {
47
46
  chainId,
48
47
  capabilities: toRpcCapabilities(capabilities),
49
48
  };
50
- const rpcParams = Value.Encode(schema.request, fullParams);
49
+ const rpcParams = encode(schema.request, fullParams);
51
50
  const rpcResp = await client.request({
52
51
  method: "wallet_sendPreparedCalls",
53
52
  params: [rpcParams],
54
53
  });
55
54
  LOGGER.debug("sendPreparedCalls:done");
56
- return Value.Decode(schema.response, rpcResp);
55
+ return decode(schema.response, rpcResp);
57
56
  }
58
57
  //# sourceMappingURL=sendPreparedCalls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE/D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAE9C,MAAM,UAAU,GACd,UAAU,CAAC,IAAI,KAAK,OAAO;QACzB,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE;QAClE,CAAC,CAAC;YACE,GAAG,UAAU;YACb,OAAO;YACP,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;SAC9C,CAAC;IAER,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAC5B,MAAM,CAAC,OAAO,EACd,UAAgD,CACjD,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { wallet_sendPreparedCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { Value } from \"typebox/value\";\nimport {\n methodSchema,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseSendPreparedCallsParams = MethodParams<typeof MethodSchema>;\ntype SendPreparedCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type SendPreparedCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseSendPreparedCallsParams, \"chainId\"> & {\n chainId?: number;\n }\n >\n>;\n\nexport type SendPreparedCallsResult = SendPreparedCallsResponse;\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 call ID\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: 0n\n * }],\n * capabilities: {\n * paymaster: { 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 const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"sendPreparedCalls:start\", { type: params.type });\n\n const { chainId: rawChainId, ...restParams } = params;\n const chainId = rawChainId ?? client.chain.id;\n\n const fullParams =\n restParams.type === \"array\"\n ? { ...restParams, capabilities: toRpcCapabilities(capabilities) }\n : {\n ...restParams,\n chainId,\n capabilities: toRpcCapabilities(capabilities),\n };\n\n const rpcParams = Value.Encode(\n schema.request,\n fullParams satisfies BaseSendPreparedCallsParams,\n );\n\n const rpcResp = await client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"sendPreparedCalls:done\");\n return Value.Decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,MAAM,YAAY,GAAG,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;IAE1E,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE/D,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAE9C,MAAM,UAAU,GACd,UAAU,CAAC,IAAI,KAAK,OAAO;QACzB,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE;QAClE,CAAC,CAAC;YACE,GAAG,UAAU;YACb,OAAO;YACP,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC;SAC9C,CAAC;IAER,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAErD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../types.ts\";\nimport { LOGGER } from \"../logger.js\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../utils/capabilities.js\";\nimport { wallet_sendPreparedCalls as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseSendPreparedCallsParams = MethodParams<typeof MethodSchema>;\ntype SendPreparedCallsResponse = MethodResponse<typeof MethodSchema>;\n\nexport type SendPreparedCallsParams = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseSendPreparedCallsParams, \"chainId\"> & {\n chainId?: number;\n }\n >\n>;\n\nexport type SendPreparedCallsResult = SendPreparedCallsResponse;\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 call ID\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: 0n\n * }],\n * capabilities: {\n * paymaster: { 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 const capabilities = mergeClientCapabilities(client, params.capabilities);\n\n LOGGER.debug(\"sendPreparedCalls:start\", { type: params.type });\n\n const { chainId: rawChainId, ...restParams } = params;\n const chainId = rawChainId ?? client.chain.id;\n\n const fullParams =\n restParams.type === \"array\"\n ? { ...restParams, capabilities: toRpcCapabilities(capabilities) }\n : {\n ...restParams,\n chainId,\n capabilities: toRpcCapabilities(capabilities),\n };\n\n const rpcParams = encode(schema.request, fullParams);\n\n const rpcResp = await client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [rpcParams],\n });\n\n LOGGER.debug(\"sendPreparedCalls:done\");\n return decode(schema.response, rpcResp);\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import { mergeClientCapabilities, toRpcCapabilities, } from "../../utils/capabilities.js";
2
2
  import { resolveAddress } from "../../utils/resolve.js";
3
3
  import { wallet_requestQuote_v0 as MethodSchema } from "@alchemy/wallet-api-types/rpc";
4
- import { Value } from "typebox/value";
5
- import { methodSchema, } from "../../utils/schema.js";
4
+ import { methodSchema, encode, decode, } from "../../utils/schema.js";
6
5
  const schema = methodSchema(MethodSchema);
7
6
  /**
8
7
  * Requests a quote for a token swap, returning either prepared calls for smart wallets
@@ -50,7 +49,7 @@ export async function requestQuoteV0(client, params) {
50
49
  ? undefined
51
50
  : mergeClientCapabilities(client, "capabilities" in params ? params.capabilities : undefined);
52
51
  const { account: _, chainId: __, ...rest } = params;
53
- const rpcParams = Value.Encode(schema.request, {
52
+ const rpcParams = encode(schema.request, {
54
53
  ...rest,
55
54
  chainId: params.chainId ?? client.chain.id,
56
55
  from,
@@ -60,6 +59,6 @@ export async function requestQuoteV0(client, params) {
60
59
  method: "wallet_requestQuote_v0",
61
60
  params: [rpcParams],
62
61
  });
63
- return Value.Decode(schema.response, rpcResp);
62
+ return decode(schema.response, rpcResp);
64
63
  }
65
64
  //# sourceMappingURL=requestQuoteV0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,YAAY,GAGb,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,YAAY,GAChB,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QACjD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CACrB,MAAM,EACN,cAAc,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAC3D,CAAC;IAER,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAC7C,GAAG,IAAI;QACP,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI;QACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;KACpC,CAAC,CAAC;IAEtC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../../types.ts\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../../utils/resolve.js\";\nimport { wallet_requestQuote_v0 as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { Value } from \"typebox/value\";\nimport {\n methodSchema,\n type MethodParams,\n type MethodResponse,\n} from \"../../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;\ntype RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;\n\nexport type RequestQuoteV0Params = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseRequestQuoteV0Params, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\nexport type RequestQuoteV0Result = RequestQuoteV0Response;\n\n/**\n * Requests a quote for a token swap, returning either prepared calls for smart wallets\n * or raw calls for EOA wallets depending on the returnRawCalls parameter.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote\n * @param {Address} params.fromToken - The address of the token to swap from\n * @param {Address} params.toToken - The address of the token to swap to\n * @param {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)\n * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)\n * @param {AccountParam} [params.account] - The account to execute the swap from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {Hex} [params.slippage] - The maximum acceptable slippage percentage\n * @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap\n * @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls\n *\n * @example\n * ```ts twoslash\n * // Request a quote for smart wallet (prepared calls)\n * const quote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n, // 1 ETH\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Request a quote for EOA wallet (raw calls)\n * const rawQuote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n,\n * returnRawCalls: true\n * });\n * ```\n */\nexport async function requestQuoteV0(\n client: InnerWalletApiClient,\n params: RequestQuoteV0Params,\n): Promise<RequestQuoteV0Result> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const capabilities =\n \"returnRawCalls\" in params && params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(\n client,\n \"capabilities\" in params ? params.capabilities : undefined,\n );\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = Value.Encode(schema.request, {\n ...rest,\n chainId: params.chainId ?? client.chain.id,\n from,\n ...(capabilities && { capabilities: toRpcCapabilities(capabilities) }),\n } satisfies BaseRequestQuoteV0Params);\n\n const rpcResp = await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [rpcParams],\n });\n\n return Value.Decode(schema.response, rpcResp);\n}\n"]}
1
+ {"version":3,"file":"requestQuoteV0.js","sourceRoot":"","sources":["../../../../src/experimental/actions/requestQuoteV0.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAElB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAqB,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,sBAAsB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,MAAM,EACN,MAAM,GAGP,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA4B;IAE5B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;QAChC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;IAE3B,MAAM,YAAY,GAChB,gBAAgB,IAAI,MAAM,IAAI,MAAM,CAAC,cAAc;QACjD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CACrB,MAAM,EACN,cAAc,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAC3D,CAAC;IAER,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QACvC,GAAG,IAAI;QACP,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QAC1C,IAAI;QACJ,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;KACvE,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;QACnC,MAAM,EAAE,wBAAwB;QAChC,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { Prettify } from \"viem\";\nimport type { DistributiveOmit, InnerWalletApiClient } from \"../../types.ts\";\nimport {\n mergeClientCapabilities,\n toRpcCapabilities,\n type WithCapabilities,\n} from \"../../utils/capabilities.js\";\nimport { resolveAddress, type AccountParam } from \"../../utils/resolve.js\";\nimport { wallet_requestQuote_v0 as MethodSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n methodSchema,\n encode,\n decode,\n type MethodParams,\n type MethodResponse,\n} from \"../../utils/schema.js\";\n\nconst schema = methodSchema(MethodSchema);\ntype BaseRequestQuoteV0Params = MethodParams<typeof MethodSchema>;\ntype RequestQuoteV0Response = MethodResponse<typeof MethodSchema>;\n\nexport type RequestQuoteV0Params = Prettify<\n WithCapabilities<\n DistributiveOmit<BaseRequestQuoteV0Params, \"from\" | \"chainId\"> & {\n account?: AccountParam;\n chainId?: number;\n }\n >\n>;\n\nexport type RequestQuoteV0Result = RequestQuoteV0Response;\n\n/**\n * Requests a quote for a token swap, returning either prepared calls for smart wallets\n * or raw calls for EOA wallets depending on the returnRawCalls parameter.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {RequestQuoteV0Params} params - Parameters for requesting a swap quote\n * @param {Address} params.fromToken - The address of the token to swap from\n * @param {Address} params.toToken - The address of the token to swap to\n * @param {Hex} [params.fromAmount] - The amount to swap from (mutually exclusive with minimumToAmount)\n * @param {Hex} [params.minimumToAmount] - The minimum amount to receive (mutually exclusive with fromAmount)\n * @param {AccountParam} [params.account] - The account to execute the swap from. Can be an address string or an object with an `address` property. Defaults to the client's account (signer address via EIP-7702).\n * @param {Hex} [params.slippage] - The maximum acceptable slippage percentage\n * @param {boolean} [params.returnRawCalls] - Whether to return raw calls for EOA wallets (defaults to false for smart wallets)\n * @param {object} [params.capabilities] - Optional capabilities to include with the request (only available when returnRawCalls is false)\n * @param {Array<{to: Address, data?: Hex, value?: Hex}>} [params.postCalls] - Optional calls to execute after the swap\n * @returns {Promise<RequestQuoteV0Result>} A Promise that resolves to either prepared calls or raw calls depending on returnRawCalls\n *\n * @example\n * ```ts twoslash\n * // Request a quote for smart wallet (prepared calls)\n * const quote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n, // 1 ETH\n * capabilities: {\n * paymaster: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Request a quote for EOA wallet (raw calls)\n * const rawQuote = await client.requestQuoteV0({\n * fromToken: \"0xA0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * toToken: \"0xB0b86a33E6441e1d6a8E8C7a8E8E8E8E8E8E8E8E\",\n * fromAmount: 1000000000000000000n,\n * returnRawCalls: true\n * });\n * ```\n */\nexport async function requestQuoteV0(\n client: InnerWalletApiClient,\n params: RequestQuoteV0Params,\n): Promise<RequestQuoteV0Result> {\n const from = params.account\n ? resolveAddress(params.account)\n : client.account.address;\n\n const capabilities =\n \"returnRawCalls\" in params && params.returnRawCalls\n ? undefined\n : mergeClientCapabilities(\n client,\n \"capabilities\" in params ? params.capabilities : undefined,\n );\n\n const { account: _, chainId: __, ...rest } = params;\n const rpcParams = encode(schema.request, {\n ...rest,\n chainId: params.chainId ?? client.chain.id,\n from,\n ...(capabilities && { capabilities: toRpcCapabilities(capabilities) }),\n });\n\n const rpcResp = await client.request({\n method: \"wallet_requestQuote_v0\",\n params: [rpcParams],\n });\n\n return decode(schema.response, rpcResp);\n}\n"]}
@@ -1,5 +1,12 @@
1
- import type { PrepareCallsCapabilities as RpcPrepareCallsCapabilities, SendPreparedCallsCapabilities as RpcSendPreparedCallsCapabilities } from "@alchemy/wallet-api-types/capabilities";
1
+ import { PrepareCallsCapabilities as PrepareCallsCapabilitiesSchema, SendPreparedCallsCapabilities as SendPreparedCallsCapabilitiesSchema } from "@alchemy/wallet-api-types/capabilities";
2
+ import type { StaticDecode } from "typebox";
2
3
  import type { InnerWalletApiClient } from "../types.js";
4
+ /**
5
+ * Decoded capabilities matching the schema shape (uses `paymasterService` key).
6
+ * `ResolveCapabilities` renames this to `paymaster` for client-facing types.
7
+ */
8
+ type DecodedPrepareCallsCaps = StaticDecode<typeof PrepareCallsCapabilitiesSchema>;
9
+ type DecodedSendPreparedCallsCaps = StaticDecode<typeof SendPreparedCallsCapabilitiesSchema>;
3
10
  /**
4
11
  * Renames `paymasterService` (RPC) to `paymaster` in a capabilities type. This
5
12
  * is because our RPC schema's paymasterService capability does not exactly match
@@ -11,8 +18,8 @@ type ResolveCapabilities<T> = T extends {
11
18
  } ? Omit<T, "paymasterService"> & {
12
19
  paymaster?: P;
13
20
  } : T;
14
- export type PrepareCallsCapabilities = ResolveCapabilities<RpcPrepareCallsCapabilities>;
15
- export type SendPreparedCallsCapabilities = ResolveCapabilities<RpcSendPreparedCallsCapabilities>;
21
+ export type PrepareCallsCapabilities = ResolveCapabilities<DecodedPrepareCallsCaps>;
22
+ export type SendPreparedCallsCapabilities = ResolveCapabilities<DecodedSendPreparedCallsCaps>;
16
23
  /**
17
24
  * Transforms a type so that any `capabilities` field uses `paymaster`
18
25
  * instead of `paymasterService` (RPC).
@@ -27,17 +34,17 @@ export type WithCapabilities<T> = T extends {
27
34
  * for use with Value.Encode before sending to the RPC.
28
35
  *
29
36
  * @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field
30
- * @returns {RpcPrepareCallsCapabilities | RpcSendPreparedCallsCapabilities | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
37
+ * @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
31
38
  */
32
- export declare function toRpcCapabilities(capabilities: PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined): RpcPrepareCallsCapabilities | RpcSendPreparedCallsCapabilities | undefined;
39
+ export declare function toRpcCapabilities(capabilities: PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined): DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined;
33
40
  /**
34
41
  * Converts RPC capabilities (with `paymasterService`) from Value.Decode
35
42
  * to capabilities (with `paymaster`).
36
43
  *
37
- * @param {RpcPrepareCallsCapabilities | RpcSendPreparedCallsCapabilities | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
44
+ * @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
38
45
  * @returns {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} Capabilities with `paymaster`, or undefined if input is undefined
39
46
  */
40
- export declare function fromRpcCapabilities(capabilities: RpcPrepareCallsCapabilities | RpcSendPreparedCallsCapabilities | undefined): PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined;
47
+ export declare function fromRpcCapabilities(capabilities: DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined): PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined;
41
48
  /**
42
49
  * Merges client capabilities with capabilities from the request.
43
50
  * Uses policyId (singular) when there's one policy, policyIds (array) when multiple.
@@ -1,3 +1,4 @@
1
+ import { PrepareCallsCapabilities as PrepareCallsCapabilitiesSchema, SendPreparedCallsCapabilities as SendPreparedCallsCapabilitiesSchema, } from "@alchemy/wallet-api-types/capabilities";
1
2
  function hasNoPaymasterField(value) {
2
3
  return !("paymaster" in value);
3
4
  }
@@ -9,7 +10,7 @@ function hasNoPaymasterServiceField(value) {
9
10
  * for use with Value.Encode before sending to the RPC.
10
11
  *
11
12
  * @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field
12
- * @returns {RpcPrepareCallsCapabilities | RpcSendPreparedCallsCapabilities | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
13
+ * @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
13
14
  */
14
15
  export function toRpcCapabilities(capabilities) {
15
16
  if (!capabilities)
@@ -26,7 +27,7 @@ export function toRpcCapabilities(capabilities) {
26
27
  * Converts RPC capabilities (with `paymasterService`) from Value.Decode
27
28
  * to capabilities (with `paymaster`).
28
29
  *
29
- * @param {RpcPrepareCallsCapabilities | RpcSendPreparedCallsCapabilities | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
30
+ * @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
30
31
  * @returns {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} Capabilities with `paymaster`, or undefined if input is undefined
31
32
  */
32
33
  export function fromRpcCapabilities(capabilities) {