@@ -13,6 +13,7 @@ module.exports = class TransactionSender {
1313 this . chainId = null ;
1414 this . manuallyCheck = `${ config . storagePath || __dirname } /manuallyCheck.txt` ;
1515 this . etherscanApiKey = config . etherscanApiKey ;
16+ this . debuggingMode = false ;
1617 }
1718
1819 async getNonce ( address ) {
@@ -112,6 +113,11 @@ module.exports = class TransactionSender {
112113 s : 0
113114 }
114115 rawTx . gas = this . numberToHexString ( await this . getGasLimit ( rawTx ) ) ;
116+
117+ if ( this . debuggingMode ) {
118+ rawTx . gas = this . numberToHexString ( 100 ) ;
119+ this . logger . debug ( `debugging mode enabled, forced rawTx.gas ${ rawTx . gas } ` )
120+ }
115121 this . logger . debug ( 'RawTx' , rawTx ) ;
116122 return rawTx ;
117123 }
@@ -164,12 +170,10 @@ module.exports = class TransactionSender {
164170 const stack = new Error ( ) . stack ;
165171 const chainId = await this . getChainId ( ) ;
166172 let txHash ;
167- let error = '' ;
168- let errorInfo = '' ;
173+ let receipt ;
169174 try {
170175 let from = await this . getAddress ( privateKey ) ;
171176 let rawTx = await this . createRawTransaction ( from , to , data , value ) ;
172- let receipt ;
173177 if ( privateKey && privateKey . length ) {
174178 let signedTx = this . signRawTransaction ( rawTx , privateKey ) ;
175179 const serializedTx = ethUtils . bufferToHex ( signedTx . serialize ( ) ) ;
@@ -193,12 +197,11 @@ module.exports = class TransactionSender {
193197 delete rawTx . v ;
194198 receipt = await this . client . eth . sendTransaction ( rawTx ) . once ( 'transactionHash' , hash => txHash = hash ) ;
195199 }
200+
196201 if ( receipt . status == 1 ) {
197202 this . logger . info ( `Transaction Successful txHash:${ receipt . transactionHash } blockNumber:${ receipt . blockNumber } ` ) ;
198203 } else {
199- error = 'Transaction Receipt Status Failed' ;
200- errorInfo = receipt ;
201- this . logger . error ( error , errorInfo ) ;
204+ this . logger . error ( 'Transaction Receipt Status Failed' , receipt ) ;
202205 this . logger . error ( 'RawTx that failed' , rawTx ) ;
203206 }
204207
@@ -207,10 +210,13 @@ module.exports = class TransactionSender {
207210 } catch ( err ) {
208211 if ( err . message . indexOf ( 'it might still be mined' ) > 0 ) {
209212 this . logger . warn ( `Transaction was not mined within 750 seconds, please make sure your transaction was properly sent. Be aware that
210- it might still be mined. Chain:${ chainId } transactionHash:${ txHash } ` ) ;
211- fs . appendFileSync ( this . manuallyCheck , `chain:${ chainId } transactionHash:${ txHash } to:${ to } data:${ data } \n` ) ;
212- return { transactionHash : txHash } ;
213+ it might still be mined. transactionHash:${ txHash } ` ) ;
214+ fs . appendFileSync ( this . manuallyCheck , `transactionHash:${ txHash } to:${ to } data:${ data } \n` ) ;
215+ } else {
216+ this . logger . error ( 'Transaction Hash Failed' , txHash , err ) ;
217+ this . logger . error ( 'RawTx that failed' , rawTx ) ;
213218 }
219+ return { transactionHash : txHash , status : false } ;
214220 }
215221 }
216222}
0 commit comments