forked from w3f/1k-validators-be
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor scorekeeper to separate files
- Loading branch information
will pankiewicz
authored and
will pankiewicz
committed
Feb 13, 2024
1 parent
878ae2f
commit ffac567
Showing
15 changed files
with
1,003 additions
and
874 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
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
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
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,35 @@ | ||
import fs from "fs"; | ||
|
||
const writeCandidatesMatrix = (path: any, network: any) => { | ||
try { | ||
const conf = fs.readFileSync(path, { encoding: "utf-8" }); | ||
const candidates = JSON.parse(conf).candidates; | ||
|
||
const filePath = `${network}-matrix.txt`; | ||
|
||
fs.writeFileSync(filePath, "", "utf8"); | ||
|
||
const matrixHandles: (string | any[])[] = []; | ||
|
||
candidates.forEach((candidate: { riotHandle: string | any[] }) => { | ||
if (typeof candidate.riotHandle == "string") { | ||
if (!matrixHandles.includes(candidate.riotHandle)) { | ||
matrixHandles.push(candidate.riotHandle); | ||
} | ||
} else if (Array.isArray(candidate.riotHandle)) { | ||
candidate.riotHandle.forEach((handle) => { | ||
if (!matrixHandles.includes(handle)) { | ||
matrixHandles.push(handle); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
matrixHandles.forEach((handle) => { | ||
fs.appendFileSync(filePath, handle + "\n", "utf8"); | ||
}); | ||
} catch (e) { | ||
console.log("Invalid JSON!"); | ||
process.exit(1); | ||
} | ||
}; |
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
Oops, something went wrong.