UNPKG

@etherspot/prime-sdk

Version:

Etherspot Prime (Account Abstraction) SDK

81 lines (80 loc) 3.7 kB
import { BigNumber, BigNumberish } from 'ethers'; import { BehaviorSubject } from 'rxjs'; import { Provider } from '@ethersproject/providers'; import { EntryPoint, INonceManager } from '../contracts'; import { UserOperationStruct } from '../contracts/account-abstraction/contracts/core/BaseAccount'; import { TransactionDetailsForUserOp } from './TransactionDetailsForUserOp'; import { PaymasterAPI } from './PaymasterAPI'; import { ErrorSubject, NotPromise } from '../common'; import { GasOverheads } from './calcPreVerificationGas'; import { Factory, MessagePayload, Network, NetworkNames, SdkOptions, SignMessageDto, State, StateService, WalletProviderLike } from '..'; import { Context } from '../context'; export interface BaseApiParams { provider: Provider; entryPointAddress: string; accountAddress?: string; overheads?: Partial<GasOverheads>; factoryAddress?: string; walletProvider: WalletProviderLike; optionsLike?: SdkOptions; } export interface UserOpResult { transactionHash: string; success: boolean; } export declare abstract class BaseAccountAPI { private senderAddress; private isPhantom; readonly services: Context['services']; context: Context; protected readonly entryPointView: EntryPoint; protected readonly nonceManager: INonceManager; provider: Provider; overheads?: Partial<GasOverheads>; entryPointAddress: string; accountAddress?: string; paymasterAPI?: PaymasterAPI; factoryUsed: Factory; factoryAddress?: string; constructor(params: BaseApiParams); get state(): StateService; get state$(): BehaviorSubject<State>; get error$(): ErrorSubject; get supportedNetworks(): Network[]; destroy(): void; signMessage(dto: SignMessageDto): Promise<string>; setPaymasterApi(paymaster: PaymasterAPI | null): Promise<void>; require(options?: { network?: boolean; wallet?: boolean; }): Promise<void>; getNetworkChainId(networkName?: NetworkNames): number; validateResolveName(options?: { network?: number; name?: string; }): Promise<void>; init(): Promise<this>; protected abstract getAccountInitCode(): Promise<string>; protected abstract getNonce(key?: number): Promise<BigNumber>; protected abstract encodeExecute(target: string, value: BigNumberish, data: string): Promise<string>; protected abstract encodeBatch(targets: string[], values: BigNumberish[], datas: string[]): Promise<string>; protected abstract signUserOpHash(userOpHash: string): Promise<string>; checkAccountPhantom(): Promise<boolean>; getCounterFactualAddress(): Promise<string>; getInitCode(): Promise<string>; getVerificationGasLimit(): Promise<BigNumberish>; getPreVerificationGas(userOp: Partial<UserOperationStruct>): Promise<number>; packUserOp(userOp: NotPromise<UserOperationStruct>): string; encodeUserOpCallDataAndGasLimit(detailsForUserOp: TransactionDetailsForUserOp): Promise<{ callData: string; callGasLimit: BigNumber; }>; getUserOpHash(userOp: UserOperationStruct): Promise<string>; getAccountAddress(): Promise<string>; estimateCreationGas(initCode?: string): Promise<BigNumberish>; createUnsignedUserOp(info: TransactionDetailsForUserOp, key?: number): Promise<UserOperationStruct>; signUserOp(userOp: UserOperationStruct): Promise<UserOperationStruct>; createSignedUserOp(info: TransactionDetailsForUserOp, key?: number): Promise<UserOperationStruct>; getUserOpReceipt(userOpHash: string, timeout?: number, interval?: number): Promise<string | null>; signTypedData(types: MessagePayload, message: any): Promise<string>; }