-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solana-contrib: Refactor
generateTXLink
(#675)
* move generate tx link logic to /packages/solana-contrib/src/utils * fix: build error with pass tx to generateTXLink * pass signature on behalf of tx
- Loading branch information
Showing
4 changed files
with
26 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Cluster } from "@solana/web3.js"; | ||
|
||
export enum ExplorerType { | ||
SOLANA_EXPLORER = "solana-explorer", | ||
SOLSCAN = "solscan", | ||
} | ||
|
||
export function generateTXLink( | ||
signature: string, | ||
cluster: Cluster = "mainnet-beta", | ||
explorerType: string = ExplorerType.SOLANA_EXPLORER | ||
): string { | ||
switch (explorerType) { | ||
case ExplorerType.SOLANA_EXPLORER: | ||
return `https://explorer.solana.com/tx/${signature}?cluster=${cluster}`; | ||
case ExplorerType.SOLSCAN: | ||
return `https://solscan.io/tx/${signature}?cluster=${cluster}`; | ||
default: | ||
throw new Error(`Explorer type ${explorerType} is not supported.`); | ||
} | ||
} |