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,
|
interval: 250,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const SEND_QUEUE = new PQueue({
|
||||||
|
concurrency: 1,
|
||||||
|
})
|
||||||
|
|
||||||
const infuraCalls = {}
|
const infuraCalls = {}
|
||||||
|
|
||||||
const pify = _function => {
|
const pify = _function => {
|
||||||
|
|
@ -78,7 +82,8 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
|
||||||
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||||
const isErc20Token = coins.utils.isErc20Token(cryptoCode)
|
const isErc20Token = coins.utils.isErc20Token(cryptoCode)
|
||||||
|
|
||||||
return (isErc20Token ? generateErc20Tx : generateTx)(toAddress, defaultWallet(account), cryptoAtoms, false, cryptoCode)
|
return SEND_QUEUE.add(() =>
|
||||||
|
(isErc20Token ? generateErc20Tx : generateTx)(toAddress, defaultWallet(account), cryptoAtoms, false, cryptoCode)
|
||||||
.then(pify(web3.eth.sendSignedTransaction))
|
.then(pify(web3.eth.sendSignedTransaction))
|
||||||
.then(txid => {
|
.then(txid => {
|
||||||
return pify(web3.eth.getTransaction)(txid)
|
return pify(web3.eth.getTransaction)(txid)
|
||||||
|
|
@ -90,6 +95,7 @@ function sendCoins (account, tx, settings, operatorId, feeMultiplier) {
|
||||||
return { txid, fee }
|
return { txid, fee }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCryptoCode (cryptoCode) {
|
function checkCryptoCode (cryptoCode) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue