Skip to content

Commit

Permalink
Add Base mainnet as a network on Grants Stack (#2737)
Browse files Browse the repository at this point in the history
* feat: add support for base chain

* chore: update lock file

* chore: update env test

* chore: update env test

* fix: issues

* fix: tests

* feat: add base logo

* chore: add alchemy rpc to base

* chore: update default rpc in base

* fix: builder alchemy issue

* chore: add base tokens

* chore: update gitcoin litjs version

* chore: add usdc permit version on base
  • Loading branch information
bhargavaparoksham authored Dec 21, 2023
1 parent 793aee9 commit e17e631
Show file tree
Hide file tree
Showing 27 changed files with 1,059 additions and 695 deletions.
1 change: 1 addition & 0 deletions packages/builder/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ REACT_APP_SUBGRAPH_POLYGON_API="https://api.thegraph.com/subgraphs/name/allo-pro
REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API="https://api.thegraph.com/subgraphs/name/allo-protocol/grants-round-mumbai"
REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API="https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-zkync-era-testnet"
REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.studio.thegraph.com/query/45391/grants-round-zkera/v0.0.2"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"

# Variables below are optional for local development
REACT_APP_DATADOG_APPLICATION_ID=
Expand Down
1 change: 1 addition & 0 deletions packages/builder/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API="https://api.thegraph.com/subgraphs/name/a
REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API="https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-zkync-era-testnet"
REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.studio.thegraph.com/query/45391/grants-round-zkera/v0.0.2"
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"

REACT_APP_PINATA_GATEWAY="https://pinata-gateway.com"
REACT_APP_PINATA_JWT="abcedfg"
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"dompurify": "^2.4.3",
"ethers": "^5.7.2",
"framer-motion": "^6",
"gitcoin-lit-js-sdk": "^1.2.6",
"gitcoin-lit-js-sdk": "^1.2.7",
"history": "^5.3.0",
"https-browserify": "^1.0.0",
"jest": "^27.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/builder/src/contracts/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const chains = {
43113: "fuji",
137: "polygon",
80001: "polygonMumbai",
8453: "base",
} as const;

export type ChainName = (typeof chains)[keyof typeof chains];
Expand Down Expand Up @@ -88,6 +89,9 @@ export const addresses: DeploymentAddressesMap = {
zkSyncEraTestnet: {
projectRegistry: "0xb0F4882184EB6e3ed120c5181651D50719329788",
},
base: {
projectRegistry: "0xA78Daa89fE9C1eC66c5cB1c5833bC8C6Cb307918",
},
};

