205 lines
5.2 KiB
Python
205 lines
5.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Find Public Haus DAO ID
|
|
|
|
This script queries the DAOhaus v3 subgraph on Optimism mainnet to find the Public Haus DAO ID.
|
|
It searches for DAOs with names containing 'Public Haus' or similar terms, and also checks
|
|
a specific DAO ID if provided.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import requests
|
|
import json
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables
|
|
load_dotenv()
|
|
|
|
# Constants
|
|
SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/hausdao/daohaus-v3-optimism"
|
|
SPECIFIC_DAO_ID = "0xf5d6b637a9185707f52d40d452956ca49018247a" # Public Haus DAO ID to check
|
|
|
|
def check_specific_dao(dao_id):
|
|
"""
|
|
Check if a specific DAO ID exists
|
|
|
|
Args:
|
|
dao_id: The DAO ID to check
|
|
|
|
Returns:
|
|
DAO data if found, None otherwise
|
|
"""
|
|
# GraphQL query to check a specific DAO
|
|
query = """
|
|
query {
|
|
dao(id: "%s") {
|
|
id
|
|
name
|
|
createdAt
|
|
totalShares
|
|
totalLoot
|
|
activeMemberCount
|
|
}
|
|
}
|
|
""" % dao_id.lower()
|
|
|
|
# Make request to subgraph
|
|
response = requests.post(
|
|
SUBGRAPH_URL,
|
|
json={"query": query}
|
|
)
|
|
|
|
# Check for errors
|
|
if response.status_code != 200:
|
|
print(f"Error checking DAO: {response.text}")
|
|
return None
|
|
|
|
data = response.json()
|
|
|
|
# Check if DAO exists
|
|
if not data.get("data") or not data["data"].get("dao"):
|
|
print(f"DAO not found with ID: {dao_id}")
|
|
return None
|
|
|
|
# Get DAO
|
|
dao = data["data"]["dao"]
|
|
print(f"Found DAO with ID: {dao_id}")
|
|
print(f"Name: {dao['name']}")
|
|
print(f"Created: {dao['createdAt']}")
|
|
print(f"Members: {dao['activeMemberCount']}")
|
|
print(f"Shares: {dao['totalShares']}")
|
|
print(f"Loot: {dao['totalLoot']}")
|
|
print("-" * 50)
|
|
|
|
return dao
|
|
|
|
def search_daos(search_term):
|
|
"""
|
|
Search for DAOs with names containing the search term
|
|
|
|
Args:
|
|
search_term: Term to search for in DAO names
|
|
|
|
Returns:
|
|
List of matching DAOs
|
|
"""
|
|
# GraphQL query to search for DAOs
|
|
query = """
|
|
query {
|
|
daos(where: {name_contains_nocase: "%s"}, first: 100) {
|
|
id
|
|
name
|
|
createdAt
|
|
totalShares
|
|
totalLoot
|
|
activeMemberCount
|
|
}
|
|
}
|
|
""" % search_term
|
|
|
|
# Make request to subgraph
|
|
response = requests.post(
|
|
SUBGRAPH_URL,
|
|
json={"query": query}
|
|
)
|
|
|
|
# Check for errors
|
|
if response.status_code != 200:
|
|
print(f"Error searching DAOs: {response.text}")
|
|
return []
|
|
|
|
data = response.json()
|
|
|
|
# Check if DAOs exist
|
|
if not data.get("data") or not data["data"].get("daos"):
|
|
print(f"No DAOs found with name containing '{search_term}'")
|
|
return []
|
|
|
|
# Get DAOs
|
|
daos = data["data"]["daos"]
|
|
print(f"Found {len(daos)} DAOs with name containing '{search_term}'")
|
|
|
|
return daos
|
|
|
|
def main():
|
|
"""Main function"""
|
|
# First check the specific DAO ID
|
|
print(f"Checking specific DAO ID: {SPECIFIC_DAO_ID}...")
|
|
specific_dao = check_specific_dao(SPECIFIC_DAO_ID)
|
|
|
|
# Search terms to try
|
|
search_terms = ["Public Haus", "PublicHaus", "Public", "Haus"]
|
|
|
|
all_daos = []
|
|
|
|
# Try each search term
|
|
for term in search_terms:
|
|
print(f"\nSearching for DAOs with name containing '{term}'...")
|
|
daos = search_daos(term)
|
|
all_daos.extend(daos)
|
|
|
|
# Print results
|
|
for dao in daos:
|
|
print(f"ID: {dao['id']}")
|
|
print(f"Name: {dao['name']}")
|
|
print(f"Created: {dao['createdAt']}")
|
|
print(f"Members: {dao['activeMemberCount']}")
|
|
print(f"Shares: {dao['totalShares']}")
|
|
print(f"Loot: {dao['totalLoot']}")
|
|
print("-" * 50)
|
|
|
|
# If no DAOs found, try listing all DAOs
|
|
if not all_daos and not specific_dao:
|
|
print("\nNo DAOs found with the search terms. Listing all DAOs...")
|
|
|
|
# GraphQL query to list all DAOs
|
|
query = """
|
|
query {
|
|
daos(first: 100) {
|
|
id
|
|
name
|
|
createdAt
|
|
totalShares
|
|
totalLoot
|
|
activeMemberCount
|
|
}
|
|
}
|
|
"""
|
|
|
|
# Make request to subgraph
|
|
response = requests.post(
|
|
SUBGRAPH_URL,
|
|
json={"query": query}
|
|
)
|
|
|
|
# Check for errors
|
|
if response.status_code != 200:
|
|
print(f"Error listing DAOs: {response.text}")
|
|
return 1
|
|
|
|
data = response.json()
|
|
|
|
# Check if DAOs exist
|
|
if not data.get("data") or not data["data"].get("daos"):
|
|
print("No DAOs found")
|
|
return 1
|
|
|
|
# Get DAOs
|
|
daos = data["data"]["daos"]
|
|
print(f"Found {len(daos)} DAOs")
|
|
|
|
# Print results
|
|
for dao in daos:
|
|
print(f"ID: {dao['id']}")
|
|
print(f"Name: {dao['name']}")
|
|
print(f"Created: {dao['createdAt']}")
|
|
print(f"Members: {dao['activeMemberCount']}")
|
|
print(f"Shares: {dao['totalShares']}")
|
|
print(f"Loot: {dao['totalLoot']}")
|
|
print("-" * 50)
|
|
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main()) |