Skip to content

Commit e44f65f

Browse files
authored
fix: return only valid links (#248)
1 parent 2b7b39c commit e44f65f

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

packages/app-commons/src/config.ts

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export const WALLET_INSTALL = process.env.NEXT_PUBLIC_WALLET_INSTALL;
1010
export const WALLET_INSTALL_NEXT = process.env.NEXT_PUBLIC_WALLET_INSTALL_NEXT;
1111
export const NODE_ENV = process.env.NODE_ENV;
1212

13-
export const BLOCK_EXPLORER_URL = process.env.NEXT_PUBLIC_BLOCK_EXPLORER_URL;
14-
1513
export const IS_PREVIEW = process.env.NEXT_PUBLIC_IS_PUBLIC_PREVIEW === 'true';
1614
export const IS_DEVELOPMENT = process.env.NODE_ENV === 'development';
1715

packages/app-portal/src/systems/Bridge/hooks/useExplorerLink.tsx

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
import { BLOCK_EXPLORER_URL, FUEL_CHAIN } from 'app-commons';
1+
import { FUEL_CHAIN } from 'app-commons';
22
import { buildBlockExplorerUrl } from 'fuels';
33
import { useMemo } from 'react';
44

55
export type ExplorerLinkProps = {
6-
network: 'ethereum' | 'fuel' | string | undefined;
6+
network: 'ethereum' | 'fuel';
77
providerUrl?: string;
8-
id?: string;
8+
id: string;
99
};
10+
1011
export function useExplorerLink({
1112
network,
1213
providerUrl,
1314
id,
1415
}: ExplorerLinkProps) {
15-
const href = useMemo(() => {
16+
const href = useMemo<string>(() => {
1617
if (network === 'ethereum') {
1718
return `https://sepolia.etherscan.io/tx/${id}`;
1819
}
20+
1921
if (network === 'fuel') {
2022
if (providerUrl === FUEL_CHAIN.providerUrl) {
21-
return `${BLOCK_EXPLORER_URL}tx/${id}`;
23+
return `/tx/${id}`;
2224
}
25+
2326
return buildBlockExplorerUrl({
24-
path: `transaction/${id || ''}`,
27+
path: `transaction/${id}`,
2528
providerUrl,
2629
});
2730
}
31+
32+
return '';
2833
}, [network, providerUrl, id]);
2934

3035
return {

packages/app-portal/src/systems/Chains/eth/hooks/useTxEthToFuel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function useTxEthToFuel({ id }: { id: string }) {
117117
const txId = id.startsWith('0x') ? (id as `0x${string}`) : undefined;
118118
const { href: explorerLink } = useExplorerLink({
119119
network: 'ethereum',
120-
id: txId,
120+
id,
121121
});
122122

123123
const txEthToFuelState = store.useSelector(

packages/app-portal/src/systems/Chains/fuel/hooks/useTxFuelToEth.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export function useTxFuelToEth({ txId }: { txId: string }) {
191191
const { assets } = useAssets();
192192
const { href: explorerLink } = useExplorerLink({
193193
network: 'fuel',
194-
providerUrl: fuelProvider?.url || '',
194+
providerUrl: fuelProvider?.url,
195195
id: txId,
196196
});
197197

0 commit comments

Comments
 (0)