Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 250 Include wormscan link #451

Merged
merged 6 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/Attest/CreatePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export default function CreatePreview() {
>
{explainerString}
</Typography>
{createTx ? <ShowTx chainId={targetChain} tx={createTx} /> : null}
{createTx ? (
<ShowTx chainId={targetChain} tx={createTx} showWormscanLink={false} />
) : null}
{howToAddToTokenListUrl ? (
<Alert severity="info" variant="outlined" className={classes.alert}>
Remember to add the token to the{" "}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Migration/EvmQuickMigrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ function EvmMigrationLineItem({
Successfully migrated your tokens. They will become available once
this transaction confirms.
</Typography>
<ShowTx chainId={chainId} tx={{ id: transaction, block: 1 }} />
<ShowTx
chainId={chainId}
tx={{ id: transaction, block: 1 }}
showWormscanLink={false}
/>
</div>
</div>
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Migration/EvmWorkflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ export default function EvmWorkflow({
Successfully migrated your tokens! They will be available once this
transaction confirms.
</Typography>
<ShowTx tx={{ id: transaction, block: 1 }} chainId={chainId} />
<ShowTx
tx={{ id: transaction, block: 1 }}
chainId={chainId}
showWormscanLink={false}
/>
</>
) : null}
</>
Expand Down
4 changes: 3 additions & 1 deletion src/components/NFT/RedeemPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default function RedeemPreview() {
>
{explainerString}
</Typography>
{redeemTx ? <ShowTx chainId={targetChain} tx={redeemTx} /> : null}
{redeemTx ? (
<ShowTx chainId={targetChain} tx={redeemTx} showWormscanLink={false} />
) : null}
<ButtonWithLoader onClick={handleResetClick}>
Transfer Another NFT!
</ButtonWithLoader>
Expand Down
71 changes: 54 additions & 17 deletions src/components/ShowTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,31 @@ import {
CHAIN_ID_BASE,
} from "@certusone/wormhole-sdk";
import { CHAIN_ID_NEAR } from "@certusone/wormhole-sdk/lib/esm";
import { Button, makeStyles, Typography } from "@material-ui/core";
import { Button, makeStyles, Typography, Chip } from "@material-ui/core";
import { Transaction } from "../store/transferSlice";
import { CLUSTER, getExplorerName } from "../utils/consts";
import { CLUSTER, getExplorerName, getWormholescanLink } from "../utils/consts";

const useStyles = makeStyles((theme) => ({
tx: {
marginTop: theme.spacing(1),
textAlign: "center",
},
txButtons: {
display: "flex",
justifyContent: "center",
gap: theme.spacing(3),
marginTop: 20,
},
wormscanButton: {
position: "relative",
},
newTag: {
position: "absolute",
backgroundColor: theme.palette.warning.main,
color: theme.palette.background.default,
fontSize: 12,
fontWeight: 500,
},
viewButton: {
marginTop: theme.spacing(1),
},
Expand All @@ -43,9 +59,11 @@ const useStyles = makeStyles((theme) => ({
export default function ShowTx({
chainId,
tx,
showWormscanLink = true,
}: {
chainId: ChainId;
tx: Transaction;
showWormscanLink?: boolean;
}) {
const classes = useStyles();
const showExplorerLink =
Expand Down Expand Up @@ -177,21 +195,40 @@ export default function ShowTx({

return (
<div className={classes.tx}>
<Typography noWrap component="div" variant="body2">
{tx.id}
</Typography>
{showExplorerLink && explorerAddress ? (
<Button
href={explorerAddress}
target="_blank"
rel="noopener noreferrer"
size="small"
variant="outlined"
className={classes.viewButton}
>
View on {explorerName}
</Button>
) : null}
<div>
<Typography noWrap component="div" variant="body2">
{tx.id}
</Typography>
</div>
<div className={classes.txButtons}>
{showExplorerLink && explorerAddress ? (
<Button
href={explorerAddress}
target="_blank"
rel="noopener noreferrer"
size="small"
variant="outlined"
className={classes.viewButton}
>
View on {explorerName}
</Button>
) : null}
{showExplorerLink && showWormscanLink && tx.id && (
<div className={classes.wormscanButton}>
<Button
href={getWormholescanLink(tx.id)}
target="_blank"
rel="noopener noreferrer"
size="small"
variant="outlined"
className={classes.viewButton}
>
View on Wormholescan
</Button>
<Chip className={classes.newTag} label="NEW!" size="small" />
</div>
)}
</div>
</div>
);
}
4 changes: 3 additions & 1 deletion src/components/Transfer/RedeemPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export default function RedeemPreview({
>
{explainerString}
</Typography>
{redeemTx ? <ShowTx chainId={targetChain} tx={redeemTx} /> : null}
{redeemTx ? (
<ShowTx chainId={targetChain} tx={redeemTx} showWormscanLink={false} />
) : null}
<AddToMetamask />
<FeaturedMarkets />
<ButtonWithLoader onClick={handleResetClick}>
Expand Down
4 changes: 4 additions & 0 deletions src/muiTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const COLORS = {
darkRed: "#810612",
white: "#FFFFFF",
whiteWithTransparency: "rgba(255,255,255,.07)",
orange: "#F0932A",
};

const suisse = {
Expand Down Expand Up @@ -49,6 +50,9 @@ export const theme = responsiveFontSizes(
error: {
main: COLORS.red,
},
warning: {
main: COLORS.orange,
},
},

typography: {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2049,3 +2049,9 @@ export const getAssetAddressNative = (
}
return hexToNativeAssetString(uint8ArrayToHex(address), chainId);
};

export const getWormholescanLink = (tx: string) => {
return `https://wormholescan.io/#/tx/${tx}?network=${
process.env.REACT_APP_CLUSTER === "mainnet" ? "MAINNET" : "TESTNET"
}`;
};