This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See PR #240
- Loading branch information
Showing
19 changed files
with
480 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Docs | ||
on: [pull_request] | ||
|
||
jobs: | ||
|
||
Build-Docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Build 🔧 | ||
run: | | ||
npm install | ||
npm ci | ||
npm run build-scripts | ||
npm run gather-data -- --csv-file-path=output.csv --scoreboard-file-path=scoreboard/scoreboard.md | ||
npm run upload-data -- --csv-file-path=output.csv | ||
npm run docs:build | ||
echo 'primer.desmos.network' > .vuepress/dist/CNAME |
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
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,142 @@ | ||
import {Utils} from "./common"; | ||
|
||
const path = require('path'); | ||
const csv = require('jquery-csv'); | ||
const PHASE_5_SUBMISSIONS = path.join(__dirname, `../../phase-5/submissions`); | ||
|
||
/** | ||
* Allows to easily get the data from the Phase 5 of the Primer program. | ||
*/ | ||
export class Phase5 { | ||
|
||
/** | ||
* Gets all the hashtag posts created. | ||
* @returns {Promise<Map<String, String>>} a map containing all the created posts. | ||
* The keys represent the names of the user, while the values represent the hashes of the post creation | ||
* transactions. | ||
*/ | ||
static async _getHashtags() { | ||
return Utils.removeEmptyValue(await Utils.getFilesContents(`${PHASE_5_SUBMISSIONS}/hashtags`)); | ||
} | ||
|
||
/** | ||
* Gets all the profiles. | ||
* @returns {Promise<Map<String, String>>} a map containing all the created or edited profiles. | ||
* The keys represent the names of the user, while the values represent the hashes of | ||
* the profile creation/edit transactions. | ||
*/ | ||
static async _getProfiles() { | ||
return Utils.removeEmptyValue(await Utils.getFilesContents(`${PHASE_5_SUBMISSIONS}/profiles`)); | ||
} | ||
|
||
/** | ||
* Gets all the posts in which a user is tagged. | ||
* @returns {Promise<Map<String, String>>} a map containing all the created posts. | ||
* The keys represent the names of the user, while the values represent the hashes of the post creation | ||
* transactions. | ||
*/ | ||
static async _getTags() { | ||
return Utils.removeEmptyValue(await Utils.getFilesContents(`${PHASE_5_SUBMISSIONS}/tags`)); | ||
} | ||
|
||
/** | ||
* Gets all the created reports. | ||
* @returns {Promise<Map<String, String>>} a map containing all the created reports. | ||
* The keys represent the names of the user, while the values represent the hashes of the report creation | ||
* transactions. | ||
*/ | ||
static async _getReports() { | ||
return Utils.removeEmptyValue(await Utils.getFilesContents(`${PHASE_5_SUBMISSIONS}/reports`)); | ||
} | ||
|
||
/** | ||
* Gets all the updated validators | ||
* @returns {Promise<Map<String, String>>} a map containing all the updated validators. | ||
* The keys represent the names of the user, while the values represent the operator address of the associated | ||
* validator. | ||
*/ | ||
static async _getValidators() { | ||
return Utils.removeEmptyValue(await Utils.getFilesContents(`${PHASE_5_SUBMISSIONS}/updates`)); | ||
} | ||
|
||
/** | ||
* Gets all the number of precommits that all the validators have signed. | ||
* @return {Promise<Map<String, int>>} Map containing the number of precommits that the validators have signed. | ||
* The key is going to be the address of the validator, and the value is going to be the number of precommits. | ||
*/ | ||
static async _getPrecommits() { | ||
const fileContents = await Utils.getFilesContents(`${PHASE_5_SUBMISSIONS}/precommits`); | ||
if (fileContents.size === 0) { | ||
return new Map(); | ||
} | ||
|
||
const morpheus4000Precommits = fileContents.get('precommits-morpheus-5000.csv'); | ||
const objects = csv.toObjects(morpheus4000Precommits.join("\n")); | ||
|
||
const map = new Map(); | ||
for (const object of objects) { | ||
const existingPrecommitsCount = map.get(object.operatorAddress) ?? 0; | ||
const currentPrecommitsCount = parseInt(object.precommitCount.replace(",", "")); | ||
map.set(object.operatorAddress, existingPrecommitsCount + currentPrecommitsCount); | ||
} | ||
|
||
return map; | ||
} | ||
|
||
/** | ||
* Gathers all the data. | ||
* @returns {Promise<Phase5Data>} containing all the Phase 5 data. | ||
*/ | ||
static async getData() { | ||
return new Phase5Data( | ||
await this._getHashtags(), | ||
await this._getProfiles(), | ||
await this._getReports(), | ||
await this._getTags(), | ||
await this._getValidators(), | ||
await this._getPrecommits(), | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* @property {Map<String, String>} hashtags | ||
* @property {Map<String, String>} profiles | ||
* @property {Map<String, String>} reports | ||
* @property {Map<String, String>} tags | ||
* @property {Map<String, String>} validators | ||
* @property {Map<String, int>} precommits | ||
*/ | ||
class Phase5Data { | ||
constructor(hashtags, profiles, reports, tags, validators, precommits) { | ||
this.hashtags = hashtags; | ||
console.log(`Hashtags created: ${this.hashtags.size}`); | ||
|
||
this.profiles = profiles; | ||
console.log(`Profiles created/edited: ${this.profiles.size}`); | ||
|
||
this.reports = reports; | ||
console.log(`Reports created: ${this.reports.size}`); | ||
|
||
this.tags = tags; | ||
console.log(`Tags created: ${this.tags.size}`); | ||
|
||
this.validators = validators; | ||
console.log(`Updated validators: ${this.validators.size}`); | ||
|
||
this.precommits = precommits; | ||
} | ||
|
||
/** | ||
* @returns {Array<String>} | ||
*/ | ||
getUsers() { | ||
return [ | ||
...this.hashtags.keys(), | ||
...this.profiles.keys(), | ||
...this.reports.keys(), | ||
...this.tags.keys(), | ||
...this.validators.keys(), | ||
]; | ||
} | ||
} |
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.