UNPKG

@account-kit/infra

Version:

adapters for @aa-sdk/core for interacting with alchemy services

85 lines 4.1 kB
import type { Address, ClientMiddlewareConfig, ClientMiddlewareFn } from "@aa-sdk/core"; import { type Hex } from "viem"; import type { AlchemyTransport } from "../alchemyTransport.js"; export type PaymasterContext = { policyId: string | string[]; erc20Context?: { tokenAddress: Address; maxTokenAmount?: bigint; permit?: Hex; }; webhookData?: string; }; export type PolicyToken = { address: Address; maxTokenAmount: bigint; permit?: { paymasterAddress?: Address; autoPermitApproveTo: bigint; autoPermitBelow: bigint; erc20Name: string; version: string; }; }; /** * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring * transactions. Adheres to the ERC-7677 standardized communication protocol. * * @example * ```ts * import { sepolia, alchemyGasManagerMiddleware } from "@account-kit/infra"; * import { http } from "viem"; * * const client = createSmartAccountClient({ * transport: http("rpc-url"), * chain: sepolia, * ...alchemyGasManagerMiddleware("policyId") * }); * ``` * * @param {string | string[]} policyId - The policyId (or list of policyIds) for Alchemy's gas manager * @param {PolicyToken | undefined} policyToken - The policy token configuration * @param {string | undefined} webhookData - The webhook data to include in the request * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} Partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData` */ export declare function alchemyGasManagerMiddleware(policyId: string | string[], policyToken?: PolicyToken, webhookData?: string): Required<Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">>; interface AlchemyGasAndPaymasterAndDataMiddlewareParams { policyId: string | string[]; policyToken?: PolicyToken; webhookData?: string; transport: AlchemyTransport; gasEstimatorOverride?: ClientMiddlewareFn; feeEstimatorOverride?: ClientMiddlewareFn; } /** * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring * transactions. Uses Alchemy's custom `alchemy_requestGasAndPaymasterAndData` * method instead of conforming to the standard ERC-7677 interface. Note that * if you use `createAlchemySmartAccountClient`, this middleware is already * used by default and you do not need to manually include it. * * @example * ```ts twoslash * import { sepolia, alchemy, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra"; * import { createSmartAccountClient } from "@aa-sdk/core"; * * const client = createSmartAccountClient({ * transport: alchemy({ apiKey: "your-api-key" }), * chain: sepolia, * ...alchemyGasAndPaymasterAndDataMiddleware({ * policyId: "policyId", * transport: alchemy({ apiKey: "your-api-key" }), * }) * }); * ``` * * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams} params configuration params * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.policyId} params.policyId the policyId for Alchemy's gas manager * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.transport} params.transport fallback transport to use for fee estimation when not using the paymaster * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.gasEstimatorOverride} params.gasEstimatorOverride custom gas estimator middleware * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.feeEstimatorOverride} params.feeEstimatorOverride custom fee estimator middleware * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData`, `feeEstimator`, `gasEstimator`, and `paymasterAndData` */ export declare function alchemyGasAndPaymasterAndDataMiddleware(params: AlchemyGasAndPaymasterAndDataMiddlewareParams): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData">; export {}; //# sourceMappingURL=gasManager.d.ts.map