forked from Dshield-xyz/Dshield
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexplorer.ts
More file actions
38 lines (33 loc) · 1.42 KB
/
Copy pathexplorer.ts
File metadata and controls
38 lines (33 loc) · 1.42 KB
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
32
33
34
35
36
37
38
import { getNetworkPassphrase } from "./stellar";
// Block-explorer links for the compliance report. On pubnet we use
// stellarchain.io (the explorer the project links to); on testnet we use
// stellar.expert's testnet explorer, which reliably serves testnet history so
// the report's deposit/withdraw links resolve while developing.
const TESTNET = "Test SDF Network ; September 2015";
export function getNetworkLabel(): string {
const pass = getNetworkPassphrase();
if (pass === TESTNET) return "Testnet";
if (pass.startsWith("Public")) return "Mainnet";
return "Local / Standalone";
}
function isPubnet(): boolean {
return getNetworkPassphrase().startsWith("Public");
}
/** Explorer URL for a transaction hash, or null on networks without an explorer (local). */
export function explorerTxUrl(hash: string): string | null {
if (!hash) return null;
if (isPubnet()) return `https://stellarchain.io/transaction/${hash}`;
if (getNetworkPassphrase() === TESTNET) {
return `https://stellar.expert/explorer/testnet/tx/${hash}`;
}
return null;
}
/** Explorer URL for a contract id, or null on networks without an explorer (local). */
export function explorerContractUrl(id: string): string | null {
if (!id) return null;
if (isPubnet()) return `https://stellarchain.io/contract/${id}`;
if (getNetworkPassphrase() === TESTNET) {
return `https://stellar.expert/explorer/testnet/contract/${id}`;
}
return null;
}