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

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 (98) hide show
  1. package/dist/cjs/chains.d.ts +21 -0
  2. package/dist/cjs/chains.js +200 -1
  3. package/dist/cjs/chains.js.map +1 -1
  4. package/dist/cjs/client/decorators/alchemyEnhancedApis.d.ts +1173 -1317
  5. package/dist/cjs/client/internal/smartAccountClientFromRpc.js +2 -14
  6. package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -1
  7. package/dist/cjs/client/isAlchemySmartAccountClient.d.ts +1173 -1317
  8. package/dist/cjs/client/rpcClient.js.map +1 -1
  9. package/dist/cjs/client/smartAccountClient.d.ts +2 -3
  10. package/dist/cjs/client/smartAccountClient.js +2 -2
  11. package/dist/cjs/client/smartAccountClient.js.map +1 -1
  12. package/dist/cjs/client/types.d.ts +1 -48
  13. package/dist/cjs/client/types.js.map +1 -1
  14. package/dist/cjs/defaults.js +7 -7
  15. package/dist/cjs/defaults.js.map +1 -1
  16. package/dist/cjs/gas-manager.js +16 -16
  17. package/dist/cjs/gas-manager.js.map +1 -1
  18. package/dist/cjs/index.d.ts +1 -1
  19. package/dist/cjs/index.js +22 -1
  20. package/dist/cjs/index.js.map +1 -1
  21. package/dist/cjs/middleware/gasManager.d.ts +2 -29
  22. package/dist/cjs/middleware/gasManager.js +4 -141
  23. package/dist/cjs/middleware/gasManager.js.map +1 -1
  24. package/dist/cjs/middleware/userOperationSimulator.d.ts +2 -2
  25. package/dist/cjs/middleware/userOperationSimulator.js.map +1 -1
  26. package/dist/cjs/schema.js +3 -10
  27. package/dist/cjs/schema.js.map +1 -1
  28. package/dist/cjs/version.d.ts +1 -1
  29. package/dist/cjs/version.js +1 -1
  30. package/dist/cjs/version.js.map +1 -1
  31. package/dist/esm/chains.d.ts +21 -0
  32. package/dist/esm/chains.js +199 -0
  33. package/dist/esm/chains.js.map +1 -1
  34. package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +1173 -1317
  35. package/dist/esm/client/internal/smartAccountClientFromRpc.js +2 -14
  36. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -1
  37. package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1173 -1317
  38. package/dist/esm/client/rpcClient.js.map +1 -1
  39. package/dist/esm/client/smartAccountClient.d.ts +2 -3
  40. package/dist/esm/client/smartAccountClient.js +2 -3
  41. package/dist/esm/client/smartAccountClient.js.map +1 -1
  42. package/dist/esm/client/types.d.ts +1 -48
  43. package/dist/esm/client/types.js.map +1 -1
  44. package/dist/esm/defaults.js +2 -1
  45. package/dist/esm/defaults.js.map +1 -1
  46. package/dist/esm/gas-manager.js +1 -1
  47. package/dist/esm/gas-manager.js.map +1 -1
  48. package/dist/esm/index.d.ts +1 -1
  49. package/dist/esm/index.js +1 -1
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/esm/middleware/gasManager.d.ts +2 -29
  52. package/dist/esm/middleware/gasManager.js +5 -142
  53. package/dist/esm/middleware/gasManager.js.map +1 -1
  54. package/dist/esm/middleware/userOperationSimulator.d.ts +2 -2
  55. package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
  56. package/dist/esm/schema.js +4 -11
  57. package/dist/esm/schema.js.map +1 -1
  58. package/dist/esm/version.d.ts +1 -1
  59. package/dist/esm/version.js +1 -1
  60. package/dist/esm/version.js.map +1 -1
  61. package/dist/types/chains.d.ts +21 -0
  62. package/dist/types/chains.d.ts.map +1 -1
  63. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +1173 -1317
  64. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
  65. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  66. package/dist/types/client/isAlchemySmartAccountClient.d.ts +1173 -1317
  67. package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
  68. package/dist/types/client/rpcClient.d.ts +1 -1
  69. package/dist/types/client/smartAccountClient.d.ts +2 -3
  70. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  71. package/dist/types/client/types.d.ts +1 -48
  72. package/dist/types/client/types.d.ts.map +1 -1
  73. package/dist/types/defaults.d.ts +1 -1
  74. package/dist/types/defaults.d.ts.map +1 -1
  75. package/dist/types/gas-manager.d.ts +1 -1
  76. package/dist/types/gas-manager.d.ts.map +1 -1
  77. package/dist/types/index.d.ts +1 -1
  78. package/dist/types/index.d.ts.map +1 -1
  79. package/dist/types/middleware/gasManager.d.ts +15 -87
  80. package/dist/types/middleware/gasManager.d.ts.map +1 -1
  81. package/dist/types/middleware/userOperationSimulator.d.ts +2 -2
  82. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
  83. package/dist/types/schema.d.ts.map +1 -1
  84. package/dist/types/version.d.ts +1 -1
  85. package/dist/types/version.d.ts.map +1 -1
  86. package/package.json +5 -4
  87. package/src/chains.ts +231 -0
  88. package/src/client/internal/smartAccountClientFromRpc.ts +4 -20
  89. package/src/client/rpcClient.ts +1 -1
  90. package/src/client/smartAccountClient.ts +4 -5
  91. package/src/client/types.ts +1 -54
  92. package/src/defaults.ts +4 -4
  93. package/src/gas-manager.ts +3 -3
  94. package/src/index.ts +24 -1
  95. package/src/middleware/gasManager.ts +21 -424
  96. package/src/middleware/userOperationSimulator.ts +6 -2
  97. package/src/schema.ts +3 -11
  98. package/src/version.ts +1 -1
