Skip to content

Commit

Permalink
Merge pull request #22 from pnetwork-association/feat/native-mode-only
Browse files Browse the repository at this point in the history
Feat/native mode only
  • Loading branch information
envin3 authored Dec 12, 2023
2 parents f6d35b9 + 5e311e0 commit a3237a6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
25 changes: 14 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dao-v2-ui",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"homepage": ".",
"dependencies": {
Expand Down
14 changes: 3 additions & 11 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ThemeContext } from 'styled-components'
import { createHashRouter, RouterProvider } from 'react-router-dom'
import { getDefaultWallets, RainbowKitProvider } from '@rainbow-me/rainbowkit'
import { configureChains, createClient, WagmiConfig, createStorage } from 'wagmi'
import { mainnet, polygon, bsc } from 'wagmi/chains'
import { polygon } from 'wagmi/chains'
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc'
import { getWeb3Settings } from 'react-web3-settings'

Expand Down Expand Up @@ -43,23 +43,15 @@ const router = createHashRouter([
const settings = getWeb3Settings()

const { chains, provider } = configureChains(
[mainnet, polygon, bsc],
[polygon],
[
jsonRpcProvider({
rpc: (chain) => ({
http:
chain.id === mainnet.id
? settings.rpcEndpoints && settings.rpcEndpoints[0] !== ''
? settings.rpcEndpoints[0]
: `https://eth-mainnet.alchemyapi.io/v2/${process.env.REACT_APP_ALCHEMY_ID}`
: chain.id === polygon.id
chain.id === polygon.id
? settings.rpcEndpoints && settings.rpcEndpoints[1] !== ''
? settings.rpcEndpoints[1]
: `https://polygon-mainnet.alchemyapi.io/v2/${process.env.REACT_APP_ALCHEMY_ID}`
: chain.id === bsc.id
? settings.rpcEndpoints && settings.rpcEndpoints[2] !== ''
? settings.rpcEndpoints[2]
: `https://bsc-mainnet.alchemyapi.io/v2/${process.env.REACT_APP_ALCHEMY_ID}`
: 'Unsupported Chain'
})
})
Expand Down
9 changes: 4 additions & 5 deletions src/components/complex/ChainModal/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fragment, useState, useEffect, useCallback } from 'react'
import { Row, Col } from 'react-bootstrap'
import { useChainId, useSwitchNetwork, useAccount } from 'wagmi'
import { useNetwork, useSwitchNetwork, useAccount } from 'wagmi'
import { polygon } from 'wagmi/chains'
import styled from 'styled-components'
import { FaInfoCircle } from 'react-icons/fa'
Expand Down Expand Up @@ -49,7 +49,7 @@ const StyledFaInfoCircle = styled(FaInfoCircle)`
`

const ChainModal = ({ show, onClose }) => {
const activeChainId = useChainId()
const activeNetwork = useNetwork()
const { chains, error: networkError, switchNetwork } = useSwitchNetwork()
const { connector: activeConnector } = useAccount()
const [switchingToChain, setSwitchingToChain] = useState(false)
Expand Down Expand Up @@ -91,7 +91,7 @@ const ChainModal = ({ show, onClose }) => {
<div className="p-1">
{switchNetwork ? (
chains.map((_chain) => {
const isCurrentChain = _chain.id === activeChainId
const isCurrentChain = _chain.id === activeNetwork.chain.id
const switching = _chain.id === switchingToChain

return (
Expand All @@ -118,8 +118,7 @@ const ChainModal = ({ show, onClose }) => {
<Tooltip
placement="bottom"
overlayType="popover"
text="The pNetwork DAO v2 is available natively on the Polygon chain, but can be used on other chains in compatibility mode.
Compatibility mode is currently available on the BNB chain and Ethereum."
text="The pNetwork DAO v2 is currently only available on the Polygon chain"
>
<div>
<StyledFaInfoCircle />
Expand Down
2 changes: 1 addition & 1 deletion src/components/complex/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const CustomConnectButton = () => {
if (chain.unsupported) {
return (
<Button onClick={() => setShowChainModal(true)} type="button">
Wrong network
Switch to Polygon
</Button>
)
}
Expand Down

0 comments on commit a3237a6

Please sign in to comment.