forked from saber-hq/saber-common
/
txLink.ts
31 lines (27 loc) 路 936 Bytes
/
txLink.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Cluster } from "@solana/web3.js";
import { PendingTransaction } from "../transaction/PendingTransaction";
import { TransactionReceipt } from "../transaction/TransactionReceipt";
export enum ExplorerType {
SOLANA_EXPLORER = "solana-explorer",
SOLSCAN = "solscan",
}
export function generateSolanaExplorerLink(
signature: string,
cluster: Cluster = "mainnet-beta"
): string {
return generateTXLink(signature, cluster);
}
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.`);
}
}