@account-kit/infra 4.0.0-beta.7 → 4.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/esm/alchemyTransport.d.ts +69 -0
  2. package/dist/esm/alchemyTransport.js +139 -0
  3. package/dist/esm/alchemyTransport.js.map +1 -0
  4. package/dist/esm/chains.d.ts +1 -0
  5. package/dist/esm/chains.js +17 -0
  6. package/dist/esm/chains.js.map +1 -1
  7. package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +2 -2
  8. package/dist/esm/client/decorators/alchemyEnhancedApis.js +3 -7
  9. package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -1
  10. package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1 -1
  11. package/dist/esm/client/isAlchemySmartAccountClient.js +2 -6
  12. package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
  13. package/dist/esm/client/rpcClient.d.ts +9 -10
  14. package/dist/esm/client/rpcClient.js +9 -33
  15. package/dist/esm/client/rpcClient.js.map +1 -1
  16. package/dist/esm/client/smartAccountClient.d.ts +12 -9
  17. package/dist/esm/client/smartAccountClient.js +34 -20
  18. package/dist/esm/client/smartAccountClient.js.map +1 -1
  19. package/dist/esm/client/types.d.ts +8 -7
  20. package/dist/esm/client/types.js.map +1 -1
  21. package/dist/esm/index.d.ts +3 -4
  22. package/dist/esm/index.js +2 -3
  23. package/dist/esm/index.js.map +1 -1
  24. package/dist/esm/middleware/feeEstimator.d.ts +10 -6
  25. package/dist/esm/middleware/feeEstimator.js +11 -6
  26. package/dist/esm/middleware/feeEstimator.js.map +1 -1
  27. package/dist/esm/middleware/gasManager.d.ts +5 -6
  28. package/dist/esm/middleware/gasManager.js +5 -6
  29. package/dist/esm/middleware/gasManager.js.map +1 -1
  30. package/dist/esm/middleware/userOperationSimulator.d.ts +11 -7
  31. package/dist/esm/middleware/userOperationSimulator.js +12 -8
  32. package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
  33. package/dist/esm/schema.d.ts +0 -391
  34. package/dist/esm/schema.js +1 -5
  35. package/dist/esm/schema.js.map +1 -1
  36. package/dist/esm/version.d.ts +1 -1
  37. package/dist/esm/version.js +1 -1
  38. package/dist/esm/version.js.map +1 -1
  39. package/dist/types/alchemyTransport.d.ts +70 -0
  40. package/dist/types/alchemyTransport.d.ts.map +1 -0
  41. package/dist/types/chains.d.ts +1 -0
  42. package/dist/types/chains.d.ts.map +1 -1
  43. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +2 -2
  44. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
  45. package/dist/types/client/isAlchemySmartAccountClient.d.ts +1 -1
  46. package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
  47. package/dist/types/client/rpcClient.d.ts +9 -10
  48. package/dist/types/client/rpcClient.d.ts.map +1 -1
  49. package/dist/types/client/smartAccountClient.d.ts +12 -9
  50. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  51. package/dist/types/client/types.d.ts +8 -7
  52. package/dist/types/client/types.d.ts.map +1 -1
  53. package/dist/types/index.d.ts +3 -4
  54. package/dist/types/index.d.ts.map +1 -1
  55. package/dist/types/middleware/feeEstimator.d.ts +10 -6
  56. package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
  57. package/dist/types/middleware/gasManager.d.ts +5 -6
  58. package/dist/types/middleware/gasManager.d.ts.map +1 -1
  59. package/dist/types/middleware/userOperationSimulator.d.ts +11 -7
  60. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
  61. package/dist/types/schema.d.ts +0 -391
  62. package/dist/types/schema.d.ts.map +1 -1
  63. package/dist/types/version.d.ts +1 -1
  64. package/package.json +3 -3
  65. package/src/alchemyTransport.ts +214 -0
  66. package/src/chains.ts +18 -0
  67. package/src/client/decorators/alchemyEnhancedApis.ts +9 -16
  68. package/src/client/isAlchemySmartAccountClient.ts +4 -9
  69. package/src/client/rpcClient.ts +14 -47
  70. package/src/client/smartAccountClient.ts +64 -57
  71. package/src/client/types.ts +10 -7
  72. package/src/index.ts +3 -3
  73. package/src/middleware/feeEstimator.ts +15 -10
  74. package/src/middleware/gasManager.ts +5 -6
  75. package/src/middleware/userOperationSimulator.ts +13 -10
  76. package/src/schema.ts +1 -14
  77. package/src/version.ts +1 -1
  78. package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +0 -18
  79. package/dist/esm/client/internal/smartAccountClientFromRpc.js +0 -56
  80. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +0 -1
  81. package/dist/esm/type.d.ts +0 -3
  82. package/dist/esm/type.js +0 -2
  83. package/dist/esm/type.js.map +0 -1
  84. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +0 -19
  85. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +0 -1
  86. package/dist/types/type.d.ts +0 -4
  87. package/dist/types/type.d.ts.map +0 -1
  88. package/src/client/internal/smartAccountClientFromRpc.ts +0 -125
  89. package/src/type.ts +0 -4
