Skip to content

Commit

Permalink
feat: add xray explorer (#3652)
Browse files Browse the repository at this point in the history
  • Loading branch information
jim4067 authored Apr 11, 2023
1 parent d9764b1 commit e03913f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,30 @@ export function PreferencesSolanaExplorer() {
const menuItems = {
"Solana Beach": {
onClick: () => changeExplorer(SolanaExplorer.SOLANA_BEACH),
detail: explorer === SolanaExplorer.SOLANA_BEACH ? <Checkmark /> : <></>,
detail:
explorer === SolanaExplorer.SOLANA_BEACH ? <Checkmark /> : <div />,
},
"Solana Explorer": {
onClick: () => changeExplorer(SolanaExplorer.SOLANA_EXPLORER),
detail:
explorer === SolanaExplorer.SOLANA_EXPLORER ? <Checkmark /> : <></>,
explorer === SolanaExplorer.SOLANA_EXPLORER ? (
<Checkmark />
) : (
<div />
),
},
"Solana FM": {
onClick: () => changeExplorer(SolanaExplorer.SOLANA_FM),
detail: explorer === SolanaExplorer.SOLANA_FM ? <Checkmark /> : <></>,
detail:
explorer === SolanaExplorer.SOLANA_FM ? <Checkmark /> : <div />,
},
Solscan: {
onClick: () => changeExplorer(SolanaExplorer.SOLSCAN),
detail: explorer === SolanaExplorer.SOLSCAN ? <Checkmark /> : <></>,
detail: explorer === SolanaExplorer.SOLSCAN ? <Checkmark /> : <div />,
},
XRAY: {
onClick: () => changeExplorer(SolanaExplorer.XRAY),
detail: explorer === SolanaExplorer.XRAY ? <Checkmark /> : <div />,
},
};

Expand Down
16 changes: 16 additions & 0 deletions packages/common/src/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export function explorerUrl(
SolanaExplorer.SOLANA_FM,
`tx/${tx}${clusterSuffix(base, connectionUrl)}`
);
case SolanaExplorer.XRAY:
return join(
SolanaExplorer.XRAY,
`tx/${tx}${clusterSuffix(base, connectionUrl)}`
);
default:
throw new Error("unknown explorer base");
}
Expand Down Expand Up @@ -62,6 +67,11 @@ export function exploreAddressUrl(
SolanaExplorer.SOLANA_FM,
`address/${address}${clusterSuffix(base, connectionUrl)}`
);
case SolanaExplorer.XRAY:
return join(
SolanaExplorer.XRAY,
`account/${address}${clusterSuffix(base, connectionUrl)}`
);
default:
throw new Error("unknown explorer base");
}
Expand Down Expand Up @@ -99,6 +109,11 @@ export function explorerNftUrl(
SolanaExplorer.SOLANA_FM,
`address/${nft.mint.toString()}${clusterSuffix(base, connectionUrl)}`
);
case SolanaExplorer.XRAY:
return join(
SolanaExplorer.XRAY,
`token/${nft.mint.toString()}${clusterSuffix(base, connectionUrl)}`
);
default:
throw new Error("unknown explorer base");
}
Expand All @@ -113,6 +128,7 @@ function clusterSuffix(base: string, connectionUrl: string): string {
case SolanaExplorer.SOLSCAN:
case SolanaExplorer.SOLANA_FM:
case SolanaExplorer.SOLANA_BEACH:
case SolanaExplorer.XRAY:
switch (connectionUrl) {
case SolanaCluster.MAINNET:
return "?cluster=mainnet";
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/solana/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const SolanaExplorer = {
SOLSCAN: "https://solscan.io",
SOLANA_BEACH: "https://solanabeach.io",
SOLANA_FM: "https://solana.fm",
XRAY: "https://xray.helius.xyz/",

DEFAULT: "https://solscan.io",
};

1 comment on commit e03913f

@vercel
Copy link

@vercel vercel bot commented on e03913f Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.