fix: add transaction ID to new sweep error logs

This commit is contained in:
Sérgio Salgado 2022-08-16 15:47:06 +01:00
parent 0f507d0a54
commit 3daf0ac865
4 changed files with 9 additions and 8 deletions

View file

@ -160,7 +160,7 @@ function generateErc20Tx (_toAddress, wallet, amount, includesFee, cryptoCode) {
const maxFeePerGas = new BN(2).times(baseFeePerGas).plus(maxPriorityFeePerGas)
if (includesFee && (toSend.isNegative() || toSend.isZero())) {
throw new Error(`Trying to send a nil or negative amount. This is probably caused due to the estimated fee being higher than the address' balance. Value provided: ${toSend.toNumber()}`)
throw new Error(`Trying to send a nil or negative amount (Transaction ID: ${txId} | Value provided: ${toSend.toNumber()}). This is probably caused due to the estimated fee being higher than the address' balance.`)
}
const rawTx = {
@ -184,7 +184,7 @@ function generateErc20Tx (_toAddress, wallet, amount, includesFee, cryptoCode) {
})
}
function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) {
function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode, txId) {
const fromAddress = '0x' + wallet.getAddress().toString('hex')
const toAddress = _toAddress.toLowerCase()
@ -251,7 +251,7 @@ function defaultAddress (account) {
return defaultWallet(account).getChecksumAddressString()
}
function sweep (account, cryptoCode, hdIndex, settings, operatorId) {
function sweep (account, txId, cryptoCode, hdIndex, settings, operatorId) {
const wallet = paymentHdNode(account).deriveChild(hdIndex).getWallet()
const fromAddress = wallet.getChecksumAddressString()
@ -259,7 +259,7 @@ function sweep (account, cryptoCode, hdIndex, settings, operatorId) {
.then(r => {
if (r.eq(0)) return
return generateTx(defaultAddress(account), wallet, r, true, cryptoCode)
return generateTx(defaultAddress(account), wallet, r, true, cryptoCode, txId)
.then(signedTx => pify(web3.eth.sendSignedTransaction)(signedTx))
})
)

View file

@ -84,7 +84,7 @@ function newFunding (account, cryptoCode, settings, operatorId) {
throw new E.NotImplementedError()
}
function sweep (account, cryptoCode, hdIndex, settings, operatorId) {
function sweep (account, txId, cryptoCode, hdIndex, settings, operatorId) {
throw new E.NotImplementedError()
}