@@ -1,47 +1,61 @@
1
- import {} from "@aa-sdk/core";
1
+ import { ChainNotFoundError, createSmartAccountClient, isSmartAccountWithSigner, } from "@aa-sdk/core";
2
2
  import {} from "viem";
3
3
  import { getDefaultUserOperationFeeOptions } from "../defaults.js";
4
- import { AlchemyProviderConfigSchema } from "../schema.js";
5
- import { createAlchemySmartAccountClientFromRpcClient } from "./internal/smartAccountClientFromRpc.js";
6
- import { createAlchemyPublicRpcClient } from "./rpcClient.js";
4
+ import { alchemyFeeEstimator } from "../middleware/feeEstimator.js";
5
+ import { alchemyGasManagerMiddleware } from "../middleware/gasManager.js";
6
+ import { alchemyUserOperationSimulator } from "../middleware/userOperationSimulator.js";
7
+ import { alchemyActions, } from "./decorators/smartAccount.js";
8
+ export function getSignerTypeHeader(account) {
9
+ return { "Alchemy-Aa-Sdk-Signer": account.getSigner().signerType };
10
+ }
7
11
  /**
8
12
  * Creates an Alchemy smart account client using the provided configuration options, including account details, gas manager configuration, and custom middleware.
9
13
  *
10
14
  * @example
11
15
  * ```ts
12
- * import { createAlchemySmartAccountClient } from "@account-kit/infra";
16
+ * import { createAlchemySmartAccountClient, alchemy } from "@account-kit/infra";
13
17
  * import { sepolia } from "@account-kit/infra/chain";
14
18
  *
15
19
  * const client = createAlchemySmartAccountClient({
16
20
  * chain: sepolia,
17
- * apiKey: "your-api-key",
21
+ * transport: alchemy({ apiKey: "your-api-key" }),
18
22
  * });
19
23
  * ```
20
24
  *
21
25
  * @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client
22
26
  * @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options
23
27
  */
24
- export function createAlchemySmartAccountClient({ account, policyId, useSimulation, feeEstimator, customMiddleware, gasEstimator, signUserOperation, ...config_ }) {
25
- const config = AlchemyProviderConfigSchema.parse(config_);
26
- const { chain, opts, ...connectionConfig } = config;
27
- const client = createAlchemyPublicRpcClient({
28
- chain,
29
- connectionConfig,
30
- });
28
+ export function createAlchemySmartAccountClient({ account, policyId, useSimulation, feeEstimator, customMiddleware, gasEstimator, signUserOperation, transport, chain, opts, }) {
29
+ if (!chain) {
30
+ throw new ChainNotFoundError();
31
+ }
31
32
  const feeOptions = opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);
32
- return createAlchemySmartAccountClientFromRpcClient({
33
- client,
33
+ const scaClient = createSmartAccountClient({
34
34
  account,
35
+ transport,
36
+ chain,
37
+ type: "AlchemySmartAccountClient",
35
38
  opts: {
36
39
  ...opts,
37
40
  feeOptions,
38
41
  },
39
- policyId,
40
- useSimulation,
41
- feeEstimator,
42
- customMiddleware,
42
+ customMiddleware: async (struct, args) => {
43
+ if (isSmartAccountWithSigner(args.account)) {
44
+ transport.updateHeaders(getSignerTypeHeader(args.account));
45
+ }
46
+ return customMiddleware ? customMiddleware(struct, args) : struct;
47
+ },
48
+ feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),
49
+ userOperationSimulator: useSimulation
50
+ ? alchemyUserOperationSimulator(transport)
51
+ : undefined,
43
52
  gasEstimator,
53
+ ...(policyId && alchemyGasManagerMiddleware(policyId)),
44
54
  signUserOperation,
45
- });
55
+ }).extend(alchemyActions);
56
+ if (account && isSmartAccountWithSigner(account)) {
57
+ transport.updateHeaders(getSignerTypeHeader(account));
58
+ }
59
+ return scaClient;
46
60
  }
