Skip to content

Instantly share code, notes, and snippets.

@CoolCatsNFTPublic
Last active December 9, 2022 03:25
Show Gist options
  • Save CoolCatsNFTPublic/4a4fc8502dc892ca695edd5de371b3ba to your computer and use it in GitHub Desktop.
Save CoolCatsNFTPublic/4a4fc8502dc892ca695edd5de371b3ba to your computer and use it in GitHub Desktop.
Combine all snapshots
// THE GIST CONTAINS A DELIBERATE ERROR FOR THE PURPOSES
// OF THE ARTICLE - DO NOT BLINDLY COPY AND PASTE
// Combine snapshots.
async function combineSnapShots() {
// Step 1 - Gathering addresses
const l1 = JSON.parse(fs.readFileSync('./snapshots/cxllabsHolders.json', 'utf8'));
const l2 = JSON.parse(fs.readFileSync('./snapshots/ghxstHolders.json', 'utf8'));
const l3 = JSON.parse(fs.readFileSync('./snapshots/ghxstsCxltureHolders.json', 'utf8'));
const l4 = JSON.parse(fs.readFileSync('./snapshots/holders.json', 'utf8'));
const l5 = JSON.parse(fs.readFileSync('./snapshots/pxinGxngHolders.json', 'utf8'));
const arr = [l1, l2, l3, l4, l5];
const allHolders = {}
// Step 2 - combining and filtering
for (const obj of arr) {
const keys = Object.keys(obj);
for (let key of keys) {
if (!allHolders[key]) {
allHolders[key] = 1;
} else {
allHolders[key]++;
}
}
}
// Step 3 - saving final addresses list
fs.writeFile('allHolders.json', JSON.stringify(allHolders), {flag: 'w'}, function(err) {
if (err) return console.log(err);
});
}
@CoolCatsNFTPublic
Copy link
Author

// THE GIST CONTAINS A DELIBERATE ERROR FOR THE PURPOSES
// OF THE ARTICLE - DO NOT BLINDLY COPY AND PASTE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment