@account-kit/infra 4.0.0-alpha.0 → 4.0.0-alpha.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 (123) hide show
  1. package/dist/cjs/actions/simulateUserOperationChanges.js.map +1 -1
  2. package/dist/cjs/chains.d.ts +25 -0
  3. package/dist/cjs/chains.js +200 -1
  4. package/dist/cjs/chains.js.map +1 -1
  5. package/dist/cjs/client/decorators/alchemyEnhancedApis.d.ts +5393 -1
  6. package/dist/cjs/client/decorators/alchemyEnhancedApis.js.map +1 -1
  7. package/dist/cjs/client/decorators/smartAccount.js.map +1 -1
  8. package/dist/cjs/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  9. package/dist/cjs/client/internal/smartAccountClientFromRpc.js +3 -14
  10. package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -1
  11. package/dist/cjs/client/isAlchemySmartAccountClient.d.ts +1173 -1317
  12. package/dist/cjs/client/isAlchemySmartAccountClient.js.map +1 -1
  13. package/dist/cjs/client/rpcClient.js.map +1 -1
  14. package/dist/cjs/client/smartAccountClient.d.ts +2 -3
  15. package/dist/cjs/client/smartAccountClient.js +2 -2
  16. package/dist/cjs/client/smartAccountClient.js.map +1 -1
  17. package/dist/cjs/client/types.d.ts +1 -48
  18. package/dist/cjs/client/types.js.map +1 -1
  19. package/dist/cjs/defaults.js +7 -7
  20. package/dist/cjs/defaults.js.map +1 -1
  21. package/dist/cjs/gas-manager.js +16 -16
  22. package/dist/cjs/gas-manager.js.map +1 -1
  23. package/dist/cjs/index.d.ts +2 -1
  24. package/dist/cjs/index.js +22 -1
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/middleware/feeEstimator.js.map +1 -1
  27. package/dist/cjs/middleware/gasManager.d.ts +2 -29
  28. package/dist/cjs/middleware/gasManager.js +4 -141
  29. package/dist/cjs/middleware/gasManager.js.map +1 -1
  30. package/dist/cjs/middleware/userOperationSimulator.d.ts +2 -2
  31. package/dist/cjs/middleware/userOperationSimulator.js.map +1 -1
  32. package/dist/cjs/schema.js +3 -10
  33. package/dist/cjs/schema.js.map +1 -1
  34. package/dist/cjs/version.d.ts +1 -1
  35. package/dist/cjs/version.js +1 -1
  36. package/dist/cjs/version.js.map +1 -1
  37. package/dist/esm/actions/simulateUserOperationChanges.js.map +1 -1
  38. package/dist/esm/chains.d.ts +25 -0
  39. package/dist/esm/chains.js +199 -0
  40. package/dist/esm/chains.js.map +1 -1
  41. package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +5393 -1
  42. package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -1
  43. package/dist/esm/client/decorators/smartAccount.js.map +1 -1
  44. package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +2 -2
  45. package/dist/esm/client/internal/smartAccountClientFromRpc.js +3 -14
  46. package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -1
  47. package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1173 -1317
  48. package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
  49. package/dist/esm/client/rpcClient.js.map +1 -1
  50. package/dist/esm/client/smartAccountClient.d.ts +2 -3
  51. package/dist/esm/client/smartAccountClient.js +2 -3
  52. package/dist/esm/client/smartAccountClient.js.map +1 -1
  53. package/dist/esm/client/types.d.ts +1 -48
  54. package/dist/esm/client/types.js.map +1 -1
  55. package/dist/esm/defaults.js +2 -1
  56. package/dist/esm/defaults.js.map +1 -1
  57. package/dist/esm/gas-manager.js +1 -1
  58. package/dist/esm/gas-manager.js.map +1 -1
  59. package/dist/esm/index.d.ts +2 -1
  60. package/dist/esm/index.js +1 -1
  61. package/dist/esm/index.js.map +1 -1
  62. package/dist/esm/middleware/feeEstimator.js.map +1 -1
  63. package/dist/esm/middleware/gasManager.d.ts +2 -29
  64. package/dist/esm/middleware/gasManager.js +5 -142
  65. package/dist/esm/middleware/gasManager.js.map +1 -1
  66. package/dist/esm/middleware/userOperationSimulator.d.ts +2 -2
  67. package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
  68. package/dist/esm/schema.js +4 -11
  69. package/dist/esm/schema.js.map +1 -1
  70. package/dist/esm/version.d.ts +1 -1
  71. package/dist/esm/version.js +1 -1
  72. package/dist/esm/version.js.map +1 -1
  73. package/dist/types/actions/simulateUserOperationChanges.d.ts +17 -0
  74. package/dist/types/actions/simulateUserOperationChanges.d.ts.map +1 -1
  75. package/dist/types/chains.d.ts +44 -0
  76. package/dist/types/chains.d.ts.map +1 -1
  77. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +5410 -1
  78. package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
  79. package/dist/types/client/decorators/smartAccount.d.ts +15 -0
  80. package/dist/types/client/decorators/smartAccount.d.ts.map +1 -1
  81. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +4 -4
  82. package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +1 -1
  83. package/dist/types/client/isAlchemySmartAccountClient.d.ts +1188 -1317
  84. package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
  85. package/dist/types/client/rpcClient.d.ts +22 -0
  86. package/dist/types/client/rpcClient.d.ts.map +1 -1
  87. package/dist/types/client/smartAccountClient.d.ts +2 -3
  88. package/dist/types/client/smartAccountClient.d.ts.map +1 -1
  89. package/dist/types/client/types.d.ts +1 -48
  90. package/dist/types/client/types.d.ts.map +1 -1
  91. package/dist/types/defaults.d.ts +14 -0
  92. package/dist/types/defaults.d.ts.map +1 -1
  93. package/dist/types/gas-manager.d.ts +13 -0
  94. package/dist/types/gas-manager.d.ts.map +1 -1
  95. package/dist/types/index.d.ts +2 -1
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/dist/types/middleware/feeEstimator.d.ts +19 -0
  98. package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
  99. package/dist/types/middleware/gasManager.d.ts +15 -87
  100. package/dist/types/middleware/gasManager.d.ts.map +1 -1
  101. package/dist/types/middleware/userOperationSimulator.d.ts +21 -2
  102. package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
  103. package/dist/types/schema.d.ts.map +1 -1
  104. package/dist/types/version.d.ts +1 -1
  105. package/dist/types/version.d.ts.map +1 -1
  106. package/package.json +5 -4
  107. package/src/actions/simulateUserOperationChanges.ts +17 -0
  108. package/src/chains.ts +255 -0
  109. package/src/client/decorators/alchemyEnhancedApis.ts +50 -33
  110. package/src/client/decorators/smartAccount.ts +15 -0
  111. package/src/client/internal/smartAccountClientFromRpc.ts +36 -32
  112. package/src/client/isAlchemySmartAccountClient.ts +15 -0
  113. package/src/client/rpcClient.ts +22 -0
  114. package/src/client/smartAccountClient.ts +21 -5
  115. package/src/client/types.ts +1 -54
  116. package/src/defaults.ts +17 -3
  117. package/src/gas-manager.ts +17 -4
  118. package/src/index.ts +25 -1
  119. package/src/middleware/feeEstimator.ts +19 -0
  120. package/src/middleware/gasManager.ts +21 -424
  121. package/src/middleware/userOperationSimulator.ts +25 -2
  122. package/src/schema.ts +3 -11
  123. package/src/version.ts +1 -1
