Skip to content

Commit 274fbd2

Browse files
authored
chore: add avax & fuji support (#2351)
1 parent 18cb8a2 commit 274fbd2

File tree

21 files changed

+433
-204
lines changed

21 files changed

+433
-204
lines changed

lefthook.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
pre-commit:
2+
skip:
3+
- merge
4+
- rebase
25
parallel: true
36
commands:
47
prettier:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@commitlint/config-conventional": "^17.6.3"
3636
},
3737
"dependencies": {
38-
"turbo": "^1.10.9"
38+
"turbo": "^1.10.14"
3939
},
4040
"pnpm": {
4141
"overrides": {

packages/builder/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@heroicons/react": "^2.0.11",
2020
"@lagunovsky/redux-react-router": "^2.2.0",
2121
"@pinata/sdk": "^1.1.26",
22-
"@rainbow-me/rainbowkit": "^0.7.2",
22+
"@rainbow-me/rainbowkit": "^0.12.18",
2323
"@redux-devtools/extension": "^3.2.3",
2424
"@tailwindcss/line-clamp": "^0.4.2",
2525
"@tailwindcss/typography": "^0.5.9",
@@ -34,7 +34,7 @@
3434
"@types/react-dom": "^18.0.1",
3535
"@types/react-redux": "^7.1.24",
3636
"@types/testing-library__jest-dom": "^5.14.5",
37-
"@wagmi/core": "0.5.4",
37+
"@wagmi/core": "0.10.17",
3838
"@walletconnect/ethereum-provider": "^2.9.0",
3939
"@walletconnect/modal": "^2.5.9",
4040
"allo-indexer-client": "github:gitcoinco/allo-indexer-client",
@@ -74,7 +74,7 @@
7474
"ts-jest": "^27.0",
7575
"typescript": "^4.6.3",
7676
"url": "^0.11.0",
77-
"wagmi": "^0.6.4",
77+
"wagmi": "^0.12.19",
7878
"web-vitals": "^2.1.4",
7979
"yup": "^0.32.11",
8080
"verify-env": "*"

packages/builder/src/components/application/AboutProject.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function AboutProject(props: {
3838
: undefined;
3939

4040
const { data: ensName } = useEnsName({
41-
address: recipient ?? "",
41+
address: (recipient ?? "") as `0x${string}`,
4242
});
4343

4444
return (

packages/builder/src/contracts/deployments.ts

+8
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+
43114: "avalanche",
15+
43113: "fuji",
1416
137: "polygon",
1517
80001: "polygonMumbai",
1618
} as const;
@@ -62,6 +64,12 @@ export const addresses: DeploymentAddressesMap = {
6264
arbitrumGoerli: {
6365
projectRegistry: "0x0CD135777dEaB6D0Bb150bDB0592aC9Baa4d0871",
6466
},
67+
avalanche: {
68+
projectRegistry: "0xDF9BF58Aa1A1B73F0e214d79C652a7dd37a6074e",
69+
},
70+
fuji: {
71+
projectRegistry: "0x8918401DD47f1645fF1111D8E513c0404b84d5bB",
72+
},
6573
polygon: {
6674
projectRegistry: "0x5C5E2D94b107C7691B08E43169fDe76EAAB6D48b",
6775
},

packages/builder/src/utils/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const getProviderByChainId = (chainId: ChainId) => {
7373
}
7474

7575
// TODO: Create a more robust RPC here to avoid fails
76-
return ethers.getDefaultProvider(chainConfig.rpcUrls.default);
76+
return ethers.getDefaultProvider(chainConfig.rpcUrls.default.http[0]);
7777
};
7878

7979
export const getAddressType = async (address: string): Promise<AddressType> => {

packages/builder/src/utils/wagmi.ts

+96-81
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,83 @@ import {
44
injectedWallet,
55
metaMaskWallet,
66
} from "@rainbow-me/rainbowkit/wallets";
7-
import { chain, configureChains, createClient } from "wagmi";
7+
import { configureChains, createClient } from "wagmi";
8+
import {
9+
fantom as fantomChain,
10+
fantomTestnet as fantomTestnetChain,
11+
mainnet,
12+
arbitrum,
13+
optimism,
14+
goerli,
15+
arbitrumGoerli,
16+
hardhat,
17+
avalancheFuji as avalancheFujiChain,
18+
avalanche as avalancheChain,
19+
} from "wagmi/chains";
820
import { alchemyProvider } from "wagmi/providers/alchemy";
921
import { infuraProvider } from "wagmi/providers/infura";
1022
import { publicProvider } from "wagmi/providers/public";
1123
import PublicGoodsNetworkIcon from "common/src/icons/PublicGoodsNetwork.svg";
12-
import { FantomFTMLogo, FTMTestnet, OPIcon } from "../assets";
13-
14-
const ftmTestnetIcon = FTMTestnet;
15-
const ftmMainnetIcon = FantomFTMLogo;
24+
import { polygon, polygonMumbai } from "@wagmi/core/chains";
25+
import { FantomFTMLogo } from "../assets";
1626

1727
// RPC keys
18-
const alchemyId = process.env.REACT_APP_ALCHEMY_ID;
19-
const infuraId = process.env.REACT_APP_INFURA_ID;
28+
const alchemyId = process.env.REACT_APP_ALCHEMY_ID!;
29+
const infuraId = process.env.REACT_APP_INFURA_ID!;
30+
31+
export const avalanche: Chain = {
32+
...avalancheChain,
33+
rpcUrls: {
34+
default: {
35+
http: [
36+
"https://avalanche-mainnet.infura.io/v3/1e0a90928efe4bb78bb1eeceb8aacc27",
37+
],
38+
},
39+
public: {
40+
http: ["https://api.avax.network/ext/bc/C/rpc"],
41+
},
42+
},
43+
};
44+
45+
export const avalancheFuji: Chain = {
46+
...avalancheFujiChain,
47+
rpcUrls: {
48+
default: {
49+
http: [
50+
"https://avalanche-fuji.infura.io/v3/1e0a90928efe4bb78bb1eeceb8aacc27",
51+
],
52+
},
53+
public: {
54+
http: ["https://api.avax-test.network/ext/bc/C/rpc"],
55+
},
56+
},
57+
};
58+
59+
export const fantom: Chain = {
60+
...fantomChain,
61+
rpcUrls: {
62+
default: {
63+
http: ["https://rpcapi.fantom.network/"],
64+
},
65+
public: {
66+
http: ["https://rpcapi.fantom.network/"],
67+
},
68+
},
69+
iconUrl: FantomFTMLogo,
70+
};
71+
72+
export const fantomTestnet: Chain = {
73+
...fantomTestnetChain,
74+
rpcUrls: {
75+
default: {
76+
http: ["https://rpc.testnet.fantom.network/"],
77+
},
78+
public: {
79+
http: ["https://rpc.testnet.fantom.network/"],
80+
},
81+
},
82+
iconUrl: FantomFTMLogo,
83+
};
2084

2185
export const pgn: Chain = {
2286
id: 424,
@@ -29,7 +93,8 @@ export const pgn: Chain = {
2993
symbol: "ETH",
3094
},
3195
rpcUrls: {
32-
default: "https://rpc.publicgoods.network",
96+
default: { http: ["https://rpc.publicgoods.network"] },
97+
public: { http: ["https://rpc.publicgoods.network"] },
3398
},
3499
blockExplorers: {
35100
default: {
@@ -51,7 +116,8 @@ export const pgnTestnet: Chain = {
51116
symbol: "ETH",
52117
},
53118
rpcUrls: {
54-
default: "https://sepolia.publicgoods.network",
119+
default: { http: ["https://sepolia.publicgoods.network"] },
120+
public: { http: ["https://sepolia.publicgoods.network"] },
55121
},
56122
blockExplorers: {
57123
default: {
@@ -61,91 +127,37 @@ export const pgnTestnet: Chain = {
61127
},
62128
testnet: true,
63129
};
64-
// Adding custom chain setups for Fantom Mainnet and Testnet
65-
const fantomTestnet: Chain = {
66-
id: 4002,
67-
name: "Fantom Testnet",
68-
network: "fantom testnet",
69-
iconUrl: ftmTestnetIcon,
70-
nativeCurrency: {
71-
decimals: 18,
72-
name: "Fantom",
73-
symbol: "FTM",
74-
},
75-
rpcUrls: {
76-
default: "https://rpc.testnet.fantom.network/",
77-
},
78-
blockExplorers: {
79-
default: { name: "ftmscan", url: "https://testnet.ftmscan.com" },
80-
},
81-
testnet: true,
82-
};
83-
84-
const fantomMainnet: Chain = {
85-
id: 250,
86-
name: "Fantom",
87-
network: "fantom mainnet",
88-
iconUrl: ftmMainnetIcon,
89-
nativeCurrency: {
90-
decimals: 18,
91-
name: "Fantom",
92-
symbol: "FTM",
93-
},
94-
rpcUrls: {
95-
default: "https://rpcapi.fantom.network/",
96-
},
97-
blockExplorers: {
98-
default: { name: "ftmscan", url: "https://ftmscan.com" },
99-
},
100-
testnet: false,
101-
};
102-
103-
const optimismMainnet: Chain = {
104-
id: 10,
105-
name: "Optimism",
106-
network: "optimism mainnet",
107-
iconUrl: OPIcon,
108-
nativeCurrency: {
109-
decimals: 18,
110-
name: "Optimism",
111-
symbol: "ETH",
112-
},
113-
rpcUrls: {
114-
default: `https://opt-mainnet.g.alchemy.com/v2/${alchemyId}`,
115-
},
116-
blockExplorers: {
117-
default: { name: "etherscan", url: "https://optimistic.etherscan.io" },
118-
},
119-
testnet: false,
120-
};
121130

122131
// todo: fix for rpc issue is with hardhat local chain calling rpc
123132
if (process.env.REACT_APP_LOCALCHAIN === "true") {
124-
chainsAvailable.push(chain.hardhat);
133+
chainsAvailable.push(hardhat);
125134
}
126135

127136
if (process.env.REACT_APP_ENV === "production") {
128137
chainsAvailable.push(
129-
chain.mainnet,
130-
fantomMainnet,
131-
optimismMainnet,
138+
mainnet,
139+
fantom,
140+
optimism,
132141
pgn,
133-
chain.arbitrum,
134-
chain.polygon
142+
arbitrum,
143+
avalanche,
144+
polygon
135145
);
136146
} else {
137147
chainsAvailable.push(
138-
optimismMainnet,
139-
chain.goerli,
148+
optimism,
149+
goerli,
140150
fantomTestnet,
141-
fantomMainnet,
142-
chain.mainnet,
151+
fantom,
152+
mainnet,
143153
pgnTestnet,
144154
pgn,
145-
chain.arbitrum,
146-
chain.arbitrumGoerli,
147-
chain.polygon,
148-
chain.polygonMumbai
155+
arbitrum,
156+
arbitrumGoerli,
157+
polygon,
158+
polygonMumbai,
159+
avalanche,
160+
avalancheFuji
149161
);
150162
}
151163

@@ -163,7 +175,10 @@ const connectors = connectorsForWallets([
163175
wallets: [
164176
injectedWallet({ chains }),
165177
coinbaseWallet({ appName: "Builder", chains }),
166-
metaMaskWallet({ chains }),
178+
metaMaskWallet({
179+
chains,
180+
projectId: "0000000000" /* We don't support walletconnect */,
181+
}),
167182
],
168183
},
169184
]);

packages/builder/src/utils/wallet.ts

+7
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 AVAXIcon from "common/src/icons/AVAX.svg";
67
import POLIcon from "common/src/icons/pol-logo.svg";
78
import {
89
EthDiamondGlyph,
@@ -38,6 +39,8 @@ export const networkPrettyNames: { [key in ChainName]: string } = {
3839
pgn: "PGN",
3940
arbitrum: "Arbitrum",
4041
arbitrumGoerli: "Arbitrum Goerli",
42+
avalanche: "Avalanche",
43+
fuji: "Fuji (Avalanche Testnet)",
4144
polygon: "Polygon PoS",
4245
polygonMumbai: "Polygon Mumbai",
4346
};
@@ -53,6 +56,8 @@ export const networkIcon: { [key in ChainName]: string } = {
5356
localhost: EthDiamondGlyph,
5457
arbitrum: ARBIcon,
5558
arbitrumGoerli: ARBIcon,
59+
avalanche: AVAXIcon,
60+
fuji: AVAXIcon,
5661
polygon: POLIcon,
5762
polygonMumbai: POLIcon,
5863
};
@@ -70,6 +75,8 @@ export const payoutIcon: { [key in ChainName]: string } = {
7075
arbitrum: ARBIcon,
7176
polygon: POLIcon,
7277
polygonMumbai: POLIcon,
78+
avalanche: AVAXIcon,
79+
fuji: AVAXIcon,
7380
};
7481

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

packages/common/src/chains.ts

+2
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+
AVALANCHE = 43114,
15+
FUJI = 43113,
1416
POLYGON = 137,
1517
POLYGON_MUMBAI = 80001,
1618
}

packages/common/src/icons/AVAX.svg

+4
Loading

packages/common/src/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ export 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.FUJI]: process.env.REACT_APP_SUBGRAPH_FUJI_API!,
114+
[ChainId.AVALANCHE]: process.env.REACT_APP_SUBGRAPH_AVALANCHE_API!,
113115
[ChainId.POLYGON]: process.env.REACT_APP_SUBGRAPH_POLYGON_API!,
114116
[ChainId.POLYGON_MUMBAI]: process.env.REACT_APP_SUBGRAPH_POLYGON_MUMBAI_API!,
115117
};
@@ -311,6 +313,7 @@ export const RedstoneTokenIds = {
311313
BUSD: "BUSD",
312314
GTC: "GTC",
313315
MATIC: "MATIC",
316+
AVAX: "AVAX",
314317
} as const;
315318

316319
export const useTokenPrice = (tokenId: string | undefined) => {
Loading

0 commit comments

Comments
 (0)