All files / app/utils external-links.ts

0% Statements 0/17
0% Branches 0/1
0% Functions 0/6
0% Lines 0/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                         
import { EXPLORER_URL, NETWORK } from '@constants/index';
import urljoin from 'url-join';
import { isWebUri } from 'valid-url';
 
export async function openExternalLink(url: string) {
  Iif (!isWebUri(url)) return;
  return main.openExternalLink(url);
}
 
export function makeExplorerLink(path: string) {
  return urljoin(EXPLORER_URL, `${path}?utm_source=leather-wallet&chain=${NETWORK}`);
}
 
export function makeExplorerTxLink(txId: string) {
  return makeExplorerLink(`/txid/${txId}`);
}
 
export async function openTxInExplorer(txid: string) {
  return openExternalLink(makeExplorerTxLink(txid));
}
 
export function makeExplorerAddressLink(address: string) {
  return makeExplorerLink(`/address/${address}`);
}
 
export async function openAddressInExplorer(address: string) {
  return openExternalLink(makeExplorerAddressLink(address));
}