Skip to content

Commit

Permalink
fix: swap networks add default fee
Browse files Browse the repository at this point in the history
  • Loading branch information
foodaka committed Oct 18, 2024
1 parent 80db222 commit b6b2ac7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/transactions/Bridge/BridgeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ export const BridgeModalContent = () => {
const { data: estimatedTimeToDestination, isFetching: loadingEstimatedTime } =
useTimeToDestination(sourceNetworkObj.chainId);

const filteredFeeTokensByChainId = laneConfig
.filter((token) => token.sourceChainId === sourceNetworkObj.chainId)
.flatMap((config) => config.feeTokens);
const getFilteredFeeTokens = (chainId: number) => {
return laneConfig
.filter((token) => token.sourceChainId === chainId)
.flatMap((config) => config.feeTokens);
};

const filteredFeeTokensByChainId = getFilteredFeeTokens(sourceNetworkObj.chainId);

const { data: feeTokenListWithBalance } = useTokensBalance(
filteredFeeTokensByChainId,
Expand All @@ -110,7 +114,7 @@ export const BridgeModalContent = () => {
if (feeTokenListWithBalance && feeTokenListWithBalance.length > 0 && !selectedFeeToken) {
setSelectedFeeToken(feeTokenListWithBalance[0]);
}
}, [feeTokenListWithBalance, selectedFeeToken]);
}, [feeTokenListWithBalance, sourceNetworkObj]);

useEffect(() => {
// reset when source network changes
Expand Down Expand Up @@ -206,6 +210,9 @@ export const BridgeModalContent = () => {
const currentSourceNetworkObj = sourceNetworkObj;
setSourceNetworkObj(destinationNetworkObj);
setDestinationNetworkObj(currentSourceNetworkObj);

const newFilteredFeeTokens = getFilteredFeeTokens(destinationNetworkObj.chainId);
setSelectedFeeToken(newFilteredFeeTokens[0]);
};

const bridgeActionsProps: BridgeActionProps = {
Expand Down

0 comments on commit b6b2ac7

Please sign in to comment.