Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91a8202737 | ||
|
|
0b4819d165 | ||
|
|
e7d3289754 | ||
|
|
0698e0f82a | ||
|
|
0350cc4701 | ||
|
|
997052869d | ||
|
|
9ec16c2ba8 | ||
|
|
e2cf8f1642 | ||
|
|
ed6952d1f7 | ||
|
|
3277d70e93 | ||
|
|
d1a31fe763 | ||
|
|
f88af029ae | ||
|
|
9f3e49b4d8 | ||
|
|
d4911d1054 |
4
.github/workflows/release.yaml
vendored
4
.github/workflows/release.yaml
vendored
@@ -7,7 +7,7 @@ on:
|
|||||||
# releases are triggered on changes to this file
|
# releases are triggered on changes to this file
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v2
|
- master
|
||||||
paths:
|
paths:
|
||||||
- '.github/workflows/release.yaml'
|
- '.github/workflows/release.yaml'
|
||||||
- '.env.production'
|
- '.env.production'
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
run: yarn install --ignore-scripts --frozen-lockfile
|
run: yarn install --ignore-scripts --frozen-lockfile
|
||||||
|
|
||||||
- name: Build the IPFS bundle
|
- name: Build the IPFS bundle
|
||||||
run: yarn ipfs-build
|
run: yarn build
|
||||||
|
|
||||||
- name: Pin to IPFS
|
- name: Pin to IPFS
|
||||||
id: upload
|
id: upload
|
||||||
|
|||||||
4
.github/workflows/tests.yaml
vendored
4
.github/workflows/tests.yaml
vendored
@@ -2,10 +2,10 @@ name: Tests
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v2
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- v2
|
- master
|
||||||
jobs:
|
jobs:
|
||||||
integration-tests:
|
integration-tests:
|
||||||
name: Integration tests
|
name: Integration tests
|
||||||
|
|||||||
42
README.md
42
README.md
@@ -1,11 +1,12 @@
|
|||||||
# Uniswap Frontend
|
# Uniswap Interface
|
||||||
|
|
||||||
[](https://github.com/Uniswap/uniswap-frontend/actions?query=workflow%3ATests)
|
[](https://github.com/Uniswap/uniswap-interface/actions?query=workflow%3ATests)
|
||||||
[](https://prettier.io/)
|
[](https://prettier.io/)
|
||||||
|
|
||||||
An open source interface for Uniswap -- a protocol for decentralized exchange of Ethereum tokens.
|
An open source interface for Uniswap -- a protocol for decentralized exchange of Ethereum tokens.
|
||||||
|
|
||||||
- Website: [uniswap.org](https://uniswap.org/)
|
- Website: [uniswap.org](https://uniswap.org/)
|
||||||
|
- Interface: [app.uniswap.org](https://app.uniswap.org)
|
||||||
- Docs: [uniswap.org/docs/](https://uniswap.org/docs/)
|
- Docs: [uniswap.org/docs/](https://uniswap.org/docs/)
|
||||||
- Twitter: [@UniswapProtocol](https://twitter.com/UniswapProtocol)
|
- Twitter: [@UniswapProtocol](https://twitter.com/UniswapProtocol)
|
||||||
- Reddit: [/r/Uniswap](https://www.reddit.com/r/Uniswap/)
|
- Reddit: [/r/Uniswap](https://www.reddit.com/r/Uniswap/)
|
||||||
@@ -13,11 +14,11 @@ An open source interface for Uniswap -- a protocol for decentralized exchange of
|
|||||||
- Discord: [Uniswap](https://discord.gg/Y7TF6QA)
|
- Discord: [Uniswap](https://discord.gg/Y7TF6QA)
|
||||||
- Whitepaper: [Link](https://hackmd.io/C-DvwDSfSxuh-Gd4WKE_ig)
|
- Whitepaper: [Link](https://hackmd.io/C-DvwDSfSxuh-Gd4WKE_ig)
|
||||||
|
|
||||||
## Accessing the frontend
|
## Accessing the Uniswap Interface
|
||||||
|
|
||||||
To access the front end, use an IPFS gateway link from the
|
To access the Uniswap Interface, use an IPFS gateway link from the
|
||||||
[latest release](https://github.com/Uniswap/uniswap-frontend/releases/latest)
|
[latest release](https://github.com/Uniswap/uniswap-interface/releases/latest),
|
||||||
or visit [uniswap.exchange](https://uniswap.exchange).
|
or visit [app.uniswap.org](https://app.uniswap.org).
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
@@ -27,31 +28,32 @@ or visit [uniswap.exchange](https://uniswap.exchange).
|
|||||||
yarn
|
yarn
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configure Environment (optional)
|
|
||||||
|
|
||||||
Copy `.env` to `.env.local` and change the appropriate variables.
|
|
||||||
|
|
||||||
### Run
|
### Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn start
|
yarn start
|
||||||
```
|
```
|
||||||
|
|
||||||
To have the frontend default to a different network, make a copy of `.env` named `.env.local`,
|
### Configuring the environment (optional)
|
||||||
change `REACT_APP_NETWORK_ID` to `"{yourNetworkId}"`, and change `REACT_APP_NETWORK_URL` to e.g.
|
|
||||||
`"https://{yourNetwork}.infura.io/v3/{yourKey}"`.
|
|
||||||
|
|
||||||
Note that the front end only works properly on testnets where both
|
To have the interface default to a different network when a wallet is not connected:
|
||||||
|
|
||||||
|
1. Make a copy of `.env` named `.env.local`
|
||||||
|
2. Change `REACT_APP_NETWORK_ID` to `"{YOUR_NETWORK_ID}"`
|
||||||
|
3. Change `REACT_APP_NETWORK_URL` to e.g. `"https://{YOUR_NETWORK_ID}.infura.io/v3/{YOUR_INFURA_KEY}"`
|
||||||
|
|
||||||
|
Note that the interface only works on testnets where both
|
||||||
[Uniswap V2](https://uniswap.org/docs/v2/smart-contracts/factory/) and
|
[Uniswap V2](https://uniswap.org/docs/v2/smart-contracts/factory/) and
|
||||||
[multicall](https://github.com/makerdao/multicall) are deployed.
|
[multicall](https://github.com/makerdao/multicall) are deployed.
|
||||||
The frontend will not work on other networks.
|
The interface will not work on other networks.
|
||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|
||||||
**Please open all pull requests against the `v2` branch.**
|
**Please open all pull requests against the `master` branch.**
|
||||||
CI checks will run against all PRs.
|
CI checks will run against all PRs.
|
||||||
|
|
||||||
## Accessing Uniswap V1 interface
|
## Accessing Uniswap Interface V1
|
||||||
|
|
||||||
The Uniswap V1 interface for mainnet and testnets is accessible via IPFS gateways linked
|
The Uniswap Interface supports swapping against, and migrating or removing liquidity from Uniswap V1. However,
|
||||||
from the [v1.0.0 release](https://github.com/Uniswap/uniswap-frontend/releases/tag/v1.0.0).
|
if you would like to use Uniswap V1, the Uniswap V1 interface for mainnet and testnets is accessible via IPFS gateways
|
||||||
|
linked from the [v1.0.0 release](https://github.com/Uniswap/uniswap-interface/releases/tag/v1.0.0).
|
||||||
|
|||||||
@@ -69,13 +69,13 @@ class CustomizedBridge extends _Eip1193Bridge {
|
|||||||
|
|
||||||
// sets up the injected provider to be a mock ethereum provider with the given mnemonic/index
|
// sets up the injected provider to be a mock ethereum provider with the given mnemonic/index
|
||||||
Cypress.Commands.overwrite('visit', (original, url, options) => {
|
Cypress.Commands.overwrite('visit', (original, url, options) => {
|
||||||
return original(url, {
|
return original(url.startsWith('/') && url.length > 2 && !url.startsWith('/#') ? `/#${url}` : url, {
|
||||||
...options,
|
...options,
|
||||||
onBeforeLoad(win) {
|
onBeforeLoad(win) {
|
||||||
options && options.onBeforeLoad && options.onBeforeLoad(win)
|
options && options.onBeforeLoad && options.onBeforeLoad(win)
|
||||||
const provider = new JsonRpcProvider('https://rinkeby.infura.io/v3/acb7e55995d04c49bfb52b7141599467', 4)
|
const provider = new JsonRpcProvider('https://rinkeby.infura.io/v3/acb7e55995d04c49bfb52b7141599467', 4)
|
||||||
const signer = new Wallet(PRIVATE_KEY_TEST_NEVER_USE, provider)
|
const signer = new Wallet(PRIVATE_KEY_TEST_NEVER_USE, provider)
|
||||||
win.ethereum = new CustomizedBridge(signer, provider)
|
win.ethereum = new CustomizedBridge(signer, provider)
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
27
netlify.toml
27
netlify.toml
@@ -1,27 +0,0 @@
|
|||||||
# block some countries
|
|
||||||
[[redirects]]
|
|
||||||
from = "/*"
|
|
||||||
to = "/451.html"
|
|
||||||
status = 451
|
|
||||||
force = true
|
|
||||||
conditions = {Country=["BY","CU","IR","IQ","CI","LR","KP","SD","SY","ZW"]}
|
|
||||||
headers = {Link="<https://uniswap.exchange>"}
|
|
||||||
|
|
||||||
# forward migrate
|
|
||||||
[[redirects]]
|
|
||||||
from = "https://migrate.uniswap.exchange/*"
|
|
||||||
to = "https://uniswap.exchange/migrate/v1"
|
|
||||||
status = 301
|
|
||||||
force = true
|
|
||||||
|
|
||||||
# forward v2 subdomain to apex
|
|
||||||
[[redirects]]
|
|
||||||
from = "https://v2.uniswap.exchange/*"
|
|
||||||
to = "https://uniswap.exchange/:splat"
|
|
||||||
status = 301
|
|
||||||
|
|
||||||
# support SPA setup
|
|
||||||
[[redirects]]
|
|
||||||
from = "/*"
|
|
||||||
to = "/index.html"
|
|
||||||
status = 200
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@uniswap/interface",
|
"name": "@uniswap/interface",
|
||||||
"description": "Uniswap Interface",
|
"description": "Uniswap Interface",
|
||||||
"homepage": "https://uniswap.exchange",
|
"homepage": ".",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ethersproject/address": "^5.0.0-beta.134",
|
"@ethersproject/address": "^5.0.0-beta.134",
|
||||||
@@ -51,6 +51,7 @@
|
|||||||
"i18next": "^15.0.9",
|
"i18next": "^15.0.9",
|
||||||
"i18next-browser-languagedetector": "^3.0.1",
|
"i18next-browser-languagedetector": "^3.0.1",
|
||||||
"i18next-xhr-backend": "^2.0.1",
|
"i18next-xhr-backend": "^2.0.1",
|
||||||
|
"inter-ui": "^3.13.1",
|
||||||
"jazzicon": "^1.5.0",
|
"jazzicon": "^1.5.0",
|
||||||
"lodash.flatmap": "^4.5.0",
|
"lodash.flatmap": "^4.5.0",
|
||||||
"polished": "^3.3.2",
|
"polished": "^3.3.2",
|
||||||
@@ -81,7 +82,6 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"ipfs-build": "cross-env PUBLIC_URL=\".\" react-scripts build",
|
|
||||||
"test": "react-scripts test --env=jsdom",
|
"test": "react-scripts test --env=jsdom",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
|
"lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const VersionLabel = styled.span<{ enabled: boolean }>`
|
|||||||
background: ${({ theme, enabled }) => (enabled ? theme.primary1 : 'none')};
|
background: ${({ theme, enabled }) => (enabled ? theme.primary1 : 'none')};
|
||||||
color: ${({ theme, enabled }) => (enabled ? theme.white : theme.text1)};
|
color: ${({ theme, enabled }) => (enabled ? theme.white : theme.text1)};
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-weight: ${({ theme, enabled }) => (enabled ? '500' : '400')};
|
font-weight: ${({ enabled }) => (enabled ? '500' : '400')};
|
||||||
:hover {
|
:hover {
|
||||||
user-select: ${({ enabled }) => (enabled ? 'none' : 'initial')};
|
user-select: ${({ enabled }) => (enabled ? 'none' : 'initial')};
|
||||||
background: ${({ theme, enabled }) => (enabled ? theme.primary1 : 'none')};
|
background: ${({ theme, enabled }) => (enabled ? theme.primary1 : 'none')};
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const MenuItem = styled(ExternalLink)`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const CODE_LINK = 'https://github.com/Uniswap/uniswap-frontend'
|
const CODE_LINK = 'https://github.com/Uniswap/uniswap-interface'
|
||||||
|
|
||||||
export default function Menu() {
|
export default function Menu() {
|
||||||
const node = useRef<HTMLDivElement>()
|
const node = useRef<HTMLDivElement>()
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export default function TokenWarningCard({ token, ...rest }: TokenWarningCardPro
|
|||||||
? `${token.name} (${token.symbol})`
|
? `${token.name} (${token.symbol})`
|
||||||
: token.name || token.symbol}
|
: token.name || token.symbol}
|
||||||
</div>
|
</div>
|
||||||
<ExternalLink style={{ fontWeight: 400 }} href={getEtherscanLink(chainId, token.address, 'address')}>
|
<ExternalLink style={{ fontWeight: 400 }} href={getEtherscanLink(chainId, token.address, 'token')}>
|
||||||
(View on Etherscan)
|
(View on Etherscan)
|
||||||
</ExternalLink>
|
</ExternalLink>
|
||||||
</Row>
|
</Row>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export default [
|
|||||||
new Token(ChainId.MAINNET, '0x459086F2376525BdCebA5bDDA135e4E9d3FeF5bf', 8, 'renBCH', 'renBCH'),
|
new Token(ChainId.MAINNET, '0x459086F2376525BdCebA5bDDA135e4E9d3FeF5bf', 8, 'renBCH', 'renBCH'),
|
||||||
new Token(ChainId.MAINNET, '0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D', 8, 'renBTC', 'renBTC'),
|
new Token(ChainId.MAINNET, '0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D', 8, 'renBTC', 'renBTC'),
|
||||||
new Token(ChainId.MAINNET, '0x1C5db575E2Ff833E46a2E9864C22F4B22E0B37C2', 8, 'renZEC', 'renZEC'),
|
new Token(ChainId.MAINNET, '0x1C5db575E2Ff833E46a2E9864C22F4B22E0B37C2', 8, 'renZEC', 'renZEC'),
|
||||||
new Token(ChainId.MAINNET, '0x1985365e9f78359a9B6AD760e32412f4a445E862', 18, 'REP', 'Reputation'),
|
new Token(ChainId.MAINNET, '0x1985365e9f78359a9B6AD760e32412f4a445E862', 18, 'REPv1', 'Augur v1 Reputation'),
|
||||||
new Token(ChainId.MAINNET, '0x9469D013805bFfB7D3DEBe5E7839237e535ec483', 18, 'RING', 'Darwinia Network Native Token'),
|
new Token(ChainId.MAINNET, '0x9469D013805bFfB7D3DEBe5E7839237e535ec483', 18, 'RING', 'Darwinia Network Native Token'),
|
||||||
new Token(ChainId.MAINNET, '0x607F4C5BB672230e8672085532f7e901544a7375', 9, 'RLC', 'iEx.ec Network Token'),
|
new Token(ChainId.MAINNET, '0x607F4C5BB672230e8672085532f7e901544a7375', 9, 'RLC', 'iEx.ec Network Token'),
|
||||||
new Token(ChainId.MAINNET, '0xB4EFd85c19999D84251304bDA99E90B92300Bd93', 18, 'RPL', 'Rocket Pool'),
|
new Token(ChainId.MAINNET, '0xB4EFd85c19999D84251304bDA99E90B92300Bd93', 18, 'RPL', 'Rocket Pool'),
|
||||||
@@ -123,6 +123,7 @@ export default [
|
|||||||
new Token(ChainId.MAINNET, '0xA4Bdb11dc0a2bEC88d24A3aa1E6Bb17201112eBe', 6, 'USDS', 'StableUSD'),
|
new Token(ChainId.MAINNET, '0xA4Bdb11dc0a2bEC88d24A3aa1E6Bb17201112eBe', 6, 'USDS', 'StableUSD'),
|
||||||
USDT,
|
USDT,
|
||||||
new Token(ChainId.MAINNET, '0xeb269732ab75A6fD61Ea60b06fE994cD32a83549', 18, 'USDx', 'dForce'),
|
new Token(ChainId.MAINNET, '0xeb269732ab75A6fD61Ea60b06fE994cD32a83549', 18, 'USDx', 'dForce'),
|
||||||
|
new Token(ChainId.MAINNET, '0x9A48BD0EC040ea4f1D3147C025cd4076A2e71e3e', 18, 'USD++', 'PieDAO USD++'),
|
||||||
new Token(ChainId.MAINNET, '0x8f3470A7388c05eE4e7AF3d01D8C722b0FF52374', 18, 'VERI', 'Veritaseum'),
|
new Token(ChainId.MAINNET, '0x8f3470A7388c05eE4e7AF3d01D8C722b0FF52374', 18, 'VERI', 'Veritaseum'),
|
||||||
new Token(ChainId.MAINNET, '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', 8, 'WBTC', 'Wrapped BTC'),
|
new Token(ChainId.MAINNET, '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', 8, 'WBTC', 'Wrapped BTC'),
|
||||||
new Token(ChainId.MAINNET, '0x09fE5f0236F0Ea5D930197DCE254d77B04128075', 18, 'WCK', 'Wrapped CryptoKitties'),
|
new Token(ChainId.MAINNET, '0x09fE5f0236F0Ea5D930197DCE254d77B04128075', 18, 'WCK', 'Wrapped CryptoKitties'),
|
||||||
|
|||||||
@@ -3,15 +3,13 @@ import { initReactI18next } from 'react-i18next'
|
|||||||
import XHR from 'i18next-xhr-backend'
|
import XHR from 'i18next-xhr-backend'
|
||||||
import LanguageDetector from 'i18next-browser-languagedetector'
|
import LanguageDetector from 'i18next-browser-languagedetector'
|
||||||
|
|
||||||
const LOAD_PATH: string = process.env.PUBLIC_URL === '.' ? `./locales/{{lng}}.json` : '/locales/{{lng}}.json'
|
|
||||||
|
|
||||||
i18next
|
i18next
|
||||||
.use(XHR)
|
.use(XHR)
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
backend: {
|
backend: {
|
||||||
loadPath: LOAD_PATH
|
loadPath: `./locales/{{lng}}.json`
|
||||||
},
|
},
|
||||||
react: {
|
react: {
|
||||||
useSuspense: true
|
useSuspense: true
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ReactDOM from 'react-dom'
|
|||||||
import ReactGA from 'react-ga'
|
import ReactGA from 'react-ga'
|
||||||
import { Provider } from 'react-redux'
|
import { Provider } from 'react-redux'
|
||||||
import { NetworkContextName } from './constants'
|
import { NetworkContextName } from './constants'
|
||||||
|
import 'inter-ui'
|
||||||
import './i18n'
|
import './i18n'
|
||||||
import App from './pages/App'
|
import App from './pages/App'
|
||||||
import store from './state'
|
import store from './state'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { Suspense } from 'react'
|
import React, { Suspense } from 'react'
|
||||||
import { BrowserRouter, HashRouter, Route, Switch } from 'react-router-dom'
|
import { HashRouter, Route, Switch } from 'react-router-dom'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import GoogleAnalyticsReporter from '../components/analytics/GoogleAnalyticsReporter'
|
import GoogleAnalyticsReporter from '../components/analytics/GoogleAnalyticsReporter'
|
||||||
import Header from '../components/Header'
|
import Header from '../components/Header'
|
||||||
@@ -53,17 +53,10 @@ const Marginer = styled.div`
|
|||||||
margin-top: 5rem;
|
margin-top: 5rem;
|
||||||
`
|
`
|
||||||
|
|
||||||
let Router: React.ComponentType
|
|
||||||
if (process.env.PUBLIC_URL === '.') {
|
|
||||||
Router = HashRouter
|
|
||||||
} else {
|
|
||||||
Router = BrowserRouter
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<Router>
|
<HashRouter>
|
||||||
<Route component={GoogleAnalyticsReporter} />
|
<Route component={GoogleAnalyticsReporter} />
|
||||||
<Route component={DarkModeQueryParamReader} />
|
<Route component={DarkModeQueryParamReader} />
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
@@ -91,7 +84,7 @@ export default function App() {
|
|||||||
<Marginer />
|
<Marginer />
|
||||||
</BodyWrapper>
|
</BodyWrapper>
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
</Router>
|
</HashRouter>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ import { useUserSlippageTolerance, useUserDeadline, useExpertModeManager } from
|
|||||||
import { ClickableText } from '../Pool/styleds'
|
import { ClickableText } from '../Pool/styleds'
|
||||||
|
|
||||||
export default function Send() {
|
export default function Send() {
|
||||||
useDefaultsFromURLSearch()
|
// override auto ETH populate to allow for single inputs or swap and send
|
||||||
|
useDefaultsFromURLSearch(true)
|
||||||
|
|
||||||
// text translation
|
// text translation
|
||||||
// const { t } = useTranslation()
|
// const { t } = useTranslation()
|
||||||
@@ -64,7 +65,19 @@ export default function Send() {
|
|||||||
const [recipientError, setRecipientError] = useState<string | null>('Enter a Recipient')
|
const [recipientError, setRecipientError] = useState<string | null>('Enter a Recipient')
|
||||||
|
|
||||||
// trade details, check query params for initial state
|
// trade details, check query params for initial state
|
||||||
const { independentField, typedValue } = useSwapState()
|
const {
|
||||||
|
independentField,
|
||||||
|
typedValue,
|
||||||
|
[Field.OUTPUT]: { address: output }
|
||||||
|
} = useSwapState()
|
||||||
|
|
||||||
|
// if output is valid set to sending view (will reset to undefined on remove swap)
|
||||||
|
useEffect(() => {
|
||||||
|
if (output) {
|
||||||
|
setSendingWithSwap(true)
|
||||||
|
}
|
||||||
|
}, [output])
|
||||||
|
|
||||||
const {
|
const {
|
||||||
parsedAmount,
|
parsedAmount,
|
||||||
bestTrade: bestTradeV2,
|
bestTrade: bestTradeV2,
|
||||||
@@ -134,13 +147,6 @@ export default function Send() {
|
|||||||
|
|
||||||
const { onSwitchTokens, onTokenSelection, onUserInput } = useSwapActionHandlers()
|
const { onSwitchTokens, onTokenSelection, onUserInput } = useSwapActionHandlers()
|
||||||
|
|
||||||
// reset field if sending with with swap is cancled
|
|
||||||
useEffect(() => {
|
|
||||||
if (!sendingWithSwap) {
|
|
||||||
onTokenSelection(Field.OUTPUT, null)
|
|
||||||
}
|
|
||||||
}, [onTokenSelection, sendingWithSwap])
|
|
||||||
|
|
||||||
const maxAmountInput: TokenAmount =
|
const maxAmountInput: TokenAmount =
|
||||||
!!tokenBalances[Field.INPUT] &&
|
!!tokenBalances[Field.INPUT] &&
|
||||||
!!tokens[Field.INPUT] &&
|
!!tokens[Field.INPUT] &&
|
||||||
@@ -419,7 +425,10 @@ export default function Send() {
|
|||||||
<ArrowDown size="16" color={theme.text2} onClick={onSwitchTokens} />
|
<ArrowDown size="16" color={theme.text2} onClick={onSwitchTokens} />
|
||||||
</ArrowWrapper>
|
</ArrowWrapper>
|
||||||
<ButtonSecondary
|
<ButtonSecondary
|
||||||
onClick={() => setSendingWithSwap(false)}
|
onClick={() => {
|
||||||
|
setSendingWithSwap(false)
|
||||||
|
onTokenSelection(Field.OUTPUT, null)
|
||||||
|
}}
|
||||||
style={{ marginRight: '0px', width: 'auto', fontSize: '14px' }}
|
style={{ marginRight: '0px', width: 'auto', fontSize: '14px' }}
|
||||||
padding={'4px 6px'}
|
padding={'4px 6px'}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -172,15 +172,14 @@ export function useDerivedSwapInfo(): {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCurrencyFromURLParameter(urlParam: any, chainId: number): string {
|
function parseCurrencyFromURLParameter(urlParam: any, chainId: number, overrideWETH: boolean): string {
|
||||||
if (typeof urlParam === 'string') {
|
if (typeof urlParam === 'string') {
|
||||||
const valid = isAddress(urlParam)
|
const valid = isAddress(urlParam)
|
||||||
if (valid) return valid
|
if (valid) return valid
|
||||||
if (urlParam.toLowerCase() === 'eth') return WETH[chainId as ChainId]?.address ?? ''
|
if (urlParam.toLowerCase() === 'eth') return WETH[chainId as ChainId]?.address ?? ''
|
||||||
if (valid === false) return WETH[chainId as ChainId]?.address ?? ''
|
if (valid === false) return WETH[chainId as ChainId]?.address ?? ''
|
||||||
}
|
}
|
||||||
|
return overrideWETH ? '' : WETH[chainId as ChainId]?.address ?? ''
|
||||||
return WETH[chainId as ChainId]?.address
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseTokenAmountURLParameter(urlParam: any): string {
|
function parseTokenAmountURLParameter(urlParam: any): string {
|
||||||
@@ -191,9 +190,9 @@ function parseIndependentFieldURLParameter(urlParam: any): Field {
|
|||||||
return typeof urlParam === 'string' && urlParam.toLowerCase() === 'output' ? Field.OUTPUT : Field.INPUT
|
return typeof urlParam === 'string' && urlParam.toLowerCase() === 'output' ? Field.OUTPUT : Field.INPUT
|
||||||
}
|
}
|
||||||
|
|
||||||
export function queryParametersToSwapState(parsedQs: ParsedQs, chainId: ChainId): SwapState {
|
export function queryParametersToSwapState(parsedQs: ParsedQs, chainId: ChainId, overrideETH: boolean): SwapState {
|
||||||
let inputCurrency = parseCurrencyFromURLParameter(parsedQs.inputCurrency, chainId)
|
let inputCurrency = parseCurrencyFromURLParameter(parsedQs.inputCurrency, chainId, overrideETH)
|
||||||
let outputCurrency = parseCurrencyFromURLParameter(parsedQs.outputCurrency, chainId)
|
let outputCurrency = parseCurrencyFromURLParameter(parsedQs.outputCurrency, chainId, overrideETH)
|
||||||
if (inputCurrency === outputCurrency) {
|
if (inputCurrency === outputCurrency) {
|
||||||
if (typeof parsedQs.outputCurrency === 'string') {
|
if (typeof parsedQs.outputCurrency === 'string') {
|
||||||
inputCurrency = ''
|
inputCurrency = ''
|
||||||
@@ -215,14 +214,16 @@ export function queryParametersToSwapState(parsedQs: ParsedQs, chainId: ChainId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updates the swap state to use the defaults for a given network
|
// updates the swap state to use the defaults for a given network
|
||||||
export function useDefaultsFromURLSearch() {
|
// set overrideETH to true if dont want to autopopulate ETH
|
||||||
|
export function useDefaultsFromURLSearch(overrideWETH = false) {
|
||||||
const { chainId } = useActiveWeb3React()
|
const { chainId } = useActiveWeb3React()
|
||||||
const dispatch = useDispatch<AppDispatch>()
|
const dispatch = useDispatch<AppDispatch>()
|
||||||
const parsedQs = useParsedQueryString()
|
const parsedQs = useParsedQueryString()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!chainId) return
|
if (!chainId) return
|
||||||
const parsed = queryParametersToSwapState(parsedQs, chainId)
|
const parsed = queryParametersToSwapState(parsedQs, chainId, overrideWETH)
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
replaceSwapState({
|
replaceSwapState({
|
||||||
typedValue: parsed.typedValue,
|
typedValue: parsed.typedValue,
|
||||||
|
|||||||
@@ -168,8 +168,6 @@ export const TYPE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const FixedGlobalStyle = createGlobalStyle`
|
export const FixedGlobalStyle = createGlobalStyle`
|
||||||
@import url('https://rsms.me/inter/inter.css');
|
|
||||||
|
|
||||||
html, input, textarea, button {
|
html, input, textarea, button {
|
||||||
font-family: 'Inter', sans-serif;
|
font-family: 'Inter', sans-serif;
|
||||||
letter-spacing: -0.018em;
|
letter-spacing: -0.018em;
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ describe('utils', () => {
|
|||||||
it('correct for tx', () => {
|
it('correct for tx', () => {
|
||||||
expect(getEtherscanLink(1, 'abc', 'transaction')).toEqual('https://etherscan.io/tx/abc')
|
expect(getEtherscanLink(1, 'abc', 'transaction')).toEqual('https://etherscan.io/tx/abc')
|
||||||
})
|
})
|
||||||
|
it('correct for token', () => {
|
||||||
|
expect(getEtherscanLink(1, 'abc', 'token')).toEqual('https://etherscan.io/token/abc')
|
||||||
|
})
|
||||||
it('correct for address', () => {
|
it('correct for address', () => {
|
||||||
expect(getEtherscanLink(1, 'abc', 'address')).toEqual('https://etherscan.io/address/abc')
|
expect(getEtherscanLink(1, 'abc', 'address')).toEqual('https://etherscan.io/address/abc')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,13 +25,16 @@ const ETHERSCAN_PREFIXES: { [chainId in ChainId]: string } = {
|
|||||||
42: 'kovan.'
|
42: 'kovan.'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getEtherscanLink(chainId: ChainId, data: string, type: 'transaction' | 'address'): string {
|
export function getEtherscanLink(chainId: ChainId, data: string, type: 'transaction' | 'token' | 'address'): string {
|
||||||
const prefix = `https://${ETHERSCAN_PREFIXES[chainId] || ETHERSCAN_PREFIXES[1]}etherscan.io`
|
const prefix = `https://${ETHERSCAN_PREFIXES[chainId] || ETHERSCAN_PREFIXES[1]}etherscan.io`
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'transaction': {
|
case 'transaction': {
|
||||||
return `${prefix}/tx/${data}`
|
return `${prefix}/tx/${data}`
|
||||||
}
|
}
|
||||||
|
case 'token': {
|
||||||
|
return `${prefix}/token/${data}`
|
||||||
|
}
|
||||||
case 'address':
|
case 'address':
|
||||||
default: {
|
default: {
|
||||||
return `${prefix}/address/${data}`
|
return `${prefix}/address/${data}`
|
||||||
|
|||||||
@@ -8419,6 +8419,11 @@ inquirer@^7.0.0:
|
|||||||
strip-ansi "^6.0.0"
|
strip-ansi "^6.0.0"
|
||||||
through "^2.3.6"
|
through "^2.3.6"
|
||||||
|
|
||||||
|
inter-ui@^3.13.1:
|
||||||
|
version "3.13.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/inter-ui/-/inter-ui-3.13.1.tgz#3b3841c1ab425035d0146b38c7ee7a640d3da3d8"
|
||||||
|
integrity sha512-A+gHBm9WXZZmIYHdQci9ZoIrsPkzwYvWqG2+DyrwOuxjZVnRyz3b73ridPUWI/JvZ1nGf2j0VdJ+vxh0/bKBwg==
|
||||||
|
|
||||||
internal-ip@^4.3.0:
|
internal-ip@^4.3.0:
|
||||||
version "4.3.0"
|
version "4.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-4.3.0.tgz#845452baad9d2ca3b69c635a137acb9a0dad0907"
|
resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-4.3.0.tgz#845452baad9d2ca3b69c635a137acb9a0dad0907"
|
||||||
|
|||||||
Reference in New Issue
Block a user