lp_ui: not-mainnet banner

Change-Id: I0cbe086134a22e8a1d89f01820cda2f91c12ca82
This commit is contained in:
Evan Gray 2021-09-15 12:17:07 -04:00
parent de257bc22c
commit 6ba172bce2
3 changed files with 36 additions and 14 deletions

View File

@ -212,9 +212,9 @@ export const ETH_TOKENS_THAT_EXIST_ELSEWHERE = [
];
export const MIGRATION_PROGRAM_ADDRESS =
process.env.REACT_APP_CLUSTER === "mainnet"
CLUSTER === "mainnet"
? "whmRZnmyxdr2TkHXcZoFdtvNYRLQ5Jtbkf6ZbGkJjdk"
: process.env.REACT_APP_CLUSTER === "testnet"
: CLUSTER === "testnet"
? ""
: "Ex9bCdVMSfx7EzB3pgSi2R4UHwJAXvTw18rBQm5YQ8gK";

View File

@ -1,15 +1,23 @@
import { clusterApiUrl } from "@solana/web3.js";
export const MIGRATION_PROGRAM_ADDRESS =
export type Cluster = "devnet" | "testnet" | "mainnet";
export const CLUSTER: Cluster =
process.env.REACT_APP_CLUSTER === "mainnet"
? "whmRZnmyxdr2TkHXcZoFdtvNYRLQ5Jtbkf6ZbGkJjdk"
? "mainnet"
: process.env.REACT_APP_CLUSTER === "testnet"
? "testnet"
: "devnet";
export const MIGRATION_PROGRAM_ADDRESS =
CLUSTER === "mainnet"
? "whmRZnmyxdr2TkHXcZoFdtvNYRLQ5Jtbkf6ZbGkJjdk"
: CLUSTER === "testnet"
? ""
: "Ex9bCdVMSfx7EzB3pgSi2R4UHwJAXvTw18rBQm5YQ8gK";
export const SOLANA_URL =
process.env.REACT_APP_CLUSTER === "mainnet"
CLUSTER === "mainnet"
? clusterApiUrl("mainnet-beta")
: process.env.REACT_APP_CLUSTER === "testnet"
: CLUSTER === "testnet"
? clusterApiUrl("testnet")
: "http://localhost:8899";

View File

@ -18,6 +18,7 @@ import {
TextField,
Typography,
CircularProgress,
AppBar,
} from "@material-ui/core";
import {
ASSOCIATED_TOKEN_PROGRAM_ID,
@ -35,7 +36,11 @@ import SolanaCreateAssociatedAddress, {
import SolanaWalletKey from "../components/SolanaWalletKey";
import { useLogger } from "../contexts/Logger";
import { useSolanaWallet } from "../contexts/SolanaWalletContext";
import { MIGRATION_PROGRAM_ADDRESS, SOLANA_URL } from "../utils/consts";
import {
CLUSTER,
MIGRATION_PROGRAM_ADDRESS,
SOLANA_URL,
} from "../utils/consts";
import { getMultipleAccounts, signSendAndConfirm } from "../utils/solana";
const useStyles = makeStyles(() => ({
@ -831,13 +836,22 @@ function Main() {
);
return (
<Container maxWidth="md" className={classes.rootContainer}>
<Paper className={classes.mainPaper}>
<SolanaWalletKey />
{content}
</Paper>
<LogWatcher />
</Container>
<>
{CLUSTER === "mainnet" ? null : (
<AppBar position="static" color="secondary">
<Typography style={{ textAlign: "center" }}>
Caution! You are using the {CLUSTER} build of this app.
</Typography>
</AppBar>
)}
<Container maxWidth="md" className={classes.rootContainer}>
<Paper className={classes.mainPaper}>
<SolanaWalletKey />
{content}
</Paper>
<LogWatcher />
</Container>
</>
);
}