Skip to content

Commit

Permalink
chore: add config for multi chain and remove env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 authored and kittybest committed Jul 4, 2024
1 parent 61fcba4 commit 3b9cf8c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
19 changes: 1 addition & 18 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ BLOB_READ_WRITE_TOKEN=
# NETWORK CONFIGURATION
# ---------------------

# Must be one of: ethereum, optimism, optimismSepolia, arbitrum, linea, sepolia, baseGoerli
# Can be 1 of: ethereum, optimism, optimismSepolia, arbitrum, linea, sepolia, baseGoerli
# Supported networks found here: https://docs.attest.sh/docs/quick--start/contracts
# NEXT_PUBLIC_CHAIN_NAME=optimism
NEXT_PUBLIC_CHAIN_NAME=optimismSepolia

# EAS GraphQL API URL
# Find the URLs here: https://docs.attest.sh/docs/developer-tools/api
NEXT_PUBLIC_EASSCAN_URL=https://optimism-sepolia.easscan.org/graphql
# NEXT_PUBLIC_EASSCAN_URL=https://optimism.easscan.org/graphql

# Optional but highly recommended
# Get your key at: https://dashboard.alchemy.com
# https://docs.alchemy.com/docs/alchemy-quickstart-guide#1key-create-an-alchemy-key
Expand All @@ -24,16 +18,11 @@ NEXT_PUBLIC_ALCHEMY_ID=
# WalletConnect (optional to support more wallets)
# Get your projectId at https://cloud.walletconnect.com
NEXT_PUBLIC_WALLETCONNECT_ID=
# NEXT_PUBLIC_WALLETCONNECT_ID="21fef48091f12692cad574a6f7753643" # https://github.com/rainbow-me/rainbowkit/blob/d68813501e40363f76856f7471552c83c08f7606/packages/rainbowkit/src/wallets/getWalletConnectConnector.ts#L73


# -----------------
# APP CONFIGURATION
# -----------------

# What the message will say when you sign in with the wallet
NEXT_PUBLIC_SIGN_STATEMENT="Sign in to MACI-RPGF"

# Event title for the round, just for display
NEXT_PUBLIC_EVENT_NAME="ETH GLOBAL"

Expand Down Expand Up @@ -74,12 +63,6 @@ NEXT_PUBLIC_APPROVAL_SCHEMA=0x858e0bc94997c072d762d90440966759b57c8bca892d4c9447
# (optional)
NEXT_PUBLIC_METADATA_SCHEMA=0xd00c966351896bd3dc37d22017bf1ef23165f859d7546a2aba12a01623dec912

# Used when creating attestations - change these if you're not on Optimism
# More info here: https://docs.attest.sh/docs/quick--start/contracts
NEXT_PUBLIC_EAS_CONTRACT_ADDRESS=0x4200000000000000000000000000000000000021
NEXT_PUBLIC_EAS_SCHEMA_REGISTRY_ADDRESS=0x4200000000000000000000000000000000000020


