Skip to content

Commit 8feaf40

Browse files
authored
chore: add polygon & mumbai support (gitcoinco#2363)
1 parent c665a9f commit 8feaf40

40 files changed

Lines changed: 325 additions & 147 deletions

docs/TOKENS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ This is the kb for token-related info in relation to GS/Allo
3434
| Chain | Address | DAI Permit | EIP2612 Permit | Version | transferWithPermit |
3535
|-------------|--------------------------------------------|------------|----------------|---------|--------------------|
3636
| Avax | 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E | ⛔️ || 2 | ⛔️ |
37-
| Polygon PoS | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 | ⛔️ || 2 | ⛔️ |
37+
| Polygon PoS | 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 | ⛔️ || 1 | ⛔️ |

packages/builder/src/contracts/deployments.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export const chains = {
1111
58008: "pgnTestnet",
1212
42161: "arbitrum",
1313
421613: "arbitrumGoerli",
14+
137: "polygon",
15+
80001: "polygonMumbai",
1416
} as const;
1517

1618
export type ChainName = (typeof chains)[keyof typeof chains];
@@ -60,6 +62,12 @@ export const addresses: DeploymentAddressesMap = {
6062
arbitrumGoerli: {
6163
projectRegistry: "0x0CD135777dEaB6D0Bb150bDB0592aC9Baa4d0871",
6264
},
65+
polygon: {
66+
projectRegistry: "0x5C5E2D94b107C7691B08E43169fDe76EAAB6D48b",
67+
},
68+
polygonMumbai: {
69+
projectRegistry: "0x545B282A50EaeA01A619914d44105437036CbB36",
70+
},
6371
};
6472

6573
export const addressesByChainID = (chainId: ChainId): DeploymentAddresses => {

packages/builder/src/utils/graphql.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
import { ChainId } from "common";
2-
3-
const graphQlEndpoints: Record<ChainId, string> = {
4-
[ChainId.PGN]: process.env.REACT_APP_SUBGRAPH_PGN_API!,
5-
[ChainId.GOERLI_CHAIN_ID]: process.env.REACT_APP_SUBGRAPH_GOERLI_API!,
6-
[ChainId.PGN_TESTNET]: process.env.REACT_APP_SUBGRAPH_PGN_TESTNET_API!,
7-
[ChainId.MAINNET]: process.env.REACT_APP_SUBGRAPH_MAINNET_API!,
8-
[ChainId.OPTIMISM_MAINNET_CHAIN_ID]:
9-
process.env.REACT_APP_SUBGRAPH_OPTIMISM_MAINNET_API!,
10-
[ChainId.FANTOM_MAINNET_CHAIN_ID]:
11-
process.env.REACT_APP_SUBGRAPH_FANTOM_MAINNET_API!,
12-
[ChainId.FANTOM_TESTNET_CHAIN_ID]:
13-
process.env.REACT_APP_SUBGRAPH_FANTOM_TESTNET_API!,
14-
[ChainId.ARBITRUM_GOERLI]:
15-
process.env.REACT_APP_SUBGRAPH_ARBITRUM_GOERLI_API!,
16-
[ChainId.ARBITRUM]: process.env.REACT_APP_SUBGRAPH_ARBITRUM_API!,
17-
};
1+
import { ChainId, graphQlEndpoints } from "common";
182

193
/**
204
* Fetch subgraph uri for a given chain id

packages/builder/src/utils/wagmi.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ if (process.env.REACT_APP_ENV === "production") {
130130
fantomMainnet,
131131
optimismMainnet,
132132
pgn,
133-
chain.arbitrum
133+
chain.arbitrum,
134+
chain.polygon
134135
);
135136
} else {
136137
chainsAvailable.push(
@@ -142,7 +143,9 @@ if (process.env.REACT_APP_ENV === "production") {
142143
pgnTestnet,
143144
pgn,
144145
chain.arbitrum,
145-
chain.arbitrumGoerli
146+
chain.arbitrumGoerli,
147+
chain.polygon,
148+
chain.polygonMumbai
146149
);
147150
}
148151

packages/builder/src/utils/wallet.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getAddress } from "@ethersproject/address";
33
import { ChainId } from "common";
44
import { ethers } from "ethers";
55
import PGNIcon from "common/src/icons/PublicGoodsNetwork.svg";
6+
import POLIcon from "common/src/icons/pol-logo.svg";
67
import {
78
EthDiamondGlyph,
89
FantomFTMLogo,
@@ -37,6 +38,8 @@ export const networkPrettyNames: { [key in ChainName]: string } = {
3738
pgn: "PGN",
3839
arbitrum: "Arbitrum",
3940
arbitrumGoerli: "Arbitrum Goerli",
41+
polygon: "Polygon PoS",
42+
polygonMumbai: "Polygon Mumbai",
4043
};
4144

4245
export const networkIcon: { [key in ChainName]: string } = {
@@ -50,6 +53,8 @@ export const networkIcon: { [key in ChainName]: string } = {
5053
localhost: EthDiamondGlyph,
5154
arbitrum: ARBIcon,
5255
arbitrumGoerli: ARBIcon,
56+
polygon: POLIcon,
57+
polygonMumbai: POLIcon,
5358
};
5459

5560
export const payoutIcon: { [key in ChainName]: string } = {
@@ -63,6 +68,8 @@ export const payoutIcon: { [key in ChainName]: string } = {
6368
localhost: EthDiamondGlyph,
6469
arbitrumGoerli: ARBIcon,
6570
arbitrum: ARBIcon,
71+
polygon: POLIcon,
72+
polygonMumbai: POLIcon,
6673
};
6774

6875
export function getNetworkIcon(chainId: ChainId): string {

packages/common/src/chains.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export enum ChainId {
1111
PGN_TESTNET = 58008,
1212
ARBITRUM = 42161,
1313
ARBITRUM_GOERLI = 421613,
14+
POLYGON = 137,
15+
POLYGON_MUMBAI = 80001,
1416
}
1517

1618
export const pgnTestnet: Chain = {
Lines changed: 16 additions & 0 deletions
Loading

packages/common/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export type Payout = {
9696
createdAt: string;
9797
};
9898

99-
const graphQlEndpoints: Record<ChainId, string> = {
99+
export const graphQlEndpoints: Record<ChainId, string> = {
100100
[ChainId.PGN]: process.env.REACT_APP_SUBGRAPH_PGN_API!,
101101
[ChainId.GOERLI_CHAIN_ID]: process.env.REACT_APP_SUBGRAPH_GOERLI_API!,
102102
[ChainId.PGN_TESTNET]: process.env.REACT_APP_SUBGRAPH_PGN_TESTNET_API!,
@@ -110,6 +110,8 @@ const graphQlEndpoints: Record<ChainId, string> = {
110110
[ChainId.ARBITRUM_GOERLI]:
111111
process.env.REACT_APP_SUBGRAPH_ARBITRUM_GOERLI_API!,
112112
[ChainId.ARBITRUM]: process.env.REACT_APP_SUBGRAPH_ARBITRUM_API!,
113+
[ChainId.POLYGON]: process.env.REACT_APP_SUBGRAPH_POLYGON_API!,
114+
[ChainId.POLYGON_MUMBAI]: process.env.REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API!,
113115
};
114116

115117
/**
@@ -267,7 +269,7 @@ export const convertStatusToText = (
267269
};
268270

269271
/** Returns true if the current javascript context is running inside a Jest test */
270-
export const isJestRunning = () => process.env.JEST_WORKER_ID !== undefined;
272+
export const isJestRunning = () => process.env["JEST_WORKER_ID"] !== undefined;
271273

272274
export const padSingleDigitNumberWithZero = (i: number): string =>
273275
i < 10 ? "0" + i : i.toString();
@@ -308,6 +310,7 @@ export const RedstoneTokenIds = {
308310
ARB: "ARB",
309311
BUSD: "BUSD",
310312
GTC: "GTC",
313+
MATIC: "MATIC",
311314
} as const;
312315

313316
export const useTokenPrice = (tokenId: string | undefined) => {
Lines changed: 16 additions & 0 deletions
Loading

packages/grant-explorer/src/app/chainConfig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
goerli,
66
mainnet,
77
optimism,
8+
polygon,
9+
polygonMumbai,
810
} from "wagmi/chains";
911
import { arbitrum, arbitrumGoerli } from "viem/chains";
1012
import { pgnTestnet, pgn } from "common/src/chains";
@@ -15,6 +17,7 @@ const testnetChains = () => {
1517
{ ...fantomTestnet, iconUrl: "/logos/fantom-logo.svg" },
1618
pgnTestnet,
1719
arbitrumGoerli,
20+
polygonMumbai,
1821
];
1922
};
2023

@@ -24,6 +27,7 @@ const mainnetChains = () => {
2427
optimism,
2528
pgn,
2629
arbitrum,
30+
polygon,
2731
{ ...fantom, iconUrl: "/logos/fantom-logo.svg" },
2832
];
2933
};

0 commit comments

Comments
 (0)