bridge_ui: Disable transfers to and from polygon, display network upgrade warning

This commit is contained in:
Kevin Peters 2022-03-07 01:53:28 +00:00 committed by Evan Gray
parent ff62a2c7f4
commit 2961462ebe
4 changed files with 53 additions and 5 deletions

View File

@ -1,4 +1,8 @@
import { CHAIN_ID_SOLANA, isEVMChain } from "@certusone/wormhole-sdk"; import {
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
isEVMChain,
} from "@certusone/wormhole-sdk";
import { Button, makeStyles } from "@material-ui/core"; import { Button, makeStyles } from "@material-ui/core";
import { VerifiedUser } from "@material-ui/icons"; import { VerifiedUser } from "@material-ui/icons";
import { Alert } from "@material-ui/lab"; import { Alert } from "@material-ui/lab";
@ -19,6 +23,7 @@ import ButtonWithLoader from "../ButtonWithLoader";
import ChainSelect from "../ChainSelect"; import ChainSelect from "../ChainSelect";
import KeyAndBalance from "../KeyAndBalance"; import KeyAndBalance from "../KeyAndBalance";
import LowBalanceWarning from "../LowBalanceWarning"; import LowBalanceWarning from "../LowBalanceWarning";
import PolygonNetworkDownWarning from "../PolygonNetworkDownWarning";
import SolanaTPSWarning from "../SolanaTPSWarning"; import SolanaTPSWarning from "../SolanaTPSWarning";
import StepDescription from "../StepDescription"; import StepDescription from "../StepDescription";
import { TokenSelector } from "../TokenSelectors/SourceTokenSelector"; import { TokenSelector } from "../TokenSelectors/SourceTokenSelector";
@ -92,9 +97,10 @@ function Source() {
</div> </div>
) : null} ) : null}
<LowBalanceWarning chainId={sourceChain} /> <LowBalanceWarning chainId={sourceChain} />
{sourceChain === CHAIN_ID_POLYGON && <PolygonNetworkDownWarning />}
{sourceChain === CHAIN_ID_SOLANA && <SolanaTPSWarning />} {sourceChain === CHAIN_ID_SOLANA && <SolanaTPSWarning />}
<ButtonWithLoader <ButtonWithLoader
disabled={!isSourceComplete} disabled={!isSourceComplete || sourceChain === CHAIN_ID_POLYGON}
onClick={handleNextClick} onClick={handleNextClick}
showLoader={false} showLoader={false}
error={statusMessage || error} error={statusMessage || error}

View File

@ -1,4 +1,5 @@
import { import {
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA, CHAIN_ID_SOLANA,
hexToNativeString, hexToNativeString,
hexToUint8Array, hexToUint8Array,
@ -31,6 +32,7 @@ import ButtonWithLoader from "../ButtonWithLoader";
import ChainSelect from "../ChainSelect"; import ChainSelect from "../ChainSelect";
import KeyAndBalance from "../KeyAndBalance"; import KeyAndBalance from "../KeyAndBalance";
import LowBalanceWarning from "../LowBalanceWarning"; import LowBalanceWarning from "../LowBalanceWarning";
import PolygonNetworkDownWarning from "../PolygonNetworkDownWarning";
import SolanaTPSWarning from "../SolanaTPSWarning"; import SolanaTPSWarning from "../SolanaTPSWarning";
import StepDescription from "../StepDescription"; import StepDescription from "../StepDescription";
@ -138,8 +140,9 @@ function Target() {
</Alert> </Alert>
<LowBalanceWarning chainId={targetChain} /> <LowBalanceWarning chainId={targetChain} />
{targetChain === CHAIN_ID_SOLANA && <SolanaTPSWarning />} {targetChain === CHAIN_ID_SOLANA && <SolanaTPSWarning />}
{targetChain === CHAIN_ID_POLYGON && <PolygonNetworkDownWarning />}
<ButtonWithLoader <ButtonWithLoader
disabled={!isTargetComplete} //|| !associatedAccountExists} disabled={!isTargetComplete || targetChain === CHAIN_ID_POLYGON} //|| !associatedAccountExists}
onClick={handleNextClick} onClick={handleNextClick}
showLoader={false} showLoader={false}
error={statusMessage || error} error={statusMessage || error}

View File

@ -0,0 +1,30 @@
import { Link, makeStyles, Typography } from "@material-ui/core";
import { Alert } from "@material-ui/lab";
const useStyles = makeStyles((theme) => ({
alert: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(1),
},
}));
export default function PolygonNetworkDownWarning() {
const classes = useStyles();
return (
<Alert variant="outlined" severity="warning" className={classes.alert}>
Polygon is experiencing downtime. As a precautionary measure, Wormhole
network and portal have temporarily paused Polygon support until the issue
is resolved.
<Typography component="div">
<Link
href="https://twitter.com/0xPolygonDevs/status/1501944974933303305"
target="_blank"
rel="noopener noreferrer"
>
Link to @0xPolygonDevs tweet
</Link>
</Typography>
</Alert>
);
}

View File

@ -1,6 +1,7 @@
import { import {
CHAIN_ID_BSC, CHAIN_ID_BSC,
CHAIN_ID_ETH, CHAIN_ID_ETH,
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA, CHAIN_ID_SOLANA,
} from "@certusone/wormhole-sdk"; } from "@certusone/wormhole-sdk";
import { getAddress } from "@ethersproject/address"; import { getAddress } from "@ethersproject/address";
@ -39,6 +40,7 @@ import ChainSelectArrow from "../ChainSelectArrow";
import KeyAndBalance from "../KeyAndBalance"; import KeyAndBalance from "../KeyAndBalance";
import LowBalanceWarning from "../LowBalanceWarning"; import LowBalanceWarning from "../LowBalanceWarning";
import NumberTextField from "../NumberTextField"; import NumberTextField from "../NumberTextField";
import PolygonNetworkDownWarning from "../PolygonNetworkDownWarning";
import SolanaTPSWarning from "../SolanaTPSWarning"; import SolanaTPSWarning from "../SolanaTPSWarning";
import StepDescription from "../StepDescription"; import StepDescription from "../StepDescription";
import { TokenSelector } from "../TokenSelectors/SourceTokenSelector"; import { TokenSelector } from "../TokenSelectors/SourceTokenSelector";
@ -140,6 +142,9 @@ function Source() {
dispatch(incrementStep()); dispatch(incrementStep());
}, [dispatch]); }, [dispatch]);
const isPolygonTransfer =
sourceChain === CHAIN_ID_POLYGON || targetChain === CHAIN_ID_POLYGON;
return ( return (
<> <>
<StepDescription> <StepDescription>
@ -159,7 +164,10 @@ function Source() {
</div> </div>
</div> </div>
</StepDescription> </StepDescription>
<div className={classes.chainSelectWrapper} style={{marginBottom:'25px'}}> <div
className={classes.chainSelectWrapper}
style={{ marginBottom: "25px" }}
>
<div className={classes.chainSelectContainer}> <div className={classes.chainSelectContainer}>
<Typography variant="caption">Source</Typography> <Typography variant="caption">Source</Typography>
<ChainSelect <ChainSelect
@ -212,6 +220,7 @@ function Source() {
<> <>
<LowBalanceWarning chainId={sourceChain} /> <LowBalanceWarning chainId={sourceChain} />
{sourceChain === CHAIN_ID_SOLANA && <SolanaTPSWarning />} {sourceChain === CHAIN_ID_SOLANA && <SolanaTPSWarning />}
{isPolygonTransfer && <PolygonNetworkDownWarning />}
<SourceAssetWarning <SourceAssetWarning
sourceChain={sourceChain} sourceChain={sourceChain}
sourceAsset={parsedTokenAccount?.mintKey} sourceAsset={parsedTokenAccount?.mintKey}
@ -233,7 +242,7 @@ function Source() {
/> />
) : null} ) : null}
<ButtonWithLoader <ButtonWithLoader
disabled={!isSourceComplete} disabled={!isSourceComplete || isPolygonTransfer}
onClick={handleNextClick} onClick={handleNextClick}
showLoader={false} showLoader={false}
error={statusMessage || error} error={statusMessage || error}