-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
128,792 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ resources/para-2076-wasm | |
.direnv | ||
.vscode | ||
|
||
scripts/edg-balances-new.json |
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Read the JSON file | ||
const data = fs.readFileSync(path.join(__dirname, 'edg-balances-new.json')); | ||
const balances = JSON.parse(data); | ||
|
||
// Calculate the total balance | ||
let totalBalance = 0; | ||
for (let account in balances) { | ||
totalBalance += balances[account].Total; | ||
} | ||
|
||
// Calculate the fraction of each account's balance over the total | ||
let fractions = {}; | ||
for (let account in balances) { | ||
if (account in fractions) { | ||
fractions[account] = fractions[account] + (balances[account].Total / totalBalance); | ||
} else { | ||
fractions[account] = balances[account].Total / totalBalance; | ||
} | ||
} | ||
|
||
// Write the output to a new JSON file | ||
fs.writeFileSync('output.json', JSON.stringify(fractions, null, 2)); |
Oops, something went wrong.