@@ -39,8 +39,8 @@ export function getSignerTypeHeader<
39
39
  * Helper method meant to be used internally to create an alchemy smart account client
40
40
  * from an existing Alchemy Rpc Client
41
41
  *
42
- * @param args configuration for the client
43
- * @returns a smart account client configured to use Alchemy's RPC
42
+ * @param {CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>} args configuration for the client
43
+ * @returns {AlchemySmartAccountClient} a smart account client configured to use Alchemy's RPC
44
44
  */
45
45
  export function createAlchemySmartAccountClientFromRpcClient<
46
46
  TChain extends Chain | undefined = Chain | undefined,
@@ -84,7 +84,7 @@ export function createAlchemySmartAccountClientFromRpcClient(
84
84
  opts,
85
85
  account,
86
86
  useSimulation,
87
- gasManagerConfig,
87
+ policyId,
88
88
  feeEstimator,
89
89
  gasEstimator,
90
90
  customMiddleware,
@@ -106,7 +106,6 @@ export function createAlchemySmartAccountClientFromRpcClient(
106
106
  if (isSmartAccountWithSigner(args.account)) {
107
107
  client.updateHeaders(getSignerTypeHeader(args.account));
108
108
  }
109
-
110
109
  return customMiddleware ? customMiddleware(struct, args) : struct;
111
110
  },
112
111
  feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),
@@ -114,22 +113,7 @@ export function createAlchemySmartAccountClientFromRpcClient(
114
113
  ? alchemyUserOperationSimulator(client)
115
114
  : undefined,
116
115
  gasEstimator,
117
- ...(gasManagerConfig &&
118
- alchemyGasManagerMiddleware(client, {
119
- ...gasManagerConfig,
120
- gasEstimationOptions: {
121
- ...gasManagerConfig.gasEstimationOptions,
122
- disableGasEstimation:
123
- gasManagerConfig.gasEstimationOptions?.disableGasEstimation ??
124
- false,
125
- fallbackFeeDataGetter:
126
- gasManagerConfig.gasEstimationOptions?.fallbackFeeDataGetter ??
127
- feeEstimator,
128
- fallbackGasEstimator:
129
- gasManagerConfig.gasEstimationOptions?.fallbackGasEstimator ??
130
- gasEstimator,
131
- },
132
- })),
116
+ ...(policyId && alchemyGasManagerMiddleware(policyId)),
133
117
  signUserOperation,
134
118
  }).extend(alchemyActions);
135
119
 
@@ -14,7 +14,7 @@ import type { ClientWithAlchemyMethods } from "./types.js";
14
14
  * @example
15
15
  * ```ts
16
16
  * import { createAlchemyPublicRpcClient } from "@account-kit/infra";
17
- * import { sepolia } from "@account-kit/infra/chains";
17
+ * import { sepolia } from "@account-kit/infra";
18
18
  *
19
19
  * const client = createAlchemyPublicRpcClient({
20
20
  * chain: sepolia,
@@ -9,7 +9,6 @@ import {
9
9
  } from "@aa-sdk/core";
10
10
  import { type Chain, type Transport } from "viem";
11
11
  import { getDefaultUserOperationFeeOptions } from "../defaults.js";
12
- import { type AlchemyGasManagerConfig } from "../middleware/gasManager.js";
13
12
  import { AlchemyProviderConfigSchema } from "../schema.js";
14
13
  import type { AlchemyProviderConfig } from "../type.js";
15
14
  import type { AlchemySmartAccountClientActions } from "./decorators/smartAccount.js";
@@ -30,7 +29,7 @@ export type AlchemySmartAccountClientConfig<
30
29
  > = {
31
30
  account?: account;
32
31
  useSimulation?: boolean;
33
- gasManagerConfig?: AlchemyGasManagerConfig;
32
+ policyId?: string;
34
33
  } & AlchemyProviderConfig &
35
34
  Pick<
36
35
  SmartAccountClientConfig<transport, chain, account, context>,
@@ -95,7 +94,7 @@ export function createAlchemySmartAccountClient<
95
94
  | undefined
96
95
  >({
97
96
  account,
98
- gasManagerConfig,
97
+ policyId,
99
98
  useSimulation,
100
99
  feeEstimator,
101
100
  customMiddleware,
@@ -134,7 +133,7 @@ export function createAlchemySmartAccountClient<
134
133
  */
135
134
  export function createAlchemySmartAccountClient({
136
135
  account,
137
- gasManagerConfig,
136
+ policyId,
138
137
  useSimulation,
139
138
  feeEstimator,
140
139
  customMiddleware,
@@ -160,7 +159,7 @@ export function createAlchemySmartAccountClient({
160
159
  ...opts,
161
160
  feeOptions,
162
161
  },
163
- gasManagerConfig,
162
+ policyId,
164
163
  useSimulation,
165
164
  feeEstimator,
166
165
  customMiddleware,
@@ -1,40 +1,11 @@
1
1
  import { type BundlerClient, type UserOperationRequest } from "@aa-sdk/core";
2
- import type { Address, Hex, HttpTransport } from "viem";
2
+ import type { HttpTransport } from "viem";
3
3
  import type {
4
4
  SimulateUserOperationAssetChangesRequest,
5
5
  SimulateUserOperationAssetChangesResponse,
6
6
  } from "../actions/types";
7
- import type {
8
- RequestGasAndPaymasterAndDataOverrides,
9
- RequestGasAndPaymasterAndDataResponse,
10
- RequestPaymasterAndDataResponse,
11
- } from "../middleware/gasManager";
12
7
 
13
8
  export type AlchemyRpcSchema = [
14
- {
15
- Method: "alchemy_requestPaymasterAndData";
16
- Parameters: [
17
- {
18
- policyId: string;
19
- entryPoint: Address;
20
- userOperation: UserOperationRequest;
21
- }
22
- ];
23
- ReturnType: RequestPaymasterAndDataResponse;
24
- },
25
- {
26
- Method: "alchemy_requestGasAndPaymasterAndData";
27
- Parameters: [
28
- {
29
- policyId: string;
30
- entryPoint: Address;
31
- userOperation: UserOperationRequest;
32
- dummySignature: Hex;
33
- overrides?: RequestGasAndPaymasterAndDataOverrides;
34
- }
35
- ];
36
- ReturnType: RequestGasAndPaymasterAndDataResponse;
37
- },
38
9
  {
39
10
  Method: "alchemy_simulateUserOperationAssetChanges";
40
11
  Parameters: SimulateUserOperationAssetChangesRequest;
@@ -50,30 +21,6 @@ export type AlchemyRpcSchema = [
50
21
  export type ClientWithAlchemyMethods = BundlerClient<HttpTransport> & {
51
22
  request: BundlerClient<HttpTransport>["request"] &
52
23
  {
53
- request(args: {
54
- method: "alchemy_requestPaymasterAndData";
55
- params: [
56
- {
57
- policyId: string;
58
- entryPoint: Address;
59
- userOperation: UserOperationRequest;
60
- }
61
- ];
62
- }): Promise<RequestPaymasterAndDataResponse>;
63
-
64
- request(args: {
65
- method: "alchemy_requestGasAndPaymasterAndData";
66
- params: [
67
- {
68
- policyId: string;
69
- entryPoint: Address;
70
- userOperation: UserOperationRequest;
71
- dummySignature: Hex;
72
- overrides?: RequestGasAndPaymasterAndDataOverrides;
73
- }
74
- ];
75
- }): Promise<RequestGasAndPaymasterAndDataResponse>;
76
-
77
24
  request(args: {
78
25
  method: "alchemy_simulateUserOperationAssetChanges";
79
26
  params: SimulateUserOperationAssetChangesRequest;
package/src/defaults.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type UserOperationFeeOptions } from "@aa-sdk/core";
2
+ import type { Chain } from "viem";
1
3
  import {
2
4
  arbitrum,
3
5
  arbitrumGoerli,
@@ -5,9 +7,7 @@ import {
5
7
  optimism,
6
8
  optimismGoerli,
7
9
  optimismSepolia,
8
- type UserOperationFeeOptions,
9
- } from "@aa-sdk/core";
10
- import type { Chain } from "viem";
10
+ } from "./chains.js";
11
11
 
12
12
  /**
13
13
  * Retrieves the default user operation fee options for a given chain. Adjusts fees for specific chains like Arbitrum and Optimism.
@@ -15,7 +15,7 @@ import type { Chain } from "viem";
15
15
  * @example
16
16
  * ```ts
