From e03913fc262497b87946ce48e76b4b2eff9a1473 Mon Sep 17 00:00:00 2001 From: Jimii <30603522+jim4067@users.noreply.github.com> Date: Tue, 11 Apr 2023 05:23:36 +0300 Subject: [PATCH] feat: add xray explorer (#3652) --- .../Settings/Preferences/Solana/Explorer.tsx | 18 ++++++++++++++---- packages/common/src/explorer.ts | 16 ++++++++++++++++ packages/common/src/solana/explorer.ts | 1 + 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/packages/app-extension/src/components/Unlocked/Settings/Preferences/Solana/Explorer.tsx b/packages/app-extension/src/components/Unlocked/Settings/Preferences/Solana/Explorer.tsx index bfb2ab129..c5c01d11a 100644 --- a/packages/app-extension/src/components/Unlocked/Settings/Preferences/Solana/Explorer.tsx +++ b/packages/app-extension/src/components/Unlocked/Settings/Preferences/Solana/Explorer.tsx @@ -22,20 +22,30 @@ export function PreferencesSolanaExplorer() { const menuItems = { "Solana Beach": { onClick: () => changeExplorer(SolanaExplorer.SOLANA_BEACH), - detail: explorer === SolanaExplorer.SOLANA_BEACH ? : <>, + detail: + explorer === SolanaExplorer.SOLANA_BEACH ? :
, }, "Solana Explorer": { onClick: () => changeExplorer(SolanaExplorer.SOLANA_EXPLORER), detail: - explorer === SolanaExplorer.SOLANA_EXPLORER ? : <>, + explorer === SolanaExplorer.SOLANA_EXPLORER ? ( + + ) : ( +
+ ), }, "Solana FM": { onClick: () => changeExplorer(SolanaExplorer.SOLANA_FM), - detail: explorer === SolanaExplorer.SOLANA_FM ? : <>, + detail: + explorer === SolanaExplorer.SOLANA_FM ? :
, }, Solscan: { onClick: () => changeExplorer(SolanaExplorer.SOLSCAN), - detail: explorer === SolanaExplorer.SOLSCAN ? : <>, + detail: explorer === SolanaExplorer.SOLSCAN ? :
, + }, + XRAY: { + onClick: () => changeExplorer(SolanaExplorer.XRAY), + detail: explorer === SolanaExplorer.XRAY ? :
, }, }; diff --git a/packages/common/src/explorer.ts b/packages/common/src/explorer.ts index 1da92ad3e..802516cf8 100644 --- a/packages/common/src/explorer.ts +++ b/packages/common/src/explorer.ts @@ -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"); } @@ -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"); } @@ -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"); } @@ -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"; diff --git a/packages/common/src/solana/explorer.ts b/packages/common/src/solana/explorer.ts index cb55ee820..dcb581fcc 100644 --- a/packages/common/src/solana/explorer.ts +++ b/packages/common/src/solana/explorer.ts @@ -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", };