Last active
August 9, 2024 12:34
-
-
Save ccerv1/323adb2f791f409acba8e2f67cc03c1a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 script converts a properly formatted CSV file to a JSON list. | |
| The CSV must have the `Project ID` in the first column and `OP Amount` in the second column. | |
| The `Project ID` can be found at the end of the voting URL, eg: | |
| https://vote.optimism.io/retropgf/3/application/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f | |
| https://round3.optimism.io/projects/0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f | |
| `Project ID` = 0xd730a803f5714c7f1b5e518edd57121d1b64c8c91cf611ae5f226cf9bb4b963f | |
| You can run this script via the following command: | |
| $ python listify.py your_list_name.csv | |
| You can also specify an impact category and outpath: | |
| $ python listify.py your_list_name.csv --category DEVELOPER_ECOSYSTEM --outpath your_outpath.json | |
| """ | |
| import argparse | |
| import json | |
| import pandas as pd | |
| CATEGORIES = [ | |
| 'COLLECTIVE_GOVERNANCE', | |
| 'DEVELOPER_ECOSYSTEM', | |
| 'END_USER_EXPERIENCE_AND_ADOPTION', | |
| 'OP_STACK' | |
| ] | |
| def load_allocation_data(csv_path): | |
| try: | |
| df = pd.read_csv(csv_path) | |
| df = df.iloc[:, :2].dropna() | |
| if len(df[df.duplicated(subset=[df.columns[0]])]) > 0: | |
| print("There are duplicate projects in the ID column. Please remove them and try again.") | |
| return None | |
| df[df.columns[1]] = df[df.columns[1]].str.replace(',', '').astype(float) | |
| df.columns = ['RPGF3_Application_UID', 'OPAmount'] | |
| data = df.to_dict('records') | |
| print(f"Successfully imported data from {csv_path}.") | |
| print(f"Found a total of {len(df)} projects.") | |
| print(f"List has a total amount of {df['OPAmount'].sum()} OP tokens.") | |
| return data | |
| except Exception as e: | |
| print(f"Could not load data from {csv_path}.") | |
| print(e) | |
| return None | |
| def get_category(category): | |
| if category not in CATEGORIES: | |
| print(f"Category must be one of:") | |
| for i, cat in enumerate(CATEGORIES): | |
| print(f"{i+1}. {cat}") | |
| while True: | |
| category = input("Please the number of a valid category: ") | |
| if category.isdigit() and int(category) <= len(CATEGORIES): | |
| category = CATEGORIES[int(category)-1] | |
| break | |
| return category | |
| def create_eas_json(allocation, category, outpath='MyList.json'): | |
| return { | |
| 'listDescription': "Add a short description of your list here.", | |
| 'impactEvaluationLink': "Add a link to your evaluation methodology here.", | |
| 'impactEvaluationDescription': "Add your impact evaluation methodology here.", | |
| 'impactCategory': [category], | |
| 'listContent': allocation | |
| } | |
| def main(csv_path, category=None, outpath='MyList.json'): | |
| allocation_data = load_allocation_data(csv_path) | |
| if allocation_data is None: | |
| return | |
| category = get_category(category) | |
| eas_json = create_eas_json(allocation_data, category, outpath) | |
| with open(outpath, 'w') as f: | |
| json.dump(eas_json, f, indent=4) | |
| print(f"Successfully created {outpath}.") | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('csv_path', help="Path to CSV file with project IDs and OP amounts.") | |
| parser.add_argument('--category', help="Category for this list.", default=None) | |
| parser.add_argument('--outpath', help="Path to save JSON file.", default='MyList.json') | |
| args = parser.parse_args() | |
| main(args.csv_path, args.category, args.outpath) |
Author
Author
Detailed steps:
- Run the script to generate your JSON file
- Open the JSON and edit the fields for
listDescription,impactEvaluationLink, etc. - Upload it to IPFS. There are a variety of ways. I like to use nft.storage for a simple GUI.
- Check the link to make sure it's OK. Copy the URI.
- Go to https://optimism.easscan.org/attestation/attestWithSchema/0x3e3e2172aebb902cf7aa6e1820809c5b469af139e7a4265442b1c22b97c6b2a5 and connect with the wallet that has your badgeholder credentials in it.
- Copy-paste the metadata link to the
list metadata ptrfield, eg, https://bafkreiegtmm4bvqsbin4gssqsqkrectgcopiz4a2cwcqglpchapmnwer3q.ipfs.nftstorage.link/ - Enter your badgeholder address or ENS in the
recipientfield - Enter a
list name(whatever you want to name your list) - Set the
list metadata ptr typeto 1 - Toggle
onchain - Make the attestation and sign it
If you make a mistake, you can easily revoke your list directly through the EAS schema.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can make attestations here