()
| 11 | import Routes from '../../constants/navigation/Routes'; |
| 12 | |
| 13 | const 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 | |
| 44 | export default useBlockExplorer; |
no test coverage detected