Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: support sepolia #136

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion packages/web-app/components/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode } from "react";
import { TopBar } from "./TopBar";
import { Footer } from "@nation3/ui-components"
import { Footer } from "@nation3/ui-components";

export interface LayoutProps {
children: ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app/components/layout/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ export const TopBar = () => {
</div>
</TopBarGrid>
);
};
};
21 changes: 21 additions & 0 deletions packages/web-app/hooks/useTokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ const goerliTokens = [
},
];

const sepoliaTokens = [
{
name: "Nation3",
symbol: "NATION",
address: "0x23Ca3002706b71a440860E3cf8ff64679A00C9d7",
decimals: 18,
icon: "/tokens/nation3.png",
},
{
name: "Wrapped Ether",
symbol: "WETH",
address: "0x7b79995e5f793a07bc00c21412e50ecae098e7f9",
decimals: 18,
icon: "/tokens/weth.png",
},
];

const empty = {
name: "?",
symbol: "?",
Expand All @@ -67,6 +84,8 @@ export const useTokenList = (): Token[] => {
return mainnetTokens;
case 5:
return goerliTokens;
case 11155111:
return sepoliaTokens;
default:
return mainnetTokens;
}
Expand All @@ -84,6 +103,8 @@ export const useFindToken = (tokenSymbol: string): Token => {
return mainnetTokens.find((token) => token.symbol === tokenSymbol);
case 5:
return goerliTokens.find((token) => token.symbol === tokenSymbol);
case 11155111:
return sepoliaTokens.find((token) => token.symbol === tokenSymbol);
default:
return mainnetTokens.find((token) => token.symbol === tokenSymbol);
}
Expand Down
25 changes: 17 additions & 8 deletions packages/web-app/lib/connectors.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getDefaultWallets } from "@rainbow-me/rainbowkit";
import { providers } from "ethers";
import { Chain, configureChains } from "wagmi";
import { goerli, mainnet } from "wagmi/chains";
import { goerli, mainnet, sepolia } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";

type FallbackProviderConfig = Omit<providers.FallbackProviderConfig, "provider">;
Expand Down Expand Up @@ -33,14 +33,23 @@ const gnosis: Chain = {
};

// Returns and alchemy provider based on the chain
// if the chain is goerli, use the goerly alchemy api key from the env
// else, use the mainnet alchemy api key from the env
const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => {
return (chain: Chain) => {
const apiKey =
chain.id === 5
? process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_GOERLI
: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;
let apiKey: any;
switch (chain?.id) {
case 1:
apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;
break;
case 5:
apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_GOERLI;
break;
case 11155111:
apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_SEPOLIA;
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that I have to add this variable in the Vercel config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the old code, but it would be better if we only needed NEXT_PUBLIC_ALCHEMY_API_KEY.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think so also. Having one variable name per chain is just weird. Let's refactor those later, in a separate pull request: #139

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already update it in my latest commit

Copy link
Member

Choose a reason for hiding this comment

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

I also added NEXT_PUBLIC_CHAIN = sepolia in the Vercel config for the Sepolia project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, wait a second, something is weird here. We don't need NEXT_PUBLIC_CHAIN since our app supports multiple chains.

Copy link
Member

Choose a reason for hiding this comment

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

Well, testing and debugging gets easier if we use one subdomain (and one Vercel project) per chain. That's how we are doing it with the other Nation3 dApps, so probably makes most sense to treat the Agreements dApp the same way?

app.nation3.org, app-sepolia.nation3.org
income.nation3.org, income-sepolia.nation3.org
agreements.nation3.org, agreements-sepolia.nation3.org

break;
default:
apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;
break;
}
if (!apiKey || !chain.rpcUrls.alchemy) return null;

return {
Expand Down Expand Up @@ -81,7 +90,7 @@ export const providersToUse = () => {
};

export const chainsToUse = () => {
return [mainnet, gnosis, goerli];
return [mainnet, gnosis, goerli, sepolia];
};

export const { chains, provider, webSocketProvider } = configureChains(
Expand Down
5 changes: 4 additions & 1 deletion packages/web-app/lib/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { BigNumber } from "ethers";
import * as mainnet from "./mainnet";
import * as goerli from "./goerli";
import * as gnosis from "./gnosis";
import * as sepolia from "./sepolia";

export { mainnet, goerli };
export { mainnet, goerli, sepolia };

export interface Constants {
permit2Address: `0x${string}`;
Expand All @@ -22,6 +23,8 @@ const constants = (chainId: number) => {
return { ...mainnet };
case 5:
return { ...goerli };
case 11155111:
return { ...sepolia };
case 100:
return { ...gnosis };
default:
Expand Down
10 changes: 10 additions & 0 deletions packages/web-app/lib/constants/sepolia.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { BigNumber } from "ethers";

export const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
aahna-ashina marked this conversation as resolved.
Show resolved Hide resolved
export const NATION = "0x23Ca3002706b71a440860E3cf8ff64679A00C9d7";
export const frameworkAddress = "0xD96aA6e2568f4e9632D2A5234Bb8410ca7609a27";
export const arbitratorAddress = "0xBe67cEdCD1FE38aac8a5781A51250FDeFB344E6C";
export const cohortAddress = "0xfbb66bc799308435ed2a0e0c0ac3ad1d46749b7b";
export const safeTxServiceUrl = "https://safe-transaction-sepolia.safe.global";
export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL_SEPOLIA;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to deploy something for the Graph API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I'm not sure. I need to take a look at this and test the app to see if there are any problems.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure either, but this is what Nation3's Subgraph dashboard looks like:

Copy link
Contributor Author

@TTNguyenDev TTNguyenDev Feb 28, 2024

Choose a reason for hiding this comment

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

@aahna-ashina Can you share the current subgraphURI that https://agreements.nation3.org/ is using

Copy link
Member

Choose a reason for hiding this comment

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

@aahna-ashina Can you share the current subgraphURI that https://agreements.nation3.org/ is using

Do you mean the NEXT_PUBLIC_GRAPH_API_URL environment variable?

export const appealCost = BigNumber.from("1000000000000000000");
Loading