@biconomy/ecosystem
Version:
Testing infrastructure for abstractjs with ephemeral networks
158 lines (147 loc) • 6.34 kB
text/typescript
import { Address, Hex, Chain, PublicClient, Transport, WalletClient, Account, TestClient, PublicRpcSchema, LocalAccount } from 'viem';
import { NexusAccount } from '@biconomy/abstractjs';
import { Options } from 'get-port';
import { BundlerClient, SmartAccount } from 'viem/account-abstraction';
import { TestClientMode } from 'viem/clients/createTestClient';
declare const DETERMINISTIC_DEPLOYER: Address;
declare const CREATE2_FACTORY_DEPLOYER_ADDRESS: Address;
declare const ENTRYPOINT_V07_ADDRESS: Address;
declare const ENTRY_POINT_SIMULATIONS_ADDRESS: Address;
declare const NEXUS_IMPLEMENTATION_ADDRESS: Address;
declare const NEXUS_BOOTSTRAP_ADDRESS: Address;
declare const NEXUS_ACCOUNT_FACTORY_ADDRESS: Address;
declare const MEE_VALIDATOR_ADDRESS: Address;
declare const COMPOSABLE_MODULE_ADDRESS: Address;
declare const SMART_SESSION_ADDRESS: Address;
declare const SUDO_POLICY_ADDRESS: Address;
declare const SPENDING_LIMITS_POLICY_ADDRESS: Address;
declare const UNIVERSAL_ACTION_POLICY_ADDRESS: Address;
declare const TIME_FRAME_POLICY_ADDRESS: Address;
declare const VALUE_LIMIT_POLICY_ADDRESS: Address;
declare const OWNABLE_VALIDATOR_ADDRESS: Address;
declare const OWNABLE_EXECUTOR_ADDRESS: Address;
declare const MINTABLE_ADDRESS: Address;
declare const COUNTER_ADDRESS: Address;
declare const TOKEN_WITH_PERMIT: Address;
declare const MOCK_SIGNATURE_VALIDATOR: Address;
declare const MOCK_CALLEE: Address;
declare const MOCK_TOKEN: Address;
declare const FREE_MINT_ERC20: Address;
declare const MEE_ENTRYPOINT: Address;
declare const ALL_ADDRESSES: Record<string, {
address: Address;
chainId: number;
}>;
declare const BYTECODES: Record<Address, {
address: Address;
bytecode: Hex;
name: string;
}>;
type DeployContractsArgs = {
rpcUrl: string;
chain: Chain;
privateKey?: Hex;
};
declare const deployContracts: ({ rpcUrl, chain }: DeployContractsArgs) => Promise<void>;
declare const ENTRY_POINT_V07_CREATECALL: Hex;
declare const ENTRY_POINT_SIMULATIONS_CREATECALL: Hex;
type FundAccountsArgs = {
rpcUrl: string;
chain: Chain;
privateKey?: Hex;
};
declare const fundAccounts: ({ rpcUrl, chain }: FundAccountsArgs) => Promise<void>;
type NetworkArgs = {
rpcPort?: number;
rpcUrl?: string;
chainId?: string;
name?: string;
privateKey?: Hex;
forkUrl?: string;
};
type Network = Awaited<ReturnType<typeof toNetwork>>;
declare const toNetwork: (parameters?: NetworkArgs) => Promise<{
instance: any;
chain: Chain;
rpcUrl: string;
rpcPort: number;
chainId: string;
name: string;
privateKey: `0x${string}`;
}>;
type Bundler = Awaited<ReturnType<typeof toBundler>>;
type ToBundlerParameters = NetworkArgs & {
port?: number;
};
declare const toBundler: (parameters: ToBundlerParameters) => Promise<{
instance: any;
port: number;
url: string;
}>;
type MeeNodeParameters = {
infras: Infra[];
};
type MeeNode = Awaited<ReturnType<typeof toMeeNode>>;
declare const toMeeNode: (parameters: MeeNodeParameters) => Promise<{
chainIds: string[];
url: `http://${string}`;
projectName: string;
meeDeploymentDir: string;
stop(): Promise<void>;
}>;
declare const getPackageRoot: () => string;
declare const getRandomNumber: (min?: number, max?: number) => number;
declare const sleep: (ms: number) => Promise<unknown>;
type Clients = {
publicClient: PublicClient<Transport, Chain>;
walletClients: WalletClient<Transport, Chain, Account>[];
testClient: TestClient<TestClientMode, Transport, Chain | undefined, Account | undefined, true, PublicRpcSchema>;
accounts: LocalAccount[];
account: LocalAccount;
};
declare const toClients: ({ rpcUrl, chain }: {
rpcUrl: string;
chain: Chain;
}) => Promise<Clients>;
declare global {
var __BICONOMY_USED_PORTS__: number[];
}
declare const PORT_OPTS: Options;
declare const getFreePort: (max: number, min: number, options?: Options) => Promise<number>;
declare const getFundedAccount: () => {
account: Account;
privateKey: Hex;
};
type Url = `https://${string}` | `http://${string}`;
type MinimalVars = {
privateKey: Hex;
chainId: number;
bundlerUrl: Url;
};
declare const getEnvVars: (prefix?: string) => MinimalVars;
type NetworkConfig = {
account: LocalAccount;
chain: Chain;
walletClient: WalletClient<Transport, Chain, Account>;
publicClient: PublicClient<Transport, Chain>;
bundlerClient: BundlerClient<Transport, Chain, SmartAccount>;
nexusAccount: NexusAccount;
};
declare const validateNetwork: ({ chain, account, nexusAccount, bundlerClient, publicClient, walletClient }: NetworkConfig) => Promise<void>;
declare const getBalance: (publicClient: PublicClient<Transport, Chain>, owner: Hex, tokenAddress?: Hex) => Promise<bigint>;
type ToEcosystemParameters = {
chainLength?: number;
forkUrl?: string;
withMee?: boolean;
};
type Infra = {
network: Network;
bundler: Bundler;
};
type Ecosystem = {
meeNode?: MeeNode;
infras: Infra[];
clients: Clients[];
};
declare const toEcosystem: (parameters?: ToEcosystemParameters) => Promise<Ecosystem>;
export { ALL_ADDRESSES, BYTECODES, type Bundler, COMPOSABLE_MODULE_ADDRESS, COUNTER_ADDRESS, CREATE2_FACTORY_DEPLOYER_ADDRESS, type Clients, DETERMINISTIC_DEPLOYER, type DeployContractsArgs, ENTRYPOINT_V07_ADDRESS, ENTRY_POINT_SIMULATIONS_ADDRESS, ENTRY_POINT_SIMULATIONS_CREATECALL, ENTRY_POINT_V07_CREATECALL, type Ecosystem, FREE_MINT_ERC20, type FundAccountsArgs, type Infra, MEE_ENTRYPOINT, MEE_VALIDATOR_ADDRESS, MINTABLE_ADDRESS, MOCK_CALLEE, MOCK_SIGNATURE_VALIDATOR, MOCK_TOKEN, type MeeNode, type MeeNodeParameters, type MinimalVars, NEXUS_ACCOUNT_FACTORY_ADDRESS, NEXUS_BOOTSTRAP_ADDRESS, NEXUS_IMPLEMENTATION_ADDRESS, type Network, type NetworkArgs, type NetworkConfig, OWNABLE_EXECUTOR_ADDRESS, OWNABLE_VALIDATOR_ADDRESS, PORT_OPTS, SMART_SESSION_ADDRESS, SPENDING_LIMITS_POLICY_ADDRESS, SUDO_POLICY_ADDRESS, TIME_FRAME_POLICY_ADDRESS, TOKEN_WITH_PERMIT, type ToBundlerParameters, type ToEcosystemParameters, UNIVERSAL_ACTION_POLICY_ADDRESS, type Url, VALUE_LIMIT_POLICY_ADDRESS, deployContracts, fundAccounts, getBalance, getEnvVars, getFreePort, getFundedAccount, getPackageRoot, getRandomNumber, sleep, toBundler, toClients, toEcosystem, toMeeNode, toNetwork, validateNetwork };