package/src/chains.ts CHANGED
@@ -1,5 +1,51 @@
1
1
  import type { Chain } from "viem";
2
2
 
3
+ import { defineChain } from "viem";
4
+ import {
5
+ arbitrum as vab,
6
+ arbitrumGoerli as vabg,
7
+ arbitrumSepolia as vabs,
8
+ base as vbase,
9
+ baseGoerli as vbaseg,
10
+ baseSepolia as vbases,
11
+ fraxtal as vfrax,
12
+ goerli as vgo,
13
+ mainnet as vmain,
14
+ optimism as vop,
15
+ optimismGoerli as vopg,
16
+ optimismSepolia as vops,
17
+ polygon as vpg,
18
+ polygonAmoy as vpga,
19
+ polygonMumbai as vpgm,
20
+ sepolia as vsep,
21
+ zora as vzora,
22
+ zoraSepolia as vzoras,
23
+ } from "viem/chains";
24
+
25
+ export type AlchemyChainConfig = {
26
+ chain: Chain;
27
+ rpcBaseUrl: string;
28
+ };
29
+
30
+ /**
31
+ * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { defineAlchemyChain } from "@account-kit/infra";
36
+ * import { sepolia } from "viem/chains";
37
+ *
38
+ * const chain = defineAlchemyChain({
39
+ * chain: sepolia,
40
+ * rpcBaseUrl: "https://eth-sepolia.g.alchemy.com/v2"
41
+ * });
42
+ * ```
43
+ *
44
+ * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain
45
+ * @param {Chain} params.chain The original chain configuration
46
+ * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL
47
+ * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added
48
+ */
3
49
  export const defineAlchemyChain = ({
4
50
  chain,
5
51
  rpcBaseUrl,
@@ -17,3 +63,212 @@ export const defineAlchemyChain = ({
17
63
  },
18
64
  };
19
65
  };
66
+
67
+ export const arbitrum: Chain = {
68
+ ...vab,
69
+ rpcUrls: {
70
+ ...vab.rpcUrls,
71
+ alchemy: {
72
+ http: ["https://arb-mainnet.g.alchemy.com/v2"],
73
+ },
74
+ },
75
+ };
76
+
77
+ export const arbitrumGoerli: Chain = {
78
+ ...vabg,
79
+ rpcUrls: {
80
+ ...vabg.rpcUrls,
81
+ alchemy: {
82
+ http: ["https://arb-goerli.g.alchemy.com/v2"],
83
+ },
84
+ },
85
+ };
86
+
87
+ export const arbitrumSepolia: Chain = {
88
+ ...vabs,
89
+ rpcUrls: {
90
+ ...vabs.rpcUrls,
91
+ alchemy: {
92
+ http: ["https://arb-sepolia.g.alchemy.com/v2"],
93
+ },
94
+ },
95
+ };
96
+ export const goerli: Chain = {
97
+ ...vgo,
98
+ rpcUrls: {
99
+ ...vgo.rpcUrls,
100
+ alchemy: {
101
+ http: ["https://eth-goerli.g.alchemy.com/v2"],
102
+ },
103
+ },
104
+ };
105
+ export const mainnet: Chain = {
106
+ ...vmain,
107
+ rpcUrls: {
108
+ ...vmain.rpcUrls,
109
+ alchemy: {
110
+ http: ["https://eth-mainnet.g.alchemy.com/v2"],
111
+ },
112
+ },
113
+ };
114
+ export const optimism: Chain = {
115
+ ...vop,
116
+ rpcUrls: {
117
+ ...vop.rpcUrls,
118
+ alchemy: {
119
+ http: ["https://opt-mainnet.g.alchemy.com/v2"],
120
+ },
121
+ },
122
+ };
123
+ export const optimismGoerli: Chain = {
124
+ ...vopg,
125
+ rpcUrls: {
126
+ ...vopg.rpcUrls,
127
+ alchemy: {
128
+ http: ["https://opt-goerli.g.alchemy.com/v2"],
129
+ },
130
+ },
131
+ };
132
+ export const optimismSepolia: Chain = {
133
+ ...vops,
134
+ rpcUrls: {
135
+ ...vops.rpcUrls,
136
+ alchemy: {
137
+ http: ["https://opt-sepolia.g.alchemy.com/v2"],
138
+ },
139
+ },
140
+ };
141
+ export const sepolia: Chain = {
142
+ ...vsep,
143
+ rpcUrls: {
144
+ ...vsep.rpcUrls,
145
+ alchemy: {
146
+ http: ["https://eth-sepolia.g.alchemy.com/v2"],
147
+ },
148
+ },
149
+ };
150
+ export const base: Chain = {
151
+ ...vbase,
152
+ rpcUrls: {
153
+ ...vbase.rpcUrls,
154
+ alchemy: {
155
+ http: ["https://base-mainnet.g.alchemy.com/v2"],
156
+ },
157
+ },
158
+ };
159
+ export const baseGoerli: Chain = {
160
+ ...vbaseg,
161
+ rpcUrls: {
162
+ ...vbaseg.rpcUrls,
163
+ alchemy: {
164
+ http: ["https://base-goerli.g.alchemy.com/v2"],
165
+ },
166
+ },
167
+ };
168
+ export const baseSepolia: Chain = {
169
+ ...vbases,
170
+ rpcUrls: {
171
+ ...vbases.rpcUrls,
172
+ alchemy: {
173
+ http: ["https://base-sepolia.g.alchemy.com/v2"],
174
+ },
175
+ },
176
+ };
177
+
178
+ export const polygonMumbai: Chain = {
179
+ ...vpgm,
180
+ rpcUrls: {
181
+ ...vpgm.rpcUrls,
182
+ alchemy: {
183
+ http: ["https://polygon-mumbai.g.alchemy.com/v2"],
184
+ },
185
+ },
186
+ };
187
+
188
+ export const polygonAmoy: Chain = {
189
+ ...vpga,
190
+ rpcUrls: {
191
+ ...vpga.rpcUrls,
192
+ alchemy: {
193
+ http: ["https://polygon-amoy.g.alchemy.com/v2"],
194
+ },
195
+ },
196
+ };
197
+
198
+ export const polygon: Chain = {
199
+ ...vpg,
200
+ rpcUrls: {
201
+ ...vpg.rpcUrls,
202
+ alchemy: {
203
+ http: ["https://polygon-mainnet.g.alchemy.com/v2"],
204
+ },
205
+ },
206
+ };
207
+
208
+ export const fraxtal: Chain = {
209
+ ...vfrax,
210
+ rpcUrls: {
211
+ ...vfrax.rpcUrls,
212
+ },
213
+ };
214
+
215
+ export const fraxtalSepolia: Chain = defineChain({
216
+ id: 2523,
217
+ name: "Fraxtal Sepolia",
218
+ nativeCurrency: { name: "Frax Ether", symbol: "frxETH", decimals: 18 },
219
+ rpcUrls: {
220
+ default: {
221
+ http: ["https://rpc.testnet-sepolia.frax.com"],
222
+ },
223
+ },
224
+ });
225
+
226
+ export const zora: Chain = {
227
+ ...vzora,
228
+ rpcUrls: {
229
+ ...vzora.rpcUrls,
230
+ },
231
+ };
232
+
233
+ export const zoraSepolia: Chain = {
234
+ ...vzoras,
235
+ rpcUrls: {
236
+ ...vzoras.rpcUrls,
237
+ },
238
+ };
239
+
240
+ export const worldChainSepolia: Chain = defineChain({
241
+ id: 4801,
242
+ name: "World Chain Sepolia",
243
+ network: "World Chain Sepolia",
244
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
245
+ rpcUrls: {
246
+ default: {
247
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
248
+ },
249
+ public: {
250
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
251
+ },
252
+ alchemy: {
253
+ http: ["https://worldchain-sepolia.g.alchemy.com/v2"],
254
+ },
255
+ },
256
+ });
257
+
258
+ export const worldChain: Chain = defineChain({
259
+ id: 480,
260
+ name: "World Chain",
261
+ network: "World Chain",
262
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
263
+ rpcUrls: {
264
+ default: {
265
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
266
+ },
267
+ public: {
268
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
269
+ },
270
+ alchemy: {
271
+ http: ["https://worldchain-mainnet.g.alchemy.com/v2"],
272
+ },
273
+ },
274
+ });
@@ -14,41 +14,58 @@ export type AlchemyEnhancedApis = {
14
14
  config: Alchemy["config"];
15
15
  };
16
16
 
17
- export const alchemyEnhancedApiActions: (
18
- alchemy: Alchemy
19
- ) => <
20
- TTransport extends Transport = Transport,
21
- TChain extends Chain | undefined = Chain | undefined,
22
- TAccount extends SmartContractAccount | undefined =
23
- | SmartContractAccount
24
- | undefined
25
- >(
26
- client: AlchemySmartAccountClient<TTransport, TChain, TAccount>
27
- ) => AlchemyEnhancedApis = (alchemy) => (client) => {
28
- const alchemySdk = AlchemySdkClientSchema.parse(alchemy);
17
+ /**
18
+ * Given an instance of the Alchemy SDK, returns a smart account client decorator which contains actions for interacting Alchemy's enhanced APIs.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { Alchemy } from "alchemy-sdk";
23
+ * import { alchemyEnhancedApiActions } from "@account-kit/infra";
24
+ * import { alchemySCAClient } from "./client";
25
+ *
26
+ * const alchemy = new Alchemy(...);
27
+ * const enhancedApiDecorator = alchemyEnhancedApiActions(alchemy);
28
+ * const withEnhancedApis = alchemySCAClient.extend(enhancedApiDecorator);
29
+ * ```
30
+ *
31
+ * @param {Alchemy} alchemy The Alchemy instance containing the SDK client
32
+ * @returns {(client: AlchemySmartAccountClient) => AlchemyEnhancedApis} A client decorator for Alchemy Smart Account clients that adds the enhanced API methods
33
+ */
34
+ export const alchemyEnhancedApiActions =
35
+ (alchemy: Alchemy) =>
36
+ <
37
+ TTransport extends Transport = Transport,
38
+ TChain extends Chain | undefined = Chain | undefined,
39
+ TAccount extends SmartContractAccount | undefined =
40
+ | SmartContractAccount
41
+ | undefined
42
+ >(
43
+ client: AlchemySmartAccountClient<TTransport, TChain, TAccount>
44
+ ): AlchemyEnhancedApis => {
45
+ const alchemySdk = AlchemySdkClientSchema.parse(alchemy);
29
46
 
30
- if (client.transport.type === "http") {
31
- const { url } = client.transport as ReturnType<HttpTransport>["config"] &
32
- ReturnType<HttpTransport>["value"];
47
+ if (client.transport.type === "http") {
48
+ const { url } = client.transport as ReturnType<HttpTransport>["config"] &
49
+ ReturnType<HttpTransport>["value"];
33
50
 
34
- if (
35
- client.transport.type === "http" &&
36
- alchemy.config.url &&
37
- alchemy.config.url !== url
38
- ) {
39
- throw new Error(
40
- "Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL"
41
- );
51
+ if (
52
+ client.transport.type === "http" &&
53
+ alchemy.config.url &&
54
+ alchemy.config.url !== url
55
+ ) {
56
+ throw new Error(
57
+ "Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL"
58
+ );
59
+ }
42
60
  }
43
- }
44
61
 
45
- return {
46
- core: alchemySdk.core,
47
- nft: alchemySdk.nft,
48
- transact: alchemySdk.transact,
49
- debug: alchemySdk.debug,
50
- ws: alchemySdk.ws,
51
- notify: alchemySdk.notify,
52
- config: alchemySdk.config,
62
+ return {
63
+ core: alchemySdk.core,
64
+ nft: alchemySdk.nft,
65
+ transact: alchemySdk.transact,
66
+ debug: alchemySdk.debug,
67
+ ws: alchemySdk.ws,
68
+ notify: alchemySdk.notify,
69
+ config: alchemySdk.config,
70
+ };
53
71
  };
54
- };
@@ -20,6 +20,21 @@ export type AlchemySmartAccountClientActions<
20
20
  ) => Promise<SimulateUserOperationAssetChangesResponse>;
21
21
  };
22
22
 
23
+ /**
24
+ * Provides a set of actions for interacting with the Alchemy Smart Account client, including the ability to simulate user operations.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { alchemyActions } from "@account-kit/infra";
29
+ * import { createPublicClient } from "viem";
30
+ *
31
+ * const client = createPublicClient(...);
32
+ * const clientWithAlchemyActions = client.extend(alchemyActions);
33
+ * ```
34
+ *
35
+ * @param {Client<TTransport, TChain, TAccount>} client The client instance used to perform actions
36
+ * @returns {AlchemySmartAccountClientActions<TAccount, TContext>} An object containing Alchemy Smart Account client actions
37
+ */
23
38
  export const alchemyActions: <
24
39
  TTransport extends Transport = Transport,
25
40
  TChain extends Chain | undefined = Chain | undefined,
@@ -17,7 +17,7 @@ import type {
17
17
  } from "../smartAccountClient.js";
18
18
  import type { ClientWithAlchemyMethods } from "../types.js";
19
19
 
20
- export type CreateAlchemySmartAccountClientFromRpcClient<
20
+ export type CreateAlchemySmartAccountClientFromRpcClientParams<
21
21
  TAccount extends SmartContractAccount | undefined =
22
22
  | SmartContractAccount
23
23
  | undefined,
@@ -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,
@@ -51,7 +51,7 @@ export function createAlchemySmartAccountClientFromRpcClient<
51
51
  | UserOperationContext
52
52
  | undefined
53
53
  >(
54
- args: CreateAlchemySmartAccountClientFromRpcClient<TAccount, TContext>
54
+ args: CreateAlchemySmartAccountClientFromRpcClientParams<TAccount, TContext>
55
55
  ): AlchemySmartAccountClient<
56
56
  CustomTransport,
57
57
  TChain,
@@ -60,17 +60,37 @@ export function createAlchemySmartAccountClientFromRpcClient<
60
60
  TContext
61
61
  >;
62
62
 
63
- export function createAlchemySmartAccountClientFromRpcClient({
64
- opts,
65
- account,
66
- useSimulation,
67
- gasManagerConfig,
68
- feeEstimator,
69
- gasEstimator,
70
- customMiddleware,
71
- signUserOperation,
72
- client,
73
- }: CreateAlchemySmartAccountClientFromRpcClient): AlchemySmartAccountClient {
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;
74
94
  const feeOptions =
75
95
  opts?.feeOptions ?? getDefaultUserOperationFeeOptions(client.chain);
76
96
 
@@ -86,7 +106,6 @@ export function createAlchemySmartAccountClientFromRpcClient({
86
106
  if (isSmartAccountWithSigner(args.account)) {
87
107
  client.updateHeaders(getSignerTypeHeader(args.account));
88
108
  }
89
-
90
109
  return customMiddleware ? customMiddleware(struct, args) : struct;
91
110
  },
92
111
  feeEstimator: feeEstimator ?? alchemyFeeEstimator(client),
@@ -94,22 +113,7 @@ export function createAlchemySmartAccountClientFromRpcClient({
94
113
  ? alchemyUserOperationSimulator(client)
95
114
  : undefined,
96
115
  gasEstimator,
97
- ...(gasManagerConfig &&
98
- alchemyGasManagerMiddleware(client, {
99
- ...gasManagerConfig,
100
- gasEstimationOptions: {
101
- ...gasManagerConfig.gasEstimationOptions,
102
- disableGasEstimation:
103
- gasManagerConfig.gasEstimationOptions?.disableGasEstimation ??
104
- false,
105
- fallbackFeeDataGetter:
106
- gasManagerConfig.gasEstimationOptions?.fallbackFeeDataGetter ??
107
- feeEstimator,
108
- fallbackGasEstimator:
109
- gasManagerConfig.gasEstimationOptions?.fallbackGasEstimator ??
110
- gasEstimator,
111
- },
112
- })),
116
+ ...(policyId && alchemyGasManagerMiddleware(policyId)),
113
117
  signUserOperation,
114
118
  }).extend(alchemyActions);
115
119
 
@@ -2,6 +2,21 @@ import { isSmartAccountClient, type SmartContractAccount } from "@aa-sdk/core";
2
2
  import type { Chain, Client, Transport } from "viem";
3
3
  import type { AlchemySmartAccountClient } from "./smartAccountClient";
4
4
 
5
+ /**
6
+ * Checks if a given client is an Alchemy Smart Account Client. The goal of this check is to ensure that the client supports certain RPC methods.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { isAlchemySmartAccountClient } from "@account-kit/infra";
11
+ *
12
+ * if (isAlchemySmartAccountClient(client)) {
13
+ * // do things with the client as an Alchemy Smart Account Client
14
+ * }
15
+ * ```
16
+ *
17
+ * @param {Client<TTransport, TChain, TAccount>} client The client instance to be checked
18
+ * @returns {boolean} `true` if the client is an Alchemy Smart Account Client, otherwise `false`
19
+ */
5
20
  export const isAlchemySmartAccountClient = <
6
21
  TTransport extends Transport = Transport,
7
22
  TChain extends Chain | undefined = Chain | undefined,
@@ -8,6 +8,28 @@ import { AlchemyChainSchema } from "../schema.js";
8
8
  import { VERSION } from "../version.js";
9
9
  import type { ClientWithAlchemyMethods } from "./types.js";
10
10
 
11
+ /**
12
+ * Creates an Alchemy public RPC client with the provided chain, connection configuration, and optional fetch options. The client has alchemy methods and can dynamically update HTTP headers.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { createAlchemyPublicRpcClient } from "@account-kit/infra";
17
+ * import { sepolia } from "@account-kit/infra";
18
+ *
19
+ * const client = createAlchemyPublicRpcClient({
20
+ * chain: sepolia,
21
+ * connectionConfig: {
22
+ * apiKey: "your-api-key",
23
+ * }
24
+ * });
25
+ * ```
26
+ *
27
+ * @param {{connectionConfig: ConnectionConfig,chain: Chain,fetchOptions?: NoUndefined<HttpTransportConfig["fetchOptions"]>}} params The parameters for creating the Alchemy public RPC client
28
+ * @param {ConnectionConfig} params.connectionConfig The connection configuration containing the RPC URL and API key
29
+ * @param {Chain} params.chain The blockchain chain configuration
30
+ * @param {NoUndefined<HttpTransportConfig["fetchOptions"]>} [params.fetchOptions] Optional fetch configuration for HTTP transport
31
+ * @returns {ClientWithAlchemyMethods} A client object tailored with Alchemy methods and capabilities to interact with the blockchain
32
+ */
11
33
  export const createAlchemyPublicRpcClient = ({
12
34
  chain: chain_,
13
35
  connectionConfig,
@@ -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,
@@ -115,9 +114,26 @@ export function createAlchemySmartAccountClient<
115
114
  TContext
116
115
  >;
117
116
 
117
+ /**
118
+ * Creates an Alchemy smart account client using the provided configuration options, including account details, gas manager configuration, and custom middleware.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * import { createAlchemySmartAccountClient } from "@account-kit/infra";
123
+ * import { sepolia } from "@account-kit/infra/chain";
124
+ *
125
+ * const client = createAlchemySmartAccountClient({
126
+ * chain: sepolia,
127
+ * apiKey: "your-api-key",
128
+ * });
129
+ * ```
130
+ *
131
+ * @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client
132
+ * @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options
133
+ */
118
134
  export function createAlchemySmartAccountClient({
119
135
  account,
120
- gasManagerConfig,
136
+ policyId,
121
137
  useSimulation,
122
138
  feeEstimator,
123
139
  customMiddleware,
@@ -143,7 +159,7 @@ export function createAlchemySmartAccountClient({
143
159
  ...opts,
144
160
  feeOptions,
145
161
  },
146
- gasManagerConfig,
162
+ policyId,
147
163
  useSimulation,
148
164
  feeEstimator,
149
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;