@account-kit/infra 4.0.0-beta.1 → 4.0.0-beta.10

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 (102) 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/decorators/smartAccount.d.ts +7 -4
  11. package/dist/esm/client/decorators/smartAccount.js +33 -0
  12. package/dist/esm/client/decorators/smartAccount.js.map +1 -1
  13. package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1 -1
  14. package/dist/esm/client/isAlchemySmartAccountClient.js +2 -6
  15. package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
  16. package/dist/esm/client/rpcClient.d.ts +9 -10
  17. package/dist/esm/client/rpcClient.js +9 -33
  18. package/dist/esm/client/rpcClient.js.map +1 -1
  19. package/dist/esm/client/smartAccountClient.d.ts +12 -9
  20. package/dist/esm/client/smartAccountClient.js +34 -20
  21. package/dist/esm/client/smartAccountClient.js.map +1 -1
  22. package/dist/esm/client/types.d.ts +8 -7
  23. package/dist/esm/client/types.js.map +1 -1
  24. package/dist/esm/index.d.ts +3 -4
  25. package/dist/esm/index.js +2 -3
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/metrics.d.ts +12 -0
  28. package/dist/esm/metrics.js +7 -0
  29. package/dist/esm/metrics.js.map +1 -0
  30. package/dist/esm/middleware/feeEstimator.d.ts +10 -6
  31. package/dist/esm/middleware/feeEstimator.js +11 -6
  32. package/dist/esm/middleware/feeEstimator.js.map +1 -1
  33. package/dist/esm/middleware/gasManager.d.ts +5 -6
  34. package/dist/esm/middleware/gasManager.js +5 -6
  35. package/dist/esm/middleware/gasManager.js.map +1 -1
  36. package/dist/esm/middleware/userOperationSimulator.d.ts +11 -7
  37. package/dist/esm/middleware/userOperationSimulator.js +12 -8
  38. package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
  39. package/dist/esm/schema.d.ts +0 -391
  40. package/dist/esm/schema.js +1 -5
  41. package/dist/esm/schema.js.map +1 -1
  42. package/dist/esm/version.d.ts +1 -1
  43. package/dist/esm/version.js +1 -1
  44. package/dist/esm/version.js.map +1 -1
  45. package/dist/types/alchemyTransport.d.ts +70 -0
  46. package/dist/types/alchemyTransport.d.ts.map +1 -0
  47. package/dist/types/chains.d.ts +1 -0
  48. package/dist/types/chains.d.ts.map +1 -1
  49. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +2 -2
  50. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
  51. package/dist/types/client/decorators/smartAccount.d.ts +7 -4
  52. package/dist/types/client/decorators/smartAccount.d.ts.map +1 -1
  53. package/dist/types/client/isAlchemySmartAccountClient.d.ts +1 -1
  54. package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
  55. package/dist/types/client/rpcClient.d.ts +9 -10
  56. package/dist/types/client/rpcClient.d.ts.map +1 -1
  57. package/dist/types/client/smartAccountClient.d.ts +12 -9
  58. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  59. package/dist/types/client/types.d.ts +8 -7
  60. package/dist/types/client/types.d.ts.map +1 -1
  61. package/dist/types/index.d.ts +3 -4
  62. package/dist/types/index.d.ts.map +1 -1
  63. package/dist/types/metrics.d.ts +13 -0
  64. package/dist/types/metrics.d.ts.map +1 -0
  65. package/dist/types/middleware/feeEstimator.d.ts +10 -6
  66. package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
  67. package/dist/types/middleware/gasManager.d.ts +5 -6
  68. package/dist/types/middleware/gasManager.d.ts.map +1 -1
  69. package/dist/types/middleware/userOperationSimulator.d.ts +11 -7
  70. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
  71. package/dist/types/schema.d.ts +0 -391
  72. package/dist/types/schema.d.ts.map +1 -1
  73. package/dist/types/version.d.ts +1 -1
  74. package/dist/types/version.d.ts.map +1 -1
  75. package/package.json +5 -5
  76. package/src/alchemyTransport.ts +214 -0
  77. package/src/chains.ts +18 -0
  78. package/src/client/decorators/alchemyEnhancedApis.ts +9 -16
  79. package/src/client/decorators/smartAccount.ts +77 -7
  80. package/src/client/isAlchemySmartAccountClient.ts +4 -9
  81. package/src/client/rpcClient.ts +14 -47
  82. package/src/client/smartAccountClient.ts +64 -57
  83. package/src/client/types.ts +10 -7
  84. package/src/index.ts +8 -8
  85. package/src/metrics.ts +19 -0
  86. package/src/middleware/feeEstimator.ts +15 -10
  87. package/src/middleware/gasManager.ts +5 -6
  88. package/src/middleware/userOperationSimulator.ts +13 -10
  89. package/src/schema.ts +1 -14
  90. package/src/version.ts +1 -1
  91. package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +0 -18
  92. package/dist/esm/client/internal/smartAccountClientFromRpc.js +0 -56
  93. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +0 -1
  94. package/dist/esm/type.d.ts +0 -3
  95. package/dist/esm/type.js +0 -2
  96. package/dist/esm/type.js.map +0 -1
  97. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +0 -19
  98. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +0 -1
  99. package/dist/types/type.d.ts +0 -4
  100. package/dist/types/type.d.ts.map +0 -1
  101. package/src/client/internal/smartAccountClientFromRpc.ts +0 -125
  102. package/src/type.ts +0 -4
