Skip to content

Automate the import of your ballot into the Retro PGF form.

License

Notifications You must be signed in to change notification settings

latticexyz/retro-pfg-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

RetroPGF Round 2 Automation

In order to fill the RetroPGF Round 2 Form as a Badgeholder; there is currently a very manual process of moving allocations from a Google Sheet into a Deform.

Ludens -- from Lattice -- is a badgeholder for RetroPGF, and we worked on a process to make this super easy for them and others to import their allocations into the final form.

CleanShot 2023-02-16 at 17 44 19@2x

Using the automation

How to use

Summary: Instead of duplicating the OP provided Sheet, you duplicate a modified Google Sheet containing an AppSript that allows for JSON export of the allocations. Then, when visiting the form, you can import the JSON into the form into a Bookmarklet.

Step 1: Make a Copy of the modified Google Sheet

Regardless of how many exports / imports you do, this step is to be done only once

Open the modified Google Sheet; and make a copy of it.

Important: Use File -> Make a Copy instead of duplicating the the sheet; otherwise the AppScript won't be carried over.

CleanShot 2023-02-16 at 17 44 19@2x

You will need to accept a disclaimer about AppScript

Step 2: Go on the sheet you copied, and export your Ballot

Fill in your ballot the same way you would with the original OP Foundation provided sheet, then click on the "OP Vote Allocation" menu and choose "Export Vote Json". If the menu doesn't appear, reload the page. If it still doesn't appear, you probably duplicated the sheet instead of making a copy.

CleanShot 2023-02-16 at 17 44 19@2x

You can now copy your ballot as a JSON file, either keeping it into your clipboard and saving it into a text file.

There is also a feature to import a Ballot! We hope Badge Holders will share their ballot in a json format on Discord and Telegram, and this function will make it easy to import someone else's ballot into your sheet.

Step 3: Create the bookmarklet to fill the form from a JSON export

Regardless of how many exports / imports you do, this step is to be done only once

You will need to create a bookmarklet with the code below:

javascript: (function () {
  var inputJsonString = prompt("Enter Project Allocation JSON");
  var projectAllocations = JSON.parse(inputJsonString);

  var inputs = document.evaluate(
    "//input",
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null
  );
  for (var i = 1; i < inputs.snapshotLength; i++) {
    var input = inputs.snapshotItem(i);
    var projectIndex = i - 1;
    var project = projectAllocations.find((projectAllocation) => {
      return projectAllocation.projectIndex === projectIndex;
    });

    input.value = project ? project.allocation * 100 : 0;
  }
})();

This bookmarklet tutorial assumes you are using Chrome, but this will work in any browser.

  1. Right click your bookmark bar and hit Add Page...

CleanShot 2023-02-16 at 17 44 19@2x

  1. Paste in the code snippet found here for the URL.

CleanShot 2023-02-16 at 17 44 52@2x

You now have the Bookmarklet that imports a Ballot in the JSON format into the RetroPGF Round 2 form

Step 4: Import your Ballot

Go to the RetroPGF Round 2 form; then click on your bookmarklet

CleanShot 2023-02-16 at 17 44 19@2x

CleanShot 2023-02-16 at 17 44 19@2x

Paste your JSON Ballot created in Step 2 from your clipboard (or first copy it from the text file you saved it to) into the text box and click "Ok".

The form should now reflect your ballot!

About

Automate the import of your ballot into the Retro PGF form.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published