From 95bf891bc339083cf3c3890f63d2bfb9e7a39915 Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 13:11:39 +0700 Subject: [PATCH 1/9] build: support sepolia --- packages/web-app/lib/connectors.tsx | 132 ++++++++++----------- packages/web-app/lib/constants/sepolia.tsx | 11 ++ 2 files changed, 77 insertions(+), 66 deletions(-) create mode 100644 packages/web-app/lib/constants/sepolia.tsx diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 2458ce03..3b0b4a1d 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -1,95 +1,95 @@ 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; // FIXME: Import from @wagmi/chains after wagmi core update const gnosis: Chain = { - id: 100, - name: "Gnosis", - network: "gnosis", - nativeCurrency: { - decimals: 18, - name: "Gnosis", - symbol: "xDAI", - }, - rpcUrls: { - default: "https://rpc.gnosischain.com", - public: "https://rpc.gnosischain.com", - }, - blockExplorers: { - etherscan: { - name: "Gnosisscan", - url: "https://gnosisscan.io/", - }, - default: { - name: "Gnosis Chain Explorer", - url: "https://blockscout.com/xdai/mainnet/", - }, - }, + id: 100, + name: "Gnosis", + network: "gnosis", + nativeCurrency: { + decimals: 18, + name: "Gnosis", + symbol: "xDAI", + }, + rpcUrls: { + default: "https://rpc.gnosischain.com", + public: "https://rpc.gnosischain.com", + }, + blockExplorers: { + etherscan: { + name: "Gnosisscan", + url: "https://gnosisscan.io/", + }, + default: { + name: "Gnosis Chain Explorer", + url: "https://blockscout.com/xdai/mainnet/", + }, + }, }; // 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; - if (!apiKey || !chain.rpcUrls.alchemy) return null; + return (chain: Chain) => { + const apiKey = + chain.id === 5 + ? process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_GOERLI + : process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + if (!apiKey || !chain.rpcUrls.alchemy) return null; - return { - chain: { - ...chain, - rpcUrls: { - ...chain.rpcUrls, - default: `${chain.rpcUrls.alchemy}/${apiKey}`, - }, - } as Chain, - provider: () => { - const provider = new providers.AlchemyProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ); - return Object.assign(provider, { priority, stallTimeout, weight }); - }, - webSocketProvider: () => - new providers.AlchemyWebSocketProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ), - }; - }; + return { + chain: { + ...chain, + rpcUrls: { + ...chain.rpcUrls, + default: `${chain.rpcUrls.alchemy}/${apiKey}`, + }, + } as Chain, + provider: () => { + const provider = new providers.AlchemyProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ); + return Object.assign(provider, { priority, stallTimeout, weight }); + }, + webSocketProvider: () => + new providers.AlchemyWebSocketProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ), + }; + }; }; export const providersToUse = () => { - const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; - return providers; + const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; + return providers; }; export const chainsToUse = () => { - return [mainnet, gnosis, goerli]; + return [mainnet, gnosis, goerli, sepolia]; }; export const { chains, provider, webSocketProvider } = configureChains( - chainsToUse(), - providersToUse(), + chainsToUse(), + providersToUse(), ); export const { connectors } = getDefaultWallets({ - appName: "Nation3 Court App", - chains, + appName: "Nation3 Court App", + chains, }); diff --git a/packages/web-app/lib/constants/sepolia.tsx b/packages/web-app/lib/constants/sepolia.tsx new file mode 100644 index 00000000..6a2f9dd1 --- /dev/null +++ b/packages/web-app/lib/constants/sepolia.tsx @@ -0,0 +1,11 @@ + +import { BigNumber } from "ethers"; + +export const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; +export const NATION = "0x23Ca3002706b71a440860E3cf8ff64679A00C9d7"; +export const frameworkAddress = "0x1dBEFF62DFa113f7254AaB5772F1AC6E66F94e7e"; +export const arbitratorAddress = "0xBe67cEdCD1FE38aac8a5781A51250FDeFB344E6C"; +export const cohortAddress = "0xfbb66bc799308435ed2a0e0c0ac3ad1d46749b7b"; +export const safeTxServiceUrl = "https://safe-transaction-mainnet.safe.global"; +export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL; +export const appealCost = BigNumber.from("1000000000000000000"); From 0cc7af0b331f96c7b5d89d41a4a7b7996bb00f4c Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 13:24:33 +0700 Subject: [PATCH 2/9] build: support sepolia --- packages/web-app/hooks/useTokenList.tsx | 163 ++++++++++++--------- packages/web-app/lib/connectors.tsx | 17 ++- packages/web-app/lib/constants/index.tsx | 41 +++--- packages/web-app/lib/constants/sepolia.tsx | 4 +- 4 files changed, 127 insertions(+), 98 deletions(-) diff --git a/packages/web-app/hooks/useTokenList.tsx b/packages/web-app/hooks/useTokenList.tsx index 801315f4..b6fae1eb 100644 --- a/packages/web-app/hooks/useTokenList.tsx +++ b/packages/web-app/hooks/useTokenList.tsx @@ -3,91 +3,112 @@ import { useNetwork } from "wagmi"; import { Token } from "../components/agreementCreate/context/types"; const mainnetTokens = [ - { - name: "Nation3", - symbol: "NATION", - address: "0x333A4823466879eeF910A04D473505da62142069", - decimals: 18, - icon: "/tokens/nation3.png", - }, - { - name: "Wrapped Ether", - symbol: "WETH", - address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - decimals: 18, - icon: "/tokens/weth.png", - }, - { - name: "Dai Stablecoin", - symbol: "DAI", - address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", - decimals: 18, - icon: "/tokens/dai.png", - }, - { - name: "Aragon Network Token", - symbol: "ANT", - address: "0xa117000000f279D81A1D3cc75430fAA017FA5A2e", - decimals: 18, - icon: "/tokens/ant.png", - }, + { + name: "Nation3", + symbol: "NATION", + address: "0x333A4823466879eeF910A04D473505da62142069", + decimals: 18, + icon: "/tokens/nation3.png", + }, + { + name: "Wrapped Ether", + symbol: "WETH", + address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + decimals: 18, + icon: "/tokens/weth.png", + }, + { + name: "Dai Stablecoin", + symbol: "DAI", + address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", + decimals: 18, + icon: "/tokens/dai.png", + }, + { + name: "Aragon Network Token", + symbol: "ANT", + address: "0xa117000000f279D81A1D3cc75430fAA017FA5A2e", + decimals: 18, + icon: "/tokens/ant.png", + }, ]; const goerliTokens = [ - { - name: "Nation3", - symbol: "NATION", - address: "0x333A4823466879eeF910A04D473505da62142069", - decimals: 18, - icon: "/tokens/nation3.png", - }, - { - name: "Wrapped Ether", - symbol: "WETH", - address: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", - decimals: 18, - icon: "/tokens/weth.png", - }, + { + name: "Nation3", + symbol: "NATION", + address: "0x333A4823466879eeF910A04D473505da62142069", + decimals: 18, + icon: "/tokens/nation3.png", + }, + { + name: "Wrapped Ether", + symbol: "WETH", + address: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + decimals: 18, + icon: "/tokens/weth.png", + }, +]; + +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: "?", - address: "", - decimals: 18, - icon: "", + name: "?", + symbol: "?", + address: "", + decimals: 18, + icon: "", }; export const useTokenList = (): Token[] => { - const { chain } = useNetwork(); + const { chain } = useNetwork(); - const tokens = useMemo(() => { - switch (chain?.id) { - case 1: - return mainnetTokens; - case 5: - return goerliTokens; - default: - return mainnetTokens; - } - }, [chain]); + const tokens = useMemo(() => { + switch (chain?.id) { + case 1: + return mainnetTokens; + case 5: + return goerliTokens; + case 11155111: + return sepoliaTokens; + default: + return mainnetTokens; + } + }, [chain]); - return tokens; + return tokens; }; export const useFindToken = (tokenSymbol: string): Token => { - const { chain } = useNetwork(); + const { chain } = useNetwork(); - const token = useMemo(() => { - switch (chain?.id) { - case 1: - return mainnetTokens.find((token) => token.symbol === tokenSymbol); - case 5: - return goerliTokens.find((token) => token.symbol === tokenSymbol); - default: - return mainnetTokens.find((token) => token.symbol === tokenSymbol); - } - }, [chain, tokenSymbol]); + const token = useMemo(() => { + switch (chain?.id) { + case 1: + 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); + } + }, [chain, tokenSymbol]); - return token ? token : empty; + return token ? token : empty; }; diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 3b0b4a1d..b22c42b0 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -33,14 +33,19 @@ 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; + var apiKey: any; + switch (chain?.id) { + case 1: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY + case 5: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_GOERLI + case 11155111: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_SEPOLIA + default: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY + } if (!apiKey || !chain.rpcUrls.alchemy) return null; return { diff --git a/packages/web-app/lib/constants/index.tsx b/packages/web-app/lib/constants/index.tsx index 8b26d765..db151b13 100644 --- a/packages/web-app/lib/constants/index.tsx +++ b/packages/web-app/lib/constants/index.tsx @@ -2,31 +2,34 @@ 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}`; - NATION: `0x${string}`; - frameworkAddress: `0x${string}`; - arbitratorAddress: `0x${string}`; - cohortAddress: `0x${string}`; - safeTxServiceUrl: string; - subgraphURI: string | undefined; - appealCost: BigNumber | undefined; + permit2Address: `0x${string}`; + NATION: `0x${string}`; + frameworkAddress: `0x${string}`; + arbitratorAddress: `0x${string}`; + cohortAddress: `0x${string}`; + safeTxServiceUrl: string; + subgraphURI: string | undefined; + appealCost: BigNumber | undefined; } const constants = (chainId: number) => { - switch (chainId) { - case 1: - return { ...mainnet }; - case 5: - return { ...goerli }; - case 100: - return { ...gnosis }; - default: - return { ...mainnet }; - } + switch (chainId) { + case 1: + return { ...mainnet }; + case 5: + return { ...goerli }; + case 11155111: + return { ...sepolia }; + case 100: + return { ...gnosis }; + default: + return { ...mainnet }; + } }; export default constants; diff --git a/packages/web-app/lib/constants/sepolia.tsx b/packages/web-app/lib/constants/sepolia.tsx index 6a2f9dd1..2f115ef8 100644 --- a/packages/web-app/lib/constants/sepolia.tsx +++ b/packages/web-app/lib/constants/sepolia.tsx @@ -6,6 +6,6 @@ export const NATION = "0x23Ca3002706b71a440860E3cf8ff64679A00C9d7"; export const frameworkAddress = "0x1dBEFF62DFa113f7254AaB5772F1AC6E66F94e7e"; export const arbitratorAddress = "0xBe67cEdCD1FE38aac8a5781A51250FDeFB344E6C"; export const cohortAddress = "0xfbb66bc799308435ed2a0e0c0ac3ad1d46749b7b"; -export const safeTxServiceUrl = "https://safe-transaction-mainnet.safe.global"; -export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL; +export const safeTxServiceUrl = "https://safe-transaction-sepolia.safe.global"; +export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL_SEPOLIA; export const appealCost = BigNumber.from("1000000000000000000"); From 8a790d4511946f37a109b9b94405bd3d3659babd Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 13:27:42 +0700 Subject: [PATCH 3/9] lint --- packages/web-app/components/layout/Layout.tsx | 2 +- packages/web-app/components/layout/TopBar.tsx | 2 +- packages/web-app/hooks/useTokenList.tsx | 178 +++++++++--------- packages/web-app/lib/connectors.tsx | 144 +++++++------- packages/web-app/lib/constants/index.tsx | 40 ++-- packages/web-app/lib/constants/sepolia.tsx | 1 - 6 files changed, 183 insertions(+), 184 deletions(-) diff --git a/packages/web-app/components/layout/Layout.tsx b/packages/web-app/components/layout/Layout.tsx index 5a2a1ae6..11d957f2 100644 --- a/packages/web-app/components/layout/Layout.tsx +++ b/packages/web-app/components/layout/Layout.tsx @@ -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; diff --git a/packages/web-app/components/layout/TopBar.tsx b/packages/web-app/components/layout/TopBar.tsx index d2b2363b..0986052d 100644 --- a/packages/web-app/components/layout/TopBar.tsx +++ b/packages/web-app/components/layout/TopBar.tsx @@ -68,4 +68,4 @@ export const TopBar = () => { ); -}; \ No newline at end of file +}; diff --git a/packages/web-app/hooks/useTokenList.tsx b/packages/web-app/hooks/useTokenList.tsx index b6fae1eb..e59aad03 100644 --- a/packages/web-app/hooks/useTokenList.tsx +++ b/packages/web-app/hooks/useTokenList.tsx @@ -3,112 +3,112 @@ import { useNetwork } from "wagmi"; import { Token } from "../components/agreementCreate/context/types"; const mainnetTokens = [ - { - name: "Nation3", - symbol: "NATION", - address: "0x333A4823466879eeF910A04D473505da62142069", - decimals: 18, - icon: "/tokens/nation3.png", - }, - { - name: "Wrapped Ether", - symbol: "WETH", - address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", - decimals: 18, - icon: "/tokens/weth.png", - }, - { - name: "Dai Stablecoin", - symbol: "DAI", - address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", - decimals: 18, - icon: "/tokens/dai.png", - }, - { - name: "Aragon Network Token", - symbol: "ANT", - address: "0xa117000000f279D81A1D3cc75430fAA017FA5A2e", - decimals: 18, - icon: "/tokens/ant.png", - }, + { + name: "Nation3", + symbol: "NATION", + address: "0x333A4823466879eeF910A04D473505da62142069", + decimals: 18, + icon: "/tokens/nation3.png", + }, + { + name: "Wrapped Ether", + symbol: "WETH", + address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + decimals: 18, + icon: "/tokens/weth.png", + }, + { + name: "Dai Stablecoin", + symbol: "DAI", + address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", + decimals: 18, + icon: "/tokens/dai.png", + }, + { + name: "Aragon Network Token", + symbol: "ANT", + address: "0xa117000000f279D81A1D3cc75430fAA017FA5A2e", + decimals: 18, + icon: "/tokens/ant.png", + }, ]; const goerliTokens = [ - { - name: "Nation3", - symbol: "NATION", - address: "0x333A4823466879eeF910A04D473505da62142069", - decimals: 18, - icon: "/tokens/nation3.png", - }, - { - name: "Wrapped Ether", - symbol: "WETH", - address: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", - decimals: 18, - icon: "/tokens/weth.png", - }, + { + name: "Nation3", + symbol: "NATION", + address: "0x333A4823466879eeF910A04D473505da62142069", + decimals: 18, + icon: "/tokens/nation3.png", + }, + { + name: "Wrapped Ether", + symbol: "WETH", + address: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + decimals: 18, + icon: "/tokens/weth.png", + }, ]; 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", - }, + { + 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: "?", - address: "", - decimals: 18, - icon: "", + name: "?", + symbol: "?", + address: "", + decimals: 18, + icon: "", }; export const useTokenList = (): Token[] => { - const { chain } = useNetwork(); + const { chain } = useNetwork(); - const tokens = useMemo(() => { - switch (chain?.id) { - case 1: - return mainnetTokens; - case 5: - return goerliTokens; - case 11155111: - return sepoliaTokens; - default: - return mainnetTokens; - } - }, [chain]); + const tokens = useMemo(() => { + switch (chain?.id) { + case 1: + return mainnetTokens; + case 5: + return goerliTokens; + case 11155111: + return sepoliaTokens; + default: + return mainnetTokens; + } + }, [chain]); - return tokens; + return tokens; }; export const useFindToken = (tokenSymbol: string): Token => { - const { chain } = useNetwork(); + const { chain } = useNetwork(); - const token = useMemo(() => { - switch (chain?.id) { - case 1: - 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); - } - }, [chain, tokenSymbol]); + const token = useMemo(() => { + switch (chain?.id) { + case 1: + 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); + } + }, [chain, tokenSymbol]); - return token ? token : empty; + return token ? token : empty; }; diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index b22c42b0..72a09a82 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -8,93 +8,93 @@ type FallbackProviderConfig = Omit // FIXME: Import from @wagmi/chains after wagmi core update const gnosis: Chain = { - id: 100, - name: "Gnosis", - network: "gnosis", - nativeCurrency: { - decimals: 18, - name: "Gnosis", - symbol: "xDAI", - }, - rpcUrls: { - default: "https://rpc.gnosischain.com", - public: "https://rpc.gnosischain.com", - }, - blockExplorers: { - etherscan: { - name: "Gnosisscan", - url: "https://gnosisscan.io/", - }, - default: { - name: "Gnosis Chain Explorer", - url: "https://blockscout.com/xdai/mainnet/", - }, - }, + id: 100, + name: "Gnosis", + network: "gnosis", + nativeCurrency: { + decimals: 18, + name: "Gnosis", + symbol: "xDAI", + }, + rpcUrls: { + default: "https://rpc.gnosischain.com", + public: "https://rpc.gnosischain.com", + }, + blockExplorers: { + etherscan: { + name: "Gnosisscan", + url: "https://gnosisscan.io/", + }, + default: { + name: "Gnosis Chain Explorer", + url: "https://blockscout.com/xdai/mainnet/", + }, + }, }; // Returns and alchemy provider based on the chain const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { - return (chain: Chain) => { - var apiKey: any; - switch (chain?.id) { - case 1: - apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY - case 5: - apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_GOERLI - case 11155111: - apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_SEPOLIA - default: - apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY - } - if (!apiKey || !chain.rpcUrls.alchemy) return null; + return (chain: Chain) => { + var apiKey: any; + switch (chain?.id) { + case 1: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + case 5: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_GOERLI; + case 11155111: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY_SEPOLIA; + default: + apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + } + if (!apiKey || !chain.rpcUrls.alchemy) return null; - return { - chain: { - ...chain, - rpcUrls: { - ...chain.rpcUrls, - default: `${chain.rpcUrls.alchemy}/${apiKey}`, - }, - } as Chain, - provider: () => { - const provider = new providers.AlchemyProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ); - return Object.assign(provider, { priority, stallTimeout, weight }); - }, - webSocketProvider: () => - new providers.AlchemyWebSocketProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ), - }; - }; + return { + chain: { + ...chain, + rpcUrls: { + ...chain.rpcUrls, + default: `${chain.rpcUrls.alchemy}/${apiKey}`, + }, + } as Chain, + provider: () => { + const provider = new providers.AlchemyProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ); + return Object.assign(provider, { priority, stallTimeout, weight }); + }, + webSocketProvider: () => + new providers.AlchemyWebSocketProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ), + }; + }; }; export const providersToUse = () => { - const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; - return providers; + const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; + return providers; }; export const chainsToUse = () => { - return [mainnet, gnosis, goerli, sepolia]; + return [mainnet, gnosis, goerli, sepolia]; }; export const { chains, provider, webSocketProvider } = configureChains( - chainsToUse(), - providersToUse(), + chainsToUse(), + providersToUse(), ); export const { connectors } = getDefaultWallets({ - appName: "Nation3 Court App", - chains, + appName: "Nation3 Court App", + chains, }); diff --git a/packages/web-app/lib/constants/index.tsx b/packages/web-app/lib/constants/index.tsx index db151b13..1b0dc42c 100644 --- a/packages/web-app/lib/constants/index.tsx +++ b/packages/web-app/lib/constants/index.tsx @@ -7,29 +7,29 @@ import * as sepolia from "./sepolia"; export { mainnet, goerli, sepolia }; export interface Constants { - permit2Address: `0x${string}`; - NATION: `0x${string}`; - frameworkAddress: `0x${string}`; - arbitratorAddress: `0x${string}`; - cohortAddress: `0x${string}`; - safeTxServiceUrl: string; - subgraphURI: string | undefined; - appealCost: BigNumber | undefined; + permit2Address: `0x${string}`; + NATION: `0x${string}`; + frameworkAddress: `0x${string}`; + arbitratorAddress: `0x${string}`; + cohortAddress: `0x${string}`; + safeTxServiceUrl: string; + subgraphURI: string | undefined; + appealCost: BigNumber | undefined; } const constants = (chainId: number) => { - switch (chainId) { - case 1: - return { ...mainnet }; - case 5: - return { ...goerli }; - case 11155111: - return { ...sepolia }; - case 100: - return { ...gnosis }; - default: - return { ...mainnet }; - } + switch (chainId) { + case 1: + return { ...mainnet }; + case 5: + return { ...goerli }; + case 11155111: + return { ...sepolia }; + case 100: + return { ...gnosis }; + default: + return { ...mainnet }; + } }; export default constants; diff --git a/packages/web-app/lib/constants/sepolia.tsx b/packages/web-app/lib/constants/sepolia.tsx index 2f115ef8..74322116 100644 --- a/packages/web-app/lib/constants/sepolia.tsx +++ b/packages/web-app/lib/constants/sepolia.tsx @@ -1,4 +1,3 @@ - import { BigNumber } from "ethers"; export const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; From 1bcf958fb5c748a7311ff9a6869d0b11d353ddab Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 13:33:45 +0700 Subject: [PATCH 4/9] lint --- packages/web-app/lib/connectors.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 72a09a82..984f9ab9 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -35,16 +35,20 @@ const gnosis: Chain = { // Returns and alchemy provider based on the chain const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { return (chain: Chain) => { - var apiKey: any; + 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; + break; default: apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + break; } if (!apiKey || !chain.rpcUrls.alchemy) return null; From 35a920d3ad8656206b46ff8ad34affe600430bca Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 13:34:32 +0700 Subject: [PATCH 5/9] fix: framework contract --- packages/web-app/lib/constants/sepolia.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web-app/lib/constants/sepolia.tsx b/packages/web-app/lib/constants/sepolia.tsx index 74322116..b784e925 100644 --- a/packages/web-app/lib/constants/sepolia.tsx +++ b/packages/web-app/lib/constants/sepolia.tsx @@ -2,7 +2,7 @@ import { BigNumber } from "ethers"; export const permit2Address = "0x000000000022D473030F116dDEE9F6B43aC78BA3"; export const NATION = "0x23Ca3002706b71a440860E3cf8ff64679A00C9d7"; -export const frameworkAddress = "0x1dBEFF62DFa113f7254AaB5772F1AC6E66F94e7e"; +export const frameworkAddress = "0xD96aA6e2568f4e9632D2A5234Bb8410ca7609a27"; export const arbitratorAddress = "0xBe67cEdCD1FE38aac8a5781A51250FDeFB344E6C"; export const cohortAddress = "0xfbb66bc799308435ed2a0e0c0ac3ad1d46749b7b"; export const safeTxServiceUrl = "https://safe-transaction-sepolia.safe.global"; From 5f53316c8a7fbcae8973f7f7402e81e5342b6ece Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 14:47:29 +0700 Subject: [PATCH 6/9] fix: simplify env variables --- packages/web-app/.env.sample | 4 +- packages/web-app/lib/connectors.tsx | 138 +++++++++------------ packages/web-app/lib/constants/gnosis.tsx | 2 +- packages/web-app/lib/constants/goerli.tsx | 2 +- packages/web-app/lib/constants/sepolia.tsx | 2 +- 5 files changed, 67 insertions(+), 81 deletions(-) diff --git a/packages/web-app/.env.sample b/packages/web-app/.env.sample index a85acb2a..21b23155 100644 --- a/packages/web-app/.env.sample +++ b/packages/web-app/.env.sample @@ -1,4 +1,4 @@ NEXT_PUBLIC_CHAIN="goerli" IPFS_API_TOKEN="" -GRAPH_API_URL="" -NEXT_PUBLIC_ALCHEMY_API_KEY="" \ No newline at end of file +NEXT_PUBLIC_GRAPH_API_URL="" +NEXT_PUBLIC_ALCHEMY_API_KEY="" diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 984f9ab9..1cbe8ea5 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -8,97 +8,83 @@ type FallbackProviderConfig = Omit // FIXME: Import from @wagmi/chains after wagmi core update const gnosis: Chain = { - id: 100, - name: "Gnosis", - network: "gnosis", - nativeCurrency: { - decimals: 18, - name: "Gnosis", - symbol: "xDAI", - }, - rpcUrls: { - default: "https://rpc.gnosischain.com", - public: "https://rpc.gnosischain.com", - }, - blockExplorers: { - etherscan: { - name: "Gnosisscan", - url: "https://gnosisscan.io/", - }, - default: { - name: "Gnosis Chain Explorer", - url: "https://blockscout.com/xdai/mainnet/", - }, - }, + id: 100, + name: "Gnosis", + network: "gnosis", + nativeCurrency: { + decimals: 18, + name: "Gnosis", + symbol: "xDAI", + }, + rpcUrls: { + default: "https://rpc.gnosischain.com", + public: "https://rpc.gnosischain.com", + }, + blockExplorers: { + etherscan: { + name: "Gnosisscan", + url: "https://gnosisscan.io/", + }, + default: { + name: "Gnosis Chain Explorer", + url: "https://blockscout.com/xdai/mainnet/", + }, + }, }; // Returns and alchemy provider based on the chain const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { - return (chain: Chain) => { - 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; - break; - default: - apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; - break; - } - if (!apiKey || !chain.rpcUrls.alchemy) return null; + return (chain: Chain) => { + let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + if (!apiKey || !chain.rpcUrls.alchemy) return null; - return { - chain: { - ...chain, - rpcUrls: { - ...chain.rpcUrls, - default: `${chain.rpcUrls.alchemy}/${apiKey}`, - }, - } as Chain, - provider: () => { - const provider = new providers.AlchemyProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ); - return Object.assign(provider, { priority, stallTimeout, weight }); - }, - webSocketProvider: () => - new providers.AlchemyWebSocketProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ), - }; - }; + return { + chain: { + ...chain, + rpcUrls: { + ...chain.rpcUrls, + default: `${chain.rpcUrls.alchemy}/${apiKey}`, + }, + } as Chain, + provider: () => { + const provider = new providers.AlchemyProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ); + return Object.assign(provider, { priority, stallTimeout, weight }); + }, + webSocketProvider: () => + new providers.AlchemyWebSocketProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ), + }; + }; }; export const providersToUse = () => { - const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; - return providers; + const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; + return providers; }; export const chainsToUse = () => { - return [mainnet, gnosis, goerli, sepolia]; + return [mainnet, gnosis, goerli, sepolia]; }; export const { chains, provider, webSocketProvider } = configureChains( - chainsToUse(), - providersToUse(), + chainsToUse(), + providersToUse(), ); export const { connectors } = getDefaultWallets({ - appName: "Nation3 Court App", - chains, + appName: "Nation3 Court App", + chains, }); diff --git a/packages/web-app/lib/constants/gnosis.tsx b/packages/web-app/lib/constants/gnosis.tsx index c99ff4a4..6b0a9410 100644 --- a/packages/web-app/lib/constants/gnosis.tsx +++ b/packages/web-app/lib/constants/gnosis.tsx @@ -6,5 +6,5 @@ export const frameworkAddress = "0xFE00E9555C3bB6c39B8632b1138C15c62a3bbE51"; export const arbitratorAddress = "0xF9319A6Cb2537b8499F7Ed4D32d8Ce40a791AAb0"; export const cohortAddress = "0x7A57010A9D664BB31FF30E5E23B8F2Edd5ED9544"; export const safeTxServiceUrl = "https://safe-transaction-gnosis-chain.safe.global/"; -export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL_GNOSIS; +export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL; export const appealCost = BigNumber.from("100000000000000000"); diff --git a/packages/web-app/lib/constants/goerli.tsx b/packages/web-app/lib/constants/goerli.tsx index 9c374c11..30b8eb4a 100644 --- a/packages/web-app/lib/constants/goerli.tsx +++ b/packages/web-app/lib/constants/goerli.tsx @@ -6,5 +6,5 @@ export const frameworkAddress = "0x710617547D96573520b5f38668168DaFDBD9EA83"; export const arbitratorAddress = "0x1dBEFF62DFa113f7254AaB5772F1AC6E66F94e7e"; export const cohortAddress = "0xD86B638A810fc0C811c6A27152744eEFFE7262C0"; export const safeTxServiceUrl = "https://safe-transaction-goerli.safe.global"; -export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL_GOERLI; +export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL; export const appealCost = BigNumber.from("100000000000000000"); diff --git a/packages/web-app/lib/constants/sepolia.tsx b/packages/web-app/lib/constants/sepolia.tsx index b784e925..9f84aab6 100644 --- a/packages/web-app/lib/constants/sepolia.tsx +++ b/packages/web-app/lib/constants/sepolia.tsx @@ -6,5 +6,5 @@ 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; +export const subgraphURI = process.env.NEXT_PUBLIC_GRAPH_API_URL; export const appealCost = BigNumber.from("1000000000000000000"); From 22e667a0b1b71ee4ab0f746be17781bb11b039e3 Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 14:49:32 +0700 Subject: [PATCH 7/9] lint --- packages/web-app/lib/connectors.tsx | 124 ++++++++++++++-------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 1cbe8ea5..a4939451 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -8,83 +8,83 @@ type FallbackProviderConfig = Omit // FIXME: Import from @wagmi/chains after wagmi core update const gnosis: Chain = { - id: 100, - name: "Gnosis", - network: "gnosis", - nativeCurrency: { - decimals: 18, - name: "Gnosis", - symbol: "xDAI", - }, - rpcUrls: { - default: "https://rpc.gnosischain.com", - public: "https://rpc.gnosischain.com", - }, - blockExplorers: { - etherscan: { - name: "Gnosisscan", - url: "https://gnosisscan.io/", - }, - default: { - name: "Gnosis Chain Explorer", - url: "https://blockscout.com/xdai/mainnet/", - }, - }, + id: 100, + name: "Gnosis", + network: "gnosis", + nativeCurrency: { + decimals: 18, + name: "Gnosis", + symbol: "xDAI", + }, + rpcUrls: { + default: "https://rpc.gnosischain.com", + public: "https://rpc.gnosischain.com", + }, + blockExplorers: { + etherscan: { + name: "Gnosisscan", + url: "https://gnosisscan.io/", + }, + default: { + name: "Gnosis Chain Explorer", + url: "https://blockscout.com/xdai/mainnet/", + }, + }, }; // Returns and alchemy provider based on the chain const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { - return (chain: Chain) => { - let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; - if (!apiKey || !chain.rpcUrls.alchemy) return null; + return (chain: Chain) => { + let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + if (!apiKey || !chain.rpcUrls.alchemy) return null; - return { - chain: { - ...chain, - rpcUrls: { - ...chain.rpcUrls, - default: `${chain.rpcUrls.alchemy}/${apiKey}`, - }, - } as Chain, - provider: () => { - const provider = new providers.AlchemyProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ); - return Object.assign(provider, { priority, stallTimeout, weight }); - }, - webSocketProvider: () => - new providers.AlchemyWebSocketProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ), - }; - }; + return { + chain: { + ...chain, + rpcUrls: { + ...chain.rpcUrls, + default: `${chain.rpcUrls.alchemy}/${apiKey}`, + }, + } as Chain, + provider: () => { + const provider = new providers.AlchemyProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ); + return Object.assign(provider, { priority, stallTimeout, weight }); + }, + webSocketProvider: () => + new providers.AlchemyWebSocketProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ), + }; + }; }; export const providersToUse = () => { - const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; - return providers; + const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; + return providers; }; export const chainsToUse = () => { - return [mainnet, gnosis, goerli, sepolia]; + return [mainnet, gnosis, goerli, sepolia]; }; export const { chains, provider, webSocketProvider } = configureChains( - chainsToUse(), - providersToUse(), + chainsToUse(), + providersToUse(), ); export const { connectors } = getDefaultWallets({ - appName: "Nation3 Court App", - chains, + appName: "Nation3 Court App", + chains, }); From 50a3e66bdab2725f680c9465c02d12c855e416a9 Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 14:58:39 +0700 Subject: [PATCH 8/9] fix: const apikey --- packages/web-app/lib/connectors.tsx | 124 ++++++++++++++-------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index a4939451..168248d4 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -8,83 +8,83 @@ type FallbackProviderConfig = Omit // FIXME: Import from @wagmi/chains after wagmi core update const gnosis: Chain = { - id: 100, - name: "Gnosis", - network: "gnosis", - nativeCurrency: { - decimals: 18, - name: "Gnosis", - symbol: "xDAI", - }, - rpcUrls: { - default: "https://rpc.gnosischain.com", - public: "https://rpc.gnosischain.com", - }, - blockExplorers: { - etherscan: { - name: "Gnosisscan", - url: "https://gnosisscan.io/", - }, - default: { - name: "Gnosis Chain Explorer", - url: "https://blockscout.com/xdai/mainnet/", - }, - }, + id: 100, + name: "Gnosis", + network: "gnosis", + nativeCurrency: { + decimals: 18, + name: "Gnosis", + symbol: "xDAI", + }, + rpcUrls: { + default: "https://rpc.gnosischain.com", + public: "https://rpc.gnosischain.com", + }, + blockExplorers: { + etherscan: { + name: "Gnosisscan", + url: "https://gnosisscan.io/", + }, + default: { + name: "Gnosis Chain Explorer", + url: "https://blockscout.com/xdai/mainnet/", + }, + }, }; // Returns and alchemy provider based on the chain const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { - return (chain: Chain) => { - let apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; - if (!apiKey || !chain.rpcUrls.alchemy) return null; + return (chain: Chain) => { + const apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + if (!apiKey || !chain.rpcUrls.alchemy) return null; - return { - chain: { - ...chain, - rpcUrls: { - ...chain.rpcUrls, - default: `${chain.rpcUrls.alchemy}/${apiKey}`, - }, - } as Chain, - provider: () => { - const provider = new providers.AlchemyProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ); - return Object.assign(provider, { priority, stallTimeout, weight }); - }, - webSocketProvider: () => - new providers.AlchemyWebSocketProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ), - }; - }; + return { + chain: { + ...chain, + rpcUrls: { + ...chain.rpcUrls, + default: `${chain.rpcUrls.alchemy}/${apiKey}`, + }, + } as Chain, + provider: () => { + const provider = new providers.AlchemyProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ); + return Object.assign(provider, { priority, stallTimeout, weight }); + }, + webSocketProvider: () => + new providers.AlchemyWebSocketProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ), + }; + }; }; export const providersToUse = () => { - const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; - return providers; + const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; + return providers; }; export const chainsToUse = () => { - return [mainnet, gnosis, goerli, sepolia]; + return [mainnet, gnosis, goerli, sepolia]; }; export const { chains, provider, webSocketProvider } = configureChains( - chainsToUse(), - providersToUse(), + chainsToUse(), + providersToUse(), ); export const { connectors } = getDefaultWallets({ - appName: "Nation3 Court App", - chains, + appName: "Nation3 Court App", + chains, }); From 84b321f499d4196c2cf0bc7df72ef15640a9d121 Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 15:01:04 +0700 Subject: [PATCH 9/9] fix: lint --- packages/web-app/lib/connectors.tsx | 124 ++++++++++++++-------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/packages/web-app/lib/connectors.tsx b/packages/web-app/lib/connectors.tsx index 168248d4..43982944 100644 --- a/packages/web-app/lib/connectors.tsx +++ b/packages/web-app/lib/connectors.tsx @@ -8,83 +8,83 @@ type FallbackProviderConfig = Omit // FIXME: Import from @wagmi/chains after wagmi core update const gnosis: Chain = { - id: 100, - name: "Gnosis", - network: "gnosis", - nativeCurrency: { - decimals: 18, - name: "Gnosis", - symbol: "xDAI", - }, - rpcUrls: { - default: "https://rpc.gnosischain.com", - public: "https://rpc.gnosischain.com", - }, - blockExplorers: { - etherscan: { - name: "Gnosisscan", - url: "https://gnosisscan.io/", - }, - default: { - name: "Gnosis Chain Explorer", - url: "https://blockscout.com/xdai/mainnet/", - }, - }, + id: 100, + name: "Gnosis", + network: "gnosis", + nativeCurrency: { + decimals: 18, + name: "Gnosis", + symbol: "xDAI", + }, + rpcUrls: { + default: "https://rpc.gnosischain.com", + public: "https://rpc.gnosischain.com", + }, + blockExplorers: { + etherscan: { + name: "Gnosisscan", + url: "https://gnosisscan.io/", + }, + default: { + name: "Gnosis Chain Explorer", + url: "https://blockscout.com/xdai/mainnet/", + }, + }, }; // Returns and alchemy provider based on the chain const customAlchemyProvider = ({ priority, stallTimeout, weight }: FallbackProviderConfig) => { - return (chain: Chain) => { - const apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; - if (!apiKey || !chain.rpcUrls.alchemy) return null; + return (chain: Chain) => { + const apiKey = process.env.NEXT_PUBLIC_ALCHEMY_API_KEY; + if (!apiKey || !chain.rpcUrls.alchemy) return null; - return { - chain: { - ...chain, - rpcUrls: { - ...chain.rpcUrls, - default: `${chain.rpcUrls.alchemy}/${apiKey}`, - }, - } as Chain, - provider: () => { - const provider = new providers.AlchemyProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ); - return Object.assign(provider, { priority, stallTimeout, weight }); - }, - webSocketProvider: () => - new providers.AlchemyWebSocketProvider( - { - chainId: chain.id, - name: chain.network, - ensAddress: chain.ens?.address, - }, - apiKey, - ), - }; - }; + return { + chain: { + ...chain, + rpcUrls: { + ...chain.rpcUrls, + default: `${chain.rpcUrls.alchemy}/${apiKey}`, + }, + } as Chain, + provider: () => { + const provider = new providers.AlchemyProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ); + return Object.assign(provider, { priority, stallTimeout, weight }); + }, + webSocketProvider: () => + new providers.AlchemyWebSocketProvider( + { + chainId: chain.id, + name: chain.network, + ensAddress: chain.ens?.address, + }, + apiKey, + ), + }; + }; }; export const providersToUse = () => { - const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; - return providers; + const providers = [customAlchemyProvider({ priority: 0 }), publicProvider({ priority: 1 })]; + return providers; }; export const chainsToUse = () => { - return [mainnet, gnosis, goerli, sepolia]; + return [mainnet, gnosis, goerli, sepolia]; }; export const { chains, provider, webSocketProvider } = configureChains( - chainsToUse(), - providersToUse(), + chainsToUse(), + providersToUse(), ); export const { connectors } = getDefaultWallets({ - appName: "Nation3 Court App", - chains, + appName: "Nation3 Court App", + chains, });