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

usePoolRegistry wagmi #1239

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
779 changes: 754 additions & 25 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@mui/lab": "^5.0.0-alpha.76",
"@mui/material": "^5.4.0",
"@mui/x-date-pickers": "^5.0.0-alpha.2",
"@rainbow-me/rainbowkit": "^0.4.6",
"@reduxjs/toolkit": "^1.4.0",
"@sentry/react": "^6.16.1",
"@sentry/tracing": "^6.16.1",
Expand All @@ -36,13 +37,14 @@
"copy-to-clipboard": "^3.3.1",
"date-fns": "^2.29.1",
"ethcall": "^4.6.3",
"ethers": "^5.5.3",
"ethers": "^5.6.9",
"framer-motion": "^4.0.3",
"history": "^5.0.0",
"i18next": "^19.8.3",
"i18next-browser-languagedetector": "^6.0.1",
"i18next-fetch-backend": "^3.0.0",
"lodash": "^4.17.20",
"lodash.merge": "^4.6.2",
"react": "^18.2.0",
"react-device-detect": "^2.2.2",
"react-dom": "^18.2.0",
Expand All @@ -54,6 +56,7 @@
"react-use-intercom": "^1.5.0",
"redux": "^4.1.0",
"redux-localstorage-simple": "^2.4.0",
"wagmi": "^0.6.3",
"web-vitals": "^2.1.4"
},
"devDependencies": {
Expand All @@ -72,6 +75,7 @@
"@testing-library/user-event": "^13.5.0",
"@typechain/ethers-v5": "^6.0.5",
"@types/async-retry": "^1.4.2",
"@types/lodash.merge": "^4.6.7",
"@types/react-dom": "^18.0.6",
"@typescript-eslint/eslint-plugin": "^5.30.4",
"@typescript-eslint/parser": "^5.30.4",
Expand Down
148 changes: 148 additions & 0 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import {
Chain,
Wallet,
connectorsForWallets,
wallet,
} from "@rainbow-me/rainbowkit"
import {
chain,
configureChains,
createClient as createWagmiClient,
} from "wagmi"

import { ChainId } from "./index"
import { InjectedConnector } from "wagmi/connectors/injected"
import { alchemyProvider } from "wagmi/providers/alchemy"
import { hexlify } from "@ethersproject/bytes"
import { publicProvider } from "wagmi/providers/public"
import tallyIcon from "../assets/icons/tally.svg"

export const NETWORK_LABEL: Partial<Record<ChainId, string>> = {
[ChainId.MAINNET]: "Ethereum",
Expand Down Expand Up @@ -149,3 +165,135 @@ export const DEV_SUPPORTED_NETWORKS: SupportedNetworks = {
blockExplorerUrls: ["https://explorer.evm-alpha.kava.io"],
},
}

const evmosChain: Chain = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Config for wagmi connection.

id: ChainId.EVMOS,
iconUrl:
"https://assets.coingecko.com/coins/images/24023/small/evmos.png?1653958927",
iconBackground: "#fff",
name: "Evmos",
nativeCurrency: {
name: "Evmos",
symbol: "EVMOS",
decimals: 18,
},
network: "evmos",
rpcUrls: { default: "https://eth.bd.evmos.org:8545" },
blockExplorers: {
default: { name: "Evmos", url: "https://evm.evmos.org" },
},
testnet: false,
}
const fantomChain: Chain = {
id: ChainId.FANTOM,
iconUrl:
"https://assets.coingecko.com/coins/images/4001/small/Fantom.png?1558015016",
iconBackground: "#fff",
name: "Fantom",
nativeCurrency: {
name: "Fantom",
symbol: "FTM",
decimals: 18,
},
network: "evmos",
rpcUrls: { default: "https://rpc.ftm.tools" },
blockExplorers: {
default: { name: "Fantom Scan", url: "https://ftmscan.com" },
},
testnet: false,
}
const kavaChain: Chain = {
id: ChainId.KAVA,
iconUrl:
"https://assets.coingecko.com/coins/images/9761/small/kava.jpg?1639703080",
iconBackground: "#fff",
name: "Kava",
nativeCurrency: {
name: "Kava",
symbol: "KAVA",
decimals: 18,
},
network: "kava",
rpcUrls: { default: "https://evm.kava.io" },
blockExplorers: {
default: { name: "Kava", url: "https://explorer.kava.io" },
},
testnet: false,
}

export const rainbowChains = [
chain.mainnet,
chain.optimism,
chain.arbitrum,
chain.hardhat,
evmosChain,
fantomChain,
kavaChain,
]

export const { chains, provider } = configureChains(rainbowChains, [
alchemyProvider({ apiKey: process.env.ALCHEMY_API_KEY }),
publicProvider(),
])

const tallyConnector = new InjectedConnector({
chains: [chain.mainnet],
options: {
shimDisconnect: true,
name: (detectedName) =>
`Injected (${
typeof detectedName === "string"
? detectedName
: detectedName.join(", ")
})`,
},
})

const tally = (): Wallet => ({
id: "tally-wallet",
name: "Tally Wallet",
iconUrl: tallyIcon,
iconBackground: "#0c2f78",
downloadUrls: {
browserExtension: "https://tally.cash/download",
},
createConnector: () => {
const connector = tallyConnector
return {
connector: connector,
}
},
})

const needsInjectedWalletFallback =
typeof window !== "undefined" &&
!window.ethereum?.isMetaMask &&
!window.ethereum?.isTally

const connectors = connectorsForWallets([
{
groupName: "Recommended",
wallets: [
wallet.metaMask({ chains }),
wallet.rainbow({ chains }),
wallet.walletConnect({ chains }),
wallet.brave({ chains }),
wallet.coinbase({ appName: "Saddle", chains }),
wallet.ledger({ chains }),
tally(),
...(needsInjectedWalletFallback
? [wallet.injected({ chains: [chain.mainnet] })]
: []),
],
},
])

export const wagmiClient = createWagmiClient({
autoConnect: true,
connectors,
provider,
})

export interface MyWalletOptions {
chains: Chain[]
}
Loading