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

Replace library of useActiveWeb3React with wagmi hook #1374

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5d7f6ac
Add wagmi config and Rainbowkit provider
nkrulikovsky May 10, 2023
e097eae
update wagmi and rainbowkit version and updated config file of wagmi
nkrulikovsky May 13, 2023
b09e16d
Merge branch 'rainbowkit-integration' into wagmi-provider
nkrulikovsky May 13, 2023
5b773ab
feat: Replace Wallet connect button using Rainbotkit ConnectButton
nkrulikovsky May 14, 2023
0c6068f
Update package.json and config.ts to use updated versions of "@rainb…
nkrulikovsky May 17, 2023
e9440ee
Merge branch 'wagmi-provider' into rainbowkit-integration
nkrulikovsky May 17, 2023
5bac88e
Merge branch 'rainbowkit-integration' into update-walletconnect-button
nkrulikovsky May 17, 2023
f91dbed
update useActiveWeb3React with wagmi hook
nkrulikovsky May 20, 2023
7aeebe2
Update useActiveWeb3React with wagmi hook
nkrulikovsky May 21, 2023
b8043fe
remove web3-react completely
nkrulikovsky May 21, 2023
f19c260
ci updte
nkrulikovsky May 22, 2023
946b8d0
Merge branch 'rainbowkit-integration' into replace-library-on-useActi…
nkrulikovsky May 22, 2023
e57a628
Refactor Web3Status component to conditionally render IconButton or B…
nkrulikovsky May 26, 2023
d24c959
replace library of useActiveWeb3React with signer or provider from wa…
nkrulikovsky May 26, 2023
2657d91
Refactor useContract hook to useActiveWeb3React instead of individual…
nkrulikovsky May 29, 2023
b4be8b2
Re Add Sentry initialization in index.tsx to enable error tracking an…
nkrulikovsky May 29, 2023
66f7e26
Refactor AppContainer and Pools components to remove unused imports a…
nkrulikovsky May 29, 2023
77d9c25
Add back error handling for missing childGaugeFactoryAddress in buil…
nkrulikovsky May 29, 2023
15aa133
Refactor usePoolRegistryMultiCall to useActiveWeb3React for signerOrP…
nkrulikovsky May 29, 2023
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
12,650 changes: 7,671 additions & 4,979 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,12 @@
"@types/react": "^17.0.38",
"@types/react-redux": "^7.1.11",
"@types/react-router-dom": "^5.3.3",
"@uauth/web3-react": "^1.0.0",
"@web3-react/abstract-connector": "^6.0.7",
"@web3-react/core": "^6.1.9",
"@web3-react/injected-connector": "^6.0.7",
"@web3-react/network-connector": "^6.1.9",
"@web3-react/types": "^6.0.7",
"@web3-react/walletconnect-connector": "^6.2.13",
"@web3-react/walletlink-connector": "^6.2.5",
"async-retry": "^1.3.1",
"classnames": "^2.3.1",
"copy-to-clipboard": "^3.3.1",
"date-fns": "^2.29.3",
"ethcall": "^4.8.13",
"ethers": "^5.5.3",
"ethers": "^5.7.2",
"framer-motion": "^4.0.3",
"history": "^5.0.0",
"i18next": "^19.8.3",
Expand Down
4 changes: 1 addition & 3 deletions src/components/AccountDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import { getMultichainScanLink } from "../utils/getEtherscanLink"
import { shortenAddress } from "../utils/shortenAddress"
import { useTheme } from "@mui/material/styles"
import { useTranslation } from "react-i18next"
import { useUDName } from "../hooks/useUDName"

