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

feat: support sepolia #147

Merged
merged 5 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/web-app/hooks/useTokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ const mainnetTokens = [
},
];

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 @@ -48,6 +65,8 @@ export const useTokenList = (): Token[] => {
switch (chain?.id) {
case 1:
return mainnetTokens;
case 11155111:
return sepoliaTokens;
default:
return mainnetTokens;
}
Expand All @@ -63,6 +82,8 @@ export const useFindToken = (tokenSymbol: string): Token => {
switch (chain?.id) {
case 1:
return mainnetTokens.find((token) => token.symbol === tokenSymbol);
case 11155111:
return mainnetTokens.find((token) => token.symbol === tokenSymbol);
default:
return mainnetTokens.find((token) => token.symbol === tokenSymbol);
}
Expand Down
9 changes: 6 additions & 3 deletions packages/web-app/lib/connectors.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { getDefaultWallets } from "@rainbow-me/rainbowkit";
import { providers } from "ethers";
import { Chain, configureChains } from "wagmi";
import { mainnet } from "wagmi/chains";
import { mainnet, sepolia } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";

type FallbackProviderConfig = Omit<providers.FallbackProviderConfig, "provider">;

const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => {
return (chain: Chain) => {
const apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; //mainnet
let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;
if (chain?.id == 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.

Suggested change
apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_SEPOLIA;
apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY;

}
if (!apiKey || !chain.rpcUrls.alchemy) return null;

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

export const chainsToUse = () => {
return [mainnet];
return [mainnet, 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
@@ -1,7 +1,8 @@
import { BigNumber } from "ethers";
import * as mainnet from "./mainnet";
import * as sepolia from "./sepolia";

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

export interface Constants {
permit2Address: `0x${string}`;
Expand All @@ -18,6 +19,8 @@ const constants = (chainId: number) => {
switch (chainId) {
case 1:
return { ...mainnet };
case 11155111:
return { ...sepolia };
default:
return { ...mainnet };
}
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";
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.

Suggested change
export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL_SEPOLIA;
export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this mean that https://agreements.nation3.org/ supports only the Ethereum mainnet, and https://sepolia.agreements.nation3.org/ supports only the Sepolia testnet, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't support network switching?

Copy link
Member

Choose a reason for hiding this comment

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

we don't support network switching?

We can still support it, by redirecting to the other URLs. If a user opens https://agreements.nation3.org and selects Sepolia in the chain selection drop-down, we can redirect to https://agreements-sepolia.nation3.org

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