export const addressesByChainID = (chainId: ChainId): DeploymentAddresses => {
Expand Down
4 changes: 4 additions & 0 deletions packages/builder/src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
avalanche,
avalancheFuji,
fantom,
base,
fantomTestnet,
customOptimism,
customPolygon,
Expand All @@ -31,6 +32,7 @@ const availableChains: { [key: string]: Chain } = {
arbitrum,
avalanche,
polygon: customPolygon,
base,
fantomTestnet,
pgnTestnet,
arbitrumGoerli,
Expand All @@ -50,6 +52,7 @@ const stagingChains = [
pgnTestnet,
pgn,
arbitrum,
base,
arbitrumGoerli,
customPolygon,
polygonMumbai,
Expand All @@ -68,6 +71,7 @@ const productionChains = [
avalanche,
customPolygon,
zkSyncEraMainnet,
base,
];

export function getEnabledChainsAndProviders() {
Expand Down
3 changes: 3 additions & 0 deletions packages/builder/src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const networkPrettyNames: { [key in ChainName]: string } = {
polygonMumbai: "Polygon Mumbai",
zkSyncEraMainnet: "zkSync Era Mainnet",
zkSyncEraTestnet: "zkSync Era Testnet",
base: "Base",
};

export const networkIcon: { [key in ChainName]: string } = {
Expand All @@ -67,6 +68,7 @@ export const networkIcon: { [key in ChainName]: string } = {
polygonMumbai: POLIcon,
zkSyncEraMainnet: ZkSyncIcon,
zkSyncEraTestnet: ZkSyncIcon,
base: EthDiamondGlyph,
};

export const payoutIcon: { [key in ChainName]: string } = {
Expand All @@ -87,6 +89,7 @@ export const payoutIcon: { [key in ChainName]: string } = {
fuji: AVAXIcon,
zkSyncEraMainnet: ZkSyncIcon,
zkSyncEraTestnet: ZkSyncIcon,
base: EthDiamondGlyph,
};

export function getNetworkIcon(chainId: ChainId): string {
Expand Down
3 changes: 2 additions & 1 deletion packages/common/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ REACT_APP_SUBGRAPH_POLYGON_API="https://api.thegraph.com/subgraphs/name/allo-pro
REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API="https://api.thegraph.com/subgraphs/name/allo-protocol/grants-round-mumbai"
REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API="https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-zkync-era-testnet"
REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.studio.thegraph.com/query/45391/grants-round-zkera/v0.0.2"
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"dependencies": {
"@ethersproject/providers": "^5.7.2",
"@rainbow-me/rainbowkit": "^0.12.16",
"@wagmi/chains": "^1.8.0",
"data-layer": "workspace:*",
"dompurify": "^2.4.3",
"ethers": "^5.6.5",
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/chain-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum ChainId {
FUJI = 43113,
POLYGON = 137,
POLYGON_MUMBAI = 80001,
BASE = 8453,
DEV1 = 313371,
DEV2 = 313372,
}
23 changes: 20 additions & 3 deletions packages/common/src/chains.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { Chain } from "@rainbow-me/rainbowkit";
import PublicGoodsNetworkIcon from "./icons/PublicGoodsNetwork.svg";
import zkSyncIcon from "./icons/zksync-logo.svg";
import BaseLogo from "./icons/base-logo.svg";
import {
avalanche as avalancheOriginal,
avalancheFuji as avalancheFujiOriginal,
fantom as fantomOriginal,
fantomTestnet as fantomTestnetOriginal,
zkSyncTestnet as zkSyncTestnetOriginal,
zkSync as zkSyncOriginal,
} from "wagmi/chains";
base as baseOriginal,
} from "@wagmi/chains";
import FantomFTMLogo from "./assets/fantom-ftm-logo.png";
import { ChainId } from "./chain-ids";
import { getConfig } from "./config";

const config = getConfig();

export const fantom: Chain = {
...fantomOriginal,
rpcUrls: {
Expand Down Expand Up @@ -53,6 +57,21 @@ export const avalancheFuji: Chain = {
},
};

export const base: Chain = {
...baseOriginal,
iconUrl: BaseLogo,
rpcUrls: {
default: {
http: [
`https://base-mainnet.g.alchemy.com/v2/${config.blockchain.alchemyId}`,
],
},
public: {
http: ["https://mainnet.base.org/"],
},
},
};

export const avalanche: Chain = {
...avalancheOriginal,
rpcUrls: {
Expand Down Expand Up @@ -146,8 +165,6 @@ export const pgn: Chain = {
},
};

const config = getConfig();

export const customOptimism = {
id: 10,
name: "Optimism",
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export function getConfig(): Config {
[ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID]: z
.string()
.parse(process.env.REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API),
[ChainId.BASE]: z
.string()
.parse(process.env.REACT_APP_SUBGRAPH_BASE_API),
},
},
pinata: {
Expand Down
10 changes: 10 additions & 0 deletions packages/common/src/icons/base-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const graphQlEndpoints: Record<ChainId, string> = {
process.env.REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API!,
[ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID]:
process.env.REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API!,
[ChainId.BASE]: process.env.REACT_APP_SUBGRAPH_BASE_API!,
};

/**
Expand Down
1 change: 1 addition & 0 deletions packages/grant-explorer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ REACT_APP_SUBGRAPH_POLYGON_API="https://api.thegraph.com/subgraphs/name/allo-pro
REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API="https://api.thegraph.com/subgraphs/name/allo-protocol/grants-round-mumbai"
REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API="https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-zkync-era-testnet"
REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-zkync-era-mainnet"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"

# Variables below are optional for local development
REACT_APP_DATADOG_APPLICATION_ID=
Expand Down
1 change: 1 addition & 0 deletions packages/grant-explorer/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API="https://api.thegraph.com/subgraphs/name/g
REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.studio.thegraph.com/query/45391/grants-round-zkera/v0.0.2"
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_ENV="test"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"
10 changes: 10 additions & 0 deletions packages/grant-explorer/public/logos/base-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/grant-explorer/src/app/chainConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { arbitrum, arbitrumGoerli } from "viem/chains";
import {
pgnTestnet,
pgn,
base,
zkSyncEraMainnet,
zkSyncEraTestnet,
} from "common/src/chains";
Expand Down Expand Up @@ -43,6 +44,7 @@ const MAINNET_CHAINS = [
avalanche,
polygon,
zkSyncEraMainnet,
base,
{ ...fantom, iconUrl: "/logos/fantom-logo.svg" },
].map(ensureValidChainId);

Expand Down
1 change: 1 addition & 0 deletions packages/grant-explorer/src/features/api/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export const MRC_CONTRACTS: Record<ChainId, Hex> = {
"0x7468C30eC48066cea6666D12F10230d118792eD5",
[ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID]:
"0x88e91283d97A482A9e0851dE335d58D97dCfF7b0",
[ChainId.BASE]: "0x7C24f3494CC958CF268a92b45D7e54310d161794",
};
33 changes: 33 additions & 0 deletions packages/grant-explorer/src/features/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ export const CHAINS: Record<
name: "zkSync Era",
logo: "./logos/zksync-logo.svg",
},
[ChainId.BASE]: {
id: ChainId.BASE,
name: "Base",
logo: "./logos/base-logo.svg",
},
};

export const TokenNamesAndLogos = {
Expand Down Expand Up @@ -374,6 +379,30 @@ const PGN_MAINNET_TOKENS: VotingToken[] = [
},
];

const BASE_TOKENS: VotingToken[] = [
{
name: "ETH",
chainId: ChainId.BASE,
address: zeroAddress,
decimal: 18,
logo: TokenNamesAndLogos["ETH"],
redstoneTokenId: RedstoneTokenIds["ETH"],
defaultForVoting: true,
canVote: true,
},
{
name: "USDC",
chainId: ChainId.BASE,
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
decimal: 6,
logo: TokenNamesAndLogos["USDC"],
redstoneTokenId: RedstoneTokenIds["USDC"],
permitVersion: "2",
defaultForVoting: false,
canVote: true,
},
];

const ARBITRUM_TOKENS: VotingToken[] = [
{
name: "ETH",
Expand Down Expand Up @@ -532,6 +561,7 @@ export const votingTokens = [
...POLYGON_MUMBAI_TOKENS,
...ZKSYNC_ERA_TESTNET_TOKENS,
...ZKSYNC_ERA_MAINNET_TOKENS,
...BASE_TOKENS,
];

type VotingTokensMap = Record<ChainId, VotingToken[]>;
Expand All @@ -554,6 +584,7 @@ export const votingTokensMap: VotingTokensMap = {
[ChainId.POLYGON_MUMBAI]: POLYGON_MUMBAI_TOKENS,
[ChainId.ZKSYNC_ERA_TESTNET_CHAIN_ID]: ZKSYNC_ERA_TESTNET_TOKENS,
[ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID]: ZKSYNC_ERA_MAINNET_TOKENS,
[ChainId.BASE]: BASE_TOKENS,
};

export const getVotingTokenOptions = (chainId: ChainId): VotingToken[] =>
Expand Down Expand Up @@ -587,6 +618,7 @@ export const txExplorerLinks: Record<ChainId, string> = {
[ChainId.ZKSYNC_ERA_TESTNET_CHAIN_ID]:
"https://goerli.explorer.zksync.io/tx/",
[ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID]: "https://explorer.zksync.io/tx/",
[ChainId.BASE]: "https://basescan.org/tx/",
};

/**
Expand Down Expand Up @@ -744,6 +776,7 @@ export function getChainIds(): number[] {
Number(ChainId.AVALANCHE),
Number(ChainId.POLYGON),
Number(ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID),
Number(ChainId.BASE),
];
} else {
return Object.values(ChainId)
Expand Down
3 changes: 2 additions & 1 deletion packages/round-manager/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ REACT_APP_SUBGRAPH_POLYGON_API="https://api.thegraph.com/subgraphs/name/allo-pro
REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API="https://api.thegraph.com/subgraphs/name/allo-protocol/grants-round-mumbai"
REACT_APP_SUBGRAPH_ZKSYNC_TESTNET_API="https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-zkync-era-testnet"
REACT_APP_SUBGRAPH_ZKSYNC_MAINNET_API="https://api.studio.thegraph.com/query/45391/grants-round-zkera/v0.0.2"
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_GRANTS_STACK_SEARCH_API_BASE_URL="https://gitcoin-search-dev.fly.dev"
REACT_APP_SUBGRAPH_BASE_API="https://api.studio.thegraph.com/query/45391/grants-round-base/v0.0.1"
2 changes: 1 addition & 1 deletion packages/round-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"html-react-parser": "^3.0.7",
"https-browserify": "^1.0.0",
"jest-fetch-mock": "^3.0.3",
"lit-js-sdk-old-w-pgn": "^1.1.254",
"lit-js-sdk-old-w-pgn": "^1.1.255",
"lodash": "^4.17.21",
"moment": "^2.29.3",
"os-browserify": "^0.3.0",
Expand Down
10 changes: 10 additions & 0 deletions packages/round-manager/public/logos/base-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/round-manager/src/app/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import {
pgn,
pgnTestnet,
base,
zkSyncEraMainnet,
zkSyncEraTestnet,
} from "common/src/chains";
Expand Down Expand Up @@ -52,6 +53,7 @@ const mainnetChains = () => {
avalanche,
polygon,
zkSyncEraMainnet,
base,
{ ...fantom, iconUrl: "/logos/fantom-logo.svg" },
];
};
Expand Down
Loading

5 comments on commit e17e631

@vercel
Copy link

@vercel vercel bot commented on e17e631 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder – ./packages/builder

builder-grants-stack.vercel.app
builder.gitcoin.co
builder-kappa-one.vercel.app
builder-git-main-grants-stack.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e17e631 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

manager – ./packages/round-manager

manager-git-main-grants-stack.vercel.app
grants-stack-round-manager.vercel.app
manager.gitcoin.co
manager-grants-stack.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e17e631 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-staging – ./packages/builder

builder-staging-grants-stack.vercel.app
builder-staging-git-main-grants-stack.vercel.app
grants-stack-builder-staging.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e17e631 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer-staging – ./packages/grant-explorer

grants-stack-explorer-staging.vercel.app
explorer-staging-grants-stack.vercel.app
explorer-staging-git-main-grants-stack.vercel.app

@vercel
Copy link

@vercel vercel bot commented on e17e631 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

manager-staging – ./packages/round-manager

manager-staging-git-main-grants-stack.vercel.app
grants-stack-manager-staging.vercel.app
manager-staging-grants-stack.vercel.app

Please sign in to comment.