export default function AccountDetail(): ReactElement {
const { t } = useTranslation()
const { address, connector } = useAccount()
const { chain } = useNetwork()
const { disconnect } = useDisconnect()
const userState = useContext(UserStateContext)
const udName = useUDName()

const nativeToken = chain?.nativeCurrency
const chainId = chain?.id
Expand Down Expand Up @@ -72,7 +70,7 @@ export default function AccountDetail(): ReactElement {
<Stack direction="row" spacing={1}>
<Identicon />
<Typography variant="subtitle1">
{udName || (address && shortenAddress(address))}
{address && shortenAddress(address)}
</Typography>
{chainId && address && (
<Link
Expand Down
82 changes: 0 additions & 82 deletions src/components/ConnectWallet.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions src/components/DepositPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const DepositPage = (props: Props): ReactElement => {
onConfirmTransaction,
onToggleDepositWrapped,
} = props
const { account, chainId, library } = useActiveWeb3React()
const { account, chainId, signerOrProvider } = useActiveWeb3React()
const { unstakeMinichef, amountStakedMinichef } = useRewardsHelpers(
poolData?.name ?? "",
)
Expand All @@ -100,18 +100,18 @@ const DepositPage = (props: Props): ReactElement => {
const gaugesAreActive = areGaugesActive(chainId)

useEffect(() => {
if (!library || !account || !chainId || !poolData || !gaugeAddr) {
if (!account || !chainId || !poolData || !gaugeAddr) {
setLiquidityGaugeContract(null)
return
}
const liquidityGaugeContract = getContract(
gaugeAddr,
LIQUIDITY_GAUGE_V5_ABI,
library,
signerOrProvider,
account,
) as LiquidityGaugeV5
setLiquidityGaugeContract(liquidityGaugeContract)
}, [library, account, chainId, poolData, gauges, gaugeAddr])
}, [account, chainId, poolData, gaugeAddr, signerOrProvider])

const onMigrateToGaugeClick = async () => {
if (
Expand Down
44 changes: 1 addition & 43 deletions src/components/SiteSettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ import {
MenuItem as MuiMenuItem,
styled,
} from "@mui/material"
import {
ChainId,
DEV_SUPPORTED_NETWORKS,
SUPPORTED_NETWORKS,
} from "../constants/networks"
import {
ExpandLess,
ExpandMore,
Expand All @@ -23,11 +18,9 @@ import {
} from "@mui/icons-material"
import { IS_SDL_LIVE, SDL_TOKEN } from "../constants"
import React, { ReactElement, useState } from "react"
import { extractAddEthereumChainArgs, getTokenIconPath } from "../utils"

import CheckIcon from "@mui/icons-material/Check"
import { IS_DEVELOPMENT } from "../utils/environment"
import { useActiveWeb3React } from "../hooks"
import { getTokenIconPath } from "../utils"
import useAddTokenToMetamask from "../hooks/useAddTokenToMetamask"
import { useThemeSettings } from "../providers/ThemeSettingsProvider"
import { useTranslation } from "react-i18next"
Expand Down Expand Up @@ -98,13 +91,7 @@ function AddTokenSection(): ReactElement | null {

function NetworkSection(): ReactElement {
const { t } = useTranslation()
const { chainId: activeChainId, library, account } = useActiveWeb3React()
const [isNetworkVisible, setIsNetworkVisible] = useState(false)
const networks = (
IS_DEVELOPMENT
? Object.values(DEV_SUPPORTED_NETWORKS)
: Object.values(SUPPORTED_NETWORKS)
).sort((a, b) => a.chainName.localeCompare(b.chainName))

return (
<div data-testid="networkMenuContainer">
Expand All @@ -114,35 +101,6 @@ function NetworkSection(): ReactElement {
>
{t("network")} {isNetworkVisible ? <ExpandLess /> : <ExpandMore />}
</MenuItem>
<Collapse in={isNetworkVisible}>
{networks.map((network) => {
return network ? (
<ListItemButton
onClick={() => {
if (Number(network.chainId) === ChainId.MAINNET) {
void library?.send("wallet_switchEthereumChain", [
{ chainId: "0x1" },
account,
])
} else {
void library?.send("wallet_addEthereumChain", [
extractAddEthereumChainArgs(network),
account,
])
}
}}
key={network.chainId}
>
<ListItemIcon sx={{ ml: 2 }}>
{activeChainId === Number(network.chainId) && (
<CheckIcon fontSize="small" />
)}
</ListItemIcon>
<ListItemText primary={network?.chainName} />
</ListItemButton>
) : null
})}
</Collapse>
</div>
)
}
Expand Down
65 changes: 0 additions & 65 deletions src/components/Web3ReactManager/index.tsx

This file was deleted.

40 changes: 23 additions & 17 deletions src/components/Web3Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,34 @@ const Web3Status = (): ReactElement => {
>
{connected ? account.displayName : "Connect Wallet"}
</Button>
<IconButton
onClick={openChainModal}
sx={{
minWidth: 0,
padding: 0.5,
backgroundColor: theme.palette.background.default,
borderRadius: theme.spacing(1),
}}
>
{chain.hasIcon && chain.iconUrl && (
<img
alt={chain.name ?? "Chain icon"}
src={chain.iconUrl}
/>
)}
</IconButton>
{chain.hasIcon ? (
<IconButton
onClick={openChainModal}
sx={{
minWidth: 0,
padding: 0.5,
backgroundColor: theme.palette.background.default,
borderRadius: theme.spacing(1),
}}
>
{chain.hasIcon && chain.iconUrl && (
<img
alt={chain.name ?? "Chain icon"}
src={chain.iconUrl}
/>
)}
</IconButton>
) : (
<Button variant="outlined" onClick={openChainModal}>
{chain.name}
</Button>
)}
</Box>
)
})()}

<Dialog
open={modalOpen}
open={modalOpen && !!account}
onClose={(): void => setModalOpen(false)}
maxWidth="sm"
fullWidth
Expand Down
9 changes: 4 additions & 5 deletions src/components/WrongNetworkModal.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { DialogContent, Typography } from "@mui/material"
import React, { ReactElement, useState } from "react"
import { UnsupportedChainIdError, useWeb3React } from "@web3-react/core"
import Dialog from "./Dialog"
import { Web3Provider } from "@ethersproject/providers"
import { useNetwork } from "wagmi"
import { useTranslation } from "react-i18next"

export default function WrongNetworkModal(): ReactElement {
const [open, setOpen] = useState<boolean | undefined>()
const { error } = useWeb3React<Web3Provider>()
const isUnsupportChainIdError = error instanceof UnsupportedChainIdError
const { chain } = useNetwork()
const unsupportedChain = chain?.unsupported
const { t } = useTranslation()

return (
<Dialog
open={open ?? isUnsupportChainIdError}
open={open ?? !!unsupportedChain}
maxWidth="xs"
onClose={() => setOpen(false)}
>
Expand Down
Loading