Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/hooks/useSmartWalletTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function useSmartWalletTransfer({
const [txHash, setTxHash] = useState<string | null>(null);
const [transferAmount, setTransferAmount] = useState("");
const [transferToken, setTransferToken] = useState("");
const [txNetworkName, setTxNetworkName] = useState<string>("");

// Helper to get the embedded wallet address (with address) for tx history
const getEmbeddedWalletAddress = (): `0x${string}` | undefined => {
Expand Down Expand Up @@ -107,6 +108,7 @@ export function useSmartWalletTransfer({
setIsSuccess(false);
setError("");
setTxHash(null);
setTxNetworkName("");
setTransferAmount("");
setTransferToken("");

Expand All @@ -128,6 +130,7 @@ export function useSmartWalletTransfer({
if (!hash) throw new Error("No transaction hash returned");
const txhash = hash as unknown as string;
setTxHash(txhash);
setTxNetworkName(selectedNetwork.chain.name);
setTransferAmount(amount.toString());
setTransferToken(token);
setIsSuccess(true);
Expand Down Expand Up @@ -246,6 +249,7 @@ export function useSmartWalletTransfer({

if (!hash) throw new Error("No transaction hash returned");
setTxHash(hash);
setTxNetworkName(selectedNetwork.chain.name);

setTransferAmount(amount.toString());
setTransferToken(token);
Expand Down Expand Up @@ -359,9 +363,9 @@ export function useSmartWalletTransfer({
);

const getTxExplorerLink = useCallback((): string | undefined => {
if (!txHash) return undefined;
return getExplorerLink(selectedNetwork.chain.name, txHash) || undefined;
}, [txHash, selectedNetwork]);
if (!txHash || !txNetworkName) return undefined;
return getExplorerLink(txNetworkName, txHash) || undefined;
}, [txHash, txNetworkName]);

return {
isLoading,
Expand Down
11 changes: 4 additions & 7 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,17 +591,14 @@ export function calculateCorrectedTotalBalance(
export async function fetchBalanceForNetwork(
network: { chain: any },
walletAddress: string,
): Promise<{ total: number; balances: Record<string, number> }> {
): Promise<{ total: number; balances: Record<string, number>; balancesInWei: Record<string, bigint> }> {
const { createPublicClient, http } = await import("viem");
const { bsc } = await import("viem/chains");

const rpcUrl = getRpcUrl(network.chain.name);

const publicClient = createPublicClient({
chain: network.chain,
transport: http(
network.chain.id === bsc.id
? "https://bsc-dataseed.bnbchain.org/"
: undefined,
),
transport: http(rpcUrl),
});

return fetchWalletBalance(publicClient, walletAddress);
Expand Down