fix: throw error on nil or negative sweeping amounts
This commit is contained in:
parent
85afa6197a
commit
0f507d0a54
1 changed files with 4 additions and 0 deletions
|
|
@ -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 maxPriorityFeePerGas = new BN(web3.utils.toWei('2.5', 'gwei')) // web3 default value
|
||||||
const maxFeePerGas = new BN(2).times(baseFeePerGas).plus(maxPriorityFeePerGas)
|
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 = {
|
const rawTx = {
|
||||||
chainId: 1,
|
chainId: 1,
|
||||||
nonce: txCount,
|
nonce: txCount,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue