@account-kit/infra 4.0.0-alpha.0 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dist/cjs/actions/simulateUserOperationChanges.js.map +1 -1
  2. package/dist/cjs/chains.d.ts +4 -0
  3. package/dist/cjs/chains.js.map +1 -1
  4. package/dist/cjs/client/decorators/alchemyEnhancedApis.d.ts +5537 -1
  5. package/dist/cjs/client/decorators/alchemyEnhancedApis.js.map +1 -1
  6. package/dist/cjs/client/decorators/smartAccount.js.map +1 -1
  7. package/dist/cjs/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  8. package/dist/cjs/client/internal/smartAccountClientFromRpc.js +2 -1
  9. package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -1
  10. package/dist/cjs/client/isAlchemySmartAccountClient.js.map +1 -1
  11. package/dist/cjs/client/rpcClient.js.map +1 -1
  12. package/dist/cjs/client/smartAccountClient.js.map +1 -1
  13. package/dist/cjs/defaults.js.map +1 -1
  14. package/dist/cjs/gas-manager.js.map +1 -1
  15. package/dist/cjs/index.d.ts +1 -0
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/middleware/feeEstimator.js.map +1 -1
  18. package/dist/cjs/middleware/gasManager.js.map +1 -1
  19. package/dist/cjs/middleware/userOperationSimulator.js.map +1 -1
  20. package/dist/cjs/version.d.ts +1 -1
  21. package/dist/cjs/version.js +1 -1
  22. package/dist/cjs/version.js.map +1 -1
  23. package/dist/esm/actions/simulateUserOperationChanges.js.map +1 -1
  24. package/dist/esm/chains.d.ts +4 -0
  25. package/dist/esm/chains.js.map +1 -1
  26. package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +5537 -1
  27. package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -1
  28. package/dist/esm/client/decorators/smartAccount.js.map +1 -1
  29. package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  30. package/dist/esm/client/internal/smartAccountClientFromRpc.js +2 -1
  31. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -1
  32. package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
  33. package/dist/esm/client/rpcClient.js.map +1 -1
  34. package/dist/esm/client/smartAccountClient.js.map +1 -1
  35. package/dist/esm/defaults.js.map +1 -1
  36. package/dist/esm/gas-manager.js +1 -1
  37. package/dist/esm/gas-manager.js.map +1 -1
  38. package/dist/esm/index.d.ts +1 -0
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/middleware/feeEstimator.js.map +1 -1
  41. package/dist/esm/middleware/gasManager.js.map +1 -1
  42. package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
  43. package/dist/esm/version.d.ts +1 -1
  44. package/dist/esm/version.js +1 -1
  45. package/dist/esm/version.js.map +1 -1
  46. package/dist/types/actions/simulateUserOperationChanges.d.ts +17 -0
  47. package/dist/types/actions/simulateUserOperationChanges.d.ts.map +1 -1
  48. package/dist/types/chains.d.ts +23 -0
  49. package/dist/types/chains.d.ts.map +1 -1
  50. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +5554 -1
  51. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
  52. package/dist/types/client/decorators/smartAccount.d.ts +15 -0
  53. package/dist/types/client/decorators/smartAccount.d.ts.map +1 -1
  54. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  55. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +1 -1
  56. package/dist/types/client/isAlchemySmartAccountClient.d.ts +15 -0
  57. package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
  58. package/dist/types/client/rpcClient.d.ts +22 -0
  59. package/dist/types/client/rpcClient.d.ts.map +1 -1
  60. package/dist/types/defaults.d.ts +14 -0
  61. package/dist/types/defaults.d.ts.map +1 -1
  62. package/dist/types/gas-manager.d.ts +13 -0
  63. package/dist/types/gas-manager.d.ts.map +1 -1
  64. package/dist/types/index.d.ts +1 -0
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/middleware/feeEstimator.d.ts +19 -0
  67. package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
  68. package/dist/types/middleware/userOperationSimulator.d.ts +19 -0
  69. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
  70. package/dist/types/version.d.ts +1 -1
  71. package/package.json +3 -3
  72. package/src/actions/simulateUserOperationChanges.ts +17 -0
  73. package/src/chains.ts +24 -0
  74. package/src/client/decorators/alchemyEnhancedApis.ts +50 -33
  75. package/src/client/decorators/smartAccount.ts +15 -0
  76. package/src/client/internal/smartAccountClientFromRpc.ts +33 -13
  77. package/src/client/isAlchemySmartAccountClient.ts +15 -0
  78. package/src/client/rpcClient.ts +22 -0
  79. package/src/client/smartAccountClient.ts +17 -0
  80. package/src/defaults.ts +14 -0
  81. package/src/gas-manager.ts +17 -4
  82. package/src/index.ts +1 -0
  83. package/src/middleware/feeEstimator.ts +19 -0
  84. package/src/middleware/gasManager.ts +1 -1
  85. package/src/middleware/userOperationSimulator.ts +19 -0
  86. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"alchemyEnhancedApis.js","sourceRoot":"","sources":["../../../../src/client/decorators/alchemyEnhancedApis.ts"],"names":[],"mappings":";;;AAGA,+CAAyD;AAalD,MAAM,yBAAyB,GAUX,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IACjD,MAAM,UAAU,GAAG,kCAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,SACa,CAAC;QAErC,IACE,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM;YAChC,OAAO,CAAC,MAAM,CAAC,GAAG;YAClB,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,EAC1B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC,CAAC;AArCW,QAAA,yBAAyB,6BAqCpC","sourcesContent":["import type { SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Alchemy } from \"alchemy-sdk\";\nimport type { Chain, HttpTransport, Transport } from \"viem\";\nimport { AlchemySdkClientSchema } from \"../../schema.js\";\nimport type { AlchemySmartAccountClient } from \"../smartAccountClient.js\";\n\nexport type AlchemyEnhancedApis = {\n core: Alchemy[\"core\"];\n nft: Alchemy[\"nft\"];\n transact: Alchemy[\"transact\"];\n debug: Alchemy[\"debug\"];\n ws: Alchemy[\"ws\"];\n notify: Alchemy[\"notify\"];\n config: Alchemy[\"config\"];\n};\n\nexport const alchemyEnhancedApiActions: (\n alchemy: Alchemy\n) => <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: AlchemySmartAccountClient<TTransport, TChain, TAccount>\n) => AlchemyEnhancedApis = (alchemy) => (client) => {\n const alchemySdk = AlchemySdkClientSchema.parse(alchemy);\n\n if (client.transport.type === \"http\") {\n const { url } = client.transport as ReturnType<HttpTransport>[\"config\"] &\n ReturnType<HttpTransport>[\"value\"];\n\n if (\n client.transport.type === \"http\" &&\n alchemy.config.url &&\n alchemy.config.url !== url\n ) {\n throw new Error(\n \"Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL\"\n );\n }\n }\n\n return {\n core: alchemySdk.core,\n nft: alchemySdk.nft,\n transact: alchemySdk.transact,\n debug: alchemySdk.debug,\n ws: alchemySdk.ws,\n notify: alchemySdk.notify,\n config: alchemySdk.config,\n };\n};\n"]}