17
17
  * import { getDefaultUserOperationFeeOptions } from "@account-kit/infra";
18
- * import { arbitrum } from "@account-kit/infra/chains";
18
+ * import { arbitrum } from "@account-kit/infra";
19
19
  *
20
20
  * const feeOpts = getDefaultUserOperationFeeOptions(arbitrum);
21
21
  * ```
@@ -1,3 +1,4 @@
1
+ import type { Address, Chain } from "viem";
1
2
  import {
2
3
  arbitrum,
3
4
  arbitrumSepolia,
@@ -14,8 +15,7 @@ import {
14
15
  sepolia,
15
16
  zora,
16
17
  zoraSepolia,
17
- } from "@aa-sdk/core";
18
- import type { Address, Chain } from "viem";
18
+ } from "./chains.js";
19
19
 
20
20
  export const AlchemyPaymasterAddressV3 =
21
21
  "0x4f84a207A80c39E9e8BaE717c1F25bA7AD1fB08F";
@@ -31,7 +31,7 @@ export const AlchemyPaymasterAddressV1 =
31
31
  *
32
32
  * @example
33
33
  * ```ts
34
- * import { sepolia, getAlchemyPaymasterAddress } from "@account-kit/infra/chains";
34
+ * import { sepolia, getAlchemyPaymasterAddress } from "@account-kit/infra";
35
35
  *
36
36
  * const paymasterAddress = getAlchemyPaymasterAddress(sepolia);
37
37
  * ```
package/src/index.ts CHANGED
@@ -2,7 +2,30 @@ export type * from "./actions/simulateUserOperationChanges.js";
2
2
  export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
3
3
  export type * from "./actions/types.js";
4
4
  export type * from "./chains.js";
5
- export { defineAlchemyChain } from "./chains.js";
5
+ export {
6
+ arbitrum,
7
+ arbitrumGoerli,
8
+ arbitrumSepolia,
9
+ base,
10
+ baseGoerli,
11
+ baseSepolia,
12
+ defineAlchemyChain,
13
+ fraxtal,
14
+ fraxtalSepolia,
15
+ goerli,
16
+ mainnet,
17
+ optimism,
18
+ optimismGoerli,
19
+ optimismSepolia,
20
+ polygon,
21
+ polygonAmoy,
22
+ polygonMumbai,
23
+ sepolia,
24
+ zora,
25
+ zoraSepolia,
26
+ worldChain,
27
+ worldChainSepolia,
28
+ } from "./chains.js";
6
29
  export type * from "./client/decorators/alchemyEnhancedApis.js";
7
30
  export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
8
31
  export type * from "./client/decorators/smartAccount.js";