import fs from 'fs' ; import { providers } from 'ethers' ; export type LogMode = { console : boolean ; file : boolean ; } ; export const logConfig = { mode : { } as LogMode , filepath : '' , } ; export interface TxLogData { hash ? : string ; from : string ; to : string ; data : string ; } export function logTx ( txName , tx ) { log ( `📕 Transaction: '${ txName }' Hash: ${ ( tx as any ) . hash } From: ${ tx . from } To: ${ tx . to } Hex data: ${ tx . data } ` ) ; } export function log ( ... args ) { const argsJoined = args . join ( '\n' ) ; if ( logConfig . mode . console ) { console . log ( argsJoined ) ; } if ( logConfig . mode . file && logConfig . filepath ) { fs . appendFileSync ( logConfig . filepath , argsJoined ) ; } }