From b6dc1430763451ed6cd799fcc14838bfeebafb11 Mon Sep 17 00:00:00 2001 From: Jimii Date: Sat, 8 Apr 2023 22:17:32 +0300 Subject: [PATCH 1/2] feat: add xray explorer --- .../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 bfb2ab1297..c5c01d11a1 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 1da92ad3e6..df7fd19d5a 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, + `address/${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 cb55ee8207..dcb581fcc9 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", }; From 1389a971011fde542a93139c37346fac41e4f8b0 Mon Sep 17 00:00:00 2001 From: Jimii Date: Sat, 8 Apr 2023 23:05:44 +0300 Subject: [PATCH 2/2] fix: correct url for accounts --- packages/common/src/explorer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/explorer.ts b/packages/common/src/explorer.ts index df7fd19d5a..802516cf88 100644 --- a/packages/common/src/explorer.ts +++ b/packages/common/src/explorer.ts @@ -70,7 +70,7 @@ export function exploreAddressUrl( case SolanaExplorer.XRAY: return join( SolanaExplorer.XRAY, - `address/${address}${clusterSuffix(base, connectionUrl)}` + `account/${address}${clusterSuffix(base, connectionUrl)}` ); default: throw new Error("unknown explorer base");