47
61
  //# sourceMappingURL=smartAccountClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAG3D,OAAO,EAAE,4CAA4C,EAAE,MAAM,yCAAyC,CAAC;AACvG,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAqG9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,+BAA+B,CAAC,EAC9C,OAAO,EACP,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,GAAG,OAAO,EACsB;IAChC,MAAM,MAAM,GAAG,2BAA2B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAEpD,MAAM,MAAM,GAAG,4BAA4B,CAAC;QAC1C,KAAK;QACL,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAE/D,OAAO,4CAA4C,CAAC;QAClD,MAAM;QACN,OAAO;QACP,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,QAAQ;QACR,aAAa;QACb,YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,iBAAiB;KAClB,CAAC,CAAC;AACL,CAAC","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 { 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 policyId?: string;\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 policyId,\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 policyId,\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 policyId,\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":"AAAA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GASzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EACL,cAAc,GAEf,MAAM,8BAA8B,CAAC;AAGtC,MAAM,UAAU,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAiFD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,+BAA+B,CAAC,EAC9C,OAAO,EACP,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,KAAK,EACL,IAAI,GAC4B;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,kBAAkB,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAE/D,MAAM,SAAS,GAAG,wBAAwB,CAAC;QACzC,OAAO;QACP,SAAS;QACT,KAAK;QACL,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACvC,IAAI,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACpE,CAAC;QACD,YAAY,EAAE,YAAY,IAAI,mBAAmB,CAAC,SAAS,CAAC;QAC5D,sBAAsB,EAAE,aAAa;YACnC,CAAC,CAAC,6BAA6B,CAAC,SAAS,CAAC;YAC1C,CAAC,CAAC,SAAS;QACb,YAAY;QACZ,GAAG,CAAC,QAAQ,IAAI,2BAA2B,CAAC,QAAQ,CAAC,CAAC;QACtD,iBAAiB;KAClB,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1B,IAAI,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n ChainNotFoundError,\n createSmartAccountClient,\n isSmartAccountWithSigner,\n type Prettify,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n type SmartContractAccountWithSigner,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport { type Chain } from \"viem\";\nimport type { AlchemyTransport } from \"../alchemyTransport.js\";\nimport { getDefaultUserOperationFeeOptions } from \"../defaults.js\";\nimport { alchemyFeeEstimator } from \"../middleware/feeEstimator.js\";\nimport { alchemyGasManagerMiddleware } from \"../middleware/gasManager.js\";\nimport { alchemyUserOperationSimulator } from \"../middleware/userOperationSimulator.js\";\nimport {\n alchemyActions,\n type AlchemySmartAccountClientActions,\n} from \"./decorators/smartAccount.js\";\nimport type { AlchemyRpcSchema } from \"./types.js\";\n\nexport function getSignerTypeHeader<\n TAccount extends SmartContractAccountWithSigner\n>(account: TAccount) {\n return { \"Alchemy-Aa-Sdk-Signer\": account.getSigner().signerType };\n}\n\n// #region AlchemySmartAccountClientConfig\nexport type AlchemySmartAccountClientConfig<\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 policyId?: string;\n} & Pick<\n SmartAccountClientConfig<AlchemyTransport, chain, account, context>,\n | \"customMiddleware\"\n | \"feeEstimator\"\n | \"gasEstimator\"\n | \"signUserOperation\"\n | \"transport\"\n | \"chain\"\n | \"opts\"\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 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 AlchemyTransport,\n chain,\n account,\n actions & BaseAlchemyActions<chain, account, context>,\n [...SmartAccountClientRpcSchema, ...AlchemyRpcSchema],\n context\n >\n>;\n\nexport type AlchemySmartAccountClient<\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<AlchemySmartAccountClient_Base<chain, account, actions, context>>;\n\nexport function createAlchemySmartAccountClient<\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 params: AlchemySmartAccountClientConfig<TChain, TAccount, TContext>\n): AlchemySmartAccountClient<TChain, TAccount, Record<string, never>, TContext>;\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, alchemy } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra/chain\";\n *\n * const client = createAlchemySmartAccountClient({\n * chain: sepolia,\n * transport: alchemy({ 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 policyId,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n transport,\n chain,\n opts,\n}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {\n if (!chain) {\n throw new ChainNotFoundError();\n }\n\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);\n\n const scaClient = createSmartAccountClient({\n account,\n transport,\n chain,\n type: \"AlchemySmartAccountClient\",\n opts: {\n ...opts,\n feeOptions,\n },\n customMiddleware: async (struct, args) => {\n if (isSmartAccountWithSigner(args.account)) {\n transport.updateHeaders(getSignerTypeHeader(args.account));\n }\n return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(transport)\n : undefined,\n gasEstimator,\n ...(policyId && alchemyGasManagerMiddleware(policyId)),\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n transport.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { type BundlerClient, type UserOperationRequest } from "@aa-sdk/core";
