Giter Site home page Giter Site logo

malvarez-0 / v4-draw-results Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pooltogether/v4-draw-results

0.0 0.0 0.0 4.32 MB

Periodically runs the draw-calculator-cli and stores the results. Also the data source of the Netlify hosted Prizes API.

JavaScript 100.00%

v4-draw-results's Introduction

PoolTogether Brand


V4 Draw Results

Draw Calculator CLI

Netlify Status

Description

This is where the results of the draw-calculator-cli are stored.

The draw calculator CLI is instantiated periodically from the cron workflow. This workflow checks if the most recent drawId for a network is greater than the last committed draw, and if so, runs the draw-calculator-cli.

This data serves as the data source for the hosted Netlify API. More information on how to use this API can be found here.

Setup

Prerequisites

This repository can be cloned/forked and the data reproduced or continued.

You'll need to add the following secrets to the repository (under settings/Secrets -> Repository Secrets):

Secret Value/Description
ALCHEMY_MAINNET_URL Mainnet RPC URL
ALCHEMY_RINKEBY_URL Rinkeby RPC URL
MATICVIGIL_URL Polygon RPC URL
MUMBAI_URL Mumbai RPC URL

You'll also need a Github Personal Access Token in order to trigger the workflow remotely using the repository_dispatch API.

The script at ./scripts/sync.js will fire requests for the workflow to run from the genesis drawId (= 1) to the most recent drawId.

Steps

  1. Add the environmental secrets to your Github repo as shown above.
  2. Add your Personal Access Token and the other environmental variables to the .envrc as shown in the .envrc.example.
  3. Install the repo using yarn.
  4. Enable Github Actions if you have not done so already.
  5. Update the constants in ./scripts/sync.js to target this repo.
  6. Run the sync script using yarn sync. This may take some time. You can see the progress by viewing the workflows executing in the Actions tab in your repo.

Adding a new network

After following the appropriate steps to add the network to the draw-calculator-cli, do the following:

  1. Add the new network RPC endpoint URL to the repo secrets.
  2. Add this under the env section in the workflow cron.yaml "Run Draw Calculator CLI (if required)" step alongside the other env variables. This makes the secret available to the workflow as it runs.
  3. Add logic to check if the CLI tool needs to be run here.
  4. Add a workflow step to commit prize files if they were created.

Data Structure

The generated file structure is:

v4-draw-results
│   README.md
│   package.json
│   ...
└───api
    └───prizes
        └───1 (chainId for mainnet)
            │    └─── 0xb9a179dca5a7bf5f8b9e088437b3a85ebb495efe (Prize Distributor address)
            │           └─── draw
            │                └─── 1
            │                     │   0xa123..json
            │                     │   0xa124..json
            │                     │   ...
            │                     │   prizes.json
            │                     │   status.json
            |
            │                └─── 2
            │               ...
        └───137 (chainId for polygon)
            └─── 0x8141bcfbcee654c5de17c4e2b2af26b67f9b9056 (Prize Distributor address)
            │           └─── draw
            │                └─── 1
            │                     │    0xa123..json
            │                     │    0xa124..json
            │                     │    ...
            │                     │    prizes.json
            │                     │    status.json
            |
            │                └─── 2
            │           ...

File Description
0xa123..json Data for a winning address for a draw
prizes.json Index file including all winners for draw
status.json Metadata about the CLI run (status and time elapsed)

Where prizes.json is an index of all the individual address files and status.json includes .

The file structure is according to Prize Distributor address (not by Ticket) is because a Ticket can mave multiple associated Prize Distributors. NOTE : The use of lower case strings for addresses.

Examples

For example:

  1. ./api/prizes/1/0xb9a179dca5a7bf5f8b9e088437b3a85ebb495efe/draw/1/prizes.json will display all prizes for chainId = 1 (Ethereum Mainnet) for Prize Distributor (address: 0xb9a179dca5a7bf5f8b9e088437b3a85ebb495efe) for draw 1.

    This is also viewable at the Netlify API.

  2. ./api/prizes/137/0x8141bcfbcee654c5de17c4e2b2af26b67f9b9056/draw/12/prizes.json will display all prizes for chainId = 137 (Polygon/Matic) for Prize Distributor (address: 0x8141bcfbcee654c5de17c4e2b2af26b67f9b9056) for draw 12.

    This is also viewable at the Netlify API.

v4-draw-results's People

Contributors

pierrickgt avatar github-actions[bot] avatar draw-calc-bot avatar aodhgan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.