fix: throw error on nil or negative sweeping amounts

This commit is contained in:
Sérgio Salgado 2022-08-03 20:00:45 +01:00
parent 85afa6197a
commit 0f507d0a54

View file

@ -159,6 +159,10 @@ function generateErc20Tx (_toAddress, wallet, amount, includesFee, cryptoCode) {
const maxPriorityFeePerGas = new BN(web3.utils.toWei('2.5', 'gwei')) // web3 default value
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()}`)
}
const rawTx = {
chainId: 1,
nonce: txCount,