@account-kit/infra 4.0.0-alpha.1 → 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/chains.d.ts +21 -0
- package/dist/cjs/chains.js +200 -1
- package/dist/cjs/chains.js.map +1 -1
- package/dist/cjs/client/decorators/alchemyEnhancedApis.d.ts +1173 -1317
- package/dist/cjs/client/internal/smartAccountClientFromRpc.js +2 -14
- package/dist/cjs/client/internal/smartAccountClientFromRpc.js.map +1 -1
- package/dist/cjs/client/isAlchemySmartAccountClient.d.ts +1173 -1317
- 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 +1 -1
- package/dist/cjs/index.js +22 -1
- package/dist/cjs/index.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/chains.d.ts +21 -0
- package/dist/esm/chains.js +199 -0
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +1173 -1317
- package/dist/esm/client/internal/smartAccountClientFromRpc.js +2 -14
- package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +1 -1
- package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1173 -1317
- 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 +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.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/chains.d.ts +21 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +1173 -1317
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +2 -2
- package/dist/types/client/isAlchemySmartAccountClient.d.ts +1173 -1317
- package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
- package/dist/types/client/rpcClient.d.ts +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 +1 -1
- package/dist/types/defaults.d.ts.map +1 -1
- package/dist/types/gas-manager.d.ts +1 -1
- package/dist/types/gas-manager.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.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 +2 -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/chains.ts +231 -0
- package/src/client/internal/smartAccountClientFromRpc.ts +4 -20
- package/src/client/rpcClient.ts +1 -1
- package/src/client/smartAccountClient.ts +4 -5
- package/src/client/types.ts +1 -54
- package/src/defaults.ts +4 -4
- package/src/gas-manager.ts +3 -3
- package/src/index.ts +24 -1
- package/src/middleware/gasManager.ts +21 -424
- package/src/middleware/userOperationSimulator.ts +6 -2
- package/src/schema.ts +3 -11
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpcClient.js","sourceRoot":"","sources":["../../../src/client/rpcClient.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AACtB,+BAAkE;AAClE,4CAAkD;AAClD,8CAAwC;AAyBjC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAChB,YAAY,GAAG,EAAE,GAKlB,EAA4B,EAAE;IAC7B,MAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,MAAM,GACV,gBAAgB,CAAC,MAAM,IAAI,IAAI;QAC7B,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,MAAM,IAAI,EAAE,EAAE;QACrE,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAE9B,YAAY,CAAC,OAAO,GAAG;QACrB,GAAG,YAAY,CAAC,OAAO;QACvB,wBAAwB,EAAE,oBAAO;KAClC,CAAC;IAEF,IAAI,gBAAgB,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,YAAY,CAAC,OAAO,GAAG;YACrB,GAAG,YAAY,CAAC,OAAO;YACvB,aAAa,EAAE,UAAU,gBAAgB,CAAC,GAAG,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,0BAAmB,EAAC;QACzB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC;KAC1C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,aAAa,CAAC,UAAuB;YACnC,YAAY,CAAC,OAAO,GAAG;gBACrB,GAAG,YAAY,CAAC,OAAO;gBACvB,GAAG,UAAU;aACd,CAAC;QACJ,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAvCW,QAAA,4BAA4B,gCAuCvC","sourcesContent":["import {\n createBundlerClient,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport { http, type Chain, type HttpTransportConfig } from \"viem\";\nimport { AlchemyChainSchema } from \"../schema.js\";\nimport { VERSION } from \"../version.js\";\nimport type { ClientWithAlchemyMethods } from \"./types.js\";\n\n/**\n * 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.\n *\n * @example\n * ```ts\n * import { createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra
|
|
1
|
+
{"version":3,"file":"rpcClient.js","sourceRoot":"","sources":["../../../src/client/rpcClient.ts"],"names":[],"mappings":";;;AAAA,uCAIsB;AACtB,+BAAkE;AAClE,4CAAkD;AAClD,8CAAwC;AAyBjC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAChB,YAAY,GAAG,EAAE,GAKlB,EAA4B,EAAE;IAC7B,MAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,MAAM,GACV,gBAAgB,CAAC,MAAM,IAAI,IAAI;QAC7B,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC,MAAM,IAAI,EAAE,EAAE;QACrE,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAE9B,YAAY,CAAC,OAAO,GAAG;QACrB,GAAG,YAAY,CAAC,OAAO;QACvB,wBAAwB,EAAE,oBAAO;KAClC,CAAC;IAEF,IAAI,gBAAgB,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,YAAY,CAAC,OAAO,GAAG;YACrB,GAAG,YAAY,CAAC,OAAO;YACvB,aAAa,EAAE,UAAU,gBAAgB,CAAC,GAAG,EAAE;SAChD,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,0BAAmB,EAAC;QACzB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,IAAA,WAAI,EAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC;KAC1C,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,aAAa,CAAC,UAAuB;YACnC,YAAY,CAAC,OAAO,GAAG;gBACrB,GAAG,YAAY,CAAC,OAAO;gBACvB,GAAG,UAAU;aACd,CAAC;QACJ,CAAC;KACF,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AAvCW,QAAA,4BAA4B,gCAuCvC","sourcesContent":["import {\n createBundlerClient,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport { http, type Chain, type HttpTransportConfig } from \"viem\";\nimport { AlchemyChainSchema } from \"../schema.js\";\nimport { VERSION } from \"../version.js\";\nimport type { ClientWithAlchemyMethods } from \"./types.js\";\n\n/**\n * 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.\n *\n * @example\n * ```ts\n * import { createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra\";\n *\n * const client = createAlchemyPublicRpcClient({\n * chain: sepolia,\n * connectionConfig: {\n * apiKey: \"your-api-key\",\n * }\n * });\n * ```\n *\n * @param {{connectionConfig: ConnectionConfig,chain: Chain,fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>}} params The parameters for creating the Alchemy public RPC client\n * @param {ConnectionConfig} params.connectionConfig The connection configuration containing the RPC URL and API key\n * @param {Chain} params.chain The blockchain chain configuration\n * @param {NoUndefined<HttpTransportConfig[\"fetchOptions\"]>} [params.fetchOptions] Optional fetch configuration for HTTP transport\n * @returns {ClientWithAlchemyMethods} A client object tailored with Alchemy methods and capabilities to interact with the blockchain\n */\nexport const createAlchemyPublicRpcClient = ({\n chain: chain_,\n connectionConfig,\n fetchOptions = {},\n}: {\n connectionConfig: ConnectionConfig;\n chain: Chain;\n fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>;\n}): ClientWithAlchemyMethods => {\n const chain = AlchemyChainSchema.parse(chain_);\n\n const rpcUrl =\n connectionConfig.rpcUrl == null\n ? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? \"\"}`\n : connectionConfig.rpcUrl;\n\n fetchOptions.headers = {\n ...fetchOptions.headers,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n\n if (connectionConfig.jwt != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt}`,\n };\n }\n\n return createBundlerClient({\n chain: chain,\n transport: http(rpcUrl, { fetchOptions }),\n }).extend(() => ({\n updateHeaders(newHeaders: HeadersInit) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n }));\n};\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type Prettify, type SmartAccountClient, type SmartAccountClientActions, type SmartAccountClientConfig, type SmartAccountClientRpcSchema, type SmartContractAccount, type UserOperationContext } from "@aa-sdk/core";
|
|
2
2
|
import { type Chain, type Transport } from "viem";
|
|
3
|
-
import { type AlchemyGasManagerConfig } from "../middleware/gasManager.js";
|
|
4
3
|
import type { AlchemyProviderConfig } from "../type.js";
|
|
5
4
|
import type { AlchemySmartAccountClientActions } from "./decorators/smartAccount.js";
|
|
6
5
|
import type { AlchemyRpcSchema } from "./types.js";
|
|
7
6
|
export type AlchemySmartAccountClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = {
|
|
8
7
|
account?: account;
|
|
9
8
|
useSimulation?: boolean;
|
|
10
|
-
|
|
9
|
+
policyId?: string;
|
|
11
10
|
} & AlchemyProviderConfig & Pick<SmartAccountClientConfig<transport, chain, account, context>, "customMiddleware" | "feeEstimator" | "gasEstimator" | "signUserOperation">;
|
|
12
11
|
export type BaseAlchemyActions<chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = SmartAccountClientActions<chain, account, context> & AlchemySmartAccountClientActions<account, context>;
|
|
13
12
|
export type AlchemySmartAccountClient_Base<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, actions extends Record<string, unknown> = Record<string, unknown>, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<SmartAccountClient<transport, chain, account, actions & BaseAlchemyActions<chain, account, context>, [
|
|
@@ -15,4 +14,4 @@ export type AlchemySmartAccountClient_Base<transport extends Transport = Transpo
|
|
|
15
14
|
...AlchemyRpcSchema
|
|
16
15
|
], context>>;
|
|
17
16
|
export type AlchemySmartAccountClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, actions extends Record<string, unknown> = Record<string, unknown>, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<AlchemySmartAccountClient_Base<transport, chain, account, actions, context>>;
|
|
18
|
-
export declare function createAlchemySmartAccountClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>({ account,
|
|
17
|
+
export declare function createAlchemySmartAccountClient<TTransport extends Transport = Transport, TChain extends Chain = Chain, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>({ account, policyId, useSimulation, feeEstimator, customMiddleware, gasEstimator, signUserOperation, ...config_ }: AlchemySmartAccountClientConfig<TTransport, TChain, TAccount, TContext>): AlchemySmartAccountClient<TTransport, TChain, TAccount, Record<string, never>, TContext>;
|
|
@@ -5,7 +5,7 @@ const defaults_js_1 = require("../defaults.js");
|
|
|
5
5
|
const schema_js_1 = require("../schema.js");
|
|
6
6
|
const smartAccountClientFromRpc_js_1 = require("./internal/smartAccountClientFromRpc.js");
|
|
7
7
|
const rpcClient_js_1 = require("./rpcClient.js");
|
|
8
|
-
function createAlchemySmartAccountClient({ account,
|
|
8
|
+
function createAlchemySmartAccountClient({ account, policyId, useSimulation, feeEstimator, customMiddleware, gasEstimator, signUserOperation, ...config_ }) {
|
|
9
9
|
const config = schema_js_1.AlchemyProviderConfigSchema.parse(config_);
|
|
10
10
|
const { chain, opts, ...connectionConfig } = config;
|
|
11
11
|
const client = (0, rpcClient_js_1.createAlchemyPublicRpcClient)({
|
|
@@ -20,7 +20,7 @@ function createAlchemySmartAccountClient({ account, gasManagerConfig, useSimulat
|
|
|
20
20
|
...opts,
|
|
21
21
|
feeOptions,
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
policyId,
|
|
24
24
|
useSimulation,
|
|
25
25
|
feeEstimator,
|
|
26
26
|
customMiddleware,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":";;;AAUA,gDAAmE;
|
|
1
|
+
{"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":";;;AAUA,gDAAmE;AACnE,4CAA2D;AAG3D,0FAAuG;AACvG,iDAA8D;AAsH9D,SAAgB,+BAA+B,CAAC,EAC9C,OAAO,EACP,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,GAAG,OAAO,EACsB;IAChC,MAAM,MAAM,GAAG,uCAA2B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAEpD,MAAM,MAAM,GAAG,IAAA,2CAA4B,EAAC;QAC1C,KAAK;QACL,gBAAgB;KACjB,CAAC,CAAC;IAEH,MAAM,UAAU,GACd,IAAI,EAAE,UAAU,IAAI,IAAA,+CAAiC,EAAC,KAAK,CAAC,CAAC;IAE/D,OAAO,IAAA,2EAA4C,EAAC;QAClD,MAAM;QACN,OAAO;QACP,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,UAAU;SACX;QACD,QAAQ;QACR,aAAa;QACb,YAAY;QACZ,gBAAgB;QAChB,YAAY;QACZ,iBAAiB;KAClB,CAAC,CAAC;AACL,CAAC;AAnCD,0EAmCC","sourcesContent":["import {\n type Prettify,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport { type Chain, type Transport } from \"viem\";\nimport { getDefaultUserOperationFeeOptions } from \"../defaults.js\";\nimport { AlchemyProviderConfigSchema } from \"../schema.js\";\nimport type { AlchemyProviderConfig } from \"../type.js\";\nimport type { AlchemySmartAccountClientActions } from \"./decorators/smartAccount.js\";\nimport { createAlchemySmartAccountClientFromRpcClient } from \"./internal/smartAccountClientFromRpc.js\";\nimport { createAlchemyPublicRpcClient } from \"./rpcClient.js\";\nimport type { AlchemyRpcSchema } from \"./types.js\";\n\n// #region AlchemySmartAccountClientConfig\nexport type AlchemySmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n account?: account;\n useSimulation?: boolean;\n policyId?: string;\n} & AlchemyProviderConfig &\n Pick<\n SmartAccountClientConfig<transport, chain, account, context>,\n \"customMiddleware\" | \"feeEstimator\" | \"gasEstimator\" | \"signUserOperation\"\n >;\n// #endregion AlchemySmartAccountClientConfig\n\nexport type BaseAlchemyActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = SmartAccountClientActions<chain, account, context> &\n AlchemySmartAccountClientActions<account, context>;\n\nexport type AlchemySmartAccountClient_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n SmartAccountClient<\n transport,\n chain,\n account,\n actions & BaseAlchemyActions<chain, account, context>,\n [...SmartAccountClientRpcSchema, ...AlchemyRpcSchema],\n context\n >\n>;\n\nexport type AlchemySmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n AlchemySmartAccountClient_Base<transport, chain, account, actions, context>\n>;\n\nexport function createAlchemySmartAccountClient<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>({\n account,\n policyId,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n ...config_\n}: AlchemySmartAccountClientConfig<\n TTransport,\n TChain,\n TAccount,\n TContext\n>): AlchemySmartAccountClient<\n TTransport,\n TChain,\n TAccount,\n Record<string, never>,\n TContext\n>;\n\n/**\n * Creates an Alchemy smart account client using the provided configuration options, including account details, gas manager configuration, and custom middleware.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClient } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra/chain\";\n *\n * const client = createAlchemySmartAccountClient({\n * chain: sepolia,\n * apiKey: \"your-api-key\",\n * });\n * ```\n *\n * @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client\n * @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options\n */\nexport function createAlchemySmartAccountClient({\n account,\n policyId,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n ...config_\n}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {\n const config = AlchemyProviderConfigSchema.parse(config_);\n const { chain, opts, ...connectionConfig } = config;\n\n const client = createAlchemyPublicRpcClient({\n chain,\n connectionConfig,\n });\n\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);\n\n return createAlchemySmartAccountClientFromRpcClient({\n client,\n account,\n opts: {\n ...opts,\n feeOptions,\n },\n policyId,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n });\n}\n"]}
|
|
@@ -1,32 +1,7 @@
|
|
|
1
1
|
import { type BundlerClient, type UserOperationRequest } from "@aa-sdk/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { HttpTransport } from "viem";
|
|
3
3
|
import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse } from "../actions/types";
|
|
4
|
-
import type { RequestGasAndPaymasterAndDataOverrides, RequestGasAndPaymasterAndDataResponse, RequestPaymasterAndDataResponse } from "../middleware/gasManager";
|
|
5
4
|
export type AlchemyRpcSchema = [
|
|
6
|
-
{
|
|
7
|
-
Method: "alchemy_requestPaymasterAndData";
|
|
8
|
-
Parameters: [
|
|
9
|
-
{
|
|
10
|
-
policyId: string;
|
|
11
|
-
entryPoint: Address;
|
|
12
|
-
userOperation: UserOperationRequest;
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
ReturnType: RequestPaymasterAndDataResponse;
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
Method: "alchemy_requestGasAndPaymasterAndData";
|
|
19
|
-
Parameters: [
|
|
20
|
-
{
|
|
21
|
-
policyId: string;
|
|
22
|
-
entryPoint: Address;
|
|
23
|
-
userOperation: UserOperationRequest;
|
|
24
|
-
dummySignature: Hex;
|
|
25
|
-
overrides?: RequestGasAndPaymasterAndDataOverrides;
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
ReturnType: RequestGasAndPaymasterAndDataResponse;
|
|
29
|
-
},
|
|
30
5
|
{
|
|
31
6
|
Method: "alchemy_simulateUserOperationAssetChanges";
|
|
32
7
|
Parameters: SimulateUserOperationAssetChangesRequest;
|
|
@@ -40,28 +15,6 @@ export type AlchemyRpcSchema = [
|
|
|
40
15
|
];
|
|
41
16
|
export type ClientWithAlchemyMethods = BundlerClient<HttpTransport> & {
|
|
42
17
|
request: BundlerClient<HttpTransport>["request"] & {
|
|
43
|
-
request(args: {
|
|
44
|
-
method: "alchemy_requestPaymasterAndData";
|
|
45
|
-
params: [
|
|
46
|
-
{
|
|
47
|
-
policyId: string;
|
|
48
|
-
entryPoint: Address;
|
|
49
|
-
userOperation: UserOperationRequest;
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
|
-
}): Promise<RequestPaymasterAndDataResponse>;
|
|
53
|
-
request(args: {
|
|
54
|
-
method: "alchemy_requestGasAndPaymasterAndData";
|
|
55
|
-
params: [
|
|
56
|
-
{
|
|
57
|
-
policyId: string;
|
|
58
|
-
entryPoint: Address;
|
|
59
|
-
userOperation: UserOperationRequest;
|
|
60
|
-
dummySignature: Hex;
|
|
61
|
-
overrides?: RequestGasAndPaymasterAndDataOverrides;
|
|
62
|
-
}
|
|
63
|
-
];
|
|
64
|
-
}): Promise<RequestGasAndPaymasterAndDataResponse>;
|
|
65
18
|
request(args: {
|
|
66
19
|
method: "alchemy_simulateUserOperationAssetChanges";
|
|
67
20
|
params: SimulateUserOperationAssetChangesRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import { type BundlerClient, type UserOperationRequest } from \"@aa-sdk/core\";\nimport type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"","sourcesContent":["import { type BundlerClient, type UserOperationRequest } from \"@aa-sdk/core\";\nimport type { HttpTransport } from \"viem\";\nimport type {\n SimulateUserOperationAssetChangesRequest,\n SimulateUserOperationAssetChangesResponse,\n} from \"../actions/types\";\n\nexport type AlchemyRpcSchema = [\n {\n Method: \"alchemy_simulateUserOperationAssetChanges\";\n Parameters: SimulateUserOperationAssetChangesRequest;\n ReturnType: SimulateUserOperationAssetChangesResponse;\n },\n {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: UserOperationRequest[\"maxPriorityFeePerGas\"];\n }\n];\n\nexport type ClientWithAlchemyMethods = BundlerClient<HttpTransport> & {\n request: BundlerClient<HttpTransport>[\"request\"] &\n {\n request(args: {\n method: \"alchemy_simulateUserOperationAssetChanges\";\n params: SimulateUserOperationAssetChangesRequest;\n }): Promise<SimulateUserOperationAssetChangesResponse>;\n\n request(args: {\n method: \"rundler_maxPriorityFeePerGas\";\n params: [];\n }): Promise<UserOperationRequest[\"maxPriorityFeePerGas\"]>;\n }[\"request\"];\n} & {\n updateHeaders: (headers: HeadersInit) => void;\n};\n"]}
|
package/dist/cjs/defaults.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultUserOperationFeeOptions = void 0;
|
|
4
|
-
const
|
|
4
|
+
const chains_js_1 = require("./chains.js");
|
|
5
5
|
const getDefaultUserOperationFeeOptions = (chain) => {
|
|
6
6
|
const feeOptions = {
|
|
7
7
|
maxFeePerGas: { multiplier: 1.5 },
|
|
8
8
|
maxPriorityFeePerGas: { multiplier: 1.05 },
|
|
9
9
|
};
|
|
10
10
|
if (new Set([
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
chains_js_1.arbitrum.id,
|
|
12
|
+
chains_js_1.arbitrumGoerli.id,
|
|
13
|
+
chains_js_1.arbitrumSepolia.id,
|
|
14
|
+
chains_js_1.optimism.id,
|
|
15
|
+
chains_js_1.optimismGoerli.id,
|
|
16
|
+
chains_js_1.optimismSepolia.id,
|
|
17
17
|
]).has(chain.id)) {
|
|
18
18
|
feeOptions.preVerificationGas = { multiplier: 1.05 };
|
|
19
19
|
}
|
package/dist/cjs/defaults.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":";;;AAEA,2CAOqB;AAgBd,MAAM,iCAAiC,GAAG,CAC/C,KAAY,EACa,EAAE;IAC3B,MAAM,UAAU,GAA4B;QAC1C,YAAY,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE;QACjC,oBAAoB,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;KAC3C,CAAC;IAEF,IACE,IAAI,GAAG,CAAS;QACd,oBAAQ,CAAC,EAAE;QACX,0BAAc,CAAC,EAAE;QACjB,2BAAe,CAAC,EAAE;QAClB,oBAAQ,CAAC,EAAE;QACX,0BAAc,CAAC,EAAE;QACjB,2BAAe,CAAC,EAAE;KACnB,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAChB,CAAC;QACD,UAAU,CAAC,kBAAkB,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;IACvD,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAtBW,QAAA,iCAAiC,qCAsB5C","sourcesContent":["import { type UserOperationFeeOptions } from \"@aa-sdk/core\";\nimport type { Chain } from \"viem\";\nimport {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n optimism,\n optimismGoerli,\n optimismSepolia,\n} from \"./chains.js\";\n\n/**\n * Retrieves the default user operation fee options for a given chain. Adjusts fees for specific chains like Arbitrum and Optimism.\n *\n * @example\n * ```ts\n * import { getDefaultUserOperationFeeOptions } from \"@account-kit/infra\";\n * import { arbitrum } from \"@account-kit/infra\";\n *\n * const feeOpts = getDefaultUserOperationFeeOptions(arbitrum);\n * ```\n *\n * @param {Chain} chain The blockchain chain for which to get the fee options\n * @returns {UserOperationFeeOptions} An object containing the default fee options for user operations on the specified chain\n */\nexport const getDefaultUserOperationFeeOptions = (\n chain: Chain\n): UserOperationFeeOptions => {\n const feeOptions: UserOperationFeeOptions = {\n maxFeePerGas: { multiplier: 1.5 },\n maxPriorityFeePerGas: { multiplier: 1.05 },\n };\n\n if (\n new Set<number>([\n arbitrum.id,\n arbitrumGoerli.id,\n arbitrumSepolia.id,\n optimism.id,\n optimismGoerli.id,\n optimismSepolia.id,\n ]).has(chain.id)\n ) {\n feeOptions.preVerificationGas = { multiplier: 1.05 };\n }\n\n return feeOptions;\n};\n"]}
|
package/dist/cjs/gas-manager.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAlchemyPaymasterAddress = exports.AlchemyPaymasterAddressV1 = exports.ArbSepoliaPaymasterAddress = exports.AlchemyPaymasterAddressV2 = exports.AlchemyPaymasterAddressV3 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const chains_js_1 = require("./chains.js");
|
|
5
5
|
exports.AlchemyPaymasterAddressV3 = "0x4f84a207A80c39E9e8BaE717c1F25bA7AD1fB08F";
|
|
6
6
|
exports.AlchemyPaymasterAddressV2 = "0x4Fd9098af9ddcB41DA48A1d78F91F1398965addc";
|
|
7
7
|
exports.ArbSepoliaPaymasterAddress = "0x0804Afe6EEFb73ce7F93CD0d5e7079a5a8068592";
|
|
8
8
|
exports.AlchemyPaymasterAddressV1 = "0xc03aac639bb21233e0139381970328db8bceeb67";
|
|
9
9
|
const getAlchemyPaymasterAddress = (chain) => {
|
|
10
10
|
switch (chain.id) {
|
|
11
|
-
case
|
|
12
|
-
case
|
|
13
|
-
case
|
|
14
|
-
case
|
|
15
|
-
case
|
|
16
|
-
case
|
|
17
|
-
case
|
|
11
|
+
case chains_js_1.polygonAmoy.id:
|
|
12
|
+
case chains_js_1.optimismSepolia.id:
|
|
13
|
+
case chains_js_1.baseSepolia.id:
|
|
14
|
+
case chains_js_1.zora.id:
|
|
15
|
+
case chains_js_1.zoraSepolia.id:
|
|
16
|
+
case chains_js_1.fraxtal.id:
|
|
17
|
+
case chains_js_1.fraxtalSepolia.id:
|
|
18
18
|
return exports.AlchemyPaymasterAddressV3;
|
|
19
|
-
case
|
|
20
|
-
case
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
case
|
|
19
|
+
case chains_js_1.mainnet.id:
|
|
20
|
+
case chains_js_1.arbitrum.id:
|
|
21
|
+
case chains_js_1.optimism.id:
|
|
22
|
+
case chains_js_1.polygon.id:
|
|
23
|
+
case chains_js_1.base.id:
|
|
24
24
|
return exports.AlchemyPaymasterAddressV2;
|
|
25
|
-
case
|
|
25
|
+
case chains_js_1.arbitrumSepolia.id:
|
|
26
26
|
return exports.ArbSepoliaPaymasterAddress;
|
|
27
|
-
case
|
|
28
|
-
case
|
|
27
|
+
case chains_js_1.sepolia.id:
|
|
28
|
+
case chains_js_1.polygonMumbai.id:
|
|
29
29
|
return exports.AlchemyPaymasterAddressV1;
|
|
30
30
|
default:
|
|
31
31
|
throw new Error(`Unsupported chain: ${chain}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas-manager.js","sourceRoot":"","sources":["../../src/gas-manager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"gas-manager.js","sourceRoot":"","sources":["../../src/gas-manager.ts"],"names":[],"mappings":";;;AACA,2CAgBqB;AAER,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAClC,QAAA,0BAA0B,GACrC,4CAA4C,CAAC;AAClC,QAAA,yBAAyB,GACpC,4CAA4C,CAAC;AAexC,MAAM,0BAA0B,GAAG,CAAC,KAAY,EAAW,EAAE;IAClE,QAAQ,KAAK,CAAC,EAAE,EAAE,CAAC;QACjB,KAAK,uBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,2BAAe,CAAC,EAAE,CAAC;QACxB,KAAK,uBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,gBAAI,CAAC,EAAE,CAAC;QACb,KAAK,uBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,mBAAO,CAAC,EAAE,CAAC;QAChB,KAAK,0BAAc,CAAC,EAAE;YACpB,OAAO,iCAAyB,CAAC;QACnC,KAAK,mBAAO,CAAC,EAAE,CAAC;QAChB,KAAK,oBAAQ,CAAC,EAAE,CAAC;QACjB,KAAK,oBAAQ,CAAC,EAAE,CAAC;QACjB,KAAK,mBAAO,CAAC,EAAE,CAAC;QAChB,KAAK,gBAAI,CAAC,EAAE;YACV,OAAO,iCAAyB,CAAC;QACnC,KAAK,2BAAe,CAAC,EAAE;YACrB,OAAO,kCAA0B,CAAC;QACpC,KAAK,mBAAO,CAAC,EAAE,CAAC;QAChB,KAAK,yBAAa,CAAC,EAAE;YACnB,OAAO,iCAAyB,CAAC;QACnC;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,0BAA0B,8BAwBrC","sourcesContent":["import type { Address, Chain } from \"viem\";\nimport {\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n fraxtal,\n fraxtalSepolia,\n mainnet,\n optimism,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n} from \"./chains.js\";\n\nexport const AlchemyPaymasterAddressV3 =\n \"0x4f84a207A80c39E9e8BaE717c1F25bA7AD1fB08F\";\nexport const AlchemyPaymasterAddressV2 =\n \"0x4Fd9098af9ddcB41DA48A1d78F91F1398965addc\";\nexport const ArbSepoliaPaymasterAddress =\n \"0x0804Afe6EEFb73ce7F93CD0d5e7079a5a8068592\";\nexport const AlchemyPaymasterAddressV1 =\n \"0xc03aac639bb21233e0139381970328db8bceeb67\";\n\n/**\n * Retrieves the Alchemy paymaster address for the given chain. Returns different addresses based on the chain ID.\n *\n * @example\n * ```ts\n * import { sepolia, getAlchemyPaymasterAddress } from \"@account-kit/infra\";\n *\n * const paymasterAddress = getAlchemyPaymasterAddress(sepolia);\n * ```\n *\n * @param {Chain} chain The chain for which the paymaster address is required\n * @returns {Address} The Alchemy paymaster address corresponding to the specified chain\n */\nexport const getAlchemyPaymasterAddress = (chain: Chain): Address => {\n switch (chain.id) {\n case polygonAmoy.id:\n case optimismSepolia.id:\n case baseSepolia.id:\n case zora.id:\n case zoraSepolia.id:\n case fraxtal.id:\n case fraxtalSepolia.id:\n return AlchemyPaymasterAddressV3;\n case mainnet.id:\n case arbitrum.id:\n case optimism.id:\n case polygon.id:\n case base.id:\n return AlchemyPaymasterAddressV2;\n case arbitrumSepolia.id:\n return ArbSepoliaPaymasterAddress;\n case sepolia.id:\n case polygonMumbai.id:\n return AlchemyPaymasterAddressV1;\n default:\n throw new Error(`Unsupported chain: ${chain}`);\n }\n};\n"]}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type * from "./actions/simulateUserOperationChanges.js";
|
|
|
2
2
|
export { simulateUserOperationChanges } from "./actions/simulateUserOperationChanges.js";
|
|
3
3
|
export type * from "./actions/types.js";
|
|
4
4
|
export type * from "./chains.js";
|
|
5
|
-
export { defineAlchemyChain } from "./chains.js";
|
|
5
|
+
export { arbitrum, arbitrumGoerli, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, zora, zoraSepolia, worldChain, worldChainSepolia, } from "./chains.js";
|
|
6
6
|
export type * from "./client/decorators/alchemyEnhancedApis.js";
|
|
7
7
|
export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
|
|
8
8
|
export type * from "./client/decorators/smartAccount.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AlchemyProviderConfigSchema = exports.alchemyUserOperationSimulator = exports.alchemyGasManagerMiddleware = exports.alchemyFeeEstimator = exports.getAlchemyPaymasterAddress = exports.getDefaultUserOperationFeeOptions = exports.createAlchemySmartAccountClient = exports.createAlchemyPublicRpcClient = exports.isAlchemySmartAccountClient = exports.createAlchemySmartAccountClientFromExisting = exports.alchemyActions = exports.alchemyEnhancedApiActions = exports.defineAlchemyChain = exports.simulateUserOperationChanges = void 0;
|
|
3
|
+
exports.AlchemyProviderConfigSchema = exports.alchemyUserOperationSimulator = exports.alchemyGasManagerMiddleware = exports.alchemyFeeEstimator = exports.getAlchemyPaymasterAddress = exports.getDefaultUserOperationFeeOptions = exports.createAlchemySmartAccountClient = exports.createAlchemyPublicRpcClient = exports.isAlchemySmartAccountClient = exports.createAlchemySmartAccountClientFromExisting = exports.alchemyActions = exports.alchemyEnhancedApiActions = exports.worldChainSepolia = exports.worldChain = exports.zoraSepolia = exports.zora = exports.sepolia = exports.polygonMumbai = exports.polygonAmoy = exports.polygon = exports.optimismSepolia = exports.optimismGoerli = exports.optimism = exports.mainnet = exports.goerli = exports.fraxtalSepolia = exports.fraxtal = exports.defineAlchemyChain = exports.baseSepolia = exports.baseGoerli = exports.base = exports.arbitrumSepolia = exports.arbitrumGoerli = exports.arbitrum = exports.simulateUserOperationChanges = void 0;
|
|
4
4
|
var simulateUserOperationChanges_js_1 = require("./actions/simulateUserOperationChanges.js");
|
|
5
5
|
Object.defineProperty(exports, "simulateUserOperationChanges", { enumerable: true, get: function () { return simulateUserOperationChanges_js_1.simulateUserOperationChanges; } });
|
|
6
6
|
var chains_js_1 = require("./chains.js");
|
|
7
|
+
Object.defineProperty(exports, "arbitrum", { enumerable: true, get: function () { return chains_js_1.arbitrum; } });
|
|
8
|
+
Object.defineProperty(exports, "arbitrumGoerli", { enumerable: true, get: function () { return chains_js_1.arbitrumGoerli; } });
|
|
9
|
+
Object.defineProperty(exports, "arbitrumSepolia", { enumerable: true, get: function () { return chains_js_1.arbitrumSepolia; } });
|
|
10
|
+
Object.defineProperty(exports, "base", { enumerable: true, get: function () { return chains_js_1.base; } });
|
|
11
|
+
Object.defineProperty(exports, "baseGoerli", { enumerable: true, get: function () { return chains_js_1.baseGoerli; } });
|
|
12
|
+
Object.defineProperty(exports, "baseSepolia", { enumerable: true, get: function () { return chains_js_1.baseSepolia; } });
|
|
7
13
|
Object.defineProperty(exports, "defineAlchemyChain", { enumerable: true, get: function () { return chains_js_1.defineAlchemyChain; } });
|
|
14
|
+
Object.defineProperty(exports, "fraxtal", { enumerable: true, get: function () { return chains_js_1.fraxtal; } });
|
|
15
|
+
Object.defineProperty(exports, "fraxtalSepolia", { enumerable: true, get: function () { return chains_js_1.fraxtalSepolia; } });
|
|
16
|
+
Object.defineProperty(exports, "goerli", { enumerable: true, get: function () { return chains_js_1.goerli; } });
|
|
17
|
+
Object.defineProperty(exports, "mainnet", { enumerable: true, get: function () { return chains_js_1.mainnet; } });
|
|
18
|
+
Object.defineProperty(exports, "optimism", { enumerable: true, get: function () { return chains_js_1.optimism; } });
|
|
19
|
+
Object.defineProperty(exports, "optimismGoerli", { enumerable: true, get: function () { return chains_js_1.optimismGoerli; } });
|
|
20
|
+
Object.defineProperty(exports, "optimismSepolia", { enumerable: true, get: function () { return chains_js_1.optimismSepolia; } });
|
|
21
|
+
Object.defineProperty(exports, "polygon", { enumerable: true, get: function () { return chains_js_1.polygon; } });
|
|
22
|
+
Object.defineProperty(exports, "polygonAmoy", { enumerable: true, get: function () { return chains_js_1.polygonAmoy; } });
|
|
23
|
+
Object.defineProperty(exports, "polygonMumbai", { enumerable: true, get: function () { return chains_js_1.polygonMumbai; } });
|
|
24
|
+
Object.defineProperty(exports, "sepolia", { enumerable: true, get: function () { return chains_js_1.sepolia; } });
|
|
25
|
+
Object.defineProperty(exports, "zora", { enumerable: true, get: function () { return chains_js_1.zora; } });
|
|
26
|
+
Object.defineProperty(exports, "zoraSepolia", { enumerable: true, get: function () { return chains_js_1.zoraSepolia; } });
|
|
27
|
+
Object.defineProperty(exports, "worldChain", { enumerable: true, get: function () { return chains_js_1.worldChain; } });
|
|
28
|
+
Object.defineProperty(exports, "worldChainSepolia", { enumerable: true, get: function () { return chains_js_1.worldChainSepolia; } });
|
|
8
29
|
var alchemyEnhancedApis_js_1 = require("./client/decorators/alchemyEnhancedApis.js");
|
|
9
30
|
Object.defineProperty(exports, "alchemyEnhancedApiActions", { enumerable: true, get: function () { return alchemyEnhancedApis_js_1.alchemyEnhancedApiActions; } });
|
|
10
31
|
var smartAccount_js_1 = require("./client/decorators/smartAccount.js");
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6FAAyF;AAAhF,+IAAA,4BAA4B,OAAA;AAGrC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,6FAAyF;AAAhF,+IAAA,4BAA4B,OAAA;AAGrC,yCAuBqB;AAtBnB,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iGAAA,IAAI,OAAA;AACJ,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,+GAAA,kBAAkB,OAAA;AAClB,oGAAA,OAAO,OAAA;AACP,2GAAA,cAAc,OAAA;AACd,mGAAA,MAAM,OAAA;AACN,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,oGAAA,OAAO,OAAA;AACP,wGAAA,WAAW,OAAA;AACX,0GAAA,aAAa,OAAA;AACb,oGAAA,OAAO,OAAA;AACP,iGAAA,IAAI,OAAA;AACJ,wGAAA,WAAW,OAAA;AACX,uGAAA,UAAU,OAAA;AACV,8GAAA,iBAAiB,OAAA;AAGnB,qFAAuF;AAA9E,mIAAA,yBAAyB,OAAA;AAElC,uEAAqE;AAA5D,iHAAA,cAAc,OAAA;AACvB,+FAA6J;AAApJ,2JAAA,4CAA4C,OAA+C;AACpG,0FAAsF;AAA7E,6IAAA,2BAA2B,OAAA;AAEpC,sDAAqE;AAA5D,4HAAA,4BAA4B,OAAA;AAErC,wEAAiF;AAAxE,wIAAA,+BAA+B,OAAA;AAExC,6CAAkE;AAAzD,gIAAA,iCAAiC,OAAA;AAC1C,mDAA8D;AAArD,4HAAA,0BAA0B,OAAA;AACnC,gEAAmE;AAA1D,sHAAA,mBAAmB,OAAA;AAE5B,4DAAyE;AAAhE,4HAAA,2BAA2B,OAAA;AACpC,oFAAuF;AAA9E,0IAAA,6BAA6B,OAAA;AAEtC,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n zora,\n zoraSepolia,\n worldChain,\n worldChainSepolia,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { createAlchemySmartAccountClientFromRpcClient as createAlchemySmartAccountClientFromExisting } from \"./client/internal/smartAccountClientFromRpc.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\nexport { AlchemyProviderConfigSchema } from \"./schema.js\";\nexport type { AlchemyProviderConfig } from \"./type.js\";\n"]}
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import type { ClientWithAlchemyMethods } from "../client/types";
|
|
4
|
-
export type RequestGasAndPaymasterAndDataOverrides<TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = Partial<{
|
|
5
|
-
maxFeePerGas: UserOperationRequest<TEntryPointVersion>["maxFeePerGas"] | Multiplier;
|
|
6
|
-
maxPriorityFeePerGas: UserOperationRequest<TEntryPointVersion>["maxPriorityFeePerGas"] | Multiplier;
|
|
7
|
-
callGasLimit: UserOperationRequest<TEntryPointVersion>["callGasLimit"] | Multiplier;
|
|
8
|
-
verificationGasLimit: UserOperationRequest<TEntryPointVersion>["verificationGasLimit"] | Multiplier;
|
|
9
|
-
preVerificationGas: UserOperationRequest<TEntryPointVersion>["preVerificationGas"] | Multiplier;
|
|
10
|
-
} & TEntryPointVersion extends "0.7.0" ? {
|
|
11
|
-
paymasterVerificationGasLimit: UserOperationRequest<"0.7.0">["paymasterVerificationGasLimit"] | Multiplier;
|
|
12
|
-
paymasterPostOpGasLimit: UserOperationRequest<"0.7.0">["paymasterPostOpGasLimit"] | Multiplier;
|
|
13
|
-
} : {}>;
|
|
14
|
-
export type RequestPaymasterAndDataResponse<TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = TEntryPointVersion extends "0.6.0" ? {
|
|
15
|
-
paymasterAndData: UserOperationRequest<"0.6.0">["paymasterAndData"];
|
|
16
|
-
} : TEntryPointVersion extends "0.7.0" ? Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData"> : {};
|
|
17
|
-
export type RequestGasAndPaymasterAndDataResponse<TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = Pick<UserOperationRequest, "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "maxFeePerGas" | "maxPriorityFeePerGas"> & RequestPaymasterAndDataResponse<TEntryPointVersion>;
|
|
18
|
-
export interface AlchemyGasManagerConfig {
|
|
19
|
-
policyId: string;
|
|
20
|
-
gasEstimationOptions?: AlchemyGasEstimationOptions;
|
|
21
|
-
paymasterAddress?: Address;
|
|
22
|
-
dummyData?: Hex;
|
|
23
|
-
}
|
|
24
|
-
export interface AlchemyGasEstimationOptions {
|
|
25
|
-
disableGasEstimation: boolean;
|
|
26
|
-
fallbackGasEstimator?: ClientMiddlewareFn;
|
|
27
|
-
fallbackFeeDataGetter?: ClientMiddlewareFn;
|
|
28
|
-
}
|
|
29
|
-
export declare function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(client: C, config: AlchemyGasManagerConfig): Pick<ClientMiddlewareConfig, "paymasterAndData" | "feeEstimator" | "gasEstimator">;
|
|
1
|
+
import type { ClientMiddlewareConfig } from "@aa-sdk/core";
|
|
2
|
+
export declare function alchemyGasManagerMiddleware(policyId: string): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">;
|
|
@@ -2,147 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.alchemyGasManagerMiddleware = void 0;
|
|
4
4
|
const core_1 = require("@aa-sdk/core");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const paymaster = config.paymasterAddress ?? (0, gas_manager_js_1.getAlchemyPaymasterAddress)(client.chain);
|
|
10
|
-
const paymasterData = config.dummyData ??
|
|
11
|
-
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";
|
|
12
|
-
return (0, viem_1.concat)([paymaster, paymasterData]);
|
|
13
|
-
};
|
|
14
|
-
function alchemyGasManagerMiddleware(client, config) {
|
|
15
|
-
const gasEstimationOptions = config.gasEstimationOptions;
|
|
16
|
-
const disableGasEstimation = gasEstimationOptions?.disableGasEstimation ?? false;
|
|
17
|
-
const fallbackFeeDataGetter = gasEstimationOptions?.fallbackFeeDataGetter ?? (0, feeEstimator_js_1.alchemyFeeEstimator)(client);
|
|
18
|
-
const fallbackGasEstimator = gasEstimationOptions?.fallbackGasEstimator ??
|
|
19
|
-
(0, core_1.defaultGasEstimator)(client);
|
|
20
|
-
return {
|
|
21
|
-
gasEstimator: disableGasEstimation
|
|
22
|
-
? fallbackGasEstimator
|
|
23
|
-
: async (struct, { overrides, account, feeOptions }) => {
|
|
24
|
-
if ((0, core_1.bypassPaymasterAndDataEmptyHex)(overrides)) {
|
|
25
|
-
return {
|
|
26
|
-
...struct,
|
|
27
|
-
...(await fallbackGasEstimator(struct, {
|
|
28
|
-
overrides,
|
|
29
|
-
account,
|
|
30
|
-
feeOptions,
|
|
31
|
-
client,
|
|
32
|
-
})),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return struct;
|
|
36
|
-
},
|
|
37
|
-
feeEstimator: disableGasEstimation
|
|
38
|
-
? fallbackFeeDataGetter
|
|
39
|
-
: async (struct, { overrides, account, feeOptions }) => {
|
|
40
|
-
let maxFeePerGas = await struct.maxFeePerGas;
|
|
41
|
-
let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;
|
|
42
|
-
if ((0, core_1.bypassPaymasterAndDataEmptyHex)(overrides)) {
|
|
43
|
-
const result = await fallbackFeeDataGetter(struct, {
|
|
44
|
-
overrides,
|
|
45
|
-
feeOptions,
|
|
46
|
-
account,
|
|
47
|
-
client,
|
|
48
|
-
});
|
|
49
|
-
maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;
|
|
50
|
-
maxPriorityFeePerGas =
|
|
51
|
-
(await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
...struct,
|
|
55
|
-
maxFeePerGas,
|
|
56
|
-
maxPriorityFeePerGas,
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
paymasterAndData: disableGasEstimation
|
|
60
|
-
? requestPaymasterAndData(client, config)
|
|
61
|
-
: requestGasAndPaymasterData(client, config),
|
|
62
|
-
};
|
|
5
|
+
function alchemyGasManagerMiddleware(policyId) {
|
|
6
|
+
return (0, core_1.erc7677Middleware)({
|
|
7
|
+
context: { policyId: policyId },
|
|
8
|
+
});
|
|
63
9
|
}
|
|
64
10
|
exports.alchemyGasManagerMiddleware = alchemyGasManagerMiddleware;
|
|
65
|
-
const overrideField = (field, overrides, feeOptions, userOperation) => {
|
|
66
|
-
let _field = field;
|
|
67
|
-
if (overrides?.[_field] != null) {
|
|
68
|
-
if ((0, core_1.isBigNumberish)(overrides[_field])) {
|
|
69
|
-
return (0, core_1.deepHexlify)(overrides[_field]);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return {
|
|
73
|
-
multiplier: Number(overrides[_field].multiplier),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if ((0, core_1.isMultiplier)(feeOptions?.[field])) {
|
|
78
|
-
return {
|
|
79
|
-
multiplier: Number(feeOptions[field].multiplier),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
const userOpField = userOperation[field];
|
|
83
|
-
if ((0, viem_1.isHex)(userOpField) && (0, viem_1.fromHex)(userOpField, "bigint") > 0n) {
|
|
84
|
-
return userOpField;
|
|
85
|
-
}
|
|
86
|
-
return undefined;
|
|
87
|
-
};
|
|
88
|
-
function requestGasAndPaymasterData(client, config) {
|
|
89
|
-
return {
|
|
90
|
-
dummyPaymasterAndData: dummyPaymasterAndData(client, config),
|
|
91
|
-
paymasterAndData: async (struct, { overrides: overrides_, feeOptions, account }) => {
|
|
92
|
-
const userOperation = (0, core_1.deepHexlify)(await (0, core_1.resolveProperties)(struct));
|
|
93
|
-
const overrides = (0, core_1.filterUndefined)({
|
|
94
|
-
maxFeePerGas: overrideField("maxFeePerGas", overrides_, feeOptions, userOperation),
|
|
95
|
-
maxPriorityFeePerGas: overrideField("maxPriorityFeePerGas", overrides_, feeOptions, userOperation),
|
|
96
|
-
callGasLimit: overrideField("callGasLimit", overrides_, feeOptions, userOperation),
|
|
97
|
-
verificationGasLimit: overrideField("verificationGasLimit", overrides_, feeOptions, userOperation),
|
|
98
|
-
preVerificationGas: overrideField("preVerificationGas", overrides_, feeOptions, userOperation),
|
|
99
|
-
});
|
|
100
|
-
if (account.getEntryPoint().version === "0.7.0") {
|
|
101
|
-
const paymasterVerificationGasLimit = overrideField("paymasterVerificationGasLimit", overrides_, feeOptions, userOperation);
|
|
102
|
-
if (paymasterVerificationGasLimit != null) {
|
|
103
|
-
overrides.paymasterVerificationGasLimit = paymasterVerificationGasLimit;
|
|
104
|
-
}
|
|
105
|
-
const paymasterPostOpGasLimit = overrideField("paymasterPostOpGasLimit", overrides_, feeOptions, userOperation);
|
|
106
|
-
if (paymasterPostOpGasLimit != null) {
|
|
107
|
-
overrides.paymasterPostOpGasLimit = paymasterPostOpGasLimit;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const result = await client.request({
|
|
111
|
-
method: "alchemy_requestGasAndPaymasterAndData",
|
|
112
|
-
params: [
|
|
113
|
-
{
|
|
114
|
-
policyId: config.policyId,
|
|
115
|
-
entryPoint: account.getEntryPoint().address,
|
|
116
|
-
userOperation,
|
|
117
|
-
dummySignature: userOperation.signature,
|
|
118
|
-
overrides,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
});
|
|
122
|
-
return {
|
|
123
|
-
...struct,
|
|
124
|
-
...result,
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
const requestPaymasterAndData = (client, config) => ({
|
|
130
|
-
dummyPaymasterAndData: dummyPaymasterAndData(client, config),
|
|
131
|
-
paymasterAndData: async (struct, { account }) => {
|
|
132
|
-
const result = await client.request({
|
|
133
|
-
method: "alchemy_requestPaymasterAndData",
|
|
134
|
-
params: [
|
|
135
|
-
{
|
|
136
|
-
policyId: config.policyId,
|
|
137
|
-
entryPoint: account.getEntryPoint().address,
|
|
138
|
-
userOperation: (0, core_1.deepHexlify)(await (0, core_1.resolveProperties)(struct)),
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
});
|
|
142
|
-
return {
|
|
143
|
-
...struct,
|
|
144
|
-
...result,
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
11
|
//# sourceMappingURL=gasManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":";;;AAUA,uCAQsB;AACtB,+BAAwD;AAExD,sDAA+D;AAC/D,uDAAwD;AAoIxD,MAAM,qBAAqB,GACzB,CACE,MAAS,EACT,MAA+B,EAC/B,EAAE,CACJ,GAAG,EAAE;IACH,MAAM,SAAS,GACb,MAAM,CAAC,gBAAgB,IAAI,IAAA,2CAA0B,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtE,MAAM,aAAa,GACjB,MAAM,CAAC,SAAS;QAChB,sMAAsM,CAAC;IAEzM,OAAO,IAAA,aAAM,EAAC,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;AAC5C,CAAC,CAAC;AAUJ,SAAgB,2BAA2B,CACzC,MAAS,EACT,MAA+B;IAK/B,MAAM,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;IACzD,MAAM,oBAAoB,GACxB,oBAAoB,EAAE,oBAAoB,IAAI,KAAK,CAAC;IACtD,MAAM,qBAAqB,GACzB,oBAAoB,EAAE,qBAAqB,IAAI,IAAA,qCAAmB,EAAC,MAAM,CAAC,CAAC;IAC7E,MAAM,oBAAoB,GACxB,oBAAoB,EAAE,oBAAoB;QAC1C,IAAA,0BAAmB,EAAI,MAAM,CAAC,CAAC;IAEjC,OAAO;QACL,YAAY,EAAE,oBAAoB;YAChC,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;gBAGnD,IAAI,IAAA,qCAA8B,EAAC,SAAS,CAAC,EAAE,CAAC;oBAC9C,OAAO;wBACL,GAAG,MAAM;wBACT,GAAG,CAAC,MAAM,oBAAoB,CAAC,MAAM,EAAE;4BACrC,SAAS;4BACT,OAAO;4BACP,UAAU;4BACV,MAAM;yBACP,CAAC,CAAC;qBACJ,CAAC;gBACJ,CAAC;gBAGD,OAAO,MAAM,CAAC;YAChB,CAAC;QACL,YAAY,EAAE,oBAAoB;YAChC,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE;gBACnD,IAAI,YAAY,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;gBAC7C,IAAI,oBAAoB,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC;gBAI7D,IAAI,IAAA,qCAA8B,EAAC,SAAS,CAAC,EAAE,CAAC;oBAC9C,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE;wBACjD,SAAS;wBACT,UAAU;wBACV,OAAO;wBACP,MAAM;qBACP,CAAC,CAAC;oBACH,YAAY,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC;oBAC3D,oBAAoB;wBAClB,CAAC,MAAM,MAAM,CAAC,oBAAoB,CAAC,IAAI,oBAAoB,CAAC;gBAChE,CAAC;gBAED,OAAO;oBACL,GAAG,MAAM;oBACT,YAAY;oBACZ,oBAAoB;iBACrB,CAAC;YACJ,CAAC;QACL,gBAAgB,EAAE,oBAAoB;YACpC,CAAC,CAAC,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC;YACzC,CAAC,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC;KAC/C,CAAC;AACJ,CAAC;AAnED,kEAmEC;AAYD,MAAM,aAAa,GAAG,CAGpB,KAAwD,EACxD,SAAiE,EACjE,UAAmE,EACnE,aAAuD,EACzB,EAAE;IAChC,IAAI,MAAM,GAAG,KAAyD,CAAC;IAEvE,IAAI,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAEhC,IAAI,IAAA,qBAAc,EAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACtC,OAAO,IAAA,kBAAW,EAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACxC,CAAC;aAEI,CAAC;YACJ,OAAO;gBACL,UAAU,EAAE,MAAM,CAAE,SAAS,CAAC,MAAM,CAAgB,CAAC,UAAU,CAAC;aACjE,CAAC;QACJ,CAAC;IACH,CAAC;IAGD,IAAI,IAAA,mBAAY,EAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,UAAU,EAAE,MAAM,CAAE,UAAW,CAAC,KAAK,CAAgB,CAAC,UAAU,CAAC;SAClE,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GACf,aAAa,CAAC,KAAuD,CAAC,CAAC;IACzE,IAAI,IAAA,YAAK,EAAC,WAAW,CAAC,IAAI,IAAA,cAAO,EAAC,WAAkB,EAAE,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;QACrE,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAWF,SAAS,0BAA0B,CACjC,MAAS,EACT,MAA+B;IAE/B,OAAO;QACL,qBAAqB,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC;QAE5D,gBAAgB,EAAE,KAAK,EACrB,MAAM,EACN,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,EAC9C,EAAE;YACF,MAAM,aAAa,GAAyB,IAAA,kBAAW,EACrD,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAChC,CAAC;YAEF,MAAM,SAAS,GAA2C,IAAA,sBAAe,EACvE;gBACE,YAAY,EAAE,aAAa,CACzB,cAAc,EACd,UAAoC,EACpC,UAAU,EACV,aAAa,CACd;gBACD,oBAAoB,EAAE,aAAa,CACjC,sBAAsB,EACtB,UAAoC,EACpC,UAAU,EACV,aAAa,CACd;gBACD,YAAY,EAAE,aAAa,CACzB,cAAc,EACd,UAAoC,EACpC,UAAU,EACV,aAAa,CACd;gBACD,oBAAoB,EAAE,aAAa,CACjC,sBAAsB,EACtB,UAAoC,EACpC,UAAU,EACV,aAAa,CACd;gBACD,kBAAkB,EAAE,aAAa,CAC/B,oBAAoB,EACpB,UAAoC,EACpC,UAAU,EACV,aAAa,CACd;aACF,CACF,CAAC;YAEF,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAChD,MAAM,6BAA6B,GAAG,aAAa,CACjD,+BAA+B,EAC/B,UAA6C,EAC7C,UAAU,EACV,aAAa,CACd,CAAC;gBACF,IAAI,6BAA6B,IAAI,IAAI,EAAE,CAAC;oBAExC,SACD,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;gBAClE,CAAC;gBAED,MAAM,uBAAuB,GAAG,aAAa,CAC3C,yBAAyB,EACzB,UAA6C,EAC7C,UAAU,EACV,aAAa,CACd,CAAC;gBACF,IAAI,uBAAuB,IAAI,IAAI,EAAE,CAAC;oBAElC,SACD,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;gBACtD,CAAC;YACH,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;gBAClC,MAAM,EAAE,uCAAuC;gBAC/C,MAAM,EAAE;oBACN;wBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;wBAC3C,aAAa;wBACb,cAAc,EAAE,aAAa,CAAC,SAAS;wBACvC,SAAS;qBACV;iBACF;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,MAAM;gBACT,GAAG,MAAM;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAWD,MAAM,uBAAuB,GAGqB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACrE,qBAAqB,EAAE,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC;IAC5D,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,EAAE,iCAAiC;YACzC,MAAM,EAAE;gBACN;oBACE,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;oBAC3C,aAAa,EAAE,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,MAAM;YACT,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type {\n Address,\n ClientMiddlewareConfig,\n ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndDataEmptyHex,\n deepHexlify,\n defaultGasEstimator,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { concat, fromHex, isHex, type Hex } from \"viem\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * overrides value for [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataOverrides<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Partial<\n {\n maxFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxFeePerGas\"]\n | Multiplier;\n maxPriorityFeePerGas:\n | UserOperationRequest<TEntryPointVersion>[\"maxPriorityFeePerGas\"]\n | Multiplier;\n callGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"callGasLimit\"]\n | Multiplier;\n verificationGasLimit:\n | UserOperationRequest<TEntryPointVersion>[\"verificationGasLimit\"]\n | Multiplier;\n preVerificationGas:\n | UserOperationRequest<TEntryPointVersion>[\"preVerificationGas\"]\n | Multiplier;\n } & TEntryPointVersion extends \"0.7.0\"\n ? {\n paymasterVerificationGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterVerificationGasLimit\"]\n | Multiplier;\n paymasterPostOpGasLimit:\n | UserOperationRequest<\"0.7.0\">[\"paymasterPostOpGasLimit\"]\n | Multiplier;\n }\n : {}\n>;\n\n/**\n * [`alchemy-requestpaymasteranddata`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<UserOperationRequest<\"0.7.0\">, \"paymaster\" | \"paymasterData\">\n : {};\n\n/**\n * [`alchemy_requestGasAndPaymasterData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n * response type\n *\n * @template {EntryPointVersion} TEntryPointVersion entry point version type\n */\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n RequestPaymasterAndDataResponse<TEntryPointVersion>;\n\n/**\n * Alchemy gas manager configuration with gas policy id and optional gas estimation options\n *\n * To create a Gas Manager Policy, go to the [gas manager](https://dashboard.alchemy.com/gas-manager?a=embedded-accounts-get-started)\n * page of the Alchemy dashboard and click the “Create new policy” button.\n */\nexport interface AlchemyGasManagerConfig {\n /**\n * the policy id of the gas manager you want to use.\n *\n */\n policyId: string;\n /**\n * optional option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\n gasEstimationOptions?: AlchemyGasEstimationOptions;\n /**\n * paymaster address to use for the gas estimation.\n * If not provided, the default paymaster address for the chain will be used.\n *\n */\n paymasterAddress?: Address;\n /**\n * dummy paymaster data to use for the gas estimation.\n *\n */\n dummyData?: Hex;\n}\n\n/**\n * Alchemy gas manager configuration option configurable for the gas estimation portion of the Alchemy gas manager\n *\n */\nexport interface AlchemyGasEstimationOptions {\n /**\n * disable gas estimation and fallback to the default gas estimation.\n *\n */\n disableGasEstimation: boolean;\n /**\n * optional fallback gas estimator to use when gas estimation is disabled.\n *\n */\n fallbackGasEstimator?: ClientMiddlewareFn;\n /**\n * optional fallback fee estimator to use when gas estimation is disabled.\n *\n */\n fallbackFeeDataGetter?: ClientMiddlewareFn;\n}\n\n/**\n * Dummy paymaster and data middleware for the alchemy gas manager\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the dummyPaymasterAndData middleware for Alchemy gas manager\n */\nconst dummyPaymasterAndData =\n <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n ) =>\n () => {\n const paymaster =\n config.paymasterAddress ?? getAlchemyPaymasterAddress(client.chain);\n const paymasterData =\n config.dummyData ??\n \"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return concat([paymaster, paymasterData]); // or you can also return { paymaster, paymasterData }\n };\n\n/**\n * Alchemy gas manager middleware used as the paymaster middleware overrides param to the client middleware config\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the gas estimator, fee estimator, and paymasterAndData middleware for Alchemy gas manager\n */\nexport function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): Pick<\n ClientMiddlewareConfig,\n \"paymasterAndData\" | \"feeEstimator\" | \"gasEstimator\"\n> {\n const gasEstimationOptions = config.gasEstimationOptions;\n const disableGasEstimation =\n gasEstimationOptions?.disableGasEstimation ?? false;\n const fallbackFeeDataGetter =\n gasEstimationOptions?.fallbackFeeDataGetter ?? alchemyFeeEstimator(client);\n const fallbackGasEstimator =\n gasEstimationOptions?.fallbackGasEstimator ??\n defaultGasEstimator<C>(client);\n\n return {\n gasEstimator: disableGasEstimation\n ? fallbackGasEstimator\n : async (struct, { overrides, account, feeOptions }) => {\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n return {\n ...struct,\n ...(await fallbackGasEstimator(struct, {\n overrides,\n account,\n feeOptions,\n client,\n })),\n };\n }\n\n // essentially noop, because the gas estimation will happen in the backend\n return struct;\n },\n feeEstimator: disableGasEstimation\n ? fallbackFeeDataGetter\n : async (struct, { overrides, account, feeOptions }) => {\n let maxFeePerGas = await struct.maxFeePerGas;\n let maxPriorityFeePerGas = await struct.maxPriorityFeePerGas;\n\n // if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override),\n // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called\n if (bypassPaymasterAndDataEmptyHex(overrides)) {\n const result = await fallbackFeeDataGetter(struct, {\n overrides,\n feeOptions,\n account,\n client,\n });\n maxFeePerGas = (await result.maxFeePerGas) ?? maxFeePerGas;\n maxPriorityFeePerGas =\n (await result.maxPriorityFeePerGas) ?? maxPriorityFeePerGas;\n }\n\n return {\n ...struct,\n maxFeePerGas,\n maxPriorityFeePerGas,\n };\n },\n paymasterAndData: disableGasEstimation\n ? requestPaymasterAndData(client, config)\n : requestGasAndPaymasterData(client, config),\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param field the field to override\n * @param overrides the overrides object\n * @param feeOptions the fee options object from the client\n * @param userOperation the user operation request\n * @returns the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestGasAndPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestgasandpaymasteranddata)\n *\n * @template {ClientWithAlchemyMethods} C\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager\n */\nfunction requestGasAndPaymasterData<C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n): ClientMiddlewareConfig[\"paymasterAndData\"] {\n return {\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n\n paymasterAndData: async (\n struct,\n { overrides: overrides_, feeOptions, account }\n ) => {\n const userOperation: UserOperationRequest = deepHexlify(\n await resolveProperties(struct)\n );\n\n const overrides: RequestGasAndPaymasterAndDataOverrides = filterUndefined(\n {\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOperation\n ),\n }\n );\n\n if (account.getEntryPoint().version === \"0.7.0\") {\n const paymasterVerificationGasLimit = overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterVerificationGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n }\n\n const paymasterPostOpGasLimit = overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOperation\n );\n if (paymasterPostOpGasLimit != null) {\n (\n overrides as RequestGasAndPaymasterAndDataOverrides<\"0.7.0\">\n ).paymasterPostOpGasLimit = paymasterPostOpGasLimit;\n }\n }\n\n const result = await client.request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation,\n dummySignature: userOperation.signature,\n overrides,\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n };\n}\n\n/**\n * Alchemy gas manager middleware function that returns the paymaster middleware for the client middleware config\n * that calls the [`alchemy_requestPaymasterAndData`](https://docs.alchemy.com/reference/alchemy-requestpaymasteranddata)\n * with gas estimation disabled.\n *\n * @param client client with alchemy methods\n * @param config alchemy gas manager configuration\n * @returns the paymasterAndData middleware for Alchemy gas manager with gas estimation disabled\n */\nconst requestPaymasterAndData: <C extends ClientWithAlchemyMethods>(\n client: C,\n config: AlchemyGasManagerConfig\n) => ClientMiddlewareConfig[\"paymasterAndData\"] = (client, config) => ({\n dummyPaymasterAndData: dummyPaymasterAndData(client, config),\n paymasterAndData: async (struct, { account }) => {\n const result = await client.request({\n method: \"alchemy_requestPaymasterAndData\",\n params: [\n {\n policyId: config.policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: deepHexlify(await resolveProperties(struct)),\n },\n ],\n });\n\n return {\n ...struct,\n ...result,\n };\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":";;;AACA,uCAAiD;AAqBjD,SAAgB,2BAA2B,CACzC,QAAgB;IAEhB,OAAO,IAAA,wBAAiB,EAAuB;QAC7C,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChC,CAAC,CAAC;AACL,CAAC;AAND,kEAMC","sourcesContent":["import type { ClientMiddlewareConfig } from \"@aa-sdk/core\";\nimport { erc7677Middleware } from \"@aa-sdk/core\";\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.\n *\n * @example\n * ```ts\n *\n * import { sepolia } from \"@account-kit/infra\";\n * import { http } from \"viem\";\n *\n * const client = createSmartAccountClient({\n * http(\"rpc-url\"),\n * sepolia,\n * alchemyErc7677Middleware(\"policyId\")\n * );\n * ```\n *\n * @param {string} policyId the policyId for Alchemy's gas manager\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasManagerMiddleware(\n policyId: string\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return erc7677Middleware<{ policyId: string }>({\n context: { policyId: policyId },\n });\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type ClientMiddlewareFn } from "@aa-sdk/core";
|
|
1
|
+
import { type ClientMiddlewareFn, type UserOperationContext } from "@aa-sdk/core";
|
|
2
2
|
import type { ClientWithAlchemyMethods } from "../client/types";
|
|
3
|
-
export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods>(client: C): ClientMiddlewareFn
|
|
3
|
+
export declare function alchemyUserOperationSimulator<C extends ClientWithAlchemyMethods, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: C): ClientMiddlewareFn<TContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"userOperationSimulator.js","sourceRoot":"","sources":["../../../src/middleware/userOperationSimulator.ts"],"names":[],"mappings":";;;AAAA,uCAKsB;AAsBtB,SAAgB,6BAA6B,CAK3C,MAAS;IACT,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC;YACvC,MAAM,EAAE,2CAA2C;YACnD,MAAM,EAAE;gBACN,IAAA,kBAAW,EAAC,MAAM,IAAA,wBAAiB,EAAC,MAAM,CAAC,CAAC;gBAC5C,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;aAChC;SACF,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AArBD,sEAqBC","sourcesContent":["import {\n deepHexlify,\n resolveProperties,\n type ClientMiddlewareFn,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport type { ClientWithAlchemyMethods } from \"../client/types\";\n\n/**\n * A middleware function to be used during simulation of user operations which leverages Alchemy's RPC uo simulation method.\n *\n * @example\n * ```ts\n * import { alchemyUserOperationSimulator, createAlchemyPublicRpcClient } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createAlchemyPublicRpcClient(...);\n * const client = createSmartAccountClient({\n * userOperationSimulator: alchemyUserOperationSimulator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template C The client object with Alchemy methods\n * @param {C} client The client object with Alchemy methods\n * @returns {ClientMiddlewareFn} A middleware function to simulate and process user operations\n */\nexport function alchemyUserOperationSimulator<\n C extends ClientWithAlchemyMethods,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(client: C): ClientMiddlewareFn<TContext> {\n return async (struct, { account }) => {\n const uoSimResult = await client.request({\n method: \"alchemy_simulateUserOperationAssetChanges\",\n params: [\n deepHexlify(await resolveProperties(struct)),\n account.getEntryPoint().address,\n ],\n });\n\n if (uoSimResult.error) {\n throw new Error(uoSimResult.error.message);\n }\n\n return struct;\n };\n}\n"]}
|