@@ -4,35 +4,38 @@ import {
4
4
  type ClientMiddlewareFn,
5
5
  type UserOperationContext,
6
6
  } from "@aa-sdk/core";
7
- import type { ClientWithAlchemyMethods } from "../client/types";
7
+ import type { AlchemyTransport } from "../alchemyTransport";
8
8
 
9
9
  /**
10
10
  * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.
11
11
  *
12
12
  * @example
13
13
  * ```ts
14
- * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from "@account-kit/infra";
14
+ * import { alchemyUserOperationSimulator, alchemy, sepolia } from "@account-kit/infra";
15
15
  * import { createSmartAccountClient } from "@aa-sdk/core";
16
16
  *
17
- * const bundlerClient = createAlchemyPublicRpcClient(...);
17
+ * const alchemyTransport = alchemy({
18
+ * chain: sepolia,
19
+ * apiKey: "your-api-key"
20
+ * });
21
+ *
18
22
  * const client = createSmartAccountClient({
19
- * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),
23
+ * chain: sepolia,
24
+ * userOperationSimulator: alchemyUserOperationSimulator(alchemyTransport),
20
25
  * ...otherParams
21
26
  * });
22
27
  * ```
23
28
  *
24
- * @template C The client object with Alchemy methods
25
- * @param {C} client The client object with Alchemy methods
29
+ * @param {AlchemyTransport} transport An Alchemy Transport that can be used for making RPC calls to alchemy
26
30
  * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations
27
31
  */
28
32
  export function alchemyUserOperationSimulator<
29
- C extends ClientWithAlchemyMethods,
30
33
  TContext extends UserOperationContext | undefined =
31
34
  | UserOperationContext
32
35
  | undefined
