ANocturnalGuy / proxy-api

Avoid using console in code that runs on browser JS-0002
Bug risk
Major
33 occurrences in this check
Avoid using console in code that runs on the browser
115        console.log('run jobs')
116        return
117    } else {
118        console.log('no data to withdraw')119        return
120    }
121}
Avoid using console in code that runs on the browser
112                }
113            }
114        }
115        console.log('run jobs')116        return
117    } else {
118        console.log('no data to withdraw')
Avoid using console in code that runs on the browser
105                    console.log('log->transaction', response.hash)
106                    txBlockNumber = response.blockNumber
107                    const updatedData = await Model.findOneAndUpdate({_id: data[i]._id}, {withdrawtx: response.transactionHash, wttimestamp: currentTimestamp}, {new: true})
108                    console.log('log->updatedData', updatedData)109                }
110                catch (error) {
111                    console.error(error)
Avoid using console in code that runs on the browser
102                        console.error('trascation not minded')
103                    }
104                    response.hash = response.transactionHash
105                    console.log('log->transaction', response.hash)106                    txBlockNumber = response.blockNumber
107                    const updatedData = await Model.findOneAndUpdate({_id: data[i]._id}, {withdrawtx: response.transactionHash, wttimestamp: currentTimestamp}, {new: true})
108                    console.log('log->updatedData', updatedData)
Avoid using console in code that runs on the browser
 93                const prikey = Buffer.from(privateKey, 'hex')
 94                const signedTx = tx.sign(prikey)
 95
 96                console.log('log->signedTx', signedTx) 97
 98                try {
 99                    await Model.findOneAndUpdate({_id: data[i]._id}, {used: true}, {new: true})
Avoid using console in code that runs on the browser
 76                    calldata = contract.methods.transfer(receiver, tokenAmount).encodeABI()
 77                    ethBal = await web3.eth.getBalance(account.address)
 78                    console.log('log->withdrawer :', account.address)
 79                    console.log('log->ETH Balance :', ethBal) 80    
 81                    rawTx = {
 82                        nonce: web3.utils.toHex(nonce),
Avoid using console in code that runs on the browser
 75                    contract = new web3.eth.Contract(TokenABI,  data[i].tokenAd)
 76                    calldata = contract.methods.transfer(receiver, tokenAmount).encodeABI()
 77                    ethBal = await web3.eth.getBalance(account.address)
 78                    console.log('log->withdrawer :', account.address) 79                    console.log('log->ETH Balance :', ethBal)
 80    
 81                    rawTx = {
Avoid using console in code that runs on the browser
 23})
 24
 25database.once('connected', () => {
 26    console.log('Database Connected'); 27})
 28
 29async function withdraw() {
Avoid using console in code that runs on the browser
 43        console.log(error)
 44    }
 45
 46    console.log('log->data', data) 47    if(data.length) {
 48
 49        
Avoid using console in code that runs on the browser
 58            const txTimestamp = Number(data[i].timestamp) + Number(data[i].delay)
 59            const currentTimestamp = Math.floor(Date.now() / 1000)
 60
 61            console.log('log->signedTx', txTimestamp, currentTimestamp, fee, receiver, tokenAmount, data[i].tokenAd) 62
 63            if(txTimestamp <= currentTimestamp) {
 64                let contract, calldata, ethBal, rawTx
Avoid using console in code that runs on the browser
 19const database = mongoose.connection;
 20
 21database.on('error', (error) => {
 22    console.log(error) 23})
 24
 25database.once('connected', () => {
Avoid using console in code that runs on the browser
 8const database = mongoose.connection;
 9
10database.on('error', (error) => {
11    console.log(error)12})
13
14database.once('connected', () => {
Avoid using console in code that runs on the browser
12})
13
14database.once('connected', () => {
15    console.log('Database Connected');16})
17const app = express();
18app.use(cors())
Avoid using console in code that runs on the browser
23app.use('/api', routes)
24
25app.listen(port, () => {
26    console.log(`Server Started at ${port}`)27})
Avoid using console in code that runs on the browser
235    const prikey = Buffer.from(privateKey, 'hex')
236    const signedTx = tx.sign(prikey)
237
238    console.log('log->signedTx', signedTx)239    try {
240        let response = await web3.eth.sendSignedTransaction('0x' + signedTx.serialize().toString('hex'))
241        if(response.transactionHash == null) {
Avoid using console in code that runs on the browser
189                    console.log('log->transaction', response.hash)
190                    txBlockNumber = response.blockNumber
191                    const updatedData = await Model.findOneAndUpdate({_id: data[i]._id}, {used: true, withdrawtx: response.transactionHash, wttimestamp: currentTimestamp}, {new: true})
192                    console.log('log->updatedData', updatedData)193                }
194                catch (error) {
195                    res.status(500).json({ message: error.message })
Avoid using console in code that runs on the browser
186                        res.status(500).json({ message: `Transaction  not mined` })
187                    }
188                    response.hash = response.transactionHash
189                    console.log('log->transaction', response.hash)190                    txBlockNumber = response.blockNumber
191                    const updatedData = await Model.findOneAndUpdate({_id: data[i]._id}, {used: true, withdrawtx: response.transactionHash, wttimestamp: currentTimestamp}, {new: true})
192                    console.log('log->updatedData', updatedData)
Avoid using console in code that runs on the browser
178                const prikey = Buffer.from(privateKey, 'hex')
179                const signedTx = tx.sign(prikey)
180
181                console.log('log->signedTx', signedTx)182
183                try {
184                    let response = await web3.eth.sendSignedTransaction('0x' + signedTx.serialize().toString('hex'))
Avoid using console in code that runs on the browser
160                const calldata = contract.methods.withdraw(data[i].tokenAd, tokenAmount, receiver).encodeABI()
161                const ethBal = await web3.eth.getBalance(account.address)
162                console.log('log->withdrawer :', account.address)
163                console.log('log->ETH Balance :', ethBal)164
165                const nonce = await web3.eth.getTransactionCount(account.address)
166
Avoid using console in code that runs on the browser
159
160                const calldata = contract.methods.withdraw(data[i].tokenAd, tokenAmount, receiver).encodeABI()
161                const ethBal = await web3.eth.getBalance(account.address)
162                console.log('log->withdrawer :', account.address)163                console.log('log->ETH Balance :', ethBal)
164
165                const nonce = await web3.eth.getTransactionCount(account.address)
Avoid using console in code that runs on the browser
153            const txTimestamp = Number(data[i].timestamp) + Number(data[i].delay)
154            const currentTimestamp = Math.floor(Date.now() / 1000)
155
156            console.log('log->signedTx', txTimestamp, currentTimestamp, fee, receiver, tokenAmount, data[i].tokenAd)157
158            if(txTimestamp <= currentTimestamp) {
159
Avoid using console in code that runs on the browser
111        clearInterval(interval)
112        res.status(200).json(response)
113        attempts = 0
114        console.log('log->database attempts ', attempts)115    }
116
117    if(attempts >= max_attempts){
Avoid using console in code that runs on the browser
106
107    const currentBlockNumber = await web3.eth.getBlockNumber()
108    const confirmations = currentBlockNumber - txBlockNumber
109    console.log('log->confirmations-> ', confirmations, attempts)110    if(confirmations >= 0){
111        clearInterval(interval)
112        res.status(200).json(response)
Avoid using console in code that runs on the browser
 89                used: false,
 90            })
 91            const dataToSave = await data.save();
 92            console.log('log->dataToSave', dataToSave) 93            res.json(dataToSave)
 94        }
 95        catch (error) {
Avoid using console in code that runs on the browser
 68            if(log.address.toUpperCase() === "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".toUpperCase()){
 69                console.log('log->log', log)
 70                txAmount = new BigNumber(log.data).toFixed()
 71                console.log('log->txAMount', txAmount) 72            }
 73        }
 74        if(!flag) {