From 86deb2aab7e75d589dfa13bffdd443ed9d83213e Mon Sep 17 00:00:00 2001 From: nabarun Date: Fri, 25 Jul 2025 07:50:21 +0000 Subject: [PATCH] Fix balance check for cosmos token transfer txs (#40) Part of https://www.notion.so/Integrate-eSIM-buy-flow-into-app-18aa6b22d47280d4a77cf1b27e2ba193 Co-authored-by: pranavjadhav007 Reviewed-on: https://git.vdb.to/LaconicNetwork/laconic-wallet-web/pulls/40 --- package.json | 2 +- src/hooks/useWebViewHandler.ts | 4 +--- src/screens/ApproveTransfer.tsx | 8 +++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 1bd8843..c2f4bc8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "web-wallet", - "version": "0.1.7", + "version": "0.1.7-nym-0.1.1", "private": true, "dependencies": { "@cerc-io/registry-sdk": "^0.2.5", diff --git a/src/hooks/useWebViewHandler.ts b/src/hooks/useWebViewHandler.ts index fdd352c..5b0fb12 100644 --- a/src/hooks/useWebViewHandler.ts +++ b/src/hooks/useWebViewHandler.ts @@ -4,7 +4,6 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { useAccounts } from '../context/AccountsContext'; import { useNetworks } from '../context/NetworksContext'; -import useAccountsData from "../hooks/useAccountsData"; import { StackParamsList } from '../types'; import useGetOrCreateAccounts from './useGetOrCreateAccounts'; @@ -15,7 +14,6 @@ export const useWebViewHandler = () => { const navigation = useNavigation>(); const { selectedNetwork } = useNetworks(); const { accounts, currentIndex } = useAccounts(); - const { getAccountsData } = useAccountsData(); const { getOrCreateAccountsForChain } = useGetOrCreateAccounts(); // Initialize accounts @@ -35,7 +33,7 @@ export const useWebViewHandler = () => { console.error('Account operation error:', error); window.Android?.onAccountError?.(`Operation failed: ${error}`); } - }, [getOrCreateAccountsForChain, getAccountsData]); + }, [getOrCreateAccountsForChain]); // Core navigation handler const navigateToSignRequest = useCallback((message: string) => { diff --git a/src/screens/ApproveTransfer.tsx b/src/screens/ApproveTransfer.tsx index 8a5c54a..b0f37c3 100644 --- a/src/screens/ApproveTransfer.tsx +++ b/src/screens/ApproveTransfer.tsx @@ -548,7 +548,7 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { if (!cosmosStargateClient) { return; } - if (!isSufficientFunds) { + if (!balance) { return; } @@ -567,13 +567,15 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => { if (!(error instanceof Error)) { throw error; } - + if (window.Android?.onTransferError) { + window.Android.onTransferError(`Not able to estimate gas`); + } setTxError(error.message); setIsTxErrorDialogOpen(true); } }; getCosmosGas(); - }, [cosmosStargateClient, isSufficientFunds, sendMsg, transaction,txMemo]); + }, [cosmosStargateClient, balance, sendMsg, transaction, txMemo]); useEffect(() => { if (balance && !isSufficientFunds && !fees) {