MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / useBlockExplorer

Function useBlockExplorer

app/components/hooks/useBlockExplorer.ts:13–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11import Routes from '../../constants/navigation/Routes';
12
13const useBlockExplorer = () => {
14 const navigation = useNavigation();
15 const providerConfig = useSelector(selectProviderConfig);
16 const networkConfigurations = useSelector(selectNetworkConfigurations);
17
18 const toBlockExplorer = useCallback(
19 (address: string) => {
20 const { type, rpcTarget } = providerConfig;
21 let accountLink: string;
22 if (type === RPC) {
23 const blockExplorer =
24 findBlockExplorerForRpc(rpcTarget, networkConfigurations) ||
25 NO_RPC_BLOCK_EXPLORER;
26 accountLink = `${blockExplorer}/address/${address}`;
27 } else {
28 accountLink = getEtherscanAddressUrl(type, address);
29 }
30 navigation.navigate(Routes.WEBVIEW.MAIN, {
31 screen: Routes.WEBVIEW.SIMPLE,
32 params: {
33 url: accountLink,
34 },
35 });
36 },
37 [networkConfigurations, navigation, providerConfig],
38 );
39 return {
40 toBlockExplorer,
41 };
42};
43
44export default useBlockExplorer;

Callers 2

AssetOptionsFunction · 0.50

Calls 2

findBlockExplorerForRpcFunction · 0.90
getEtherscanAddressUrlFunction · 0.90

Tested by

no test coverage detected