fix: serialize ETH sendCoins()
This commit is contained in:
parent
58e625f798
commit
2ade6c21cc
1 changed files with 16 additions and 10 deletions
|
|
@ -42,6 +42,10 @@ const SWEEP_QUEUE = new PQueue({
|
|||
interval: 250,
|
||||
})
|
||||
|
||||
const SEND_QUEUE = new PQueue({
|
||||
concurrency: 1,
|
||||
})
|
||||
|
||||
const infuraCalls = {}
|
||||
|
||||
const pify = _function => {
|
||||
|
|
@ -78,18 +82,20 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
|
|||
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||
const isErc20Token = coins.utils.isErc20Token(cryptoCode)
|
||||
|
||||
return (isErc20Token ? generateErc20Tx : generateTx)(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 }
|
||||
return SEND_QUEUE.add(() =>
|
||||
(isErc20Token ? generateErc20Tx : generateTx)(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)
|
||||
const fee = new BN(tx.gas).times(new BN(tx.gasPrice)).decimalPlaces(0)
|
||||
|
||||
return { txid, fee }
|
||||
})
|
||||
})
|
||||
return { txid, fee }
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
function checkCryptoCode (cryptoCode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue