From 65ee30165875cc24922cccace63e2188b6aa0eef Mon Sep 17 00:00:00 2001 From: - <-> Date: Wed, 29 Sep 2021 12:40:10 -0300 Subject: [PATCH] links to relay and faucet inside bridge --- src/modals/ChainModal/index.tsx | 7 +- src/pages/bridge/faucet/index.tsx | 187 +++++++++++++++++++++++++++++ src/pages/bridge/history/index.tsx | 4 +- src/pages/bridge/index.tsx | 2 +- src/pages/eclipse/index.tsx | 2 +- src/pages/faucet/index.tsx | 144 ---------------------- 6 files changed, 194 insertions(+), 152 deletions(-) create mode 100644 src/pages/bridge/faucet/index.tsx delete mode 100644 src/pages/faucet/index.tsx diff --git a/src/modals/ChainModal/index.tsx b/src/modals/ChainModal/index.tsx index bb8a478..6f91605 100644 --- a/src/modals/ChainModal/index.tsx +++ b/src/modals/ChainModal/index.tsx @@ -85,7 +85,7 @@ export default function ChainModal({ const { chainId, library, account, activate } = useWeb3React(BridgeContextName) const goToRelay = () => { - window.open('https://app.relaychain.com/transfer', '_blank').focus(); + window.open('https://app.relaychain.com/transfer', '_blank').focus() } return ( @@ -136,7 +136,7 @@ export default function ChainModal({ {/* Redirect to relay bridge while implementing UI integration */} - ) diff --git a/src/pages/bridge/faucet/index.tsx b/src/pages/bridge/faucet/index.tsx new file mode 100644 index 0000000..62853d5 --- /dev/null +++ b/src/pages/bridge/faucet/index.tsx @@ -0,0 +1,187 @@ +/* eslint-disable @next/next/link-passhref */ + +import Head from 'next/head' +import React, { useCallback, useState } from 'react' +import { t } from '@lingui/macro' +import { formatNumberScale } from '../../../functions' +import { ButtonError } from '../../../components/Button' +import { AutoColumn } from '../../../components/Column' +import { AutoRow } from '../../../components/Row' +import DoubleGlowShadow from '../../../components/DoubleGlowShadow' +import SolarbeamLogo from '../../../components/SolarbeamLogo' +import Container from '../../../components/Container' +import Typography from '../../../components/Typography' +import { i18n } from '@lingui/core' +import Image from '../../../components/Image' +import { useActiveWeb3React } from '../../../hooks' +import Web3Connect from '../../../components/Web3Connect' +import { Loader } from 'react-feather' +import { useETHBalances } from '../../../state/wallet/hooks' +import axios from 'axios' +import ReCAPTCHA from 'react-google-recaptcha' +import { FAUCET_ADDRESS } from '../../../constants' +import NavLink from '../../../components/NavLink' + +export default function Faucet(): JSX.Element { + const { chainId, account, library } = useActiveWeb3React() + const [token, setToken] = useState('') + const tokenBalance = useETHBalances([FAUCET_ADDRESS]) + const [pendingTx, setPendingTx] = useState(false) + const [requested, setRequested] = useState(false) + const [faucetResult, setFaucetResult] = useState({ status: 200, message: null }) + const recaptchaRef: any = React.createRef() + + const onReCAPTCHAChange = async (captchaCode) => { + if (!captchaCode) { + return + } + + setPendingTx(true) + + try { + const faucetResponse = await axios.post('/api/faucet', { address: account, 'g-recaptcha-response': captchaCode }) + if (faucetResponse.data) { + setFaucetResult(faucetResponse.data) + if (faucetResponse.data.status == 200) { + setRequested(true) + } else if (faucetResponse.data.message.indexOf('daily limit') >= 0) { + setRequested(true) + } + } + } catch (err) { + setFaucetResult({ status: 400, message: 'Failed to send the request to the server.' }) + } finally { + setPendingTx(false) + } + } + + const handleRequest = useCallback(async () => { + recaptchaRef.current.execute() + }, [recaptchaRef]) + + return ( + <> + + Faucet | Solarbeam + + + + + + + + + +
+ +
+
+ + A Faucet is a tool that provides a small amount of MOVR for users that used the bridge to start using + Solarbeam.io without having to buy MOVR somewhere else. + +
+
+ Solarbeam +
+
+ + Faucet balance:{' '} + {formatNumberScale(tokenBalance[FAUCET_ADDRESS]?.toSignificant(4, undefined, 2) ?? 0, false, 4)} MOVR + + + Faucet Address: {FAUCET_ADDRESS} + +
+ + +
+ {!account ? ( + + ) : ( + + {pendingTx ? ( +
+ + Requesting + +
+ ) : ( + i18n._(t`Give me some MOVR`) + )} +
+ )} +
+
+
+ {faucetResult?.message && ( + + {faucetResult?.message} + + )} +
+
+
+
+
+ + ) +} diff --git a/src/pages/bridge/history/index.tsx b/src/pages/bridge/history/index.tsx index 9c7a800..a03ccd4 100644 --- a/src/pages/bridge/history/index.tsx +++ b/src/pages/bridge/history/index.tsx @@ -265,7 +265,7 @@ export default function Bridge() { activeClassName="font-bold border rounded text-high-emphesis border-dark-700 bg-dark-700" exact href={{ - pathname: '/faucet', + pathname: '/bridge/faucet', }} > @@ -297,7 +297,7 @@ export default function Bridge() { {!account && activeAccount ? ( ) : ( -
+
{allTransactions && Object.keys(allTransactions).length > 0 ? ( <>
diff --git a/src/pages/bridge/index.tsx b/src/pages/bridge/index.tsx index c7ffde2..1197a55 100644 --- a/src/pages/bridge/index.tsx +++ b/src/pages/bridge/index.tsx @@ -501,7 +501,7 @@ export default function Bridge() { activeClassName="font-bold border rounded text-high-emphesis border-dark-700 bg-dark-700" exact href={{ - pathname: '/faucet', + pathname: '/bridge/faucet', }} > diff --git a/src/pages/eclipse/index.tsx b/src/pages/eclipse/index.tsx index 44b8d75..ffda811 100644 --- a/src/pages/eclipse/index.tsx +++ b/src/pages/eclipse/index.tsx @@ -17,7 +17,7 @@ export default function NFTLaunchpad(): JSX.Element {
- Coming sooon + Coming soon
diff --git a/src/pages/faucet/index.tsx b/src/pages/faucet/index.tsx deleted file mode 100644 index 1392e71..0000000 --- a/src/pages/faucet/index.tsx +++ /dev/null @@ -1,144 +0,0 @@ -/* eslint-disable @next/next/link-passhref */ - -import Head from 'next/head' -import React, { useCallback, useState } from 'react' -import { t } from '@lingui/macro' -import { formatNumberScale } from '../../functions' -import { ButtonError } from '../../components/Button' -import { AutoColumn } from '../../components/Column' -import { AutoRow } from '../../components/Row' -import DoubleGlowShadow from '../../components/DoubleGlowShadow' -import SolarbeamLogo from '../../components/SolarbeamLogo' -import Container from '../../components/Container' -import Typography from '../../components/Typography' -import { i18n } from '@lingui/core' -import Image from '../../components/Image' -import { useActiveWeb3React } from '../../hooks' -import Web3Connect from '../../components/Web3Connect' -import { Loader } from 'react-feather' -import { useETHBalances } from '../../state/wallet/hooks' -import axios from 'axios' -import ReCAPTCHA from 'react-google-recaptcha' -import { FAUCET_ADDRESS } from '../../constants' - -export default function Faucet(): JSX.Element { - const { chainId, account, library } = useActiveWeb3React() - const [token, setToken] = useState('') - const tokenBalance = useETHBalances([FAUCET_ADDRESS]) - const [pendingTx, setPendingTx] = useState(false) - const [requested, setRequested] = useState(false) - const [faucetResult, setFaucetResult] = useState({ status: 200, message: null }) - const recaptchaRef: any = React.createRef() - - const onReCAPTCHAChange = async (captchaCode) => { - if (!captchaCode) { - return - } - - setPendingTx(true) - - try { - const faucetResponse = await axios.post('/api/faucet', { address: account, 'g-recaptcha-response': captchaCode }) - if (faucetResponse.data) { - setFaucetResult(faucetResponse.data) - if (faucetResponse.data.status == 200) { - setRequested(true) - } else if (faucetResponse.data.message.indexOf('daily limit') >= 0) { - setRequested(true) - } - } - } catch (err) { - setFaucetResult({ status: 400, message: 'Failed to send the request to the server.' }) - } finally { - setPendingTx(false) - } - } - - const handleRequest = useCallback(async () => { - recaptchaRef.current.execute() - }, [recaptchaRef]) - - return ( - <> - - Faucet | Solarbeam - - - - - - - - - -
-
- - {i18n._(t`Moonriver Faucet`)} - - - A Faucet is a tool that provides a small amount of MOVR for users that used the bridge to start using Solarbeam.io without having to - buy MOVR somewhere else. - -
-
- Solarbeam -
-
- - Faucet balance:{' '} - {formatNumberScale(tokenBalance[FAUCET_ADDRESS]?.toSignificant(4, undefined, 2) ?? 0, false, 4)} MOVR - - - Faucet Address: {FAUCET_ADDRESS} - -
- - -
- {!account ? ( - - ) : ( - - {pendingTx ? ( -
- - Requesting - -
- ) : ( - i18n._(t`Give me some MOVR`) - )} -
- )} -
-
-
- {faucetResult?.message && ( - - {faucetResult?.message} - - )} -
-
-
-
- - ) -}