diff --git a/package-lock.json b/package-lock.json index fd59405..d601058 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@dotenvx/dotenvx": "^1.14.0", - "smol-toml": "^1.3.1" + "@dotenvx/dotenvx": "^1.14.0" }, "devDependencies": { "@nomicfoundation/hardhat-toolbox": "^5.0.0", @@ -6310,17 +6309,6 @@ "dev": true, "peer": true }, - "node_modules/smol-toml": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.3.1.tgz", - "integrity": "sha512-tEYNll18pPKHroYSmLLrksq233j021G0giwW7P3D24jC54pQ5W5BXMsQ/Mvw1OJCmEYDgY+lrzT+3nNUtoNfXQ==", - "engines": { - "node": ">= 18" - }, - "funding": { - "url": "https://github.com/sponsors/cyyynthia" - } - }, "node_modules/solc": { "version": "0.8.26", "resolved": "https://registry.npmjs.org/solc/-/solc-0.8.26.tgz", diff --git a/package.json b/package.json index d17f217..101e056 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "hardhat": "^2.22.8" }, "dependencies": { - "@dotenvx/dotenvx": "^1.14.0", - "smol-toml": "^1.3.1" + "@dotenvx/dotenvx": "^1.14.0" } -} \ No newline at end of file +} diff --git a/scripts/genesisEvents.js b/scripts/genesisEvents.js index cd6225f..bf1e867 100644 --- a/scripts/genesisEvents.js +++ b/scripts/genesisEvents.js @@ -1,6 +1,5 @@ require('@dotenvx/dotenvx').config(); const { ethers } = require("ethers"); -const toml = require("smol-toml"); const fs = require("fs"); // Chain metadata to combine both calls to Ethereum and BSC @@ -93,6 +92,29 @@ async function fetchEvents(chain) { return { stakeEntries: mergedStakeEntries, moonlightEntries: mergedMoonlightEntries }; } +// Custom TOML writer to handle our number formatting +function writeTOML(data) { + let tomlContent = ""; + + if (data.stake) { + data.stake.forEach((entry, index) => { + tomlContent += "[[stake]]\n"; + tomlContent += `address = '${entry.address}'\n`; + tomlContent += `amount = ${entry.amount}\n\n`; + }); + } + + if (data.moonlight_account) { + data.moonlight_account.forEach((entry) => { + tomlContent += "[[moonlight_account]]\n"; + tomlContent += `address = '${entry.address}'\n`; + tomlContent += `balance = ${entry.balance}\n\n`; + }); + } + + return tomlContent.trim(); +} + async function main() { let allStakeEntries = []; let allMoonlightEntries = []; @@ -115,11 +137,11 @@ async function main() { moonlight_account: allMoonlightEntries, }; - // Convert to TOML format - const genesisToml = toml.stringify(genesisData); + // Generate TOML content + const tomlContent = writeTOML(genesisData); - // Write events to genesis.toml - fs.writeFileSync("genesis.toml", genesisToml); + // Write TOML content to a file + fs.writeFileSync("genesis.toml", tomlContent); console.log("Generated genesis.toml file."); }