From 92aaa5738ae4c76c2f62dda8cdadcc67d1d8edfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 20 Jun 2022 01:45:24 +0100 Subject: [PATCH] refactor: merge return calls on sendCoins --- lib/plugins/wallet/geth/base.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/plugins/wallet/geth/base.js b/lib/plugins/wallet/geth/base.js index 6674dfd3..08ccffa8 100644 --- a/lib/plugins/wallet/geth/base.js +++ b/lib/plugins/wallet/geth/base.js @@ -54,22 +54,7 @@ function sendCoins (account, tx, settings, operatorId) { const { toAddress, cryptoAtoms, cryptoCode } = tx const isErc20Token = coins.utils.isErc20Token(cryptoCode) - if (isErc20Token) { - return generateErc20Tx(toAddress, defaultWallet(account), cryptoAtoms, false, cryptoCode) - .then(pify(web3.eth.sendSignedTransaction)) - .then(txid => { - return pify(web3.eth.getTransaction)(txid) - .then(tx => { - if (!tx) return { txid } - - const fee = new BN(tx.gas).times(new BN(tx.gasPrice)).decimalPlaces(0) - - return { txid, fee } - }) - }) - } - - return generateTx(toAddress, defaultWallet(account), cryptoAtoms, false, cryptoCode) + return (isErc20Token ? generateErc20Tx : generateTx)(toAddress, defaultWallet(account), cryptoAtoms, false, cryptoCode) .then(pify(web3.eth.sendSignedTransaction)) .then(txid => { return pify(web3.eth.getTransaction)(txid)