Role: {profile?.role || authUser?.role || roleLabel.toLowerCase()}
-Wallet: {profile?.walletAddress || authUser?.walletAddress || "Not linked"}
+{walletDisplay.addressLabel}: {walletDisplay.address || "Not linked"}
+Network: {walletDisplay.networkLabel}
Internal balance: {formatNaira(Number(profile?.availableBalance || authUser?.availableBalance || 0))}
diff --git a/components/dashboard/investor-wallet-panel.tsx b/components/dashboard/investor-wallet-panel.tsx index 1fa229a..c629778 100644 --- a/components/dashboard/investor-wallet-panel.tsx +++ b/components/dashboard/investor-wallet-panel.tsx @@ -3,7 +3,6 @@ import { useCallback, useEffect, useMemo, useState } from "react" import { usePathname, useRouter, useSearchParams } from "next/navigation" import { formatEther } from "viem" -import { liskSepolia } from "viem/chains" import { ArrowRight, CheckCircle2, @@ -31,6 +30,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Skeleton } from "@/components/ui/skeleton" +import { CURRENT_EMBEDDED_WALLET, getWalletDisplay, shortenWalletAddress } from "@/lib/wallet/config" import { Table, TableBody, @@ -66,11 +66,6 @@ interface InvestorWalletPanelProps { showTitle?: boolean } -function truncateAddress(address: string) { - if (address.length < 10) return address - return `${address.slice(0, 6)}...${address.slice(-4)}` -} - function toPaystackAmount(value: string) { const parsed = Number.parseFloat(value) if (!Number.isFinite(parsed)) return null @@ -87,7 +82,8 @@ function isValidEmail(value: string) { } async function resolveOnchainBalance(address: string) { - const rpcUrl = liskSepolia.rpcUrls.default.http[0] + const rpcUrl = CURRENT_EMBEDDED_WALLET.network.rpcUrl + if (!rpcUrl) return null const response = await fetch(rpcUrl, { method: "POST", headers: { "Content-Type": "application/json" }, @@ -104,7 +100,7 @@ async function resolveOnchainBalance(address: string) { const balance = Number.parseFloat(formatEther(BigInt(payload.result))) if (!Number.isFinite(balance)) return null - return `${balance.toFixed(4)} ETH` + return `${balance.toFixed(4)} ${CURRENT_EMBEDDED_WALLET.network.nativeAsset}` } export function InvestorWalletPanel({ sectionId = "wallet", className, showTitle = true }: InvestorWalletPanelProps) { @@ -133,6 +129,10 @@ export function InvestorWalletPanel({ sectionId = "wallet", className, showTitle ) const walletAddress = isMockStellar ? mockAccount.publicKey : (walletSummary?.wallet.walletAddress || embeddedWallet?.address || authUser?.walletAddress || "") + const walletDisplay = getWalletDisplay({ + embeddedWalletAddress: walletAddress, + stellarPublicKey: isMockStellar ? mockAccount.publicKey : authUser?.stellarPublicKey, + }) const internalBalance = walletSummary?.wallet.internalBalanceNgn || 0 const fundingTransactions = useMemo(() => { @@ -224,12 +224,12 @@ export function InvestorWalletPanel({ sectionId = "wallet", className, showTitle ) const openWalletExplorer = () => { - if (!walletAddress) return - window.open(`https://sepolia-blockscout.lisk.com/address/${walletAddress}`, "_blank", "noopener,noreferrer") + if (!walletDisplay.explorerUrl) return + window.open(walletDisplay.explorerUrl, "_blank", "noopener,noreferrer") } const handleOpenWalletView = () => { - if (!walletAddress) { + if (!walletDisplay.explorerUrl) { toast({ title: "Wallet unavailable", description: "Your embedded wallet address is not ready yet. Please sign out and sign in again.", @@ -362,8 +362,8 @@ export function InvestorWalletPanel({ sectionId = "wallet", className, showTitle } const handleCopyAddress = async () => { - if (!walletAddress) return - await navigator.clipboard.writeText(walletAddress) + if (!walletDisplay.address) return + await navigator.clipboard.writeText(walletDisplay.address) toast({ title: "Address copied", description: "Wallet address copied to clipboard.", @@ -510,14 +510,15 @@ export function InvestorWalletPanel({ sectionId = "wallet", className, showTitleWallet address
-{walletAddress ? truncateAddress(walletAddress) : "Not available"}
+{walletDisplay.addressLabel}
+{walletDisplay.address ? shortenWalletAddress(walletDisplay.address) : "Not available"}
+{walletDisplay.networkLabel}
{formatNaira(internalBalance)}
Onchain balance
+{CURRENT_EMBEDDED_WALLET.network.label} balance
{!walletAddress ? "Unavailable" : isBalanceLoading ? "Loading..." : onchainBalance.value || "Unavailable"}
@@ -180,8 +183,8 @@ export function WalletMenu() {