Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solana-contrib: Add support for solscan link generation for TransactionReceipt #664

Merged
merged 6 commits into from Aug 13, 2022
20 changes: 18 additions & 2 deletions packages/solana-contrib/src/transaction/TransactionReceipt.ts
Expand Up @@ -19,6 +19,11 @@ export type TransactionLike =
| PendingTransaction
| TransactionReceipt;

export enum ExplorerType {
SOLANA_EXPLORER = "solana-explorer",
SOLSCAN = "solscan",
}

/**
* Confirms a transaction, returning its receipt.
*
Expand Down Expand Up @@ -96,7 +101,18 @@ export class TransactionReceipt {
* @param network
* @returns
*/
generateSolanaExplorerLink(cluster: Cluster = "mainnet-beta"): string {
return `https://explorer.solana.com/tx/${this.signature}?cluster=${cluster}`;
michaelhly marked this conversation as resolved.
Show resolved Hide resolved

michaelhly marked this conversation as resolved.
Show resolved Hide resolved
generateTXLink(
cluster: Cluster = "mainnet-beta",
explorerType: string = ExplorerType.SOLANA_EXPLORER
): string {
switch (explorerType) {
case ExplorerType.SOLANA_EXPLORER:
return `https://explorer.solana.com/tx/${this.signature}?cluster=${cluster}`;
case ExplorerType.SOLSCAN:
return `https://solscan.io/tx/${this.signature}?cluster=${cluster}`;
default:
throw new Error(`Explorer type is not passed.`);
michaelhly marked this conversation as resolved.
Show resolved Hide resolved
}
}
}