fix: check for wallet tx batching support
This commit is contained in:
parent
73c0d09198
commit
8289c55acf
10 changed files with 77 additions and 26 deletions
|
|
@ -238,6 +238,7 @@ function plugins (settings, deviceId) {
|
|||
const pingPromise = recordPing(deviceTime, machineVersion, machineModel)
|
||||
const currentConfigVersionPromise = fetchCurrentConfigVersion()
|
||||
const currentAvailablePromoCodes = loyalty.getNumberOfAvailablePromoCodes()
|
||||
const supportsBatchingPromise = cryptoCodes.map(c => wallet.supportsBatching(settings, c))
|
||||
const timezoneObj = { utcOffset: timezone[0], dstOffset: timezone[1] }
|
||||
|
||||
const promises = [
|
||||
|
|
@ -246,6 +247,7 @@ function plugins (settings, deviceId) {
|
|||
currentConfigVersionPromise,
|
||||
timezoneObj
|
||||
].concat(
|
||||
supportsBatchingPromise,
|
||||
tickerPromises,
|
||||
balancePromises,
|
||||
testnetPromises,
|
||||
|
|
@ -258,9 +260,10 @@ function plugins (settings, deviceId) {
|
|||
const configVersion = arr[2]
|
||||
const tz = arr[3]
|
||||
const cryptoCodesCount = cryptoCodes.length
|
||||
const tickers = arr.slice(4, cryptoCodesCount + 4)
|
||||
const balances = arr.slice(cryptoCodesCount + 4, 2 * cryptoCodesCount + 4)
|
||||
const testNets = arr.slice(2 * cryptoCodesCount + 4, arr.length - 2)
|
||||
const batchableCoins = arr.slice(4, cryptoCodesCount + 4)
|
||||
const tickers = arr.slice(cryptoCodesCount + 4, 2 * cryptoCodesCount + 4)
|
||||
const balances = arr.slice(2 * cryptoCodesCount + 4, 3 * cryptoCodesCount + 4)
|
||||
const testNets = arr.slice(3 * cryptoCodesCount + 4, arr.length - 1)
|
||||
const coinParams = _.zip(cryptoCodes, testNets)
|
||||
const coinsWithoutRate = _.map(mapCoinSettings, coinParams)
|
||||
const areThereAvailablePromoCodes = arr[arr.length - 1] > 0
|
||||
|
|
@ -278,16 +281,19 @@ function plugins (settings, deviceId) {
|
|||
}
|
||||
|
||||
function sendCoins (tx) {
|
||||
if (wallet.supportsBatching(settings, tx.cryptoCode)) {
|
||||
return transactionBatching.addTransactionToBatch(tx)
|
||||
.then(() => ({
|
||||
batched: true,
|
||||
sendPending: false,
|
||||
error: null,
|
||||
errorCode: null
|
||||
}))
|
||||
}
|
||||
return wallet.sendCoins(settings, tx)
|
||||
return wallet.supportsBatching(settings, tx.cryptoCode)
|
||||
.then(supportsBatching => {
|
||||
if (supportsBatching) {
|
||||
return transactionBatching.addTransactionToBatch(tx)
|
||||
.then(() => ({
|
||||
batched: true,
|
||||
sendPending: false,
|
||||
error: null,
|
||||
errorCode: null
|
||||
}))
|
||||
}
|
||||
return wallet.sendCoins(settings, tx)
|
||||
})
|
||||
}
|
||||
|
||||
function recordPing (deviceTime, version, model) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue