@account-kit/infra 4.21.0 → 4.23.0
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/esm/alchemyTrackerHeaders.d.ts +24 -0
- package/dist/esm/alchemyTrackerHeaders.js +63 -0
- package/dist/esm/alchemyTrackerHeaders.js.map +1 -0
- package/dist/esm/alchemyTransport.d.ts +2 -0
- package/dist/esm/alchemyTransport.js +4 -1
- package/dist/esm/alchemyTransport.js.map +1 -1
- package/dist/esm/chains.d.ts +2 -0
- package/dist/esm/chains.js +13 -1
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/client/decorators/smartAccount.d.ts +1 -1
- package/dist/esm/client/decorators/smartAccount.js +11 -5
- package/dist/esm/client/decorators/smartAccount.js.map +1 -1
- package/dist/esm/client/smartAccountClient.d.ts +1 -1
- package/dist/esm/client/smartAccountClient.js +43 -23
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/middleware/feeEstimator.js +3 -2
- package/dist/esm/middleware/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/gasManager.js +3 -2
- package/dist/esm/middleware/gasManager.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/alchemyTrackerHeaders.d.ts +25 -0
- package/dist/types/alchemyTrackerHeaders.d.ts.map +1 -0
- package/dist/types/alchemyTransport.d.ts +2 -0
- package/dist/types/alchemyTransport.d.ts.map +1 -1
- package/dist/types/chains.d.ts +2 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccount.d.ts +1 -1
- package/dist/types/client/decorators/smartAccount.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts +1 -1
- package/dist/types/client/smartAccountClient.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.map +1 -1
- package/dist/types/middleware/gasManager.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/alchemyTrackerHeaders.ts +64 -0
- package/src/alchemyTransport.ts +5 -1
- package/src/chains.ts +16 -0
- package/src/client/decorators/smartAccount.ts +11 -5
- package/src/client/smartAccountClient.ts +53 -34
- package/src/index.ts +3 -0
- package/src/middleware/feeEstimator.ts +7 -2
- package/src/middleware/gasManager.ts +3 -1
- package/src/version.ts +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChainNotFoundError,
|
|
3
|
+
clientHeaderTrack,
|
|
3
4
|
createSmartAccountClient,
|
|
4
5
|
isSmartAccountWithSigner,
|
|
5
6
|
type Prettify,
|
|
@@ -12,7 +13,11 @@ import {
|
|
|
12
13
|
type UserOperationContext,
|
|
13
14
|
} from "@aa-sdk/core";
|
|
14
15
|
import { type Chain } from "viem";
|
|
15
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
alchemy,
|
|
18
|
+
convertHeadersToObject,
|
|
19
|
+
type AlchemyTransport,
|
|
20
|
+
} from "../alchemyTransport.js";
|
|
16
21
|
import { getDefaultUserOperationFeeOptions } from "../defaults.js";
|
|
17
22
|
import { alchemyFeeEstimator } from "../middleware/feeEstimator.js";
|
|
18
23
|
import { alchemyGasAndPaymasterAndDataMiddleware } from "../middleware/gasManager.js";
|
|
@@ -22,6 +27,7 @@ import {
|
|
|
22
27
|
type AlchemySmartAccountClientActions,
|
|
23
28
|
} from "./decorators/smartAccount.js";
|
|
24
29
|
import type { AlchemyRpcSchema } from "./types.js";
|
|
30
|
+
import { headersUpdate } from "../alchemyTrackerHeaders.js";
|
|
25
31
|
|
|
26
32
|
export function getSignerTypeHeader<
|
|
27
33
|
TAccount extends SmartContractAccountWithSigner
|
|
@@ -125,58 +131,71 @@ export function createAlchemySmartAccountClient<
|
|
|
125
131
|
* @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client
|
|
126
132
|
* @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options
|
|
127
133
|
*/
|
|
128
|
-
export function createAlchemySmartAccountClient(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
feeEstimator,
|
|
133
|
-
customMiddleware,
|
|
134
|
-
gasEstimator,
|
|
135
|
-
signUserOperation,
|
|
136
|
-
transport,
|
|
137
|
-
chain,
|
|
138
|
-
opts,
|
|
139
|
-
}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {
|
|
140
|
-
if (!chain) {
|
|
134
|
+
export function createAlchemySmartAccountClient(
|
|
135
|
+
config: AlchemySmartAccountClientConfig
|
|
136
|
+
): AlchemySmartAccountClient {
|
|
137
|
+
if (!config.chain) {
|
|
141
138
|
throw new ChainNotFoundError();
|
|
142
139
|
}
|
|
143
140
|
|
|
144
141
|
const feeOptions =
|
|
145
|
-
opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);
|
|
142
|
+
config.opts?.feeOptions ?? getDefaultUserOperationFeeOptions(config.chain);
|
|
146
143
|
|
|
147
144
|
const scaClient = createSmartAccountClient({
|
|
148
|
-
account,
|
|
149
|
-
transport,
|
|
150
|
-
chain,
|
|
145
|
+
account: config.account,
|
|
146
|
+
transport: config.transport,
|
|
147
|
+
chain: config.chain,
|
|
151
148
|
type: "AlchemySmartAccountClient",
|
|
152
149
|
opts: {
|
|
153
|
-
...opts,
|
|
150
|
+
...config.opts,
|
|
154
151
|
feeOptions,
|
|
155
152
|
},
|
|
156
|
-
feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),
|
|
157
|
-
gasEstimator,
|
|
153
|
+
feeEstimator: config.feeEstimator ?? alchemyFeeEstimator(config.transport),
|
|
154
|
+
gasEstimator: config.gasEstimator,
|
|
158
155
|
customMiddleware: async (struct, args) => {
|
|
159
156
|
if (isSmartAccountWithSigner(args.account)) {
|
|
160
|
-
transport.updateHeaders(getSignerTypeHeader(args.account));
|
|
157
|
+
config.transport.updateHeaders(getSignerTypeHeader(args.account));
|
|
161
158
|
}
|
|
162
|
-
return customMiddleware
|
|
159
|
+
return config.customMiddleware
|
|
160
|
+
? config.customMiddleware(struct, args)
|
|
161
|
+
: struct;
|
|
163
162
|
},
|
|
164
|
-
...(policyId
|
|
163
|
+
...(config.policyId
|
|
165
164
|
? alchemyGasAndPaymasterAndDataMiddleware({
|
|
166
|
-
policyId,
|
|
167
|
-
transport,
|
|
168
|
-
gasEstimatorOverride: gasEstimator,
|
|
169
|
-
feeEstimatorOverride: feeEstimator,
|
|
165
|
+
policyId: config.policyId,
|
|
166
|
+
transport: config.transport,
|
|
167
|
+
gasEstimatorOverride: config.gasEstimator,
|
|
168
|
+
feeEstimatorOverride: config.feeEstimator,
|
|
170
169
|
})
|
|
171
170
|
: {}),
|
|
172
|
-
userOperationSimulator: useSimulation
|
|
173
|
-
? alchemyUserOperationSimulator(transport)
|
|
171
|
+
userOperationSimulator: config.useSimulation
|
|
172
|
+
? alchemyUserOperationSimulator(config.transport)
|
|
174
173
|
: undefined,
|
|
175
|
-
signUserOperation,
|
|
176
|
-
|
|
174
|
+
signUserOperation: config.signUserOperation,
|
|
175
|
+
addBreadCrumb(breadcrumb: string) {
|
|
176
|
+
const oldConfig = config.transport.config;
|
|
177
|
+
const dynamicFetchOptions = config.transport.dynamicFetchOptions;
|
|
178
|
+
const newTransport = alchemy({ ...oldConfig });
|
|
179
|
+
newTransport.updateHeaders(
|
|
180
|
+
headersUpdate(breadcrumb)(
|
|
181
|
+
convertHeadersToObject(dynamicFetchOptions?.headers)
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
return createAlchemySmartAccountClient({
|
|
185
|
+
...config,
|
|
186
|
+
transport: newTransport,
|
|
187
|
+
}) as any;
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
.extend(alchemyActions)
|
|
191
|
+
.extend((client_) => ({
|
|
192
|
+
addBreadcrumb(breadcrumb: string) {
|
|
193
|
+
return clientHeaderTrack(client_, breadcrumb);
|
|
194
|
+
},
|
|
195
|
+
}));
|
|
177
196
|
|
|
178
|
-
if (account && isSmartAccountWithSigner(account)) {
|
|
179
|
-
transport.updateHeaders(getSignerTypeHeader(account));
|
|
197
|
+
if (config.account && isSmartAccountWithSigner(config.account)) {
|
|
198
|
+
config.transport.updateHeaders(getSignerTypeHeader(config.account));
|
|
180
199
|
}
|
|
181
200
|
|
|
182
201
|
return scaClient;
|
package/src/index.ts
CHANGED
|
@@ -44,6 +44,8 @@ export {
|
|
|
44
44
|
openlootSepolia,
|
|
45
45
|
gensynTestnet,
|
|
46
46
|
riseTestnet,
|
|
47
|
+
sonic,
|
|
48
|
+
sonicTestnet,
|
|
47
49
|
} from "./chains.js";
|
|
48
50
|
export type * from "./client/decorators/alchemyEnhancedApis.js";
|
|
49
51
|
export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
|
|
@@ -59,6 +61,7 @@ export { getDefaultUserOperationFeeOptions } from "./defaults.js";
|
|
|
59
61
|
export { getAlchemyPaymasterAddress } from "./gas-manager.js";
|
|
60
62
|
export { alchemyFeeEstimator } from "./middleware/feeEstimator.js";
|
|
61
63
|
export type * from "./middleware/gasManager.js";
|
|
64
|
+
export * from "./alchemyTrackerHeaders.js";
|
|
62
65
|
export {
|
|
63
66
|
alchemyGasManagerMiddleware,
|
|
64
67
|
alchemyGasAndPaymasterAndDataMiddleware,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ClientMiddlewareFn } from "@aa-sdk/core";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
applyUserOpOverrideOrFeeOption,
|
|
4
|
+
bigIntMultiply,
|
|
5
|
+
clientHeaderTrack,
|
|
6
|
+
} from "@aa-sdk/core";
|
|
3
7
|
import type { AlchemyTransport } from "../alchemyTransport";
|
|
4
8
|
|
|
5
9
|
/**
|
|
@@ -29,7 +33,8 @@ export const alchemyFeeEstimator: (
|
|
|
29
33
|
transport: AlchemyTransport
|
|
30
34
|
) => ClientMiddlewareFn =
|
|
31
35
|
(transport) =>
|
|
32
|
-
async (struct, { overrides, feeOptions, client }) => {
|
|
36
|
+
async (struct, { overrides, feeOptions, client: client_ }) => {
|
|
37
|
+
const client = clientHeaderTrack(client_, "alchemyFeeEstimator");
|
|
33
38
|
const transport_ = transport({ chain: client.chain });
|
|
34
39
|
let [block, maxPriorityFeePerGasEstimate] = await Promise.all([
|
|
35
40
|
client.getBlock({ blockTag: "latest" }),
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
import {
|
|
11
11
|
bypassPaymasterAndData,
|
|
12
12
|
ChainNotFoundError,
|
|
13
|
+
clientHeaderTrack,
|
|
13
14
|
deepHexlify,
|
|
14
15
|
defaultGasEstimator,
|
|
15
16
|
erc7677Middleware,
|
|
@@ -129,8 +130,9 @@ export function alchemyGasAndPaymasterAndDataMiddleware(
|
|
|
129
130
|
},
|
|
130
131
|
paymasterAndData: async (
|
|
131
132
|
uo,
|
|
132
|
-
{ account, client, feeOptions, overrides: overrides_ }
|
|
133
|
+
{ account, client: client_, feeOptions, overrides: overrides_ }
|
|
133
134
|
) => {
|
|
135
|
+
const client = clientHeaderTrack(client_, "alchemyFeeEstimator");
|
|
134
136
|
if (!client.chain) {
|
|
135
137
|
throw new ChainNotFoundError();
|
|
136
138
|
}
|
package/src/version.ts
CHANGED