@account-kit/infra 4.0.0-beta.7 → 4.0.0-beta.9
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/alchemyTransport.d.ts +69 -0
- package/dist/esm/alchemyTransport.js +139 -0
- package/dist/esm/alchemyTransport.js.map +1 -0
- package/dist/esm/chains.d.ts +1 -0
- package/dist/esm/chains.js +17 -0
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +2 -2
- package/dist/esm/client/decorators/alchemyEnhancedApis.js +3 -7
- package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -1
- package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1 -1
- package/dist/esm/client/isAlchemySmartAccountClient.js +2 -6
- package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
- package/dist/esm/client/rpcClient.d.ts +9 -10
- package/dist/esm/client/rpcClient.js +9 -33
- package/dist/esm/client/rpcClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.d.ts +12 -9
- package/dist/esm/client/smartAccountClient.js +34 -20
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +8 -7
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/index.d.ts +3 -4
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/middleware/feeEstimator.d.ts +10 -6
- package/dist/esm/middleware/feeEstimator.js +11 -6
- package/dist/esm/middleware/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/gasManager.d.ts +5 -6
- package/dist/esm/middleware/gasManager.js +5 -6
- package/dist/esm/middleware/gasManager.js.map +1 -1
- package/dist/esm/middleware/userOperationSimulator.d.ts +11 -7
- package/dist/esm/middleware/userOperationSimulator.js +12 -8
- package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
- package/dist/esm/schema.d.ts +0 -391
- package/dist/esm/schema.js +1 -5
- 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/alchemyTransport.d.ts +70 -0
- package/dist/types/alchemyTransport.d.ts.map +1 -0
- package/dist/types/chains.d.ts +1 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +2 -2
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
- package/dist/types/client/isAlchemySmartAccountClient.d.ts +1 -1
- package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
- package/dist/types/client/rpcClient.d.ts +9 -10
- package/dist/types/client/rpcClient.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts +12 -9
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +8 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/feeEstimator.d.ts +10 -6
- package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
- package/dist/types/middleware/gasManager.d.ts +5 -6
- package/dist/types/middleware/gasManager.d.ts.map +1 -1
- package/dist/types/middleware/userOperationSimulator.d.ts +11 -7
- package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
- package/dist/types/schema.d.ts +0 -391
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/alchemyTransport.ts +214 -0
- package/src/chains.ts +18 -0
- package/src/client/decorators/alchemyEnhancedApis.ts +9 -16
- package/src/client/isAlchemySmartAccountClient.ts +4 -9
- package/src/client/rpcClient.ts +14 -47
- package/src/client/smartAccountClient.ts +64 -57
- package/src/client/types.ts +10 -7
- package/src/index.ts +3 -3
- package/src/middleware/feeEstimator.ts +15 -10
- package/src/middleware/gasManager.ts +5 -6
- package/src/middleware/userOperationSimulator.ts +13 -10
- package/src/schema.ts +1 -14
- package/src/version.ts +1 -1
- package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +0 -18
- package/dist/esm/client/internal/smartAccountClientFromRpc.js +0 -56
- package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +0 -1
- package/dist/esm/type.d.ts +0 -3
- package/dist/esm/type.js +0 -2
- package/dist/esm/type.js.map +0 -1
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +0 -19
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +0 -1
- package/dist/types/type.d.ts +0 -4
- package/dist/types/type.d.ts.map +0 -1
- package/src/client/internal/smartAccountClientFromRpc.ts +0 -125
- package/src/type.ts +0 -4
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type * from "./actions/simulateUserOperationChanges.js";
|
|
2
2
|
export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
|
|
3
3
|
export type * from "./actions/types.js";
|
|
4
|
+
export type * from "./alchemyTransport.js";
|
|
5
|
+
export { alchemy } from "./alchemyTransport.js";
|
|
4
6
|
export type * from "./chains.js";
|
|
5
7
|
export {
|
|
6
8
|
arbitrum,
|
|
@@ -28,12 +30,12 @@ export {
|
|
|
28
30
|
worldChainSepolia,
|
|
29
31
|
zora,
|
|
30
32
|
zoraSepolia,
|
|
33
|
+
beraChainBartio,
|
|
31
34
|
} from "./chains.js";
|
|
32
35
|
export type * from "./client/decorators/alchemyEnhancedApis.js";
|
|
33
36
|
export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
|
|
34
37
|
export type * from "./client/decorators/smartAccount.js";
|
|
35
38
|
export { alchemyActions } from "./client/decorators/smartAccount.js";
|
|
36
|
-
export { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from "./client/internal/smartAccountClientFromRpc.js";
|
|
37
39
|
export { isAlchemySmartAccountClient } from "./client/isAlchemySmartAccountClient.js";
|
|
38
40
|
export type * from "./client/rpcClient.js";
|
|
39
41
|
export { createAlchemyPublicRpcClient } from "./client/rpcClient.js";
|
|
@@ -47,5 +49,3 @@ export type * from "./middleware/gasManager.js";
|
|
|
47
49
|
export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
|
|
48
50
|
export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
|
|
49
51
|
export type * from "./schema.js";
|
|
50
|
-
export { AlchemyProviderConfigSchema } from "./schema.js";
|
|
51
|
-
export type { AlchemyProviderConfig } from "./type.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ClientMiddlewareFn } from "@aa-sdk/core";
|
|
2
2
|
import { applyUserOpOverrideOrFeeOption } from "@aa-sdk/core";
|
|
3
|
-
import type {
|
|
3
|
+
import type { AlchemyTransport } from "../alchemyTransport";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Function that estimates the transaction fees using Alchemy methods for a given client.
|
|
@@ -8,28 +8,33 @@ import type { ClientWithAlchemyMethods } from "../client/types";
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
-
* import { alchemyFeeEstimator,
|
|
11
|
+
* import { alchemyFeeEstimator, alchemy } from "@account-kit/infra";
|
|
12
12
|
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
13
13
|
*
|
|
14
|
-
* const
|
|
14
|
+
* const alchemyTransport = alchemy({
|
|
15
|
+
* chain: sepolia,
|
|
16
|
+
* apiKey: "your-api-key"
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
15
19
|
* const client = createSmartAccountClient({
|
|
16
|
-
* feeEstimator: alchemyFeeEstimator(
|
|
20
|
+
* feeEstimator: alchemyFeeEstimator(alchemyTransport),
|
|
17
21
|
* ...otherParams
|
|
18
22
|
* });
|
|
19
23
|
* ```
|
|
20
24
|
*
|
|
21
|
-
* @param {
|
|
25
|
+
* @param {AlchemyTransport} transport An alchemy transport for making Alchemy specific RPC calls
|
|
22
26
|
* @returns {ClientMiddlewareFn} A middleware function that takes a transaction structure and fee options, and returns the augmented structure with estimated fees
|
|
23
27
|
*/
|
|
24
|
-
export const alchemyFeeEstimator:
|
|
25
|
-
|
|
28
|
+
export const alchemyFeeEstimator: (
|
|
29
|
+
transport: AlchemyTransport
|
|
26
30
|
) => ClientMiddlewareFn =
|
|
27
|
-
(
|
|
28
|
-
async (struct, { overrides, feeOptions }) => {
|
|
31
|
+
(transport) =>
|
|
32
|
+
async (struct, { overrides, feeOptions, client }) => {
|
|
33
|
+
const transport_ = transport({ chain: client.chain });
|
|
29
34
|
let [block, maxPriorityFeePerGasEstimate] = await Promise.all([
|
|
30
35
|
client.getBlock({ blockTag: "latest" }),
|
|
31
36
|
// it is a fair assumption that if someone is using this Alchemy Middleware, then they are using Alchemy RPC
|
|
32
|
-
|
|
37
|
+
transport_.request({
|
|
33
38
|
method: "rundler_maxPriorityFeePerGas",
|
|
34
39
|
params: [],
|
|
35
40
|
}),
|
|
@@ -6,15 +6,14 @@ import { erc7677Middleware } from "@aa-sdk/core";
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
-
*
|
|
10
|
-
* import { sepolia } from "@account-kit/infra";
|
|
9
|
+
* import { sepolia, alchemyErc7677Middleware } from "@account-kit/infra";
|
|
11
10
|
* import { http } from "viem";
|
|
12
11
|
*
|
|
13
12
|
* const client = createSmartAccountClient({
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* transport: http("rpc-url"),
|
|
14
|
+
* chain: sepolia,
|
|
15
|
+
* ...alchemyErc7677Middleware("policyId")
|
|
16
|
+
* });
|
|
18
17
|
* ```
|
|
19
18
|
*
|
|
20
19
|
* @param {string} policyId the policyId for Alchemy's gas manager
|
|
@@ -4,35 +4,38 @@ import {
|
|
|
4
4
|
type ClientMiddlewareFn,
|
|
5
5
|
type UserOperationContext,
|
|
6
6
|
} from "@aa-sdk/core";
|
|
7
|
-
import type {
|
|
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,
|
|
14
|
+
* import { alchemyUserOperationSimulator, alchemy, sepolia } from "@account-kit/infra";
|
|
15
15
|
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
16
16
|
*
|
|
17
|
-
* const
|
|
17
|
+
* const alchemyTransport = alchemy({
|
|
18
|
+
* chain: sepolia,
|
|
19
|
+
* apiKey: "your-api-key"
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
18
22
|
* const client = createSmartAccountClient({
|
|
19
|
-
*
|
|
23
|
+
* chain: sepolia,
|
|
24
|
+
* userOperationSimulator: alchemyUserOperationSimulator(alchemyTransport),
|
|
20
25
|
* ...otherParams
|
|
21
26
|
* });
|
|
22
27
|
* ```
|
|
23
28
|
*
|
|
24
|
-
* @
|
|
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
|
-
>(
|
|
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,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"]}
|
package/dist/esm/type.d.ts
DELETED
package/dist/esm/type.js
DELETED
package/dist/esm/type.js.map
DELETED
|
@@ -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"}
|
package/dist/types/type.d.ts
DELETED
package/dist/types/type.d.ts.map
DELETED
|
@@ -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