@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.
- package/dist/cjs/actions/simulateUserOperationChanges.js.map +1 -1
- package/dist/cjs/chains.d.ts +25 -0
- package/dist/cjs/chains.js +200 -1
- package/dist/cjs/chains.js.map +1 -1
- package/dist/cjs/client/decorators/alchemyEnhancedApis.d.ts +5393 -1
- package/dist/cjs/client/decorators/alchemyEnhancedApis.js.map +1 -1
- package/dist/cjs/client/decorators/smartAccount.js.map +1 -1
- package/dist/cjs/client/internal/smartAccountClientFromRpc.d.ts +2 -2
- package/dist/cjs/client/internal/smartAccountClientFromRpc.js +3 -14
- package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -1
- package/dist/cjs/client/isAlchemySmartAccountClient.d.ts +1173 -1317
- package/dist/cjs/client/isAlchemySmartAccountClient.js.map +1 -1
- package/dist/cjs/client/rpcClient.js.map +1 -1
- package/dist/cjs/client/smartAccountClient.d.ts +2 -3
- package/dist/cjs/client/smartAccountClient.js +2 -2
- package/dist/cjs/client/smartAccountClient.js.map +1 -1
- package/dist/cjs/client/types.d.ts +1 -48
- package/dist/cjs/client/types.js.map +1 -1
- package/dist/cjs/defaults.js +7 -7
- package/dist/cjs/defaults.js.map +1 -1
- package/dist/cjs/gas-manager.js +16 -16
- package/dist/cjs/gas-manager.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +22 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/middleware/feeEstimator.js.map +1 -1
- package/dist/cjs/middleware/gasManager.d.ts +2 -29
- package/dist/cjs/middleware/gasManager.js +4 -141
- package/dist/cjs/middleware/gasManager.js.map +1 -1
- package/dist/cjs/middleware/userOperationSimulator.d.ts +2 -2
- package/dist/cjs/middleware/userOperationSimulator.js.map +1 -1
- package/dist/cjs/schema.js +3 -10
- package/dist/cjs/schema.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/simulateUserOperationChanges.js.map +1 -1
- package/dist/esm/chains.d.ts +25 -0
- package/dist/esm/chains.js +199 -0
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +5393 -1
- package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -1
- package/dist/esm/client/decorators/smartAccount.js.map +1 -1
- package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +2 -2
- package/dist/esm/client/internal/smartAccountClientFromRpc.js +3 -14
- package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -1
- package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1173 -1317
- package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
- package/dist/esm/client/rpcClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.d.ts +2 -3
- package/dist/esm/client/smartAccountClient.js +2 -3
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +1 -48
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/defaults.js +2 -1
- package/dist/esm/defaults.js.map +1 -1
- package/dist/esm/gas-manager.js +1 -1
- package/dist/esm/gas-manager.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/middleware/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/gasManager.d.ts +2 -29
- package/dist/esm/middleware/gasManager.js +5 -142
- package/dist/esm/middleware/gasManager.js.map +1 -1
- package/dist/esm/middleware/userOperationSimulator.d.ts +2 -2
- package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
- package/dist/esm/schema.js +4 -11
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/simulateUserOperationChanges.d.ts +17 -0
- package/dist/types/actions/simulateUserOperationChanges.d.ts.map +1 -1
- package/dist/types/chains.d.ts +44 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +5410 -1
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccount.d.ts +15 -0
- package/dist/types/client/decorators/smartAccount.d.ts.map +1 -1
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +4 -4
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +1 -1
- package/dist/types/client/isAlchemySmartAccountClient.d.ts +1188 -1317
- package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
- package/dist/types/client/rpcClient.d.ts +22 -0
- package/dist/types/client/rpcClient.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts +2 -3
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +1 -48
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/defaults.d.ts +14 -0
- package/dist/types/defaults.d.ts.map +1 -1
- package/dist/types/gas-manager.d.ts +13 -0
- package/dist/types/gas-manager.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/feeEstimator.d.ts +19 -0
- package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
- package/dist/types/middleware/gasManager.d.ts +15 -87
- package/dist/types/middleware/gasManager.d.ts.map +1 -1
- package/dist/types/middleware/userOperationSimulator.d.ts +21 -2
- package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/actions/simulateUserOperationChanges.ts +17 -0
- package/src/chains.ts +255 -0
- package/src/client/decorators/alchemyEnhancedApis.ts +50 -33
- package/src/client/decorators/smartAccount.ts +15 -0
- package/src/client/internal/smartAccountClientFromRpc.ts +36 -32
- package/src/client/isAlchemySmartAccountClient.ts +15 -0
- package/src/client/rpcClient.ts +22 -0
- package/src/client/smartAccountClient.ts +21 -5
- package/src/client/types.ts +1 -54
- package/src/defaults.ts +17 -3
- package/src/gas-manager.ts +17 -4
- package/src/index.ts +25 -1
- package/src/middleware/feeEstimator.ts +19 -0
- package/src/middleware/gasManager.ts +21 -424
- package/src/middleware/userOperationSimulator.ts +25 -2
- package/src/schema.ts +3 -11
- 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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
if (client.transport.type === "http") {
|
|
48
|
+
const { url } = client.transport as ReturnType<HttpTransport>["config"] &
|
|
49
|
+
ReturnType<HttpTransport>["value"];
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
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:
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
client,
|
|
73
|
-
|
|
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
|
-
...(
|
|
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,
|
package/src/client/rpcClient.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
162
|
+
policyId,
|
|
147
163
|
useSimulation,
|
|
148
164
|
feeEstimator,
|
|
149
165
|
customMiddleware,
|
package/src/client/types.ts
CHANGED
|
@@ -1,40 +1,11 @@
|
|
|
1
1
|
import { type BundlerClient, type UserOperationRequest } from "@aa-sdk/core";
|
|
2
|
-
import type {
|
|
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;
|