Skip to content

Commit

Permalink
feat: config mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzhenbin committed Jul 19, 2023
1 parent d04fe1f commit 23ceb85
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 29 deletions.
7 changes: 5 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
REACT_APP_CHAIN_ID="5167003"
REACT_APP_NETWORK_URL="https://wannsee-rpc.mxc.com"
REACT_APP_CHAIN_ID="18686"
REACT_APP_CHAIN_ID_HEX="0x48fe"
REACT_APP_CHAIN_NAME="zkEVM Mainnet"
REACT_APP_CHAIN_EXPLORER="https://explorer.mxc.com/"
REACT_APP_NETWORK_URL="https://rpc.mxc.com/"
5 changes: 5 additions & 0 deletions .env.mainnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REACT_APP_CHAIN_ID="18686"
REACT_APP_CHAIN_ID_HEX="0x48fe"
REACT_APP_CHAIN_NAME="zkEVM Mainnet"
REACT_APP_CHAIN_EXPLORER="https://explorer.mxc.com/"
REACT_APP_NETWORK_URL="https://rpc.mxc.com/"
5 changes: 5 additions & 0 deletions .env.testnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
REACT_APP_CHAIN_ID="5167003"
REACT_APP_CHAIN_ID_HEX="0x4ed79b"
REACT_APP_CHAIN_NAME="Wannsee"
REACT_APP_CHAIN_EXPLORER="https://wannsee-explorer.mxc.com/"
REACT_APP_NETWORK_URL="https://wannsee-rpc.mxc.com"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ cypress/videos
cypress/screenshots
cypress/fixtures/example.json
.vercel
vercel.*
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
"integration-test": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'"
"integration-test": "start-server-and-test 'serve build -l 3000' http://localhost:3000 'cypress run'",
"vercel:mainnet": "cp vercel.mainnet.json .vercel/project.json && cp .env.mainnet .env && vercel --prod",
"vercel:testnet": "cp vercel.testnet.json .vercel/project.json && cp .env.testnet .env && vercel --prod"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
5 changes: 2 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://mxc.instatus.com/en/13076080/widget/script.js">
</script>
<script src="https://mxc.instatus.com/en/13076080/widget/script.js"></script>
<meta charset="utf-8" />
<link rel="shortcut icon" type="image/png" href="%PUBLIC_URL%/favicon.png" />
<link rel="apple-touch-icon" sizes="192x192" href="%PUBLIC_URL%/favicon.png" />
Expand All @@ -27,7 +26,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->

<title>Wannsee Swap</title>
<title>MXC Swap</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
5 changes: 3 additions & 2 deletions src/components/AccountDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Identicon from '../Identicon'
import { ButtonSecondary } from '../Button'
import { ExternalLink as LinkIcon } from 'react-feather'
import { ExternalLink, LinkStyledButton, TYPE } from '../../theme'
const chainName = process.env.REACT_APP_CHAIN_NAME

