From 7132839468a50123f9bca5c27e6797294ef701d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Tue, 10 May 2022 18:07:07 +0100 Subject: [PATCH] fix: eth bn to bn convertion --- lib/plugins/wallet/geth/base.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/plugins/wallet/geth/base.js b/lib/plugins/wallet/geth/base.js index 3904b911..8720808d 100644 --- a/lib/plugins/wallet/geth/base.js +++ b/lib/plugins/wallet/geth/base.js @@ -40,7 +40,6 @@ function connect (url) { } const hex = bigNum => '0x' + bigNum.integerValue(BN.ROUND_DOWN).toString(16) -const bn2bn = bn => new BN(bn.toString(16), 16) function privateKey (account) { return defaultWallet(account).getPrivateKey() @@ -92,7 +91,7 @@ function _balance (includePending, address, cryptoCode) { const block = includePending ? 'pending' : undefined return pify(web3.eth.getBalance)(address.toLowerCase(), block) /* NOTE: Convert bn.js bignum to bignumber.js bignum */ - .then(balance => balance ? BN(balance.toString(16), 16) : BN(0)) + .then(balance => balance ? BN(balance) : BN(0)) } function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) { @@ -126,10 +125,10 @@ function generateTx (_toAddress, wallet, amount, includesFee, cryptoCode) { return Promise.all(promises) .then(([gas, gasPrice, txCount, { baseFeePerGas }]) => [ - bn2bn(gas), - bn2bn(gasPrice), + BN(gas), + BN(gasPrice), _.max([1, txCount, lastUsedNonces[fromAddress] + 1]), - bn2bn(baseFeePerGas) + BN(baseFeePerGas) ]) .then(([gas, gasPrice, txCount, baseFeePerGas]) => { lastUsedNonces[fromAddress] = txCount