Skip to content

Commit

Permalink
Feature: 250 Include wormscan link (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuli-ferna authored Oct 3, 2023
1 parent 3c27905 commit 9536d3d
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xlabs/portal-bridge-ui",
"version": "0.1.84",
"version": "0.1.85",
"private": true,
"dependencies": {
"@certusone/wormhole-sdk": "^0.10.4",
Expand Down
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"
}`;
};

0 comments on commit 9536d3d

Please sign in to comment.