From a9548296c7fad064c070028353c8d772b5ad4167 Mon Sep 17 00:00:00 2001 From: Corey Phillips Date: Wed, 30 Dec 2020 15:14:37 -0500 Subject: [PATCH] Updated getTransactions method helpers/index.js. --- helpers/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/helpers/index.js b/helpers/index.js index 7435db5..2869403 100644 --- a/helpers/index.js +++ b/helpers/index.js @@ -14,12 +14,12 @@ const _getTimeout = ({ arr = [], timeout = 1000 } = {}) => { } } -const _attemptToGetArray = (scriptHashes = []) => { +const _attemptToGetArray = (item = []) => { try { - if (Array.isArray(scriptHashes)) return scriptHashes; - if ("data" in scriptHashes) { - if (Array.isArray(scriptHashes.data)) return scriptHashes.data; - if (typeof scriptHashes.data === 'object') return Object.values(scriptHashes.data); + if (Array.isArray(item)) return item; + if ("data" in item) { + if (Array.isArray(item.data)) return item.data; + if (typeof item.data === 'object') return Object.values(item.data); } return []; } catch { return []; } @@ -400,8 +400,8 @@ const getTransactions = ({ txHashes = [], id = Math.random(), network = "", time return new Promise(async (resolve) => { try { if (clients.mainClient[network] === false) await connectToRandomPeer(network, clients.peers[network]); - if (!timeout) timeout = _getTimeout({ arr: scriptHashes }); - const { error, data } = await promiseTimeout(timeout, clients.mainClient[network].blockchainTransaction_getBatch(txHashes)); + if (!timeout) timeout = _getTimeout({ arr: txHashes }); + const { error, data } = await promiseTimeout(timeout, clients.mainClient[network].blockchainTransaction_getBatch(txHashes, true)); resolve({ id, error, method, data, network }); } catch (e) { console.log(e);