const HeaderRow = styled.div`
${({ theme }) => theme.flexRowNoWrap};
Expand Down Expand Up @@ -358,7 +359,7 @@ export default function AccountDetails({
href={chainId && getEtherscanLink(chainId, ENSName, 'address')}
>
<LinkIcon size={16} />
<span style={{ marginLeft: '4px' }}>View on Wannsee Explorer</span>
<span style={{ marginLeft: '4px' }}>View on {chainName} Explorer</span>
</AddressLink>
)}
</div>
Expand All @@ -380,7 +381,7 @@ export default function AccountDetails({
href={getEtherscanLink(chainId, account, 'address')}
>
<LinkIcon size={16} />
<span style={{ marginLeft: '4px' }}>View on Wannsee Explorer</span>
<span style={{ marginLeft: '4px' }}>View on {chainName} Explorer</span>
</AddressLink>
)}
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ const NETWORK_LABELS: { [chainId in ChainId]: string | null } = {
[ChainId.GÖRLI]: 'Görli',
[ChainId.KOVAN]: 'Kovan',
[ChainId.WANNSEE]: 'Wannsee',
[ChainId.GANACHE]: 'Ganache'
[ChainId.WANNSEEMAINNET]: 'zkEVM Mainnet',
[ChainId.GANACHE]: 'Ganache',
[ChainId.HARDHAT]: 'Hardhat'
}

export default function Header() {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ export default function Menu() {
<MessageCircle size={14} />
Discord
</MenuItem>
<MenuItem id="link" href="https://uniswap.info/">
{/* <MenuItem id="link" href="https://wannsee-swap-info.mxc.com/">
<PieChart size={14} />
Analytics
</MenuItem> */}
<MenuItem id="link" href="https://swap-info.mxc.com/">
<PieChart size={14} />
Analytics
</MenuItem>
Expand Down
21 changes: 13 additions & 8 deletions src/components/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import { OVERLAY_READY } from '../../connectors/Fortmatic'
import { WalletConnectConnector } from '@web3-react/walletconnect-connector'
import { AbstractConnector } from '@web3-react/abstract-connector'

const chainName = process.env.REACT_APP_CHAIN_NAME || ''
const chainIDHex = process.env.REACT_APP_CHAIN_ID_HEX || ''
const chainRPC = process.env.REACT_APP_NETWORK_URL || ''
const explorer = process.env.REACT_APP_CHAIN_EXPLORER || ''

const CloseIcon = styled.div`
position: absolute;
right: 1rem;
Expand Down Expand Up @@ -295,7 +300,7 @@ export default function WalletModal({
method: 'wallet_switchEthereumChain',
params: [
{
chainId: '0x4ed79b'
chainId: chainIDHex
}
]
})
Expand All @@ -311,15 +316,15 @@ export default function WalletModal({
method: 'wallet_addEthereumChain',
params: [
{
chainId: '0x4ed79b',
rpcUrls: ['https://wannsee-rpc.mxc.com/'],
chainName: 'wannsee',
chainId: chainIDHex,
rpcUrls: [chainRPC],
chainName,
nativeCurrency: {
name: 'MXC',
symbol: 'MXC',
decimals: 18
},
blockExplorerUrls: ['https://wannsee-explorer.mxc.com/']
blockExplorerUrls: [explorer]
}
]
})
Expand All @@ -338,12 +343,12 @@ export default function WalletModal({
{error instanceof UnsupportedChainIdError ? (
// <h5>Please connect to the appropriate Ethereum network.</h5>
<>
<h5>Please connect to the appropriate Wannsee network.</h5>
<h5>Please connect to the appropriate {chainName} network.</h5>
<ButtonPrimary onClick={switchChain} style={{ marginBottom: '10px' }}>
Switch MXC Network
Switch {chainName} Network
</ButtonPrimary>
<ButtonPrimary onClick={addChain} className="btns">
Add MXC Network
Add {chainName} Network
</ButtonPrimary>
</>
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function getNetworkLibrary(): Web3Provider {

export const injected = new InjectedConnector({
// supportedChainIds: [1, 3, 4, 5, 42]
supportedChainIds: [5167003, 1337]
supportedChainIds: [5167003, 1337, 31337, 18686]
})

// mainnet only
Expand Down
12 changes: 10 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { AbstractConnector } from '@web3-react/abstract-connector'

import { fortmatic, injected, portis, walletconnect, walletlink } from '../connectors'

export const ROUTER_ADDRESS = '0xCaf6FE52B3b2948EFe7EA72C1ffd0B49C5FB030E'
// wannsee
// export const ROUTER_ADDRESS = '0xCaf6FE52B3b2948EFe7EA72C1ffd0B49C5FB030E'
// hardhat
// export const ROUTER_ADDRESS = '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'
// wannsee-mainnet
export const ROUTER_ADDRESS = '0x757e5af94fC9b3d4035C2e6Cb1fD304F43c0A1A4'


// a list of tokens by chain
type ChainTokenList = {
Expand All @@ -24,7 +30,9 @@ const WETH_ONLY: ChainTokenList = {
[ChainId.GÖRLI]: [WETH[ChainId.GÖRLI]],
[ChainId.KOVAN]: [WETH[ChainId.KOVAN]],
[ChainId.WANNSEE]: [WETH[ChainId.WANNSEE]],
[ChainId.GANACHE]: [WETH[ChainId.GANACHE]]
[ChainId.WANNSEEMAINNET]: [WETH[ChainId.WANNSEEMAINNET]],
[ChainId.GANACHE]: [WETH[ChainId.GANACHE]],
[ChainId.HARDHAT]: [WETH[ChainId.HARDHAT]]
}

// used to construct intermediary pairs for trading
Expand Down
3 changes: 2 additions & 1 deletion src/constants/lists.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// the Uniswap Default token list lives here
// export const DEFAULT_TOKEN_LIST_URL = 'tokens.uniswap.eth'
export const DEFAULT_TOKEN_LIST_URL =
'https://raw.githubusercontent.com/MXCzkEVM/wannseeswap-tokenlist/main/tokenlist.json?version=7'
'https://raw.githubusercontent.com/MXCzkEVM/wannseeswap-tokenlist/main/tokenlist-mainnet.json?version=1'
// 'https://raw.githubusercontent.com/MXCzkEVM/wannseeswap-tokenlist/main/tokenlist.json?version=7'
// https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json

// export const DEFAULT_LIST_OF_LISTS: string[] = [
Expand Down
4 changes: 3 additions & 1 deletion src/constants/multicall/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const MULTICALL_NETWORKS: { [chainId in ChainId]: string } = {
[ChainId.RINKEBY]: '0x42Ad527de7d4e9d9d011aC45B31D8551f8Fe9821',
[ChainId.GÖRLI]: '0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e',
[ChainId.WANNSEE]: '0x8aE2B89eA3d9fe8E214698D78aCce5614F492087',
[ChainId.GANACHE]: '0xad34a1e01f26250894FC463e68De7ffcE83DE2aF'
[ChainId.GANACHE]: '0xad34a1e01f26250894FC463e68De7ffcE83DE2aF',
[ChainId.HARDHAT]: '0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0',
[ChainId.WANNSEEMAINNET]: '0xbf5c081C000a02c07BC9a6141a7bfC6E85259946'
}

export { MULTICALL_ABI, MULTICALL_NETWORKS }
2 changes: 2 additions & 0 deletions src/constants/v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const V1_FACTORY_ADDRESSES: { [chainId in ChainId]: string } = {
[ChainId.GÖRLI]: '0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA',
[ChainId.KOVAN]: '0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30',
[ChainId.WANNSEE]: '0x86f515845c3451742d1dB85B77Fd53f83fA1D393',
[ChainId.WANNSEEMAINNET]: '0x8bC7cf83f5F83781Ec85B78d866222987Ae24657',
[ChainId.GANACHE]: '0x6FA34D533Ed090ED1Bb76f4ed9FBB201D51Dc25D',
[ChainId.HARDHAT]: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
}

const V1_FACTORY_INTERFACE = new Interface(V1_FACTORY_ABI)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RemoveLiquidity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function RemoveLiquidity({
{ name: 'verifyingContract', type: 'address' }
]
const domain = {
name: 'Uniswap V2',
name: 'Wannsee LPs',
version: '1',
chainId: chainId,
verifyingContract: pair.liquidityToken.address
Expand Down
4 changes: 3 additions & 1 deletion src/state/lists/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const EMPTY_LIST: TokenAddressMap = {
[ChainId.GÖRLI]: {},
[ChainId.MAINNET]: {},
[ChainId.WANNSEE]: {},
[ChainId.GANACHE]: {}
[ChainId.WANNSEEMAINNET]: {},
[ChainId.GANACHE]: {},
[ChainId.HARDHAT]: {}
}

const listCache: WeakMap<TokenList, TokenAddressMap> | null =
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = {
5: 'goerli.',
42: 'kovan.',
5167003: 'wannsee-explorer.mxc.com',
1337: 'ganache'
18686: 'explorer.mxc.com',
1337: 'ganache',
31337: 'hardhat'
}

export function getEtherscanLink(chainId: ChainId, data: string, type: 'transaction' | 'token' | 'address'): string {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2575,9 +2575,9 @@
integrity sha512-2yK7sLpKIT91TiS5sewHtOa7YuM8IuBXVl4GZv2jZFys4D2sY7K5vZh6MqD25TPA95Od+0YzCVq6cTF2IKrOmg==

"@uniswap/sdk@npm:mxcswap-sdk":
version "1.0.5"
resolved "https://registry.npmmirror.com/mxcswap-sdk/-/mxcswap-sdk-1.0.5.tgz#bed43be3d277562ea342e17bc5fc4dda7b37a079"
integrity sha512-BC/QdHwE6zuWrVHo1ZiKEVrHzyCEsZtnnqnuqSIvpyGntfXI3BdqTXDG4RjCs5KEvkUy8iSOq/odNudwLqJtyA==
version "1.0.6"
resolved "https://registry.npmjs.org/mxcswap-sdk/-/mxcswap-sdk-1.0.6.tgz#d9747609c9efd4928059bbaaa121c8e0ae3cfee8"
integrity sha512-us3I51mwok/VWPuhXf0leQvFimKQhRuSJRliqLxa81K79Ov7Y3l6XjJJueAr0AOnvGZ3VlX4P36JfORlYn9i1g==
dependencies:
"@uniswap/v2-core" "^1.0.0"
big.js "^5.2.2"
Expand Down

1 comment on commit 23ceb85

@vercel
Copy link

@vercel vercel bot commented on 23ceb85 Jul 19, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.