import '../env/BigIntSerializer'; import { class_Dfr, class_EventEmitter } from 'atma-utils'; import type { Web3Client } from '../clients/Web3Client'; import { TxDataBuilder } from './TxDataBuilder'; import { EoAccount, IAccount, TAccount } from "../models/TAccount"; import { TAddress } from '../models/TAddress'; import { TPlatform } from '../models/TPlatform'; import { ITxLogItem } from './receipt/ITxLogItem'; import { ISafeServiceTransport } from '../safe/transport/ISafeServiceTransport'; import { TEth } from '../models/TEth'; import { SafeServiceTypes } from '../safe/types/SafeServiceTypes'; import { ITxWriterAgent } from './agents/TxWriterAccountAgents'; export interface ITxWriterEvents { transactionHash(hash: TEth.Hex): any; receipt(receipt: TEth.TxReceipt): any; confirmation(confNumber: number, receipt: TEth.TxReceipt): any; error(error: Error): any; sent(): any; log(message: string): any; safeTxProposed(safeTx: SafeServiceTypes.ProposeTransactionProps): any; } export interface ITxWriterEmitter { onSent: PromiseLike; onCompleted: PromiseLike; tx: ITxWriterTransaction; receipt: TEth.TxReceipt; on(event: keyof ITxWriterEvents, callback: Function): any | this; } export interface ITxWriterTransaction { timestamp: number; confirmations: number; hash?: TEth.Hex; timeout?: NodeJS.Timer; receipt?: TEth.TxReceipt; error?: Error; knownLogs?: ITxLogItem[]; } export interface ITxWriterOptions { timeout?: number | boolean; retries?: number; retryDelay?: number; safeTransport?: ISafeServiceTransport; /** Tx Data will be saved to the store(e.g. a File), and will wait until the signature appears in the store. */ sigTransport?: string; /** Optionally disable waiting for the transport response */ sigTransportWait?: boolean; /** Save the tx data to the file (before agents run, if any) */ txOutput?: string; /** Proceed the Tx up to the signature */ signOnly?: boolean; /** Provide a pre-signed signature for this transaction data. */ signature?: TEth.Hex; /** * The callback is executed on error, to give the opportunity to build a new Tx to resubmit the tx. * @param tx - current TxWriter object * @param error - current Error with receipt(if any) * @param errCount - num of errors already handled */ onErrorRebuild?(tx: TxWriter, error: Error & { receipt?: TEth.TxReceipt; }, errCount: number): Promise; /** * Do not log Transaction states (start, receipt, etc) */ silent?: boolean; /** * Custom agent to process the transaction data. */ agent?: ITxWriterAgent; } export declare class TxWriter extends class_EventEmitter implements ITxWriterEmitter { client: Web3Client; builder: TxDataBuilder; account: TAccount; onSent: class_Dfr; onCompleted: class_Dfr; onSaved: class_Dfr; onSigned: class_Dfr<`0x${string}`>; receipt: TEth.TxReceipt; onConfirmed(waitForCount: number): Promise; wait(): Promise; id: string; tx: ITxWriterTransaction; txs: ITxWriterTransaction[]; options: ITxWriterOptions; private logger; private confirmationAwaiters; protected constructor(client: Web3Client, builder: TxDataBuilder, account: TAccount); send(options?: ITxWriterOptions): this; call(): Promise; protected write(options?: ITxWriterOptions): void; private sendTxInner; catch(fn: any): class_Dfr; private getSender; private getSenderName; private extractLogs; private fundAccountAndResend; private startTimer; private clearTimer; private resubmit; private pipeInnerWriter; /** Use this transfer also in case of additional account funding */ transferNative(from: EoAccount, to: TAddress, amount: bigint): Promise; toJSON(): TTxWriterJson; saveTxAndExit(additionalProperties?: any): Promise; static fromJSON(json: TTxWriterJson, client?: Web3Client, account?: TAccount): Promise; static write(client: Web3Client, builder: TxDataBuilder, account: IAccount, options?: ITxWriterOptions): TxWriter; static create(client: Web3Client, builder: TxDataBuilder, account: TAccount, options?: ITxWriterOptions): TxWriter; static writeTxData(client: Web3Client, data: Partial, accountMix: TAccount, options?: ITxWriterOptions): Promise; static prepareAccount(account: TAccount): Promise; static hasAgent(account: IAccount): Promise; static defaultOptions(options: ITxWriterOptions): void; static DEFAULTS: ITxWriterOptions; debugEnsureBalance(address: TEth.Address): Promise; } export type TTxWriterJson = { id: string; platform: TPlatform; options: ITxWriterOptions; account: TAccount; txs: TxWriter['txs']; builder: ReturnType; };