2
- import type { HttpTransport } from "viem";
1
+ import { type BundlerClient, type Erc7677RpcSchema, type UserOperationRequest } from "@aa-sdk/core";
3
2
  import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse } from "../actions/types";
3
+ import type { AlchemyTransport } from "../alchemyTransport";
4
4
  export type AlchemyRpcSchema = [
5
5
  {
6
6
  Method: "alchemy_simulateUserOperationAssetChanges";
@@ -11,10 +11,13 @@ export type AlchemyRpcSchema = [
11
11
  Method: "rundler_maxPriorityFeePerGas";
12
12
  Parameters: [];
13
13
  ReturnType: UserOperationRequest["maxPriorityFeePerGas"];
14
- }
14
+ },
15
+ ...Erc7677RpcSchema<{
16
+ policyId: string;
17
+ }>
15
18
  ];
16
- export type ClientWithAlchemyMethods = BundlerClient<HttpTransport> & {
17
- request: BundlerClient<HttpTransport>["request"] & {
19
+ export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
20
+ request: BundlerClient<AlchemyTransport>["request"] & {
18
21
  request(args: {
19
22
  method: "alchemy_simulateUserOperationAssetChanges";
20
23
  params: SimulateUserOperationAssetChangesRequest;
@@ -24,6 +27,4 @@ export type ClientWithAlchemyMethods = BundlerClient<HttpTransport> & {
24
27
  params: [];
25
28
  }): Promise<UserOperationRequest["maxPriorityFeePerGas"]>;
26
29
  }["request"];
27
- } & {
28
- updateHeaders: (headers: HeadersInit) => void;
29
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiD,MAAM,cAAc,CAAC","sourcesContent":["import { type BundlerClient, type UserOperationRequest } from \"@aa-sdk/core\";\nimport type { HttpTransport } from \"viem\";\nimport type {\n SimulateUserOperationAssetChangesRequest,\n SimulateUserOperationAssetChangesResponse,\n} from \"../actions/types\";\n\nexport type AlchemyRpcSchema = [\n {\n Method: \"alchemy_simulateUserOperationAssetChanges\";\n Parameters: SimulateUserOperationAssetChangesRequest;\n ReturnType: SimulateUserOperationAssetChangesResponse;\n },\n {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: UserOperationRequest[\"maxPriorityFeePerGas\"];\n }\n];\n\nexport type ClientWithAlchemyMethods = BundlerClient<HttpTransport> & {\n request: BundlerClient<HttpTransport>[\"request\"] &\n {\n request(args: {\n method: \"alchemy_simulateUserOperationAssetChanges\";\n params: SimulateUserOperationAssetChangesRequest;\n }): Promise<SimulateUserOperationAssetChangesResponse>;\n\n request(args: {\n method: \"rundler_maxPriorityFeePerGas\";\n params: [];\n }): Promise<UserOperationRequest[\"maxPriorityFeePerGas\"]>;\n }[\"request\"];\n} & {\n updateHeaders: (headers: HeadersInit) => void;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,MAAM,cAAc,CAAC","sourcesContent":["import {\n type BundlerClient,\n type Erc7677RpcSchema,\n type UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport type {\n SimulateUserOperationAssetChangesRequest,\n SimulateUserOperationAssetChangesResponse,\n} from \"../actions/types\";\nimport type { AlchemyTransport } from \"../alchemyTransport\";\n\nexport type AlchemyRpcSchema = [\n {\n Method: \"alchemy_simulateUserOperationAssetChanges\";\n Parameters: SimulateUserOperationAssetChangesRequest;\n ReturnType: SimulateUserOperationAssetChangesResponse;\n },\n {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: UserOperationRequest[\"maxPriorityFeePerGas\"];\n },\n ...Erc7677RpcSchema<{ policyId: string }>\n];\n\nexport type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {\n request: BundlerClient<AlchemyTransport>[\"request\"] &\n {\n request(args: {\n method: \"alchemy_simulateUserOperationAssetChanges\";\n params: SimulateUserOperationAssetChangesRequest;\n }): Promise<SimulateUserOperationAssetChangesResponse>;\n\n request(args: {\n method: \"rundler_maxPriorityFeePerGas\";\n params: [];\n }): Promise<UserOperationRequest[\"maxPriorityFeePerGas\"]>;\n }[\"request\"];\n};\n"]}
@@ -1,13 +1,14 @@
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 "./alchemyTransport.js";
5
+ export { alchemy } from "./alchemyTransport.js";
4
6
  export type * from "./chains.js";
5
- export { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, } from "./chains.js";
7
+ export { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, beraChainBartio, } from "./chains.js";
6
8
  export type * from "./client/decorators/alchemyEnhancedApis.js";
7
9
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
8
10
  export type * from "./client/decorators/smartAccount.js";
9
11
  export { alchemyActions } from "./client/decorators/smartAccount.js";
10
- export { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from "./client/internal/smartAccountClientFromRpc.js";
11
12
  export { isAlchemySmartAccountClient } from "./client/isAlchemySmartAccountClient.js";
12
13
  export type * from "./client/rpcClient.js";
13
14
  export { createAlchemyPublicRpcClient } from "./client/rpcClient.js";
@@ -21,5 +22,3 @@ export type * from "./middleware/gasManager.js";
21
22
  export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
22
23
  export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
23
24
  export type * from "./schema.js";
24
- export { AlchemyProviderConfigSchema } from "./schema.js";
25
- export type { AlchemyProviderConfig } from "./type.js";
package/dist/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
2
- export { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, } from "./chains.js";
2
+ export { alchemy } from "./alchemyTransport.js";
3
+ export { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, beraChainBartio, } from "./chains.js";
3
4
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
4
5
  export { alchemyActions } from "./client/decorators/smartAccount.js";
5
- export { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from "./client/internal/smartAccountClientFromRpc.js";
6
6
  export { isAlchemySmartAccountClient } from "./client/isAlchemySmartAccountClient.js";
7
7
  export { createAlchemyPublicRpcClient } from "./client/rpcClient.js";
8
8
  export { createAlchemySmartAccountClient } from "./client/smartAccountClient.js";
@@ -11,5 +11,4 @@ export { getAlchemyPaymasterAddress } from "./gas-manager.js";
11
11
  export { alchemyFeeEstimator } from "./middleware/feeEstimator.js";
12
12
  export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
13
13
  export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
14
- export { AlchemyProviderConfigSchema } from "./schema.js";
15
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,4CAA4C,IAAI,2CAA2C,EAAE,MAAM,gDAAgD,CAAC;AAC7J,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC","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 {\n arbitrum,\n arbitrumGoerli,\n arbitrumNova,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n shape,\n shapeSepolia,\n worldChain,\n worldChainSepolia,\n zora,\n zoraSepolia,\n} 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,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./alchemyTransport.js\";\nexport { alchemy } from \"./alchemyTransport.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumNova,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n shape,\n shapeSepolia,\n worldChain,\n worldChainSepolia,\n zora,\n zoraSepolia,\n beraChainBartio,\n} 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 { 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\";\n"]}
@@ -1,22 +1,26 @@
1
1
  import type { ClientMiddlewareFn } from "@aa-sdk/core";
2
- import type { ClientWithAlchemyMethods } from "../client/types";
2
+ import type { AlchemyTransport } from "../alchemyTransport";
3
3
  /**
4
4
  * Function that estimates the transaction fees using Alchemy methods for a given client.
5
5
  * It fetches the latest block and estimates the max priority fee per gas, applying any overrides or fee options provided.
6
6
  *
7
7
  * @example
8
8
  * ```ts
9
- * import { alchemyFeeEstimator, createAlchemyPublicRpcClient } from "@account-kit/infra";
9
+ * import { alchemyFeeEstimator, alchemy } from "@account-kit/infra";
10
10
  * import { createSmartAccountClient } from "@aa-sdk/core";
11
11
  *
12
- * const bundlerClient = createAlchemyPublicRpcClient(...);
12
+ * const alchemyTransport = alchemy({
13
+ * chain: sepolia,
14
+ * apiKey: "your-api-key"
15
+ * });
16
+ *
13
17
  * const client = createSmartAccountClient({
14
- * feeEstimator: alchemyFeeEstimator(bundlerClient),
18
+ * feeEstimator: alchemyFeeEstimator(alchemyTransport),
15
19
  * ...otherParams
16
20
  * });
17
21
  * ```
18
22
  *
19
- * @param {ClientWithAlchemyMethods} client The client with Alchemy methods
23
+ * @param {AlchemyTransport} transport An alchemy transport for making Alchemy specific RPC calls
20
24
  * @returns {ClientMiddlewareFn} A middleware function that takes a transaction structure and fee options, and returns the augmented structure with estimated fees
21
25
  */
22
- export declare const alchemyFeeEstimator: <C extends ClientWithAlchemyMethods>(client: C) => ClientMiddlewareFn;
26
+ export declare const alchemyFeeEstimator: (transport: AlchemyTransport) => ClientMiddlewareFn;
@@ -5,24 +5,29 @@ import { applyUserOpOverrideOrFeeOption } from "@aa-sdk/core";
5
5
  *
6
6
  * @example
7
7
  * ```ts
8
- * import { alchemyFeeEstimator, createAlchemyPublicRpcClient } from "@account-kit/infra";
8
+ * import { alchemyFeeEstimator, alchemy } from "@account-kit/infra";
9
9
  * import { createSmartAccountClient } from "@aa-sdk/core";
10
10
  *
11
- * const bundlerClient = createAlchemyPublicRpcClient(...);
11
+ * const alchemyTransport = alchemy({
12
+ * chain: sepolia,
13
+ * apiKey: "your-api-key"
14
+ * });
15
+ *
12
16
  * const client = createSmartAccountClient({
13
- * feeEstimator: alchemyFeeEstimator(bundlerClient),
17
+ * feeEstimator: alchemyFeeEstimator(alchemyTransport),
14
18
  * ...otherParams
15
19
  * });
16
20
  * ```
17
21
  *
18
- * @param {ClientWithAlchemyMethods} client The client with Alchemy methods
22
+ * @param {AlchemyTransport} transport An alchemy transport for making Alchemy specific RPC calls
19
23
  * @returns {ClientMiddlewareFn} A middleware function that takes a transaction structure and fee options, and returns the augmented structure with estimated fees
20
24
  */
21
- export const alchemyFeeEstimator = (client) => async (struct, { overrides, feeOptions }) => {
25
+ export const alchemyFeeEstimator = (transport) => async (struct, { overrides, feeOptions, client }) => {
26
+ const transport_ = transport({ chain: client.chain });
22
27
  let [block, maxPriorityFeePerGasEstimate] = await Promise.all([
23
28
  client.getBlock({ blockTag: "latest" }),
24
29
  // it is a fair assumption that if someone is using this Alchemy Middleware, then they are using Alchemy RPC
25
- client.request({
30
+ transport_.request({
26
31
  method: "rundler_maxPriorityFeePerGas",
27
32
  params: [],
28
33
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"feeEstimator.js","sourceRoot":"","sources":["../../../src/middleware/feeEstimator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAG9D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,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;QACvC,4GAA4G;QAC5G,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,8BAA8B,CACzD,4BAA4B,EAC5B,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,oBAAoB,CACjC,CAAC;IACF,MAAM,YAAY,GAAG,8BAA8B,CACjD,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","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
+ {"version":3,"file":"feeEstimator.js","sourceRoot":"","sources":["../../../src/middleware/feeEstimator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAG9B,CAAC,SAAS,EAAE,EAAE,CACd,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;IAClD,MAAM,UAAU,GAAG,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACtD,IAAI,CAAC,KAAK,EAAE,4BAA4B,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5D,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACvC,4GAA4G;QAC5G,UAAU,CAAC,OAAO,CAAC;YACjB,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,8BAA8B,CACzD,4BAA4B,EAC5B,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,oBAAoB,CACjC,CAAC;IACF,MAAM,YAAY,GAAG,8BAA8B,CACjD,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","sourcesContent":["import type { ClientMiddlewareFn } from \"@aa-sdk/core\";\nimport { applyUserOpOverrideOrFeeOption } from \"@aa-sdk/core\";\nimport type { AlchemyTransport } from \"../alchemyTransport\";\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, alchemy } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const alchemyTransport = alchemy({\n * chain: sepolia,\n * apiKey: \"your-api-key\"\n * });\n *\n * const client = createSmartAccountClient({\n * feeEstimator: alchemyFeeEstimator(alchemyTransport),\n * ...otherParams\n * });\n * ```\n *\n * @param {AlchemyTransport} transport An alchemy transport for making Alchemy specific RPC calls\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: (\n transport: AlchemyTransport\n) => ClientMiddlewareFn =\n (transport) =>\n async (struct, { overrides, feeOptions, client }) => {\n const transport_ = transport({ chain: client.chain });\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 transport_.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"]}
@@ -4,15 +4,14 @@ import type { ClientMiddlewareConfig } from "@aa-sdk/core";
4
4
  *
5
5
  * @example
6
6
  * ```ts
7
- *
8
- * import { sepolia } from "@account-kit/infra";
7
+ * import { sepolia, alchemyErc7677Middleware } from "@account-kit/infra";
9
8
  * import { http } from "viem";
10
9
  *
11
10
  * const client = createSmartAccountClient({
12
- * http("rpc-url"),
13
- * sepolia,
14
- * alchemyErc7677Middleware("policyId")
15
- * );
11
+ * transport: http("rpc-url"),
12
+ * chain: sepolia,
13
+ * ...alchemyErc7677Middleware("policyId")
14
+ * });
16
15
  * ```
17
16
  *
18
17
  * @param {string} policyId the policyId for Alchemy's gas manager
@@ -4,15 +4,14 @@ import { erc7677Middleware } from "@aa-sdk/core";
4
4
  *
5
5
  * @example
6
6
  * ```ts
7
- *
8
- * import { sepolia } from "@account-kit/infra";
7
+ * import { sepolia, alchemyErc7677Middleware } from "@account-kit/infra";
9
8
  * import { http } from "viem";
10
9
  *
11
10
  * const client = createSmartAccountClient({
12
- * http("rpc-url"),
13
- * sepolia,
14
- * alchemyErc7677Middleware("policyId")
15
- * );
11
+ * transport: http("rpc-url"),
12
+ * chain: sepolia,
13
+ * ...alchemyErc7677Middleware("policyId")
14
+ * });
16
15
  * ```
17
16
  *
18
17
  * @param {string} policyId the policyId for Alchemy's gas manager
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAgB;IAEhB,OAAO,iBAAiB,CAAuB;QAC7C,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ClientMiddlewareConfig } from \"@aa-sdk/core\";\nimport { erc7677Middleware } from \"@aa-sdk/core\";\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.\n *\n * @example\n * ```ts\n *\n * import { sepolia } from \"@account-kit/infra\";\n * import { http } from \"viem\";\n *\n * const client = createSmartAccountClient({\n * http(\"rpc-url\"),\n * sepolia,\n * alchemyErc7677Middleware(\"policyId\")\n * );\n * ```\n *\n * @param {string} policyId the policyId for Alchemy's gas manager\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasManagerMiddleware(\n policyId: string\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return erc7677Middleware<{ policyId: string }>({\n context: { policyId: policyId },\n });\n}\n"]}
1
+ {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAgB;IAEhB,OAAO,iBAAiB,CAAuB;QAC7C,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ClientMiddlewareConfig } from \"@aa-sdk/core\";\nimport { erc7677Middleware } from \"@aa-sdk/core\";\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.\n *\n * @example\n * ```ts\n * import { sepolia, alchemyErc7677Middleware } from \"@account-kit/infra\";\n * import { http } from \"viem\";\n *\n * const client = createSmartAccountClient({\n * transport: http(\"rpc-url\"),\n * chain: sepolia,\n * ...alchemyErc7677Middleware(\"policyId\")\n * });\n * ```\n *\n * @param {string} policyId the policyId for Alchemy's gas manager\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasManagerMiddleware(\n policyId: string\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return erc7677Middleware<{ policyId: string }>({\n context: { policyId: policyId },\n });\n}\n"]}
@@ -1,22 +1,26 @@
1
1
  import { type ClientMiddlewareFn, type UserOperationContext } from "@aa-sdk/core";
2
- import type { ClientWithAlchemyMethods } from "../client/types";
2
+ import type { AlchemyTransport } from "../alchemyTransport";
3
3
  /**
4
4
  * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.
5
5
  *
6
6
  * @example
7
7
  * ```ts
8
- * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from "@account-kit/infra";
8
+ * import { alchemyUserOperationSimulator, alchemy, sepolia } from "@account-kit/infra";
9
9
  * import { createSmartAccountClient } from "@aa-sdk/core";
10
10
  *
11
- * const bundlerClient = createAlchemyPublicRpcClient(...);
11
+ * const alchemyTransport = alchemy({
12
+ * chain: sepolia,
13
+ * apiKey: "your-api-key"
14
+ * });
15
+ *
12
16
  * const client = createSmartAccountClient({
13
- * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),
17
+ * chain: sepolia,
18
+ * userOperationSimulator: alchemyUserOperationSimulator(alchemyTransport),
14
19
  * ...otherParams
15
20
  * });
16
21
  * ```
17
22
  *
18
- * @template C The client object with Alchemy methods
19
- * @param {C} client The client object with Alchemy methods
23
+ * @param {AlchemyTransport} transport An Alchemy Transport that can be used for making RPC calls to alchemy
20
24
  * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations
21
25
  */
22
- export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: C): ClientMiddlewareFn<TContext>;
26
+ export declare function alchemyUserOperationSimulator<TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(transport: AlchemyTransport): ClientMiddlewareFn<TContext>;
@@ -4,23 +4,27 @@ import { deepHexlify, resolveProperties, } from "@aa-sdk/core";
4
4
  *
5
5
  * @example
6
6
  * ```ts
7
- * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from "@account-kit/infra";
7
+ * import { alchemyUserOperationSimulator, alchemy, sepolia } from "@account-kit/infra";
8
8
  * import { createSmartAccountClient } from "@aa-sdk/core";
9
9
  *
10
- * const bundlerClient = createAlchemyPublicRpcClient(...);
10
+ * const alchemyTransport = alchemy({
11
+ * chain: sepolia,
12
+ * apiKey: "your-api-key"
13
+ * });
14
+ *
11
15
  * const client = createSmartAccountClient({
12
- * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),
16
+ * chain: sepolia,
17
+ * userOperationSimulator: alchemyUserOperationSimulator(alchemyTransport),
13
18
  * ...otherParams
14
19
  * });
15
20
  * ```
16
21
  *
17
- * @template C The client object with Alchemy methods
18
- * @param {C} client The client object with Alchemy methods
22
+ * @param {AlchemyTransport} transport An Alchemy Transport that can be used for making RPC calls to alchemy
19
23
  * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations
20
24
  */
21
- export function alchemyUserOperationSimulator(client) {
22
- return async (struct, { account }) => {
23
- const uoSimResult = await client.request({
25
+ export function alchemyUserOperationSimulator(transport) {
26
+ return async (struct, { account, client }) => {
27
+ const uoSimResult = await transport({ chain: client.chain }).request({
24
28
  method: "alchemy_simulateUserOperationAssetChanges",
25
29
  params: [
26
30
  deepHexlify(await resolveProperties(struct)),
@@ -1 +1 @@
1
- {"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,6BAA6B,CAK3C,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,WAAW,CAAC,MAAM,iBAAiB,CAAC,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","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n type UserOperationContext,\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 TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(client: C): ClientMiddlewareFn<TContext> {\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,OAAO,EACL,WAAW,EACX,iBAAiB,GAGlB,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,6BAA6B,CAI3C,SAA2B;IAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QAC3C,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC;YACnE,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,WAAW,CAAC,MAAM,iBAAiB,CAAC,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","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { AlchemyTransport } from \"../alchemyTransport\";\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, alchemy, sepolia } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const alchemyTransport = alchemy({\n * chain: sepolia,\n * apiKey: \"your-api-key\"\n * });\n *\n * const client = createSmartAccountClient({\n * chain: sepolia,\n * userOperationSimulator: alchemyUserOperationSimulator(alchemyTransport),\n * ...otherParams\n * });\n * ```\n *\n * @param {AlchemyTransport} transport An Alchemy Transport that can be used for making RPC calls to alchemy\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(transport: AlchemyTransport): ClientMiddlewareFn<TContext> {\n return async (struct, { account, client }) => {\n const uoSimResult = await transport({ chain: client.chain }).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"]}