From 36ad7d0ce52440003cbad019a6f3196d2b1dbbfe Mon Sep 17 00:00:00 2001 From: Nikunj Date: Fri, 16 Jan 2026 00:48:26 +0530 Subject: [PATCH 1/3] update: token metadata get when wallet is not connect --- frontend/src/page/CreateInvoice.jsx | 78 +++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/frontend/src/page/CreateInvoice.jsx b/frontend/src/page/CreateInvoice.jsx index 8bf93782..07b48924 100644 --- a/frontend/src/page/CreateInvoice.jsx +++ b/frontend/src/page/CreateInvoice.jsx @@ -236,31 +236,65 @@ function CreateInvoice() { ]); }; - const verifyToken = async (address) => { - setTokenVerificationState("verifying"); - - try { - if (typeof window !== "undefined" && window.ethereum) { - const provider = new BrowserProvider(window.ethereum); - const contract = new ethers.Contract(address, ERC20_ABI, provider); - - const [symbol, name, decimals] = await Promise.all([ - contract.symbol().catch(() => "UNKNOWN"), - contract.name().catch(() => "Unknown Token"), - contract.decimals().catch(() => 18), - ]); - - setVerifiedToken({ address, symbol, name, decimals }); - setTokenVerificationState("success"); - } else { - console.error("No Ethereum provider found"); + +const verifyToken = async (address, targetChainId = null) => { + setTokenVerificationState("verifying"); + + // Determine which chain to verify on + const chainIdToUse = targetChainId || searchParams.get("chain") || account?.chainId; + + try { + let provider; + + + // for UNKNOWN symbol and name unknown update this rpc with some better one + const rpcUrls = { + 1: "https://eth.llamarpc.com", // Ethereum (very fast) + 61: "https://etc.rivet.link", // Ethereum Classic + 137: "https://polygon.llamarpc.com", // Polygon + 56: "https://bsc.llamarpc.com", // BNB Smart Chain + 8453: "https://base.llamarpc.com", // Base + 11155111: "https://rpc.ankr.com/eth_sepolia", // Sepolia + }; + if (typeof window !== "undefined" && window.ethereum) { + // Fallback to wallet provider if no chainId specified + provider = new BrowserProvider(walletClient); + // If chainId is available, always use public RPC (works without wallet) + } else if (chainIdToUse) { + const rpcUrl = rpcUrls[chainIdToUse]; + + if (!rpcUrl) { + console.error(`Unsupported chain ${chainIdToUse}. Supported chains: Ethereum (1), Ethereum Classic (61), Polygon (137), BNB Smart Chain (56), Base (8453), Sepolia (11155111)`); setTokenVerificationState("error"); + return; } - } catch (error) { - console.error("Verification failed:", error); - setTokenVerificationState("error"); + + // Use JsonRpcProvider with timeout for faster response + provider = new ethers.JsonRpcProvider(rpcUrl, Number(chainIdToUse)); } - }; + + const contract = new ethers.Contract(address, ERC20_ABI, provider); + + const [symbol, name, decimals] = await Promise.all([ + contract.symbol().catch(() => "UNKNOWN"), + contract.name().catch(() => "Unknown Token"), + contract.decimals().catch(() => 18), + ]); + + console.log([symbol, name, decimals]); + setVerifiedToken({ + address, + symbol, + name, + decimals: Number(decimals), + chainId: chainIdToUse + }); + setTokenVerificationState("success"); + } catch (error) { + console.error("Verification failed:", error); + setTokenVerificationState("error"); + } +}; const createInvoiceRequest = async (data) => { if (!isConnected || !walletClient) { From 5fe96d43cf069f23d94303a2eadc3bb0fdd49abe Mon Sep 17 00:00:00 2001 From: Nikunj Date: Fri, 16 Jan 2026 01:27:09 +0530 Subject: [PATCH 2/3] fix: page refresh get metadata bug --- frontend/src/page/CreateInvoice.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/page/CreateInvoice.jsx b/frontend/src/page/CreateInvoice.jsx index 07b48924..ba9eb779 100644 --- a/frontend/src/page/CreateInvoice.jsx +++ b/frontend/src/page/CreateInvoice.jsx @@ -157,7 +157,7 @@ function CreateInvoice() { }; processUrlToken(); - }, [searchParams, tokens, loadingTokens, account.address]); + }, [searchParams, walletClient, tokens, loadingTokens, account.address]); useEffect(() => { const total = itemData.reduce((sum, item) => { @@ -256,7 +256,7 @@ const verifyToken = async (address, targetChainId = null) => { 8453: "https://base.llamarpc.com", // Base 11155111: "https://rpc.ankr.com/eth_sepolia", // Sepolia }; - if (typeof window !== "undefined" && window.ethereum) { + if (typeof window !== "undefined" && isConnected) { // Fallback to wallet provider if no chainId specified provider = new BrowserProvider(walletClient); // If chainId is available, always use public RPC (works without wallet) @@ -274,7 +274,7 @@ const verifyToken = async (address, targetChainId = null) => { } const contract = new ethers.Contract(address, ERC20_ABI, provider); - + const [symbol, name, decimals] = await Promise.all([ contract.symbol().catch(() => "UNKNOWN"), contract.name().catch(() => "Unknown Token"), From 83c6656defd3ba9ee2e8e2a35efd554c3833b573 Mon Sep 17 00:00:00 2001 From: Nikunj Date: Fri, 16 Jan 2026 01:49:55 +0530 Subject: [PATCH 3/3] fix: navbar overlap --- frontend/src/components/Navbar.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index a4af563f..74ac36ed 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -143,7 +143,7 @@ function Navbar() { { navigate("/"); closeMobileMenu(); @@ -156,7 +156,7 @@ function Navbar() { {/* Desktop Navigation */} -
+
{/* {navItems.map((item) => (