From 8a790d4511946f37a109b9b94405bd3d3659babd Mon Sep 17 00:00:00 2001 From: TTNguyenDev Date: Wed, 28 Feb 2024 13:27:42 +0700 Subject: [PATCH] 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";