From 831e96adb5e038d66ea7da7cb8c4145f2a5927ac Mon Sep 17 00:00:00 2001 From: Evan Gray Date: Mon, 4 Oct 2021 12:36:07 -0400 Subject: [PATCH] bridge_ui: add terra finder links Change-Id: I70b9b6ec378c57799e86345d76fde7f49cf3acdb --- bridge_ui/src/components/ShowTx.tsx | 19 +++++++++++++++++-- bridge_ui/src/components/SmartAddress.tsx | 17 +++++++++++++++-- bridge_ui/src/utils/solana.ts | 4 +++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/bridge_ui/src/components/ShowTx.tsx b/bridge_ui/src/components/ShowTx.tsx index 06142c3d2..8f614ac32 100644 --- a/bridge_ui/src/components/ShowTx.tsx +++ b/bridge_ui/src/components/ShowTx.tsx @@ -2,6 +2,7 @@ import { ChainId, CHAIN_ID_ETH, CHAIN_ID_SOLANA, + CHAIN_ID_TERRA, } from "@certusone/wormhole-sdk"; import { Button, makeStyles, Typography } from "@material-ui/core"; import { Transaction } from "../store/transferSlice"; @@ -28,7 +29,8 @@ export default function ShowTx({ const showExplorerLink = CLUSTER === "testnet" || CLUSTER === "mainnet" || - (CLUSTER === "devnet" && chainId === CHAIN_ID_SOLANA); + (CLUSTER === "devnet" && + (chainId === CHAIN_ID_SOLANA || chainId === CHAIN_ID_TERRA)); const explorerAddress = chainId === CHAIN_ID_ETH ? `https://${CLUSTER === "testnet" ? "goerli." : ""}etherscan.io/tx/${ @@ -42,8 +44,21 @@ export default function ShowTx({ ? "?cluster=custom&customUrl=http%3A%2F%2Flocalhost%3A8899" : "" }` + : chainId === CHAIN_ID_TERRA + ? `https://finder.terra.money/${ + CLUSTER === "devnet" + ? "localterra" + : CLUSTER === "testnet" + ? "bombay-12" + : "columbus-5" + }/tx/${tx?.id}` : undefined; - const explorerName = chainId === CHAIN_ID_ETH ? "Etherscan" : "Explorer"; + const explorerName = + chainId === CHAIN_ID_ETH + ? "Etherscan" + : chainId === CHAIN_ID_TERRA + ? "Finder" + : "Explorer"; return (
diff --git a/bridge_ui/src/components/SmartAddress.tsx b/bridge_ui/src/components/SmartAddress.tsx index da2099912..bc7148e4d 100644 --- a/bridge_ui/src/components/SmartAddress.tsx +++ b/bridge_ui/src/components/SmartAddress.tsx @@ -2,6 +2,7 @@ import { ChainId, CHAIN_ID_ETH, CHAIN_ID_SOLANA, + CHAIN_ID_TERRA, } from "@certusone/wormhole-sdk"; import { Button, makeStyles, Tooltip, Typography } from "@material-ui/core"; import { FileCopy, OpenInNew } from "@material-ui/icons"; @@ -79,7 +80,6 @@ export default function SmartAddress({ : tokenName ? tokenName : ""; - //TODO terra const explorerAddress = isNative ? null : chainId === CHAIN_ID_ETH @@ -94,8 +94,21 @@ export default function SmartAddress({ ? "?cluster=custom&customUrl=http%3A%2F%2Flocalhost%3A8899" : "" }` + : chainId === CHAIN_ID_TERRA + ? `https://finder.terra.money/${ + CLUSTER === "devnet" + ? "localterra" + : CLUSTER === "testnet" + ? "bombay-12" + : "columbus-5" + }/address/${useableAddress}` : undefined; - const explorerName = chainId === CHAIN_ID_ETH ? "Etherscan" : "Explorer"; + const explorerName = + chainId === CHAIN_ID_ETH + ? "Etherscan" + : chainId === CHAIN_ID_TERRA + ? "Finder" + : "Explorer"; const copyToClipboard = useCopyToClipboard(useableAddress); diff --git a/bridge_ui/src/utils/solana.ts b/bridge_ui/src/utils/solana.ts index e79d18ea3..7c7cb60e4 100644 --- a/bridge_ui/src/utils/solana.ts +++ b/bridge_ui/src/utils/solana.ts @@ -73,5 +73,7 @@ export function chunks(array: T[], size: number): T[][] { } export function shortenAddress(address: string) { - return `${address.slice(0, 4)}...${address.slice(-4)}`; + return address.length > 10 + ? `${address.slice(0, 4)}...${address.slice(-4)}` + : address; }