fix: promise all array values and monero get_transfers arg

This commit is contained in:
José Oliveira 2022-07-21 10:22:24 +01:00
parent baf95b1e7c
commit bc1925a14c
5 changed files with 5 additions and 6 deletions

View file

@ -132,7 +132,7 @@ function checkBlockchainStatus (cryptoCode) {
function getTxHashesByAddress (cryptoCode, address) { function getTxHashesByAddress (cryptoCode, address) {
checkCryptoCode(cryptoCode) checkCryptoCode(cryptoCode)
.then(() => fetch('listreceivedbyaddress', [0, true, true, address])) .then(() => fetch('listreceivedbyaddress', [0, true, true, address]))
.then(txsByAddress => Promise.all(_.forEach(id => fetch('getrawtransaction', [id]), _.head(txsByAddress).txids))) .then(txsByAddress => Promise.all(_.map(id => fetch('getrawtransaction', [id]), _.flatMap(it => it.txids, txsByAddress))))
.then(_.map(({ hash }) => hash)) .then(_.map(({ hash }) => hash))
} }

View file

@ -194,7 +194,7 @@ function checkBlockchainStatus (cryptoCode) {
function getTxHashesByAddress (cryptoCode, address) { function getTxHashesByAddress (cryptoCode, address) {
checkCryptoCode(cryptoCode) checkCryptoCode(cryptoCode)
.then(() => fetch('listreceivedbyaddress', [0, true, true, address])) .then(() => fetch('listreceivedbyaddress', [0, true, true, address]))
.then(txsByAddress => Promise.all(_.forEach(id => fetch('getrawtransaction', [id]), _.head(txsByAddress).txids))) .then(txsByAddress => Promise.all(_.map(id => fetch('getrawtransaction', [id]), _.flatMap(it => it.txids, txsByAddress))))
.then(_.map(({ hash }) => hash)) .then(_.map(({ hash }) => hash))
} }

View file

@ -128,7 +128,7 @@ function checkBlockchainStatus (cryptoCode) {
function getTxHashesByAddress (cryptoCode, address) { function getTxHashesByAddress (cryptoCode, address) {
checkCryptoCode(cryptoCode) checkCryptoCode(cryptoCode)
.then(() => fetch('listreceivedbyaddress', [0, true, true, true, address])) .then(() => fetch('listreceivedbyaddress', [0, true, true, true, address]))
.then(txsByAddress => Promise.all(_.forEach(id => fetch('getrawtransaction', [id]), _.head(txsByAddress).txids))) .then(txsByAddress => Promise.all(_.map(id => fetch('getrawtransaction', [id]), _.flatMap(it => it.txids, txsByAddress))))
.then(_.map(({ hash }) => hash)) .then(_.map(({ hash }) => hash))
} }

View file

@ -164,7 +164,7 @@ function getStatus (account, tx, requested, settings, operatorId) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => refreshWallet()) .then(() => refreshWallet())
.then(() => fetch('get_address_index', { address: toAddress })) .then(() => fetch('get_address_index', { address: toAddress }))
.then(addressRes => fetch('get_transfers', { in: true, pool: true, account_index: addressRes.index.major, address_indices: [addressRes.index.minor] })) .then(addressRes => fetch('get_transfers', { in: true, pool: true, account_index: addressRes.index.major, subaddr_indices: [addressRes.index.minor] }))
.then(transferRes => { .then(transferRes => {
const confirmedToAddress = _.filter(it => it.address === toAddress, transferRes.in ?? []) const confirmedToAddress = _.filter(it => it.address === toAddress, transferRes.in ?? [])
const pendingToAddress = _.filter(it => it.address === toAddress, transferRes.pool ?? []) const pendingToAddress = _.filter(it => it.address === toAddress, transferRes.pool ?? [])
@ -239,7 +239,7 @@ function getTxHashesByAddress (cryptoCode, address) {
checkCryptoCode(cryptoCode) checkCryptoCode(cryptoCode)
.then(() => refreshWallet()) .then(() => refreshWallet())
.then(() => fetch('get_address_index', { address: address })) .then(() => fetch('get_address_index', { address: address }))
.then(addressRes => fetch('get_transfers', { in: true, pool: true, pending: true, account_index: addressRes.index.major, address_indices: [addressRes.index.minor] })) .then(addressRes => fetch('get_transfers', { in: true, pool: true, pending: true, account_index: addressRes.index.major, subaddr_indices: [addressRes.index.minor] }))
.then(_.map(({ txid }) => txid)) .then(_.map(({ txid }) => txid))
} }

View file

@ -154,7 +154,6 @@ function checkBlockchainStatus (cryptoCode) {
function getTxHashesByAddress (cryptoCode, address) { function getTxHashesByAddress (cryptoCode, address) {
checkCryptoCode(cryptoCode) checkCryptoCode(cryptoCode)
.then(() => fetch('getaddresstxids', [address])) .then(() => fetch('getaddresstxids', [address]))
.then(_.values)
} }
module.exports = { module.exports = {