Skip to content

Commit eaa5afd

Browse files
authored
feat(vara-eth-idea/frontend): enhance Etherscan integration and network handling (#2447)
1 parent 2b078a9 commit eaa5afd

12 files changed

Lines changed: 31 additions & 13 deletions

File tree

idea/vara-eth/frontend/src/app/api/use-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useAtomValue } from 'jotai';
44
import { useEffect } from 'react';
55
import { usePublicClient } from 'wagmi';
66

7-
import { nodeAtom } from '@/app/store/node';
7+
import { nodeAtom } from '@/app/store';
88

99
import { useSigner } from './use-signer';
1010

idea/vara-eth/frontend/src/app/providers/eth/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useAtomValue } from 'jotai';
66
import { type PropsWithChildren, useEffect } from 'react';
77
import { useChainId, useSwitchChain, WagmiProvider, webSocket } from 'wagmi';
88

9-
import { nodeAtom } from '@/app/store/node';
9+
import { nodeAtom } from '@/app/store';
1010
import {
1111
ETH_CHAIN_ID_MAINNET,
1212
ETH_CHAIN_ID_TESTNET,
@@ -63,6 +63,7 @@ createAppKit({
6363
history: false,
6464
receive: false,
6565
},
66+
enableNetworkSwitch: false,
6667
enableWalletGuide: false,
6768
allWallets: 'HIDE',
6869
excludeWalletIds: [TRUST_WALLET_ID],

idea/vara-eth/frontend/src/components/ui/explorer-link/explorer-link.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import { useAtomValue } from 'jotai';
2+
3+
import { nodeAtom } from '@/app/store';
14
import EtherscanSvg from '@/assets/icons/etherscan.svg?react';
5+
import { getEtherscanBaseUrl } from '@/shared/config';
26
import type { PropsWithClassName } from '@/shared/types';
37
import { cx } from '@/shared/utils';
48

@@ -12,10 +16,13 @@ type Props = PropsWithClassName & {
1216
};
1317

1418
const ExplorerLink = ({ path, id, className }: Props) => {
19+
const { ethChainId } = useAtomValue(nodeAtom);
20+
const etherscanBaseUrl = getEtherscanBaseUrl(ethChainId);
21+
1522
return (
1623
<Tooltip value="View on Etherscan">
1724
<a
18-
href={`https://hoodi.etherscan.io/${path}/${id}`}
25+
href={`${etherscanBaseUrl}/${path}/${id}`}
1926
target="_blank"
2027
rel="noreferrer"
2128
className={cx(styles.link, className)}>

idea/vara-eth/frontend/src/components/wallet/wallet-button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ const WalletButton = () => {
1111

1212
const ethAccount = useAccount();
1313
const name = useEnsName({ address: ethAccount.address });
14+
const chainName = ethAccount.chain?.name;
1415

1516
return (
1617
<Button onClick={() => open()} className={styles.button}>
1718
{ethAccount.address ? (
1819
<>
1920
{name.data || getTruncatedText(ethAccount.address)}
20-
<span className={styles.chain}>Hoodi</span>
21+
<span className={styles.chain}>{chainName || 'Unknown network'}</span>
2122
</>
2223
) : (
2324
'Connect Wallet'

idea/vara-eth/frontend/src/features/codes/lib/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
22
import { useAtomValue } from 'jotai';
33
import type { Hex } from 'viem';
44

5-
import { nodeAtom } from '@/app/store/node';
5+
import { nodeAtom } from '@/app/store';
66
import type { PaginatedResponse } from '@/shared/types';
77
import { fetchWithGuard } from '@/shared/utils';
88

idea/vara-eth/frontend/src/features/codes/nodes-switch/ui/nodes-switch.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { useAtomValue, useSetAtom } from 'jotai';
22
import { useEffect, useState } from 'react';
33
import { useSearchParams } from 'react-router-dom';
44

5-
import { myActivityAtom } from '@/app/store';
6-
import { type NodeState, nodeAtom } from '@/app/store/node';
5+
import { myActivityAtom, type NodeState, nodeAtom } from '@/app/store';
76

87
import { NODE_SECTIONS } from '../api';
98
import { getSectionByNodeAddress, LocalStorage, NODE_ADRESS_URL_PARAM } from '../config';

idea/vara-eth/frontend/src/features/messages/lib/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
22
import { useAtomValue } from 'jotai';
33
import type { Hex } from 'viem';
44

5-
import { nodeAtom } from '@/app/store/node';
5+
import { nodeAtom } from '@/app/store';
66

77
import {
88
getMessageRequest,

idea/vara-eth/frontend/src/features/programs/lib/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
22
import { useAtomValue } from 'jotai';
33
import type { Hex } from 'viem';
44

5-
import { nodeAtom } from '@/app/store/node';
5+
import { nodeAtom } from '@/app/store';
66
import type { Code } from '@/features/codes/lib/requests';
77
import type { PaginatedResponse } from '@/shared/types';
88
import { fetchWithGuard } from '@/shared/utils';

idea/vara-eth/frontend/src/features/search/ui/search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type Hex, isAddress, isHash } from 'viem';
77
import { useConfig } from 'wagmi';
88
import { z } from 'zod';
99

10-
import { nodeAtom } from '@/app/store/node';
10+
import { nodeAtom } from '@/app/store';
1111
import SearchSVG from '@/assets/icons/search.svg?react';
1212
import { Button } from '@/components';
1313
import { routes } from '@/shared/config';

idea/vara-eth/frontend/src/features/transactions/lib/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
22
import { useAtomValue } from 'jotai';
33
import type { Hex } from 'viem';
44

5-
import { nodeAtom } from '@/app/store/node';
5+
import { nodeAtom } from '@/app/store';
66
import type { PaginatedResponse } from '@/shared/types';
77
import { fetchWithGuard } from '@/shared/utils';
88

0 commit comments

Comments
 (0)