33
- >(client: C): ClientMiddlewareFn<TContext> {
34
- return async (struct, { account }) => {
35
- const uoSimResult = await client.request({
36
+ >(transport: AlchemyTransport): ClientMiddlewareFn<TContext> {
37
+ return async (struct, { account, client }) => {
38
+ const uoSimResult = await transport({ chain: client.chain }).request({
36
39
  method: "alchemy_simulateUserOperationAssetChanges",
37
40
  params: [
38
41
  deepHexlify(await resolveProperties(struct)),
package/src/schema.ts CHANGED
@@ -1,8 +1,4 @@
1
- import {
2
- ChainSchema,
3
- ConnectionConfigSchema,
4
- SmartAccountClientOptsSchema,
5
- } from "@aa-sdk/core";
1
+ import { ChainSchema } from "@aa-sdk/core";
6
2
  import { Alchemy } from "alchemy-sdk";
7
3
  import type { Chain } from "viem";
8
4
  import z from "zod";
@@ -13,13 +9,4 @@ export const AlchemyChainSchema = z.custom<Chain>((chain) => {
13
9
  return chain_.rpcUrls.alchemy != null;
14
10
  }, "chain must include an alchemy rpc url. See `createAlchemyChain` or import a chain from `@account-kit/infra`.");
15
11
 
16
- export const AlchemyProviderConfigSchema = ConnectionConfigSchema.and(
17
- z.object({
18
- chain: AlchemyChainSchema,
19
- opts: SmartAccountClientOptsSchema.optional().default(
20
- SmartAccountClientOptsSchema.parse({})
21
- ),
22
- })
23
- );
24
-
25
12
  export const AlchemySdkClientSchema = z.instanceof(Alchemy);
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.0.0-beta.1";
3
+ export const VERSION = "4.0.0-beta.10";
@@ -1,18 +0,0 @@
1
- import { type SmartContractAccount, type SmartContractAccountWithSigner, type UserOperationContext } from "@aa-sdk/core";
2
- import type { Chain, CustomTransport, Transport } from "viem";
3
- import type { AlchemySmartAccountClient, AlchemySmartAccountClientConfig } from "../smartAccountClient.js";
4
- import type { ClientWithAlchemyMethods } from "../types.js";
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
- client: ClientWithAlchemyMethods;
7
- };
8
- export declare function getSignerTypeHeader<TAccount extends SmartContractAccountWithSigner>(account: TAccount): {
9
- "Alchemy-Aa-Sdk-Signer": string;
10
- };
11
- /**
12
- * Helper method meant to be used internally to create an alchemy smart account client
13
- * from an existing Alchemy Rpc Client
14
- *
15
- * @param {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client
16
- * @returns {AlchemySmartAccountClient} a smart account client configured to use Alchemy's RPC
17
- */
18
- 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>;
@@ -1,56 +0,0 @@
1
- import { createSmartAccountClientFromExisting, getDefaultUserOperationFeeOptions, isSmartAccountWithSigner, } from "@aa-sdk/core";
2
- import { alchemyFeeEstimator } from "../../middleware/feeEstimator.js";
3
- import { alchemyGasManagerMiddleware } from "../../middleware/gasManager.js";
4
- import { alchemyUserOperationSimulator } from "../../middleware/userOperationSimulator.js";
5
- import { alchemyActions } from "../decorators/smartAccount.js";
6
- export function getSignerTypeHeader(account) {
7
- return { "Alchemy-Aa-Sdk-Signer": account.getSigner().signerType };
8
- }
9
- /**
10
- * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.
11
- *
12
- * @example
13
- * ```ts
14
- * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from "@account-kit/infra";
15
- *
16
- * const client = createAlchemyPublicRpcClient(...);
17
- * const scaClient = createAlchemySmartAccountClientFromRpcClient({
18
- * client,
19
- * ...
20
- * });
21
- * ```
22
- *
23
- * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters
24
- * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient
25
- */
26
- export function createAlchemySmartAccountClientFromRpcClient(args) {
27
- const { opts, account, useSimulation, policyId, feeEstimator, gasEstimator, customMiddleware, signUserOperation, client, } = args;
28
- const feeOptions = opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);
29
- const scaClient = createSmartAccountClientFromExisting({
30
- account,
31
- client,
32
- type: "AlchemySmartAccountClient",
33
- opts: {
34
- ...opts,
35
- feeOptions,
36
- },
37
- customMiddleware: async (struct, args) => {
38
- if (isSmartAccountWithSigner(args.account)) {
39
- client.updateHeaders(getSignerTypeHeader(args.account));
40
- }
41
- return customMiddleware ? customMiddleware(struct, args) : struct;
42
- },
43
- feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),
44
- userOperationSimulator: useSimulation
45
- ? alchemyUserOperationSimulator(client)
46
- : undefined,
47
- gasEstimator,
48
- ...(policyId && alchemyGasManagerMiddleware(policyId)),
49
- signUserOperation,
50
- }).extend(alchemyActions);
51
- if (account && isSmartAccountWithSigner(account)) {
52
- client.updateHeaders(getSignerTypeHeader(account));
53
- }
54
- return scaClient;
55
- }
56
- //# sourceMappingURL=smartAccountClientFromRpc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smartAccountClientFromRpc.js","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,iCAAiC,EACjC,wBAAwB,GAIzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAmB/D,MAAM,UAAU,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AA2BD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,4CAA4C,CAC1D,IAAwD;IAExD,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,GACP,GAAG,IAAI,CAAC;IACT,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,iCAAiC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEtE,MAAM,SAAS,GAAG,oCAAoC,CAAC;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,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC1D,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,MAAM,CAAC;QACzD,sBAAsB,EAAE,aAAa;YACnC,CAAC,CAAC,6BAA6B,CAAC,MAAM,CAAC;YACvC,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,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","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 {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client\n * @returns {AlchemySmartAccountClient} 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 policyId,\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 return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(client)\n : undefined,\n gasEstimator,\n ...(policyId && alchemyGasManagerMiddleware(policyId)),\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n client.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { z } from "zod";
2
- import type { AlchemyProviderConfigSchema } from "./schema.js";
3
- export type AlchemyProviderConfig = z.input<typeof AlchemyProviderConfigSchema>;
package/dist/esm/type.js DELETED
@@ -1,2 +0,0 @@
1
- import { z } from "zod";
2
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC","sourcesContent":["import { z } from \"zod\";\nimport type { AlchemyProviderConfigSchema } from \"./schema.js\";\n\nexport type AlchemyProviderConfig = z.input<typeof AlchemyProviderConfigSchema>;\n"]}
@@ -1,19 +0,0 @@
1
- import { type SmartContractAccount, type SmartContractAccountWithSigner, type UserOperationContext } from "@aa-sdk/core";
2
- import type { Chain, CustomTransport, Transport } from "viem";
3
- import type { AlchemySmartAccountClient, AlchemySmartAccountClientConfig } from "../smartAccountClient.js";
4
- import type { ClientWithAlchemyMethods } from "../types.js";
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
- client: ClientWithAlchemyMethods;
7
- };
8
- export declare function getSignerTypeHeader<TAccount extends SmartContractAccountWithSigner>(account: TAccount): {
9
- "Alchemy-Aa-Sdk-Signer": string;
10
- };
11
- /**
12
- * Helper method meant to be used internally to create an alchemy smart account client
13
- * from an existing Alchemy Rpc Client
14
- *
15
- * @param {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client
16
- * @returns {AlchemySmartAccountClient} a smart account client configured to use Alchemy's RPC
17
- */
18
- 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>;
19
- //# sourceMappingURL=smartAccountClientFromRpc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"smartAccountClientFromRpc.d.ts","sourceRoot":"","sources":["../../../../src/client/internal/smartAccountClientFromRpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAK9D,OAAO,KAAK,EACV,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,MAAM,kDAAkD,CAC5D,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,EACb,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,IACX,IAAI,CACN,+BAA+B,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,EACrE,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CACtC,GAAG;IAAE,MAAM,EAAE,wBAAwB,CAAA;CAAE,CAAC;AAEzC,wBAAgB,mBAAmB,CACjC,QAAQ,SAAS,8BAA8B,EAC/C,OAAO,EAAE,QAAQ;;EAElB;AAED;;;;;;GAMG;AACH,wBAAgB,4CAA4C,CAC1D,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,EACb,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,EAEb,IAAI,EAAE,kDAAkD,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAC3E,yBAAyB,CAC1B,eAAe,EACf,MAAM,EACN,QAAQ,EACR,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,QAAQ,CACT,CAAC"}
@@ -1,4 +0,0 @@
1
- import { z } from "zod";
2
- import type { AlchemyProviderConfigSchema } from "./schema.js";
3
- export type AlchemyProviderConfig = z.input<typeof AlchemyProviderConfigSchema>;
4
- //# sourceMappingURL=type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -1,125 +0,0 @@
1
- import {
2
- createSmartAccountClientFromExisting,
3
- getDefaultUserOperationFeeOptions,
4
- isSmartAccountWithSigner,
5
- type SmartContractAccount,
6
- type SmartContractAccountWithSigner,
7
- type UserOperationContext,
8
- } from "@aa-sdk/core";
9
- import type { Chain, CustomTransport, Transport } from "viem";
10
- import { alchemyFeeEstimator } from "../../middleware/feeEstimator.js";
11
- import { alchemyGasManagerMiddleware } from "../../middleware/gasManager.js";
12
- import { alchemyUserOperationSimulator } from "../../middleware/userOperationSimulator.js";
13
- import { alchemyActions } from "../decorators/smartAccount.js";
14
- import type {
15
- AlchemySmartAccountClient,
16
- AlchemySmartAccountClientConfig,
17
- } from "../smartAccountClient.js";
18
- import type { ClientWithAlchemyMethods } from "../types.js";
19
-
20
- export type CreateAlchemySmartAccountClientFromRpcClientParams<
21
- TAccount extends SmartContractAccount | undefined =
22
- | SmartContractAccount
23
- | undefined,
24
- TContext extends UserOperationContext | undefined =
25
- | UserOperationContext
26
- | undefined
27
- > = Omit<
28
- AlchemySmartAccountClientConfig<Transport, Chain, TAccount, TContext>,
29
- "rpcUrl" | "chain" | "apiKey" | "jwt"
30
- > & { client: ClientWithAlchemyMethods };
31
-
32
- export function getSignerTypeHeader<
33
- TAccount extends SmartContractAccountWithSigner
34
- >(account: TAccount) {
35
- return { "Alchemy-Aa-Sdk-Signer": account.getSigner().signerType };
36
- }
37
-
38
- /**
39
- * Helper method meant to be used internally to create an alchemy smart account client
40
- * from an existing Alchemy Rpc Client
41
- *
42
- * @param {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client
43
- * @returns {AlchemySmartAccountClient} a smart account client configured to use Alchemy's RPC
44
- */
45
- export function createAlchemySmartAccountClientFromRpcClient<
46
- TChain extends Chain | undefined = Chain | undefined,
47
- TAccount extends SmartContractAccount | undefined =
48
- | SmartContractAccount
49
- | undefined,
50
- TContext extends UserOperationContext | undefined =
51
- | UserOperationContext
52
- | undefined
53
- >(
54
- args: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>
55
- ): AlchemySmartAccountClient<
56
- CustomTransport,
57
- TChain,
58
- TAccount,
59
- Record<string, never>,
60
- TContext
61
- >;
62
-
63
- /**
64
- * Creates an AlchemySmartAccountClient using the provided RPC client configuration, including options, account, simulation settings, gas management, fee estimation, middleware and user operation signing.
65
- *
66
- * @example
67
- * ```ts
68
- * import { createAlchemySmartAccountClientFromRpcClient, createAlchemyPublicRpcClient } from "@account-kit/infra";
69
- *
70
- * const client = createAlchemyPublicRpcClient(...);
71
- * const scaClient = createAlchemySmartAccountClientFromRpcClient({
72
- * client,
73
- * ...
74
- * });
75
- * ```
76
- *
77
- * @param {CreateAlchemySmartAccountClientFromRpcClientParams} args The configuration object containing all required parameters
78
- * @returns {AlchemySmartAccountClient} An instance of AlchemySmartAccountClient
79
- */
80
- export function createAlchemySmartAccountClientFromRpcClient(
81
- args: CreateAlchemySmartAccountClientFromRpcClientParams
82
- ): AlchemySmartAccountClient {
83
- const {
84
- opts,
85
- account,
86
- useSimulation,
87
- policyId,
88
- feeEstimator,
89
- gasEstimator,
90
- customMiddleware,
91
- signUserOperation,
92
- client,
93
- } = args;
94
- const feeOptions =
95
- opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);
96
-
97
- const scaClient = createSmartAccountClientFromExisting({
98
- account,
99
- client,
100
- type: "AlchemySmartAccountClient",
101
- opts: {
102
- ...opts,
103
- feeOptions,
104
- },
105
- customMiddleware: async (struct, args) => {
106
- if (isSmartAccountWithSigner(args.account)) {
107
- client.updateHeaders(getSignerTypeHeader(args.account));
108
- }
109
- return customMiddleware ? customMiddleware(struct, args) : struct;
110
- },
111
- feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),
112
- userOperationSimulator: useSimulation
113
- ? alchemyUserOperationSimulator(client)
114
- : undefined,
115
- gasEstimator,
116
- ...(policyId && alchemyGasManagerMiddleware(policyId)),
117
- signUserOperation,
118
- }).extend(alchemyActions);
119
-
120
- if (account && isSmartAccountWithSigner(account)) {
121
- client.updateHeaders(getSignerTypeHeader(account));
122
- }
123
-
124
- return scaClient;
125
- }
package/src/type.ts DELETED
@@ -1,4 +0,0 @@
1
- import { z } from "zod";
2
- import type { AlchemyProviderConfigSchema } from "./schema.js";
3
-
4
- export type AlchemyProviderConfig = z.input<typeof AlchemyProviderConfigSchema>;