# ----------------------
# Advanced Configuration
# ----------------------
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ env:
NEXT_PUBLIC_FEEDBACK_URL: ${{ vars.NEXT_PUBLIC_FEEDBACK_URL }}
NEXT_PUBLIC_MACI_START_BLOCK: ${{ vars.NEXT_PUBLIC_MACI_START_BLOCK }}
NEXT_PUBLIC_MACI_SUBGRAPH_URL: ${{ vars.NEXT_PUBLIC_MACI_SUBGRAPH_URL }}
NEXT_PUBLIC_EAS_CONTRACT_ADDRESS: ${{ vars.NEXT_PUBLIC_EAS_CONTRACT_ADDRESS }}
NEXT_PUBLIC_EAS_SCHEMA_REGISTRY_ADDRESS: ${{ vars.NEXT_PUBLIC_EAS_SCHEMA_REGISTRY_ADDRESS }}
NEXT_PUBLIC_SIGN_STATEMENT: ${{ vars.NEXT_PUBLIC_SIGN_STATEMENT }}
NEXT_PUBLIC_TOKEN_NAME: ${{ vars.NEXT_PUBLIC_TOKEN_NAME }}
NEXT_PUBLIC_MAX_VOTES_TOTAL: ${{ vars.NEXT_PUBLIC_MAX_VOTES_TOTAL }}
NEXT_PUBLIC_MAX_VOTES_PROJECT: ${{ vars.NEXT_PUBLIC_MAX_VOTES_PROJECT }}
NEXT_PUBLIC_EASSCAN_URL: ${{ vars.NEXT_PUBLIC_EASSCAN_URL }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
NEXT_PUBLIC_ALCHEMY_ID: ${{ secrets.NEXT_PUBLIC_ALCHEMY_ID }}
NEXT_PUBLIC_START_DATE: ${{ vars.NEXT_PUBLIC_START_DATE }}
Expand Down
44 changes: 40 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ export const metadata = {

const parseDate = (env?: string) => (env ? new Date(env) : undefined);

// URLs for the EAS GraphQL endpoint for each chain
const easScanUrl = {
ethereum: "https://easscan.org/graphql",
optimism: "https://optimism.easscan.org/graphql",
optimismSepolia: "https://optimism-sepolia.easscan.org/graphql",
arbitrum: " https://arbitrum.easscan.org/graphql",
linea: "https://linea.easscan.org/graphql",
sepolia: "https://sepolia.easscan.org/graphql",
base: "https://base.easscan.org/graphql",
};

// EAS contract addresses for each chain
const easContractAddresses = {
ethereum: "0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587",
optimism: "0x4200000000000000000000000000000000000021",
optimismSepolia: "0x4200000000000000000000000000000000000021",
arbitrum: "0xbD75f629A22Dc1ceD33dDA0b68c546A1c035c458",
linea: "0xaEF4103A04090071165F78D45D83A0C0782c2B2a",
sepolia: "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
base: "0x4200000000000000000000000000000000000021",
};

// EAS Schema Registry contract addresses for each chain
const easSchemaRegistryContractAddresses = {
ethereum: "0xA7b39296258348C78294F95B872b282326A97BDF",
optimism: "0x4200000000000000000000000000000000000020",
optimismSepolia: "0x4200000000000000000000000000000000000020",
arbitrum: "0xA310da9c5B885E7fb3fbA9D66E9Ba6Df512b78eB",
linea: "0x55D26f9ae0203EF95494AE4C170eD35f4Cf77797",
sepolia: "0x0a7E2Ff54e76B8E6659aedc9103FB21c038050D0",
base: "0x4200000000000000000000000000000000000020",
};

export const config = {
logoUrl: "/Logo.svg",
pageSize: 3 * 4,
Expand All @@ -29,7 +62,7 @@ export const config = {
maciStartBlock: Number(process.env.NEXT_PUBLIC_MACI_START_BLOCK ?? 0),
maciSubgraphUrl: process.env.NEXT_PUBLIC_MACI_SUBGRAPH_URL ?? "",
tallyUrl: process.env.NEXT_PUBLIC_TALLY_URL,
roundOrganizer: process.env.NEXT_PUBLIC_ROUND_ORGANIZER ?? "Optimism",
roundOrganizer: process.env.NEXT_PUBLIC_ROUND_ORGANIZER ?? "PSE",
pollMode: process.env.NEXT_PUBLIC_POLL_MODE ?? "non-qv",
roundLogo: process.env.NEXT_PUBLIC_ROUND_LOGO,
};
Expand All @@ -39,12 +72,15 @@ export const theme = {
};

export const eas = {
url: process.env.NEXT_PUBLIC_EASSCAN_URL ?? "",
url: easScanUrl[process.env.NEXT_PUBLIC_CHAIN_NAME as keyof typeof easScanUrl],
attesterAddress: process.env.NEXT_PUBLIC_APPROVED_APPLICATIONS_ATTESTER ?? "",

contracts: {
eas: process.env.NEXT_PUBLIC_EAS_CONTRACT_ADDRESS ?? "0x4200000000000000000000000000000000000021",
schemaRegistry: process.env.NEXT_PUBLIC_EAS_SCHEMA_REGISTRY_ADDRESS ?? "0x4200000000000000000000000000000000000020",
eas: easContractAddresses[process.env.NEXT_PUBLIC_CHAIN_NAME as keyof typeof easContractAddresses],
schemaRegistry:
easSchemaRegistryContractAddresses[
process.env.NEXT_PUBLIC_CHAIN_NAME as keyof typeof easSchemaRegistryContractAddresses
],
},
schemas: {
metadata: process.env.NEXT_PUBLIC_METADATA_SCHEMA!,
Expand Down
8 changes: 0 additions & 8 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = createEnv({
"baseSepolia",
"localhost",
]),
NEXT_PUBLIC_SIGN_STATEMENT: z.string().optional(),

NEXT_PUBLIC_FEEDBACK_URL: z.string().default("#"),

Expand All @@ -51,10 +50,6 @@ module.exports = createEnv({
.string()
.default("0xac4c92fc5c7babed88f78a917cdbcdc1c496a8f4ab2d5b2ec29402736b2cf929"),

NEXT_PUBLIC_EAS_CONTRACT_ADDRESS: z.string().default("0x4200000000000000000000000000000000000021"),

NEXT_PUBLIC_EASSCAN_URL: z.string().default("https://optimism.easscan.org/graphql"),

NEXT_PUBLIC_ADMIN_ADDRESS: z.string().startsWith("0x"),
NEXT_PUBLIC_APPROVAL_SCHEMA: z.string().startsWith("0x"),
NEXT_PUBLIC_METADATA_SCHEMA: z.string().startsWith("0x"),
Expand Down Expand Up @@ -84,7 +79,6 @@ module.exports = createEnv({
NODE_ENV: process.env.NODE_ENV,

NEXT_PUBLIC_CHAIN_NAME: process.env.NEXT_PUBLIC_CHAIN_NAME,
NEXT_PUBLIC_SIGN_STATEMENT: process.env.NEXT_PUBLIC_SIGN_STATEMENT,

NEXT_PUBLIC_FEEDBACK_URL: process.env.NEXT_PUBLIC_FEEDBACK_URL,

Expand All @@ -95,8 +89,6 @@ module.exports = createEnv({
NEXT_PUBLIC_BADGEHOLDER_ATTESTER: process.env.NEXT_PUBLIC_BADGEHOLDER_ATTESTER,
NEXT_PUBLIC_PROFILE_SCHEMA: process.env.NEXT_PUBLIC_PROFILE_SCHEMA,

NEXT_PUBLIC_EAS_CONTRACT_ADDRESS: process.env.NEXT_PUBLIC_EAS_CONTRACT_ADDRESS,
NEXT_PUBLIC_EASSCAN_URL: process.env.NEXT_PUBLIC_EASSCAN_URL,
NEXT_PUBLIC_WALLETCONNECT_ID: process.env.NEXT_PUBLIC_WALLETCONNECT_ID,
NEXT_PUBLIC_ALCHEMY_ID: process.env.NEXT_PUBLIC_ALCHEMY_ID,
NEXT_PUBLIC_SKIP_APPROVED_VOTER_CHECK: process.env.NEXT_PUBLIC_SKIP_APPROVED_VOTER_CHECK,
Expand Down

0 comments on commit 3b9cf8c

Please sign in to comment.