From 57cb7e15438003970ac102cb123e52ef956ad22c Mon Sep 17 00:00:00 2001 From: sven Date: Sat, 28 May 2022 10:39:12 +0200 Subject: [PATCH 1/2] total balance with locked --- src/App.js | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/App.js b/src/App.js index 6f20602..91367c3 100644 --- a/src/App.js +++ b/src/App.js @@ -150,34 +150,47 @@ function App() { }; + function chunk(arr, len) { + var chunks = []; + var i = 0; + var n = arr.length; + + while (i < n) { + chunks.push(arr.slice(i, i += len)); // gives [[0,1,2] [3,4,5]] + } + + return chunks; + }; + + fetch('https://alephium.ono.re/api/stats/addresses?top=356') .then(response => response.json()) .then(data => { + fetch('https://mainnet-backend.alephium.org/infos/supply/total-alph') + .then(response => response.json()) + .then(data2 => { - - totalAlph = data.total_balance - addresses = data.addresses + series = [] //reinit array until page load completely + totalAlph = data2 * 10**18 + addresses = data.addresses - series = addresses.map(a => a.balance).slice(0, 10) - - - console.log(series) + //compute balance without locked ALPH + addresses.slice(0,10).forEach(element => { + let nonLockedBalance = element['balance']-element['locked'] + series.push(nonLockedBalance) + topSum += nonLockedBalance + }) - series.forEach(element => { - topSum += element / Math.pow(10,18) - }) - - othersSum = totalAlph - topSum + othersSum = totalAlph - topSum - // othersSum = totalAlph - series.reduce((partialSum, a) => partialSum + a, 0) - - series.push(othersSum) + series.push(othersSum) - options.labels = ['#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', '#10', 'others'] + options.labels = ['#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', '#10', 'others'] - setLoading(false) + setLoading(false) + }) }) @@ -190,7 +203,7 @@ function App() {

Pie Chart

-

Top 10 addresses displayed in a pie chart compared to others "Currently not working, but i'm working on it"

+

Top 10 addresses (without locked balance) displayed compared to all "others" addresses

@@ -262,7 +275,7 @@ function App() {

Pie Chart

-

Top 10 addresses displayed in a pie chart compared to "others"

+

Top 10 addresses (without locked balance) displayed in a pie chart compared to all "others" addresses

From 312b29dfc1b28775a0fbdfd3310dc14f7bbc410f Mon Sep 17 00:00:00 2001 From: sven Date: Sat, 28 May 2022 10:39:25 +0200 Subject: [PATCH 2/2] idea ignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 4d29575..2dd22d7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,9 @@ .env.development.local .env.test.local .env.production.local +.idea/ npm-debug.log* yarn-debug.log* yarn-error.log* +