refactor: merge return calls on sendCoins
This commit is contained in:
parent
15e8e46c0f
commit
92aaa5738a
1 changed files with 1 additions and 16 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue