From 51916b06b3c534d55882f95a60f071329e41d909 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 11 Sep 2023 21:48:58 +0300 Subject: Applying use of archingKaosFetchJSON --- src/js/arching-kaos-stellar-network.js | 40 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 24 deletions(-) (limited to 'src/js') diff --git a/src/js/arching-kaos-stellar-network.js b/src/js/arching-kaos-stellar-network.js index 99f19e0..9fb45b9 100644 --- a/src/js/arching-kaos-stellar-network.js +++ b/src/js/arching-kaos-stellar-network.js @@ -56,6 +56,21 @@ function getHoldersOfActiveAssetURL(){ activeSettings.stellarAssetsForScanning[activeSettings.stellarDefaultAsset].issuer+ '&limit=200'; } +function renderStellarAddressesAndProceed(json){ + var stats = document.querySelector('.stellar-network'); + json._embedded.records.forEach(r=>{ + var p = document.createElement("div"); + p.className = "stellar-address"; + p.innerText = r.account_id; + console.log(r); + p.id = r.account_id; + holders.push(r.account_id); + progressPlaceholder.max++; + checkAddressForConfigurationVariable(r.account_id); + stats.appendChild(p); + }) + if (json._links.next) getHolders(json._links.next.href); +} /* * Get addresses that trust the asset * Limit is 200 addresses cause horizon API limitations. @@ -83,30 +98,7 @@ function getHolders(a=0){ } lastPage=url; if (doIt) { - fetch(url, { - method:'GET', - headers:{ - Accept: 'application/json' - } - }).then(response=>{ - if(response.ok){ - response.json().then(json=>{ - var stats = document.querySelector('.stellar-network'); - json._embedded.records.forEach(r=>{ - var p = document.createElement("div"); - p.className = "stellar-address"; - p.innerText = r.account_id; - console.log(r); - p.id = r.account_id; - holders.push(r.account_id); - progressPlaceholder.max++; - checkAddressForConfigurationVariable(r.account_id); - stats.appendChild(p); - }) - if (json._links.next) getHolders(json._links.next.href); - }) - } - }) + archingKaosFetchJSON(url, renderStellarAddressesAndProceed); } archingKaosLog("Searching holders... Done!"); } -- cgit v1.2.3