CryptoDonate: convert utils to ts

This commit is contained in:
Alex Gleason
2022-03-25 16:39:26 -05:00
parent c62d402a4e
commit 5d4eb96cca
4 changed files with 10 additions and 7 deletions

View File

@@ -1,7 +0,0 @@
import blockExplorers from './block_explorers.json';
export const getExplorerUrl = (ticker, address) => {
const template = blockExplorers[ticker];
if (!template) return false;
return template.replace('{address}', address);
};

View File

@@ -0,0 +1,9 @@
import blockExplorers from './block_explorers.json';
type BlockExplorers = Record<string, string | null>;
export const getExplorerUrl = (ticker: string, address: string): string | null => {
const template = (blockExplorers as BlockExplorers)[ticker];
if (!template) return null;
return template.replace('{address}', address);
};