115 console.log('run jobs')
116 return
117 } else {
118 console.log('no data to withdraw')119 return
120 }
121}
112 }
113 }
114 }
115 console.log('run jobs')116 return
117 } else {
118 console.log('no data to withdraw')
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)
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)
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})
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),
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 = {
23})
24
25database.once('connected', () => {
26 console.log('Database Connected'); 27})
28
29async function withdraw() {
43 console.log(error)
44 }
45
46 console.log('log->data', data) 47 if(data.length) {
48
49
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
19const database = mongoose.connection;
20
21database.on('error', (error) => {
22 console.log(error) 23})
24
25database.once('connected', () => {
8const database = mongoose.connection;
9
10database.on('error', (error) => {
11 console.log(error)12})
13
14database.once('connected', () => {
12})
13
14database.once('connected', () => {
15 console.log('Database Connected');16})
17const app = express();
18app.use(cors())
23app.use('/api', routes)
24
25app.listen(port, () => {
26 console.log(`Server Started at ${port}`)27})
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) {
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 })
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)
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'))
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
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)
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
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){
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)
89 used: false,
90 })
91 const dataToSave = await data.save();
92 console.log('log->dataToSave', dataToSave) 93 res.json(dataToSave)
94 }
95 catch (error) {
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) {
It is considered a best practice to avoid the use of any console
methods in JavaScript code that will run on the browser.
NOTE: If your repository contains a server side project, you can add "nodejs"
to the environment
property of analyzer meta in .deepsource.toml
.
This will prevent this issue from getting raised.
Documentation for the analyzer meta can be found here.
Alternatively, you can silence this issue for your repository as shown here.
If a specific console
call is meant to stay for other reasons, you can add a skipcq comment to that line.
This will inform other developers about the reason behind the log's presence, and prevent DeepSource from flagging it.
Usually, console
methods are only used for debugging, and can leak internal info to the client.
Removing the console
call will fix this issue.
Bad Practice
if (!secure(data)) {
console.log("data is not secure", data) // `data` is visible to the client
}
console.table(tableObj)
Recommended
if (!secure(data)) {
// alter the DOM to inform the user that `data` is insecure.
}
console.table(tableObj) // skipcq: JS-0002 Easter egg. Users are meant to see this.