1
+ {"version":3,"file":"alchemyEnhancedApis.js","sourceRoot":"","sources":["../../../../src/client/decorators/alchemyEnhancedApis.ts"],"names":[],"mappings":";;;AAGA,+CAAyD;AA8BlD,MAAM,yBAAyB,GACpC,CAAC,OAAgB,EAAE,EAAE,CACrB,CAOE,MAA+D,EAC1C,EAAE;IACvB,MAAM,UAAU,GAAG,kCAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEzD,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACrC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,SACa,CAAC;QAErC,IACE,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM;YAChC,OAAO,CAAC,MAAM,CAAC,GAAG;YAClB,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,GAAG,EAC1B,CAAC;YACD,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,GAAG,EAAE,UAAU,CAAC,GAAG;QACnB,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC,CAAC;AArCS,QAAA,yBAAyB,6BAqClC","sourcesContent":["import type { SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Alchemy } from \"alchemy-sdk\";\nimport type { Chain, HttpTransport, Transport } from \"viem\";\nimport { AlchemySdkClientSchema } from \"../../schema.js\";\nimport type { AlchemySmartAccountClient } from \"../smartAccountClient.js\";\n\nexport type AlchemyEnhancedApis = {\n core: Alchemy[\"core\"];\n nft: Alchemy[\"nft\"];\n transact: Alchemy[\"transact\"];\n debug: Alchemy[\"debug\"];\n ws: Alchemy[\"ws\"];\n notify: Alchemy[\"notify\"];\n config: Alchemy[\"config\"];\n};\n\n/**\n * Given an instance of the Alchemy SDK, returns a smart account client decorator which contains actions for interacting Alchemy's enhanced APIs.\n *\n * @example\n * ```ts\n * import { Alchemy } from \"alchemy-sdk\";\n * import { alchemyEnhancedApiActions } from \"@account-kit/infra\";\n * import { alchemySCAClient } from \"./client\";\n *\n * const alchemy = new Alchemy(...);\n * const enhancedApiDecorator = alchemyEnhancedApiActions(alchemy);\n * const withEnhancedApis = alchemySCAClient.extend(enhancedApiDecorator);\n * ```\n *\n * @param {Alchemy} alchemy The Alchemy instance containing the SDK client\n * @returns {(client: AlchemySmartAccountClient) => AlchemyEnhancedApis} A client decorator for Alchemy Smart Account clients that adds the enhanced API methods\n */\nexport const alchemyEnhancedApiActions =\n (alchemy: Alchemy) =>\n <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n >(\n client: AlchemySmartAccountClient<TTransport, TChain, TAccount>\n ): AlchemyEnhancedApis => {\n const alchemySdk = AlchemySdkClientSchema.parse(alchemy);\n\n if (client.transport.type === \"http\") {\n const { url } = client.transport as ReturnType<HttpTransport>[\"config\"] &\n ReturnType<HttpTransport>[\"value\"];\n\n if (\n client.transport.type === \"http\" &&\n alchemy.config.url &&\n alchemy.config.url !== url\n ) {\n throw new Error(\n \"Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL\"\n );\n }\n }\n\n return {\n core: alchemySdk.core,\n nft: alchemySdk.nft,\n transact: alchemySdk.transact,\n debug: alchemySdk.debug,\n ws: alchemySdk.ws,\n notify: alchemySdk.notify,\n config: alchemySdk.config,\n };\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccount.ts"],"names":[],"mappings":";;;AAMA,mGAA6F;AAgBtF,MAAM,cAAc,GAWiC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvE,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACpC,IAAA,8DAA4B,EAAC,MAAM,EAAE,IAAI,CAAC;CAC7C,CAAC,CAAC;AAdU,QAAA,cAAc,kBAcxB","sourcesContent":["import type {\n SendUserOperationParameters,\n SmartContractAccount,\n UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport { simulateUserOperationChanges } from \"../../actions/simulateUserOperationChanges.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"../../actions/types.js\";\n\nexport type AlchemySmartAccountClientActions<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n simulateUserOperation: (\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<SimulateUserOperationAssetChangesResponse>;\n};\n\nexport const alchemyActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => AlchemySmartAccountClientActions<TAccount, TContext> = (client) => ({\n simulateUserOperation: async (args) =>\n simulateUserOperationChanges(client, args),\n});\n"]}
1
+ {"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccount.ts"],"names":[],"mappings":";;;AAMA,mGAA6F;AA+BtF,MAAM,cAAc,GAWiC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACvE,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACpC,IAAA,8DAA4B,EAAC,MAAM,EAAE,IAAI,CAAC;CAC7C,CAAC,CAAC;AAdU,QAAA,cAAc,kBAcxB","sourcesContent":["import type {\n SendUserOperationParameters,\n SmartContractAccount,\n UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport { simulateUserOperationChanges } from \"../../actions/simulateUserOperationChanges.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"../../actions/types.js\";\n\nexport type AlchemySmartAccountClientActions<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n simulateUserOperation: (\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<SimulateUserOperationAssetChangesResponse>;\n};\n\n/**\n * Provides a set of actions for interacting with the Alchemy Smart Account client, including the ability to simulate user operations.\n *\n * @example\n * ```ts\n * import { alchemyActions } from \"@account-kit/infra\";\n * import { createPublicClient } from \"viem\";\n *\n * const client = createPublicClient(...);\n * const clientWithAlchemyActions = client.extend(alchemyActions);\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to perform actions\n * @returns {AlchemySmartAccountClientActions<TAccount, TContext>} An object containing Alchemy Smart Account client actions\n */\nexport const alchemyActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => AlchemySmartAccountClientActions<TAccount, TContext> = (client) => ({\n simulateUserOperation: async (args) =>\n simulateUserOperationChanges(client, args),\n});\n"]}
@@ -2,10 +2,10 @@ import { type SmartContractAccount, type SmartContractAccountWithSigner, type Us
2
2
  import type { Chain, CustomTransport, Transport } from "viem";
3
3
  import type { AlchemySmartAccountClient, AlchemySmartAccountClientConfig } from "../smartAccountClient.js";
4
4
  import type { ClientWithAlchemyMethods } from "../types.js";
5
- export type CreateAlchemySmartAccountClientFromRpcClient<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined> = Omit<AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>, "rpcUrl" | "chain" | "apiKey" | "jwt"> & {
5
+ export type CreateAlchemySmartAccountClientFromRpcClientParams<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined> = Omit<AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>, "rpcUrl" | "chain" | "apiKey" | "jwt"> & {
6
6
  client: ClientWithAlchemyMethods;
7
7
  };
8
8
  export declare function getSignerTypeHeader<TAccount extends SmartContractAccountWithSigner>(account: TAccount): {
9
9
  "Alchemy-Aa-Sdk-Signer": string;
10
10
  };
11
- export declare function createAlchemySmartAccountClientFromRpcClient<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(args: CreateAlchemySmartAccountClientFromRpcClient<TAccount, TContext>): AlchemySmartAccountClient<CustomTransport, TChain, TAccount, Record<string, never>, TContext>;
11
+ export declare function createAlchemySmartAccountClientFromRpcClient<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(args: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>): AlchemySmartAccountClient<CustomTransport, TChain, TAccount, Record<string, never>, TContext>;
@@ -10,7 +10,8 @@ function getSignerTypeHeader(account) {
10
10
  return { "Alchemy-Aa-Sdk-Signer": account.getSigner().signerType };
11
11
  }
12
12
  exports.getSignerTypeHeader = getSignerTypeHeader;
13
- function createAlchemySmartAccountClientFromRpcClient({ opts, account, useSimulation, gasManagerConfig, feeEstimator, gasEstimator, customMiddleware, signUserOperation, client, }) {
13
+ function createAlchemySmartAccountClientFromRpcClient(args) {
14
+ const { opts, account, useSimulation, gasManagerConfig, feeEstimator, gasEstimator, customMiddleware, signUserOperation, client, } = args;
14
15
  const feeOptions = opts?.feeOptions ?? (0, core_1.getDefaultUserOperationFeeOptions)(client.chain);
15
16
  const scaClient = (0, core_1.createSmartAccountClientFromExisting)({
16
17
  account,
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClientFromRpc.js","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":";;;AAAA,uCAOsB;AAEtB,sEAAuE;AACvE,kEAA6E;AAC7E,0FAA2F;AAC3F,mEAA+D;AAmB/D,SAAgB,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAJD,kDAIC;AA2BD,SAAgB,4CAA4C,CAAC,EAC3D,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACuC;IAC7C,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,wCAAiC,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,IAAA,2CAAoC,EAAC;QACrD,OAAO;QACP,MAAM;QACN,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACvC,IAAI,IAAA,+BAAwB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1D,CAAC;YAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACpE,CAAC;QACD,YAAY,EAAE,YAAY,IAAI,IAAA,qCAAmB,EAAC,MAAM,CAAC;QACzD,sBAAsB,EAAE,aAAa;YACnC,CAAC,CAAC,IAAA,yDAA6B,EAAC,MAAM,CAAC;YACvC,CAAC,CAAC,SAAS;QACb,YAAY;QACZ,GAAG,CAAC,gBAAgB;YAClB,IAAA,2CAA2B,EAAC,MAAM,EAAE;gBAClC,GAAG,gBAAgB;gBACnB,oBAAoB,EAAE;oBACpB,GAAG,gBAAgB,CAAC,oBAAoB;oBACxC,oBAAoB,EAClB,gBAAgB,CAAC,oBAAoB,EAAE,oBAAoB;wBAC3D,KAAK;oBACP,qBAAqB,EACnB,gBAAgB,CAAC,oBAAoB,EAAE,qBAAqB;wBAC5D,YAAY;oBACd,oBAAoB,EAClB,gBAAgB,CAAC,oBAAoB,EAAE,oBAAoB;wBAC3D,YAAY;iBACf;aACF,CAAC,CAAC;QACL,iBAAiB;KAClB,CAAC,CAAC,MAAM,CAAC,gCAAc,CAAC,CAAC;IAE1B,IAAI,OAAO,IAAI,IAAA,+BAAwB,EAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AA1DD,oGA0DC","sourcesContent":["import {\n createSmartAccountClientFromExisting,\n getDefaultUserOperationFeeOptions,\n isSmartAccountWithSigner,\n type SmartContractAccount,\n type SmartContractAccountWithSigner,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { Chain, CustomTransport, Transport } from \"viem\";\nimport { alchemyFeeEstimator } from \"../../middleware/feeEstimator.js\";\nimport { alchemyGasManagerMiddleware } from \"../../middleware/gasManager.js\";\nimport { alchemyUserOperationSimulator } from \"../../middleware/userOperationSimulator.js\";\nimport { alchemyActions } from \"../decorators/smartAccount.js\";\nimport type {\n AlchemySmartAccountClient,\n AlchemySmartAccountClientConfig,\n} from \"../smartAccountClient.js\";\nimport type { ClientWithAlchemyMethods } from \"../types.js\";\n\nexport type CreateAlchemySmartAccountClientFromRpcClient<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Omit<\n AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>,\n \"rpcUrl\" | \"chain\" | \"apiKey\" | \"jwt\"\n> & { client: ClientWithAlchemyMethods };\n\nexport function getSignerTypeHeader<\n TAccount extends SmartContractAccountWithSigner\n>(account: TAccount) {\n return { \"Alchemy-Aa-Sdk-Signer\": account.getSigner().signerType };\n}\n\n/**\n * Helper method meant to be used internally to create an alchemy smart account client\n * from an existing Alchemy Rpc Client\n *\n * @param args configuration for the client\n * @returns a smart account client configured to use Alchemy's RPC\n */\nexport function createAlchemySmartAccountClientFromRpcClient<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n args: CreateAlchemySmartAccountClientFromRpcClient<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\nexport function createAlchemySmartAccountClientFromRpcClient({\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n}: CreateAlchemySmartAccountClientFromRpcClient): AlchemySmartAccountClient {\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);\n\n const scaClient = createSmartAccountClientFromExisting({\n account,\n client,\n type: \"AlchemySmartAccountClient\",\n opts: {\n ...opts,\n feeOptions,\n },\n customMiddleware: async (struct, args) => {\n if (isSmartAccountWithSigner(args.account)) {\n client.updateHeaders(getSignerTypeHeader(args.account));\n }\n\n return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(client)\n : undefined,\n gasEstimator,\n ...(gasManagerConfig &&\n alchemyGasManagerMiddleware(client, {\n ...gasManagerConfig,\n gasEstimationOptions: {\n ...gasManagerConfig.gasEstimationOptions,\n disableGasEstimation:\n gasManagerConfig.gasEstimationOptions?.disableGasEstimation ??\n false,\n fallbackFeeDataGetter:\n gasManagerConfig.gasEstimationOptions?.fallbackFeeDataGetter ??\n feeEstimator,\n fallbackGasEstimator:\n gasManagerConfig.gasEstimationOptions?.fallbackGasEstimator ??\n gasEstimator,\n },\n })),\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n client.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}
1
+ {"version":3,"file":"smartAccountClientFromRpc.js","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":";;;AAAA,uCAOsB;AAEtB,sEAAuE;AACvE,kEAA6E;AAC7E,0FAA2F;AAC3F,mEAA+D;AAmB/D,SAAgB,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAJD,kDAIC;AA4CD,SAAgB,4CAA4C,CAC1D,IAAwD;IAExD,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACP,GAAG,IAAI,CAAC;IACT,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,wCAAiC,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,IAAA,2CAAoC,EAAC;QACrD,OAAO;QACP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C;AA7DD,oGA6DC","sourcesContent":["import {\n createSmartAccountClientFromExisting,\n getDefaultUserOperationFeeOptions,\n isSmartAccountWithSigner,\n type SmartContractAccount,\n type SmartContractAccountWithSigner,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { Chain, CustomTransport, Transport } from \"viem\";\nimport { alchemyFeeEstimator } from \"../../middleware/feeEstimator.js\";\nimport { alchemyGasManagerMiddleware } from \"../../middleware/gasManager.js\";\nimport { alchemyUserOperationSimulator } from \"../../middleware/userOperationSimulator.js\";\nimport { alchemyActions } from \"../decorators/smartAccount.js\";\nimport type {\n AlchemySmartAccountClient,\n AlchemySmartAccountClientConfig,\n} from \"../smartAccountClient.js\";\nimport type { ClientWithAlchemyMethods } from \"../types.js\";\n\nexport type CreateAlchemySmartAccountClientFromRpcClientParams<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Omit<\n AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>,\n \"rpcUrl\" | \"chain\" | \"apiKey\" | \"jwt\"\n> & { client: ClientWithAlchemyMethods };\n\nexport function getSignerTypeHeader<\n TAccount extends SmartContractAccountWithSigner\n>(account: TAccount) {\n return { \"Alchemy-Aa-Sdk-Signer\": account.getSigner().signerType };\n}\n\n/**\n * Helper method meant to be used internally to create an alchemy smart account client\n * from an existing Alchemy Rpc Client\n *\n * @param args configuration for the client\n * @returns a smart account client configured to use Alchemy's RPC\n */\nexport function createAlchemySmartAccountClientFromRpcClient<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n args: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>\n): AlchemySmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient(...);\n * const scaClient = createAlchemySmartAccountClientFromRpcClient({\n * client,\n * ...\n * });\n * ```\n *\n * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters\n * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient\n */\nexport function createAlchemySmartAccountClientFromRpcClient(\n args: CreateAlchemySmartAccountClientFromRpcClientParams\n): AlchemySmartAccountClient {\n const {\n opts,\n account,\n useSimulation,\n gasManagerConfig,\n feeEstimator,\n gasEstimator,\n customMiddleware,\n signUserOperation,\n client,\n } = args;\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);\n\n const scaClient = createSmartAccountClientFromExisting({\n account,\n client,\n type: \"AlchemySmartAccountClient\",\n opts: {\n ...opts,\n feeOptions,\n },\n customMiddleware: async (struct, args) => {\n if (isSmartAccountWithSigner(args.account)) {\n client.updateHeaders(getSignerTypeHeader(args.account));\n }\n\n return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(client)\n : undefined,\n gasEstimator,\n ...(gasManagerConfig &&\n alchemyGasManagerMiddleware(client, {\n ...gasManagerConfig,\n gasEstimationOptions: {\n ...gasManagerConfig.gasEstimationOptions,\n disableGasEstimation:\n gasManagerConfig.gasEstimationOptions?.disableGasEstimation ??\n false,\n fallbackFeeDataGetter:\n gasManagerConfig.gasEstimationOptions?.fallbackFeeDataGetter ??\n feeEstimator,\n fallbackGasEstimator:\n gasManagerConfig.gasEstimationOptions?.fallbackGasEstimator ??\n gasEstimator,\n },\n })),\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n client.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"isAlchemySmartAccountClient.js","sourceRoot":"","sources":["../../../src/client/isAlchemySmartAccountClient.ts"],"names":[],"mappings":";;;AAAA,uCAA+E;AAIxE,MAAM,2BAA2B,GAAG,CAOzC,MAA4C,EACuB,EAAE;IAKrE,OAAO,IAAA,2BAAoB,EAAC,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAdW,QAAA,2BAA2B,+BActC","sourcesContent":["import { isSmartAccountClient, type SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport type { AlchemySmartAccountClient } from \"./smartAccountClient\";\n\nexport const isAlchemySmartAccountClient = <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n): client is AlchemySmartAccountClient<TTransport, TChain, TAccount> => {\n // TODO: the goal of this check is to make sure that the client supports certain RPC methods\n // we should probably do this by checking the client's transport and configured URL, since alchemy\n // clients have to be RPC clients. this is difficult to do though because the transport might\n // point to a proxy url :/\n return isSmartAccountClient(client);\n};\n"]}
1
+ {"version":3,"file":"isAlchemySmartAccountClient.js","sourceRoot":"","sources":["../../../src/client/isAlchemySmartAccountClient.ts"],"names":[],"mappings":";;;AAAA,uCAA+E;AAmBxE,MAAM,2BAA2B,GAAG,CAOzC,MAA4C,EACuB,EAAE;IAKrE,OAAO,IAAA,2BAAoB,EAAC,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC;AAdW,QAAA,2BAA2B,+BActC","sourcesContent":["import { isSmartAccountClient, type SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport type { AlchemySmartAccountClient } from \"./smartAccountClient\";\n\n/**\n * Checks if a given client is an Alchemy Smart Account Client. The goal of this check is to ensure that the client supports certain RPC methods.\n *\n * @example\n * ```ts\n * import { isAlchemySmartAccountClient } from \"@account-kit/infra\";\n *\n * if (isAlchemySmartAccountClient(client)) {\n * // do things with the client as an Alchemy Smart Account Client\n * }\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance to be checked\n * @returns {boolean} `true` if the client is an Alchemy Smart Account Client, otherwise `false`\n */\nexport const isAlchemySmartAccountClient = <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n): client is AlchemySmartAccountClient<TTransport, TChain, TAccount> => {\n // TODO: the goal of this check is to make sure that the client supports certain RPC methods\n // we should probably do this by checking the client's transport and configured URL, since alchemy\n // clients have to be RPC clients. this is difficult to do though because the transport might\n // point to a proxy url :/\n return isSmartAccountClient(client);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rpcClient.js","sourceRoot":"","sources":["../../../src/client/rpcClient.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AACtB,+BAAkE;AAClE,4CAAkD;AAClD,8CAAwC;AAGjC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAChB,YAAY,GAAG,EAAE,GAKlB,EAA4B,EAAE;IAC7B,MAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,MAAM,GACV,gBAAgB,CAAC,MAAM,IAAI,IAAI;QAC7B,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,MAAM,IAAI,EAAE,EAAE;QACrE,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAE9B,YAAY,CAAC,OAAO,GAAG;QACrB,GAAG,YAAY,CAAC,OAAO;QACvB,wBAAwB,EAAE,oBAAO;KAClC,CAAC;IAEF,IAAI,gBAAgB,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,YAAY,CAAC,OAAO,GAAG;YACrB,GAAG,YAAY,CAAC,OAAO;YACvB,aAAa,EAAE,UAAU,gBAAgB,CAAC,GAAG,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,0BAAmB,EAAC;QACzB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC;KAC1C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,aAAa,CAAC,UAAuB;YACnC,YAAY,CAAC,OAAO,GAAG;gBACrB,GAAG,YAAY,CAAC,OAAO;gBACvB,GAAG,UAAU;aACd,CAAC;QACJ,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAvCW,QAAA,4BAA4B,gCAuCvC","sourcesContent":["import {\n createBundlerClient,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport { http, type Chain, type HttpTransportConfig } from \"viem\";\nimport { AlchemyChainSchema } from \"../schema.js\";\nimport { VERSION } from \"../version.js\";\nimport type { ClientWithAlchemyMethods } from \"./types.js\";\n\nexport const createAlchemyPublicRpcClient = ({\n chain: chain_,\n connectionConfig,\n fetchOptions = {},\n}: {\n connectionConfig: ConnectionConfig;\n chain: Chain;\n fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>;\n}): ClientWithAlchemyMethods => {\n const chain = AlchemyChainSchema.parse(chain_);\n\n const rpcUrl =\n connectionConfig.rpcUrl == null\n ? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? \"\"}`\n : connectionConfig.rpcUrl;\n\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n\n if (connectionConfig.jwt != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt}`,\n };\n }\n\n return createBundlerClient({\n chain: chain,\n transport: http(rpcUrl, { fetchOptions }),\n }).extend(() => ({\n updateHeaders(newHeaders: HeadersInit) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n }));\n};\n"]}
1
+ {"version":3,"file":"rpcClient.js","sourceRoot":"","sources":["../../../src/client/rpcClient.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AACtB,+BAAkE;AAClE,4CAAkD;AAClD,8CAAwC;AAyBjC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAChB,YAAY,GAAG,EAAE,GAKlB,EAA4B,EAAE;IAC7B,MAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,MAAM,GACV,gBAAgB,CAAC,MAAM,IAAI,IAAI;QAC7B,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,MAAM,IAAI,EAAE,EAAE;QACrE,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAE9B,YAAY,CAAC,OAAO,GAAG;QACrB,GAAG,YAAY,CAAC,OAAO;QACvB,wBAAwB,EAAE,oBAAO;KAClC,CAAC;IAEF,IAAI,gBAAgB,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,YAAY,CAAC,OAAO,GAAG;YACrB,GAAG,YAAY,CAAC,OAAO;YACvB,aAAa,EAAE,UAAU,gBAAgB,CAAC,GAAG,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,0BAAmB,EAAC;QACzB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC;KAC1C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,aAAa,CAAC,UAAuB;YACnC,YAAY,CAAC,OAAO,GAAG;gBACrB,GAAG,YAAY,CAAC,OAAO;gBACvB,GAAG,UAAU;aACd,CAAC;QACJ,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAvCW,QAAA,4BAA4B,gCAuCvC","sourcesContent":["import {\n createBundlerClient,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport { http, type Chain, type HttpTransportConfig } from \"viem\";\nimport { AlchemyChainSchema } from \"../schema.js\";\nimport { VERSION } from \"../version.js\";\nimport type { ClientWithAlchemyMethods } from \"./types.js\";\n\n/**\n * Creates an Alchemy public RPC client with the provided chain, connection configuration, and optional fetch options. The client has alchemy methods and can dynamically update HTTP headers.\n *\n * @example\n * ```ts\n * import { createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra/chains\";\n *\n * const client = createAlchemyPublicRpcClient({\n * chain: sepolia,\n * connectionConfig: {\n * apiKey: \"your-api-key\",\n * }\n * });\n * ```\n *\n * @param {{connectionConfig: ConnectionConfig,chain: Chain,fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>}} params The parameters for creating the Alchemy public RPC client\n * @param {ConnectionConfig} params.connectionConfig The connection configuration containing the RPC URL and API key\n * @param {Chain} params.chain The blockchain chain configuration\n * @param {NoUndefined<HttpTransportConfig[\"fetchOptions\"]>} [params.fetchOptions] Optional fetch configuration for HTTP transport\n * @returns {ClientWithAlchemyMethods} A client object tailored with Alchemy methods and capabilities to interact with the blockchain\n */\nexport const createAlchemyPublicRpcClient = ({\n chain: chain_,\n connectionConfig,\n fetchOptions = {},\n}: {\n connectionConfig: ConnectionConfig;\n chain: Chain;\n fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>;\n}): ClientWithAlchemyMethods => {\n const chain = AlchemyChainSchema.parse(chain_);\n\n const rpcUrl =\n connectionConfig.rpcUrl == null\n ? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? \"\"}`\n : connectionConfig.rpcUrl;\n\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n\n if (connectionConfig.jwt != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt}`,\n };\n }\n\n return createBundlerClient({\n chain: chain,\n transport: http(rpcUrl, { fetchOptions }),\n }).extend(() => ({\n updateHeaders(newHeaders: HeadersInit) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n }));\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":";;;AAUA,gDAAmE;AAEnE,4CAA2D;AAG3D,0FAAuG;AACvG,iDAA8D;AAqG9D,SAAgB,+BAA+B,CAAC,EAC9C,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,GAAG,OAAO,EACsB;IAChC,MAAM,MAAM,GAAG,uCAA2B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAEpD,MAAM,MAAM,GAAG,IAAA,2CAA4B,EAAC;QAC1C,KAAK;QACL,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,+CAAiC,EAAC,KAAK,CAAC,CAAC;IAE/D,OAAO,IAAA,2EAA4C,EAAC;QAClD,MAAM;QACN,OAAO;QACP,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,gBAAgB;QAChB,aAAa;QACb,YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,iBAAiB;KAClB,CAAC,CAAC;AACL,CAAC;AAnCD,0EAmCC","sourcesContent":["import {\n type Prettify,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport { type Chain, type Transport } from \"viem\";\nimport { getDefaultUserOperationFeeOptions } from \"../defaults.js\";\nimport { type AlchemyGasManagerConfig } from \"../middleware/gasManager.js\";\nimport { AlchemyProviderConfigSchema } from \"../schema.js\";\nimport type { AlchemyProviderConfig } from \"../type.js\";\nimport type { AlchemySmartAccountClientActions } from \"./decorators/smartAccount.js\";\nimport { createAlchemySmartAccountClientFromRpcClient } from \"./internal/smartAccountClientFromRpc.js\";\nimport { createAlchemyPublicRpcClient } from \"./rpcClient.js\";\nimport type { AlchemyRpcSchema } from \"./types.js\";\n\n// #region AlchemySmartAccountClientConfig\nexport type AlchemySmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n account?: account;\n useSimulation?: boolean;\n gasManagerConfig?: AlchemyGasManagerConfig;\n} & AlchemyProviderConfig &\n Pick<\n SmartAccountClientConfig<transport, chain, account, context>,\n \"customMiddleware\" | \"feeEstimator\" | \"gasEstimator\" | \"signUserOperation\"\n >;\n// #endregion AlchemySmartAccountClientConfig\n\nexport type BaseAlchemyActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = SmartAccountClientActions<chain, account, context> &\n AlchemySmartAccountClientActions<account, context>;\n\nexport type AlchemySmartAccountClient_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n SmartAccountClient<\n transport,\n chain,\n account,\n actions & BaseAlchemyActions<chain, account, context>,\n [...SmartAccountClientRpcSchema, ...AlchemyRpcSchema],\n context\n >\n>;\n\nexport type AlchemySmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n AlchemySmartAccountClient_Base<transport, chain, account, actions, context>\n>;\n\nexport function createAlchemySmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>({\n account,\n gasManagerConfig,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n ...config_\n}: AlchemySmartAccountClientConfig<\n TTransport,\n TChain,\n TAccount,\n TContext\n>): AlchemySmartAccountClient<\n TTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\nexport function createAlchemySmartAccountClient({\n account,\n gasManagerConfig,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n ...config_\n}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {\n const config = AlchemyProviderConfigSchema.parse(config_);\n const { chain, opts, ...connectionConfig } = config;\n\n const client = createAlchemyPublicRpcClient({\n chain,\n connectionConfig,\n });\n\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);\n\n return createAlchemySmartAccountClientFromRpcClient({\n client,\n account,\n opts: {\n ...opts,\n feeOptions,\n },\n gasManagerConfig,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n });\n}\n"]}
1
+ {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":";;;AAUA,gDAAmE;AAEnE,4CAA2D;AAG3D,0FAAuG;AACvG,iDAA8D;AAsH9D,SAAgB,+BAA+B,CAAC,EAC9C,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,GAAG,OAAO,EACsB;IAChC,MAAM,MAAM,GAAG,uCAA2B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAEpD,MAAM,MAAM,GAAG,IAAA,2CAA4B,EAAC;QAC1C,KAAK;QACL,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,+CAAiC,EAAC,KAAK,CAAC,CAAC;IAE/D,OAAO,IAAA,2EAA4C,EAAC;QAClD,MAAM;QACN,OAAO;QACP,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,gBAAgB;QAChB,aAAa;QACb,YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,iBAAiB;KAClB,CAAC,CAAC;AACL,CAAC;AAnCD,0EAmCC","sourcesContent":["import {\n type Prettify,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport { type Chain, type Transport } from \"viem\";\nimport { getDefaultUserOperationFeeOptions } from \"../defaults.js\";\nimport { type AlchemyGasManagerConfig } from \"../middleware/gasManager.js\";\nimport { AlchemyProviderConfigSchema } from \"../schema.js\";\nimport type { AlchemyProviderConfig } from \"../type.js\";\nimport type { AlchemySmartAccountClientActions } from \"./decorators/smartAccount.js\";\nimport { createAlchemySmartAccountClientFromRpcClient } from \"./internal/smartAccountClientFromRpc.js\";\nimport { createAlchemyPublicRpcClient } from \"./rpcClient.js\";\nimport type { AlchemyRpcSchema } from \"./types.js\";\n\n// #region AlchemySmartAccountClientConfig\nexport type AlchemySmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n account?: account;\n useSimulation?: boolean;\n gasManagerConfig?: AlchemyGasManagerConfig;\n} & AlchemyProviderConfig &\n Pick<\n SmartAccountClientConfig<transport, chain, account, context>,\n \"customMiddleware\" | \"feeEstimator\" | \"gasEstimator\" | \"signUserOperation\"\n >;\n// #endregion AlchemySmartAccountClientConfig\n\nexport type BaseAlchemyActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = SmartAccountClientActions<chain, account, context> &\n AlchemySmartAccountClientActions<account, context>;\n\nexport type AlchemySmartAccountClient_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n SmartAccountClient<\n transport,\n chain,\n account,\n actions & BaseAlchemyActions<chain, account, context>,\n [...SmartAccountClientRpcSchema, ...AlchemyRpcSchema],\n context\n >\n>;\n\nexport type AlchemySmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n AlchemySmartAccountClient_Base<transport, chain, account, actions, context>\n>;\n\nexport function createAlchemySmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>({\n account,\n gasManagerConfig,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n ...config_\n}: AlchemySmartAccountClientConfig<\n TTransport,\n TChain,\n TAccount,\n TContext\n>): AlchemySmartAccountClient<\n TTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an Alchemy smart account client using the provided configuration options, including account details, gas manager configuration, and custom middleware.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra/chain\";\n *\n * const client = createAlchemySmartAccountClient({\n * chain: sepolia,\n * apiKey: \"your-api-key\",\n * });\n * ```\n *\n * @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client\n * @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options\n */\nexport function createAlchemySmartAccountClient({\n account,\n gasManagerConfig,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n ...config_\n}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {\n const config = AlchemyProviderConfigSchema.parse(config_);\n const { chain, opts, ...connectionConfig } = config;\n\n const client = createAlchemyPublicRpcClient({\n chain,\n connectionConfig,\n });\n\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);\n\n return createAlchemySmartAccountClientFromRpcClient({\n client,\n account,\n opts: {\n ...opts,\n feeOptions,\n },\n gasManagerConfig,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";;;AAAA,uCAQsB;AAGf,MAAM,iCAAiC,GAAG,CAC/C,KAAY,EACa,EAAE;IAC3B,MAAM,UAAU,GAA4B;QAC1C,YAAY,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE;QACjC,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF,IACE,IAAI,GAAG,CAAS;QACd,eAAQ,CAAC,EAAE;QACX,qBAAc,CAAC,EAAE;QACjB,sBAAe,CAAC,EAAE;QAClB,eAAQ,CAAC,EAAE;QACX,qBAAc,CAAC,EAAE;QACjB,sBAAe,CAAC,EAAE;KACnB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAChB,CAAC;QACD,UAAU,CAAC,kBAAkB,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAtBW,QAAA,iCAAiC,qCAsB5C","sourcesContent":["import {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n optimism,\n optimismGoerli,\n optimismSepolia,\n type UserOperationFeeOptions,\n} from \"@aa-sdk/core\";\nimport type { Chain } from \"viem\";\n\nexport const getDefaultUserOperationFeeOptions = (\n chain: Chain\n): UserOperationFeeOptions => {\n const feeOptions: UserOperationFeeOptions = {\n maxFeePerGas: { multiplier: 1.5 },\n maxPriorityFeePerGas: { multiplier: 1.05 },\n };\n\n if (\n new Set<number>([\n arbitrum.id,\n arbitrumGoerli.id,\n arbitrumSepolia.id,\n optimism.id,\n optimismGoerli.id,\n optimismSepolia.id,\n ]).has(chain.id)\n ) {\n feeOptions.preVerificationGas = { multiplier: 1.05 };\n }\n\n return feeOptions;\n};\n"]}
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";;;AAAA,uCAQsB;AAiBf,MAAM,iCAAiC,GAAG,CAC/C,KAAY,EACa,EAAE;IAC3B,MAAM,UAAU,GAA4B;QAC1C,YAAY,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE;QACjC,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF,IACE,IAAI,GAAG,CAAS;QACd,eAAQ,CAAC,EAAE;QACX,qBAAc,CAAC,EAAE;QACjB,sBAAe,CAAC,EAAE;QAClB,eAAQ,CAAC,EAAE;QACX,qBAAc,CAAC,EAAE;QACjB,sBAAe,CAAC,EAAE;KACnB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAChB,CAAC;QACD,UAAU,CAAC,kBAAkB,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAtBW,QAAA,iCAAiC,qCAsB5C","sourcesContent":["import {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n optimism,\n optimismGoerli,\n optimismSepolia,\n type UserOperationFeeOptions,\n} from \"@aa-sdk/core\";\nimport type { Chain } from \"viem\";\n\n/**\n * Retrieves the default user operation fee options for a given chain. Adjusts fees for specific chains like Arbitrum and Optimism.\n *\n * @example\n * ```ts\n * import { getDefaultUserOperationFeeOptions } from \"@account-kit/infra\";\n * import { arbitrum } from \"@account-kit/infra/chains\";\n *\n * const feeOpts = getDefaultUserOperationFeeOptions(arbitrum);\n * ```\n *\n * @param {Chain} chain The blockchain chain for which to get the fee options\n * @returns {UserOperationFeeOptions} An object containing the default fee options for user operations on the specified chain\n */\nexport const getDefaultUserOperationFeeOptions = (\n chain: Chain\n): UserOperationFeeOptions => {\n const feeOptions: UserOperationFeeOptions = {\n maxFeePerGas: { multiplier: 1.5 },\n maxPriorityFeePerGas: { multiplier: 1.05 },\n };\n\n if (\n new Set<number>([\n arbitrum.id,\n arbitrumGoerli.id,\n arbitrumSepolia.id,\n optimism.id,\n optimismGoerli.id,\n optimismSepolia.id,\n ]).has(chain.id)\n ) {\n feeOptions.preVerificationGas = { multiplier: 1.05 };\n }\n\n return feeOptions;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"gas-manager.js","sourceRoot":"","sources":["../../src/gas-manager.ts"],"names":[],"mappings":";;;AACA,uCAgBsB;AAET,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,0BAA0B,GACrC,4CAA4C,CAAC;AAClC,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAExC,MAAM,0BAA0B,GAAG,CAAC,KAAY,EAAW,EAAE;IAClE,QAAQ,KAAK,CAAC,EAAE,EAAE,CAAC;QACjB,KAAK,kBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,sBAAe,CAAC,EAAE,CAAC;QACxB,KAAK,kBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,WAAI,CAAC,EAAE,CAAC;QACb,KAAK,kBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,qBAAc,CAAC,EAAE;YACpB,OAAO,iCAAyB,CAAC;QACnC,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,eAAQ,CAAC,EAAE,CAAC;QACjB,KAAK,eAAQ,CAAC,EAAE,CAAC;QACjB,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,WAAI,CAAC,EAAE;YACV,OAAO,iCAAyB,CAAC;QACnC,KAAK,sBAAe,CAAC,EAAE;YACrB,OAAO,kCAA0B,CAAC;QACpC,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,oBAAa,CAAC,EAAE;YACnB,OAAO,iCAAyB,CAAC;QACnC;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,0BAA0B,8BAwBrC","sourcesContent":["import type { Address, Chain } from \"viem\";\nimport {\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n mainnet,\n sepolia,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n fraxtal,\n fraxtalSepolia,\n zora,\n zoraSepolia,\n} from \"@aa-sdk/core\";\n\nexport const AlchemyPaymasterAddressV3 =\n \"0x4f84a207A80c39E9e8BaE717c1F25bA7AD1fB08F\";\nexport const AlchemyPaymasterAddressV2 =\n \"0x4Fd9098af9ddcB41DA48A1d78F91F1398965addc\";\nexport const ArbSepoliaPaymasterAddress =\n \"0x0804Afe6EEFb73ce7F93CD0d5e7079a5a8068592\";\nexport const AlchemyPaymasterAddressV1 =\n \"0xc03aac639bb21233e0139381970328db8bceeb67\";\n\nexport const getAlchemyPaymasterAddress = (chain: Chain): Address => {\n switch (chain.id) {\n case polygonAmoy.id:\n case optimismSepolia.id:\n case baseSepolia.id:\n case zora.id:\n case zoraSepolia.id:\n case fraxtal.id:\n case fraxtalSepolia.id:\n return AlchemyPaymasterAddressV3;\n case mainnet.id:\n case arbitrum.id:\n case optimism.id:\n case polygon.id:\n case base.id:\n return AlchemyPaymasterAddressV2;\n case arbitrumSepolia.id:\n return ArbSepoliaPaymasterAddress;\n case sepolia.id:\n case polygonMumbai.id:\n return AlchemyPaymasterAddressV1;\n default:\n throw new Error(`Unsupported chain: ${chain}`);\n }\n};\n"]}
1
+ {"version":3,"file":"gas-manager.js","sourceRoot":"","sources":["../../src/gas-manager.ts"],"names":[],"mappings":";;;AAAA,uCAgBsB;AAGT,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,0BAA0B,GACrC,4CAA4C,CAAC;AAClC,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAexC,MAAM,0BAA0B,GAAG,CAAC,KAAY,EAAW,EAAE;IAClE,QAAQ,KAAK,CAAC,EAAE,EAAE,CAAC;QACjB,KAAK,kBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,sBAAe,CAAC,EAAE,CAAC;QACxB,KAAK,kBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,WAAI,CAAC,EAAE,CAAC;QACb,KAAK,kBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,qBAAc,CAAC,EAAE;YACpB,OAAO,iCAAyB,CAAC;QACnC,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,eAAQ,CAAC,EAAE,CAAC;QACjB,KAAK,eAAQ,CAAC,EAAE,CAAC;QACjB,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,WAAI,CAAC,EAAE;YACV,OAAO,iCAAyB,CAAC;QACnC,KAAK,sBAAe,CAAC,EAAE;YACrB,OAAO,kCAA0B,CAAC;QACpC,KAAK,cAAO,CAAC,EAAE,CAAC;QAChB,KAAK,oBAAa,CAAC,EAAE;YACnB,OAAO,iCAAyB,CAAC;QACnC;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,0BAA0B,8BAwBrC","sourcesContent":["import {\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n fraxtal,\n fraxtalSepolia,\n mainnet,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n} from \"@aa-sdk/core\";\nimport type { Address, Chain } from \"viem\";\n\nexport const AlchemyPaymasterAddressV3 =\n \"0x4f84a207A80c39E9e8BaE717c1F25bA7AD1fB08F\";\nexport const AlchemyPaymasterAddressV2 =\n \"0x4Fd9098af9ddcB41DA48A1d78F91F1398965addc\";\nexport const ArbSepoliaPaymasterAddress =\n \"0x0804Afe6EEFb73ce7F93CD0d5e7079a5a8068592\";\nexport const AlchemyPaymasterAddressV1 =\n \"0xc03aac639bb21233e0139381970328db8bceeb67\";\n\n/**\n * Retrieves the Alchemy paymaster address for the given chain. Returns different addresses based on the chain ID.\n *\n * @example\n * ```ts\n * import { sepolia, getAlchemyPaymasterAddress } from \"@account-kit/infra/chains\";\n *\n * const paymasterAddress = getAlchemyPaymasterAddress(sepolia);\n * ```\n *\n * @param {Chain} chain The chain for which the paymaster address is required\n * @returns {Address} The Alchemy paymaster address corresponding to the specified chain\n */\nexport const getAlchemyPaymasterAddress = (chain: Chain): Address => {\n switch (chain.id) {\n case polygonAmoy.id:\n case optimismSepolia.id:\n case baseSepolia.id:\n case zora.id:\n case zoraSepolia.id:\n case fraxtal.id:\n case fraxtalSepolia.id:\n return AlchemyPaymasterAddressV3;\n case mainnet.id:\n case arbitrum.id:\n case optimism.id:\n case polygon.id:\n case base.id:\n return AlchemyPaymasterAddressV2;\n case arbitrumSepolia.id:\n return ArbSepoliaPaymasterAddress;\n case sepolia.id:\n case polygonMumbai.id:\n return AlchemyPaymasterAddressV1;\n default:\n throw new Error(`Unsupported chain: ${chain}`);\n }\n};\n"]}
@@ -1,6 +1,7 @@
1
1
  export type * from "./actions/simulateUserOperationChanges.js";
2
2
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
3
3
  export type * from "./actions/types.js";
4
+ export type * from "./chains.js";
4
5
  export { defineAlchemyChain } from "./chains.js";
5
6
  export type * from "./client/decorators/alchemyEnhancedApis.js";
6
7
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6FAAyF;AAAhF,+IAAA,4BAA4B,OAAA;AAErC,yCAAiD;AAAxC,+GAAA,kBAAkB,OAAA;AAE3B,qFAAuF;AAA9E,mIAAA,yBAAyB,OAAA;AAElC,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,+FAA6J;AAApJ,2JAAA,4CAA4C,OAA+C;AACpG,0FAAsF;AAA7E,6IAAA,2BAA2B,OAAA;AAEpC,sDAAqE;AAA5D,4HAAA,4BAA4B,OAAA;AAErC,wEAAiF;AAAxE,wIAAA,+BAA+B,OAAA;AAExC,6CAAkE;AAAzD,gIAAA,iCAAiC,OAAA;AAC1C,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AACnC,gEAAmE;AAA1D,sHAAA,mBAAmB,OAAA;AAE5B,4DAAyE;AAAhE,4HAAA,2BAA2B,OAAA;AACpC,oFAAuF;AAA9E,0IAAA,6BAA6B,OAAA;AAEtC,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport { defineAlchemyChain } from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6FAAyF;AAAhF,+IAAA,4BAA4B,OAAA;AAGrC,yCAAiD;AAAxC,+GAAA,kBAAkB,OAAA;AAE3B,qFAAuF;AAA9E,mIAAA,yBAAyB,OAAA;AAElC,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,+FAA6J;AAApJ,2JAAA,4CAA4C,OAA+C;AACpG,0FAAsF;AAA7E,6IAAA,2BAA2B,OAAA;AAEpC,sDAAqE;AAA5D,4HAAA,4BAA4B,OAAA;AAErC,wEAAiF;AAAxE,wIAAA,+BAA+B,OAAA;AAExC,6CAAkE;AAAzD,gIAAA,iCAAiC,OAAA;AAC1C,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AACnC,gEAAmE;AAA1D,sHAAA,mBAAmB,OAAA;AAE5B,4DAAyE;AAAhE,4HAAA,2BAA2B,OAAA;AACpC,oFAAuF;AAA9E,0IAAA,6BAA6B,OAAA;AAEtC,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./chains.js\";\nexport { defineAlchemyChain } from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"feeEstimator.js","sourceRoot":"","sources":["../../../src/middleware/feeEstimator.ts"],"names":[],"mappings":";;;AACA,uCAA8D;AAGvD,MAAM,mBAAmB,GAG9B,CAAC,MAAM,EAAE,EAAE,CACX,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE;IAC1C,IAAI,CAAC,KAAK,EAAE,4BAA4B,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5D,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QAEvC,MAAM,CAAC,OAAO,CAAC;YACb,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,EAAE;SACX,CAAC;KACH,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,oBAAoB,GAAG,IAAA,qCAA8B,EACzD,4BAA4B,EAC5B,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,oBAAoB,CACjC,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,qCAA8B,EACjD,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC,EAC5C,SAAS,EAAE,YAAY,EACvB,UAAU,EAAE,YAAY,CACzB,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAnCS,QAAA,mBAAmB,uBAmC5B","sourcesContent":["import type { ClientMiddlewareFn } from \"@aa-sdk/core\";\nimport { applyUserOpOverrideOrFeeOption } from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\nexport const alchemyFeeEstimator: <C extends ClientWithAlchemyMethods>(\n client: C\n) => ClientMiddlewareFn =\n (client) =>\n async (struct, { overrides, feeOptions }) => {\n let [block, maxPriorityFeePerGasEstimate] = await Promise.all([\n client.getBlock({ blockTag: \"latest\" }),\n // it is a fair assumption that if someone is using this Alchemy Middleware, then they are using Alchemy RPC\n client.request({\n method: \"rundler_maxPriorityFeePerGas\",\n params: [],\n }),\n ]);\n\n const baseFeePerGas = block.baseFeePerGas;\n if (baseFeePerGas == null) {\n throw new Error(\"baseFeePerGas is null\");\n }\n\n const maxPriorityFeePerGas = applyUserOpOverrideOrFeeOption(\n maxPriorityFeePerGasEstimate,\n overrides?.maxPriorityFeePerGas,\n feeOptions?.maxPriorityFeePerGas\n );\n const maxFeePerGas = applyUserOpOverrideOrFeeOption(\n baseFeePerGas + BigInt(maxPriorityFeePerGas),\n overrides?.maxFeePerGas,\n feeOptions?.maxFeePerGas\n );\n\n return {\n ...struct,\n maxPriorityFeePerGas,\n maxFeePerGas,\n };\n };\n"]}
1
+ {"version":3,"file":"feeEstimator.js","sourceRoot":"","sources":["../../../src/middleware/feeEstimator.ts"],"names":[],"mappings":";;;AACA,uCAA8D;AAsBvD,MAAM,mBAAmB,GAG9B,CAAC,MAAM,EAAE,EAAE,CACX,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE;IAC1C,IAAI,CAAC,KAAK,EAAE,4BAA4B,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5D,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QAEvC,MAAM,CAAC,OAAO,CAAC;YACb,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,EAAE;SACX,CAAC;KACH,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,oBAAoB,GAAG,IAAA,qCAA8B,EACzD,4BAA4B,EAC5B,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,oBAAoB,CACjC,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,qCAA8B,EACjD,aAAa,GAAG,MAAM,CAAC,oBAAoB,CAAC,EAC5C,SAAS,EAAE,YAAY,EACvB,UAAU,EAAE,YAAY,CACzB,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,YAAY;KACb,CAAC;AACJ,CAAC,CAAC;AAnCS,QAAA,mBAAmB,uBAmC5B","sourcesContent":["import type { ClientMiddlewareFn } from \"@aa-sdk/core\";\nimport { applyUserOpOverrideOrFeeOption } from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * Function that estimates the transaction fees using Alchemy methods for a given client.\n * It fetches the latest block and estimates the max priority fee per gas, applying any overrides or fee options provided.\n *\n * @example\n * ```ts\n * import { alchemyFeeEstimator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * feeEstimator: alchemyFeeEstimator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @param {ClientWithAlchemyMethods} client The client with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function that takes a transaction structure and fee options, and returns the augmented structure with estimated fees\n */\nexport const alchemyFeeEstimator: <C extends ClientWithAlchemyMethods>(\n client: C\n) => ClientMiddlewareFn =\n (client) =>\n async (struct, { overrides, feeOptions }) => {\n let [block, maxPriorityFeePerGasEstimate] = await Promise.all([\n client.getBlock({ blockTag: \"latest\" }),\n // it is a fair assumption that if someone is using this Alchemy Middleware, then they are using Alchemy RPC\n client.request({\n method: \"rundler_maxPriorityFeePerGas\",\n params: [],\n }),\n ]);\n\n const baseFeePerGas = block.baseFeePerGas;\n if (baseFeePerGas == null) {\n throw new Error(\"baseFeePerGas is null\");\n }\n\n const maxPriorityFeePerGas = applyUserOpOverrideOrFeeOption(\n maxPriorityFeePerGasEstimate,\n overrides?.maxPriorityFeePerGas,\n feeOptions?.maxPriorityFeePerGas\n );\n const maxFeePerGas = applyUserOpOverrideOrFeeOption(\n baseFeePerGas + BigInt(maxPriorityFeePerGas),\n overrides?.maxFeePerGas,\n feeOptions?.maxFeePerGas\n );\n\n return {\n ...struct,\n maxPriorityFeePerGas,\n maxFeePerGas,\n };\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":";;;AAUA,uCAQsB;AACtB,+BAAwD;AAExD,sDAA+D;AAC/D,uDAAwD;AAoIxD,MAAM,qBAAqB,GACzB,CACE,MAAS,EACT,MAA+B,EAC/B,EAAE,CACJ,GAAG,EAAE;IACH,MAAM,SAAS,GACb,MAAM,CAAC,gBAAgB,IAAI,IAAA,2CAA0B,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,aAAa,GACjB,MAAM,CAAC,SAAS;QAChB,sMAAsM,CAAC;IAEzM,OAAO,IAAA,aAAM,EAAC,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAUJ,SAAgB,2BAA2B,CACzC,MAAS,EACT,MAA+B;IAK/B,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;IACzD,MAAM,oBAAoB,GACxB,oBAAoB,EAAE,oBAA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C;YACH,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;gBAClC,MAAM,EAAE,uCAAuC;gBAC/C,MAAM,EAAE;oBACN;wBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;wBAC3C,aAAa;wBACb,cAAc,EAAE,aAAa,CAAC,SAAS;wBACvC,SAAS;qBACV;iBACF;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,MAAM;gBACT,GAAG,MAAM;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAWD,MAAM,uBAAuB,GAGqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACrE,qBAAqB,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,EAAE,iCAAiC;YACzC,MAAM,EAAE;gBACN;oBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;oBAC3C,aAAa,EAAE,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * dummy paymaster and data middleware for the alchemy gas manager\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ) =>\n () => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return concat([paymaster, paymasterData]); // or you can also return { paymaster, paymasterData }\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n paymasterAndData: disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param field the field to override\n * @param overrides the overrides object\n * @param feeOptions the fee options object from the client\n * @param userOperation the user operation request\n * @returns the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): ClientMiddlewareConfig[\"paymasterAndData\"] {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => ClientMiddlewareConfig[\"paymasterAndData\"] = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
1
+ {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":";;;AAUA,uCAQsB;AACtB,+BAAwD;AAExD,sDAA+D;AAC/D,uDAAwD;AAoIxD,MAAM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,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;oBAC3C,aAAa,EAAE,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * Dummy paymaster and data middleware for the alchemy gas manager\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ) =>\n () => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return concat([paymaster, paymasterData]); // or you can also return { paymaster, paymasterData }\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n paymasterAndData: disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param field the field to override\n * @param overrides the overrides object\n * @param feeOptions the fee options object from the client\n * @param userOperation the user operation request\n * @returns the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): ClientMiddlewareConfig[\"paymasterAndData\"] {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => ClientMiddlewareConfig[\"paymasterAndData\"] = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AAGtB,SAAgB,6BAA6B,CAE3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAlBD,sEAkBC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods\n>(client: C): ClientMiddlewareFn {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
1
+ {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AAsBtB,SAAgB,6BAA6B,CAE3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAlBD,sEAkBC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.\n *\n * @example\n * ```ts\n * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template C The client object with Alchemy methods\n * @param {C} client The client object with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods\n>(client: C): ClientMiddlewareFn {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.0.0-alpha.0";
1
+ export declare const VERSION = "4.0.0-alpha.1";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "4.0.0-alpha.0";
4
+ exports.VERSION = "4.0.0-alpha.1";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.0.0-alpha.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAEa,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.0.0-alpha.1\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"simulateUserOperationChanges.js","sourceRoot":"","sources":["../../../src/actions/simulateUserOperationChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAIvF,MAAM,CAAC,MAAM,4BAA4B,GAQiB,KAAK,EAC7D,MAAM,EACN,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,EAAE;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,uBAAuB,CAC/B,2BAA2B,EAC3B,mCAAmC,EACnC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAC1B,MAAM,MAAM,CAAC,kBAAkB,CAAC;QAC9B,GAAG,MAAM;QACT,OAAO;QACP,SAAS;KACV,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,2CAA2C;QACnD,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC;KACpD,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n deepHexlify,\n type SendUserOperationParameters,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport { isAlchemySmartAccountClient } from \"../client/isAlchemySmartAccountClient.js\";\nimport type { AlchemyRpcSchema } from \"../client/types.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"./types.js\";\n\nexport const simulateUserOperationChanges: <\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<Transport, TChain, TAccount, AlchemyRpcSchema>,\n args: SendUserOperationParameters<TAccount>\n) => Promise<SimulateUserOperationAssetChangesResponse> = async (\n client,\n { account = client.account, overrides, ...params }\n) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isAlchemySmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"AlchemySmartAccountClient\",\n \"SimulateUserOperationAssetChanges\",\n client\n );\n }\n\n const uoStruct = deepHexlify(\n await client.buildUserOperation({\n ...params,\n account,\n overrides,\n })\n );\n\n return client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [uoStruct, account.getEntryPoint().address],\n });\n};\n"]}
1
+ {"version":3,"file":"simulateUserOperationChanges.js","sourceRoot":"","sources":["../../../src/actions/simulateUserOperationChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,GAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAqBvF,MAAM,CAAC,MAAM,4BAA4B,GAQiB,KAAK,EAC7D,MAAM,EACN,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAClD,EAAE;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,uBAAuB,CAC/B,2BAA2B,EAC3B,mCAAmC,EACnC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAC1B,MAAM,MAAM,CAAC,kBAAkB,CAAC;QAC9B,GAAG,MAAM;QACT,OAAO;QACP,SAAS;KACV,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,2CAA2C;QACnD,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC;KACpD,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n deepHexlify,\n type SendUserOperationParameters,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport { isAlchemySmartAccountClient } from \"../client/isAlchemySmartAccountClient.js\";\nimport type { AlchemyRpcSchema } from \"../client/types.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"./types.js\";\n\n/**\n * Simulates user operation changes including asset changes for a specified user operation and returns the resulting state changes.\n *\n * @example\n * ```ts\n * import { simulateUserOperationChanges, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient(...);\n * const response = await simulateUserOperationChanges(client, {\n * uo: ...\n * });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount, AlchemyRpcSchema>} client The client instance used to send the simulation request\n * @param {SendUserOperationParameters<TAccount>} args The parameters of the user operation including the account and other overrides\n * @returns {Promise<SimulateUserOperationAssetChangesResponse>} A promise that resolves to the response of the simulation showing the asset changes\n */\nexport const simulateUserOperationChanges: <\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<Transport, TChain, TAccount, AlchemyRpcSchema>,\n args: SendUserOperationParameters<TAccount>\n) => Promise<SimulateUserOperationAssetChangesResponse> = async (\n client,\n { account = client.account, overrides, ...params }\n) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isAlchemySmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"AlchemySmartAccountClient\",\n \"SimulateUserOperationAssetChanges\",\n client\n );\n }\n\n const uoStruct = deepHexlify(\n await client.buildUserOperation({\n ...params,\n account,\n overrides,\n })\n );\n\n return client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [uoStruct, account.getEntryPoint().address],\n });\n};\n"]}
@@ -1,4 +1,8 @@
1
1
  import type { Chain } from "viem";
2
+ export type AlchemyChainConfig = {
3
+ chain: Chain;
4
+ rpcBaseUrl: string;
5
+ };
2
6
  export declare const defineAlchemyChain: ({ chain, rpcBaseUrl, }: {
3
7
  chain: Chain;
4
8
  rpcBaseUrl: string;
@@ -1 +1 @@
1
- {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,UAAU,GAIX,EAAS,EAAE;IACV,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO;YAChB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,UAAU,CAAC;aACnB;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nexport const defineAlchemyChain = ({\n chain,\n rpcBaseUrl,\n}: {\n chain: Chain;\n rpcBaseUrl: string;\n}): Chain => {\n return {\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n alchemy: {\n http: [rpcBaseUrl],\n },\n },\n };\n};\n"]}
1
+ {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,UAAU,GAIX,EAAS,EAAE;IACV,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO;YAChB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,UAAU,CAAC;aACnB;SACF;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\n */\nexport const defineAlchemyChain = ({\n chain,\n rpcBaseUrl,\n}: {\n chain: Chain;\n rpcBaseUrl: string;\n}): Chain => {\n return {\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n alchemy: {\n http: [rpcBaseUrl],\n },\n },\n };\n};\n"]}