-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Solana Explorer and Solscan links after tx submission
- Loading branch information
1 parent
5359092
commit aed7153
Showing
18 changed files
with
208 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default } from "./Left"; | ||
export * from "./Left"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
client/src/components/Panels/Side/Right/Wallet/useAirdropAmount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useAtom } from "jotai"; | ||
import styled from "styled-components"; | ||
|
||
import { Endpoint, EXPLORER_URL, SOLSCAN_URL } from "../../constants"; | ||
import { endpointAtom, txHashAtom } from "../../state"; | ||
import Link from "../Link"; | ||
|
||
export const ExplorerLink = () => { | ||
const [txHash] = useAtom(txHashAtom); | ||
const [endpoint] = useAtom(endpointAtom); | ||
|
||
const [explorer, solscan] = getUrls(txHash, endpoint); | ||
|
||
return ( | ||
<Wrapper> | ||
<Link href={explorer}>Solana Explorer</Link> | ||
{solscan && <Link href={solscan}>Solscan</Link>} | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
const getUrls = (txHash: string, endpoint: Endpoint) => { | ||
const explorer = | ||
EXPLORER_URL + "/tx/" + txHash + "?cluster=custom&customUrl=" + endpoint; | ||
|
||
let cluster = ""; | ||
if (endpoint === Endpoint.LOCALHOST) return [explorer]; | ||
else if ( | ||
endpoint === Endpoint.DEVNET || | ||
endpoint === Endpoint.DEVNET_GENESYSGO | ||
) | ||
cluster = "?cluster=devnet"; | ||
else if (endpoint === Endpoint.TESTNET) cluster = "?cluster=testnet"; | ||
|
||
const solscan = SOLSCAN_URL + "/tx/" + txHash + cluster; | ||
|
||
return [explorer, solscan]; | ||
}; | ||
|
||
const Wrapper = styled.div` | ||
display: flex; | ||
justify-content: space-around; | ||
& > a:hover { | ||
text-decoration: underline; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useCallback, useEffect } from "react"; | ||
import { useAtom } from "jotai"; | ||
import styled, { css } from "styled-components"; | ||
import { ToastContainer, toast } from "react-toastify"; | ||
import "react-toastify/dist/ReactToastify.min.css"; | ||
|
||
import { ICONBAR_WIDTH } from "../Panels/Side/Left"; | ||
import { ExplorerLink } from "./ExplorerLink"; | ||
import { txHashAtom } from "../../state"; | ||
|
||
const Toast = () => { | ||
const [txHash] = useAtom(txHashAtom); | ||
|
||
const notify = useCallback(() => { | ||
if (!txHash) return; | ||
toast(<ExplorerLink />, { toastId: txHash }); | ||
}, [txHash]); | ||
|
||
useEffect(() => { | ||
notify(); | ||
}, [notify]); | ||
|
||
if (!txHash) return null; | ||
|
||
return ( | ||
<StyledContainer | ||
position={toast.POSITION.BOTTOM_LEFT} | ||
closeOnClick={false} | ||
/> | ||
); | ||
}; | ||
|
||
const StyledContainer = styled(ToastContainer)` | ||
${({ theme }) => css` | ||
&&&.Toastify__toast-container { | ||
left: ${ICONBAR_WIDTH}; | ||
z-index: 1; | ||
} | ||
.Toastify__toast { | ||
background-color: ${theme.colors.toast?.bg ?? theme.colors.default.bg}; | ||
border-radius: ${theme.borderRadius}; | ||
color: ${theme.colors.default.textPrimary}; | ||
font-family: ${theme.font?.family}; | ||
font-size: ${theme.font?.size.medium}; | ||
} | ||
.Toastify__progress-bar { | ||
background: ${theme.colors.default.primary}; | ||
} | ||
.Toastify__close-button--light { | ||
color: ${theme.colors.default.textSecondary}; | ||
} | ||
`} | ||
`; | ||
|
||
export default Toast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./Toast"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export const DEFAULT_CURSOR = { cursor: "default" }; | ||
|
||
export const EXPLORER_URL = "https://explorer.solana.com"; | ||
export const SOLSCAN_URL = "https://solscan.io"; |
Oops, something went wrong.