Skip to content

Instantly share code, notes, and snippets.

@ccerv1
Last active August 9, 2024 12:34
Show Gist options
  • Select an option

  • Save ccerv1/323adb2f791f409acba8e2f67cc03c1a to your computer and use it in GitHub Desktop.

Select an option

Save ccerv1/323adb2f791f409acba8e2f67cc03c1a to your computer and use it in GitHub Desktop.
"""
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)
@ccerv1
Copy link
Copy Markdown
Author

ccerv1 commented Nov 15, 2023

You can make attestations here

image

@ccerv1
Copy link
Copy Markdown
Author

ccerv1 commented Nov 21, 2023

Detailed steps:

  1. Run the script to generate your JSON file
  2. Open the JSON and edit the fields for listDescription, impactEvaluationLink, etc.
  3. Upload it to IPFS. There are a variety of ways. I like to use nft.storage for a simple GUI.
  4. Check the link to make sure it's OK. Copy the URI.
  5. Go to https://optimism.easscan.org/attestation/attestWithSchema/0x3e3e2172aebb902cf7aa6e1820809c5b469af139e7a4265442b1c22b97c6b2a5 and connect with the wallet that has your badgeholder credentials in it.
  6. Copy-paste the metadata link to the list metadata ptr field, eg, https://bafkreiegtmm4bvqsbin4gssqsqkrectgcopiz4a2cwcqglpchapmnwer3q.ipfs.nftstorage.link/
  7. Enter your badgeholder address or ENS in the recipient field
  8. Enter a list name (whatever you want to name your list)
  9. Set the list metadata ptr type to 1
  10. Toggle onchain
  11. 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