diff --git a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js index 8ef431f6d5..55e0e75355 100644 --- a/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js +++ b/packages/yoroi-extension/app/api/ada/lib/state-fetch/remoteFetcher.js @@ -551,34 +551,32 @@ export class RemoteFetcher implements IFetcher { getUtxoData: GetUtxoDataRequest => Promise = async (body) => { const { BackendService } = body.network.Backend; - if (body.utxos.length !== 1) { - throw new Error('the RemoteFetcher.getUtxoData expects 1 UTXO'); - } - const { txHash, txIndex } = body.utxos[0]; if (BackendService == null) throw new Error(`${nameof(this.getUtxoData)} missing backend url`); - return axios( - `${BackendService}/api/txs/io/${txHash}/o/${txIndex}`, - { - method: 'get', - timeout: 2 * CONFIG.app.walletRefreshInterval, - headers: { - 'yoroi-version': this.getLastLaunchVersion(), - 'yoroi-locale': this.getCurrentLocale() - } - } - ).then(response => [ response.data ]) - .catch((error) => { - if (error.response.status === 404 && error.response.data === 'Transaction not found') { - return [ null ]; + return Promise.all(body.utxos.map(({ txHash, txIndex }) => { + return axios( + `${BackendService}/api/txs/io/${txHash}/o/${txIndex}`, + { + method: 'get', + timeout: 2 * CONFIG.app.walletRefreshInterval, + headers: { + 'yoroi-version': this.getLastLaunchVersion(), + 'yoroi-locale': this.getCurrentLocale() + } } - Logger.error(`${nameof(RemoteFetcher)}::${nameof(this.getUtxoData)} error: ` + stringifyError(error)); - throw new GetUtxoDataError(); - }); + ).then(response => response.data) + .catch((error) => { + if (error.response.status === 404 && error.response.data === 'No outputs found') { + return null; + } + Logger.error(`${nameof(RemoteFetcher)}::${nameof(this.getUtxoData)} error: ` + stringifyError(error)); + throw new GetUtxoDataError(); + }); + })); } getLatestBlockBySlot: GetLatestBlockBySlotFunc = async (body) => { const { BackendService } = body.network.Backend; - if (BackendService == null) throw new Error(`${nameof(this.getUtxoData)} missing backend url`); + if (BackendService == null) throw new Error(`${nameof(this.getLatestBlockBySlot)} missing backend url`); return axios( `${BackendService}/api/v2.1/lastBlockBySlot`, {