Files
explore/lib/networks/networkExplorers.ts
T
tom goriunovandGitHub b9c24fea17 Replace lodash with es-toolkit (#2503)
* first part of migration

* second part of migration

* bump up es-toolkit version

* bump up `es-toolkit` version and remove `lodash` completely

* update screenshot
2025-01-14 12:30:05 +01:00

39 lines
1.1 KiB
TypeScript

import { mapValues } from 'es-toolkit';
import type { NetworkExplorer } from 'types/networks';
import config from 'configs/app';
// for easy .env update
// const NETWORK_EXPLORERS = JSON.stringify([
// {
// title: 'Anyblock',
// baseUrl: 'https://explorer.anyblock.tools',
// paths: {
// tx: '/ethereum/ethereum/goerli/transaction',
// address: '/ethereum/ethereum/goerli/address'
// },
// },
// {
// title: 'Etherscan',
// baseUrl: 'https://goerli.etherscan.io/',
// paths: {
// tx: '/tx',
// address: '/address',
// },
// },
// ]).replaceAll('"', '\'');
const stripTrailingSlash = (str: string) => str[str.length - 1] === '/' ? str.slice(0, -1) : str;
const addLeadingSlash = (str: string) => str[0] === '/' ? str : '/' + str;
const networkExplorers: Array<NetworkExplorer> = (() => {
return config.UI.explorers.items.map((explorer) => ({
...explorer,
baseUrl: stripTrailingSlash(explorer.baseUrl),
paths: mapValues(explorer.paths, (value) => value ? stripTrailingSlash(addLeadingSlash(value)) : value),
}));
})();
export default networkExplorers;