Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
TTNguyenDev committed Feb 28, 2024
1 parent 0cc7af0 commit 8a790d4
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 184 deletions.
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>
);
};
};
178 changes: 89 additions & 89 deletions packages/web-app/hooks/useTokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
144 changes: 72 additions & 72 deletions packages/web-app/lib/connectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,93 +8,93 @@ type FallbackProviderConfig = Omit<providers.FallbackProviderConfig, "provider">

// 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,
});
Loading

0 comments on commit 8a790d4

Please sign in to comment.