Skip to content

Commit fbba7ea

Browse files
authored
Merge pull request #968 from bobanetwork/fix/boba-bnb-withdrawal-check
Fix/boba bnb withdrawal check
2 parents f98e62d + 61731cb commit fbba7ea

File tree

6 files changed

+1067
-1009
lines changed

6 files changed

+1067
-1009
lines changed

pnpm-lock.yaml

Lines changed: 1038 additions & 996 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/bridge/useClassicWithdrawal.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export function useClassicWithdrawal() {
100100
if (!address) {
101101
throw new Error(`${ERROR_CODE}: Wallet not connected`)
102102
}
103+
if (!Number(amount)) {
104+
throw new Error(`${ERROR_CODE}: Invalid amount ${amount}`)
105+
}
106+
103107
if (!bridgeContracts?.l2BillingContract?.address) {
104108
throw new Error(`${ERROR_CODE}: Invalid l2BillingContract fee contract address`)
105109
}
@@ -128,8 +132,6 @@ export function useClassicWithdrawal() {
128132
functionName: 'exitFee',
129133
})
130134

131-
console.log(`ExitFee!!`, exitFee)
132-
133135
// Handle allowance approval for erc20 token not boba
134136
if (!isAddressEqual(token.address!, bridgeContracts.l2BOBA.address)) {
135137
const tokenAllownce: bigint = await provider.readContract({

src/hooks/bridge/useExitCostEstimate.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export function useExitCostEstimate() {
2121
amount: string,
2222
decimals: number
2323
) => {
24-
if (!isActiveNetworkBnb || !chainId || !address) {
24+
if (!isActiveNetworkBnb
25+
|| !chainId
26+
|| !address
27+
|| !Number(amount)) {
2528
setClassicExitCost(null);
2629
return;
2730
}

src/hooks/common/useTokenBalances.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ export function useTokenBalance({
9292
const tokenAddress = resolveTokenAddress(tokens, chainId);
9393
const { data: tokenBalance, isLoading, isError, error } = useBalance({
9494
address: userAddress,
95-
token: tokenAddress as any
95+
token: tokenAddress as any,
96+
query: {
97+
enabled: !!userAddress,
98+
refetchOnWindowFocus: true,
99+
staleTime: 0, // Consider data stale immediately
100+
}
96101
});
97102

98103
return {
@@ -124,12 +129,19 @@ export function useTokenBalance({
124129
const { data: nativeBalance } = useBalance({
125130
address: userAddress,
126131
query: {
127-
enabled: !!userAddress
132+
enabled: !!userAddress,
133+
refetchOnWindowFocus: true,
134+
staleTime: 0, // Consider data stale immediately
128135
}
129136
})
130137

131-
const { data: balances, isLoading, isError } = useReadContracts({
138+
const { data: balances, isLoading, isError, error } = useReadContracts({
132139
contracts: contractReads as any[],
140+
query: {
141+
enabled: !!userAddress && contractReads.length > 0,
142+
refetchOnWindowFocus: true,
143+
staleTime: 0, // Consider data stale immediately
144+
}
133145
});
134146

135147
return tokenAddresses.map((address, index) => {
@@ -150,7 +162,7 @@ export function useTokenBalance({
150162
address,
151163
isLoading,
152164
isError,
153-
error: null
165+
error: error
154166
};
155167
});
156168
}

src/layout/bridge/TokenPickerModal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ export const TokenPickerContent: React.FC<TokenPickerContentProps> = ({ onClose
4040
if (!chainId) return []
4141
return TOKEN_REGISTRY[chainId] || []
4242
}, [chainId])
43-
4443
// Fetch all token balances at once
4544
const tokenBalances = useTokenBalance({
46-
tokens: availableTokens.map(token => ({ address: token.address! })),
45+
tokens: availableTokens.map(token => ({ address: token.address! }))
4746
}) as Array<{
4847
balance: string
4948
symbol: string

src/layout/bridge/modal/BridgeConfirmModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ const BridgeConfirmModalContent = () => {
312312
<NetworkIcon chainId={fromNetwork!} />
313313
<Text variant="small" >{networkDetails[fromNetwork!].name}</Text>
314314
<Text variant="small" className="text-blue-500 hover:underline">
315-
<a href={`${networkDetails[fromNetwork!]?.explorer}/tx/${depositTxHash || teleportTxHash || withdrawalTxHash}`} target="_blank" rel="noopener noreferrer">
316-
<IconLink size="20" /> {shortenString(depositTxHash || teleportTxHash || withdrawalTxHash || ''!, '...', 4)}
315+
<a href={`${networkDetails[fromNetwork!]?.explorer}/tx/${depositTxHash || teleportTxHash}`} target="_blank" rel="noopener noreferrer">
316+
<IconLink size="20" /> {shortenString(depositTxHash || teleportTxHash || ''!, '...', 4)}
317317
</a>
318318
</Text>
319319
</div>
@@ -324,8 +324,8 @@ const BridgeConfirmModalContent = () => {
324324
<NetworkIcon chainId={toNetwork!} />
325325
<Text variant="small" >{networkDetails[toNetwork!].name}</Text>
326326
<Text variant="small" className="text-blue-500 hover:underline">
327-
<a href={`${networkDetails[toNetwork!]?.explorer}/tx/${depositTxHash || teleportTxHash || withdrawalTxHash}`} target="_blank" rel="noopener noreferrer">
328-
<IconLink size="20" /> {shortenString(depositTxHash || teleportTxHash || withdrawalTxHash || ''!, '...', 4)}
327+
<a href={`${networkDetails[toNetwork!]?.explorer}/tx/${teleportTxHash || withdrawalTxHash}`} target="_blank" rel="noopener noreferrer">
328+
<IconLink size="20" /> {shortenString(teleportTxHash || withdrawalTxHash || ''!, '...', 4)}
329329
</a>
330330
</Text>
331331
</div>

0 commit comments

Comments
 (0)