Skip to content

Commit

Permalink
[APIS-181] Squid cosmos swap ibc logic 개선 (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Gamja authored Feb 19, 2024
1 parent 68853f1 commit 7512d1c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Popup/hooks/SWR/integratedSwap/squid/useSquidCosmosSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { SQUID_COLLECT_FEE_BPF, SQUID_COLLECT_FEE_INTEGRATOR_ADDRESS } from '~/c
import { useAssetsSWR, useAssetsSWR as useCosmosAssetsSWR } from '~/Popup/hooks/SWR/cosmos/useAssetsSWR';
import { useExtensionStorage } from '~/Popup/hooks/useExtensionStorage';
import { divide, gt, plus, times, toDisplayDenomAmount } from '~/Popup/utils/big';
import { convertAssetNameToCosmos, getPublicKeyType } from '~/Popup/utils/cosmos';
import { convertAssetNameToCosmos, findCosmosChainByAddress, getPublicKeyType } from '~/Popup/utils/cosmos';
import { protoTx, protoTxBytes } from '~/Popup/utils/proto';
import { isEqualsIgnoringCase } from '~/Popup/utils/string';
import type { CosmosChain } from '~/types/chain';
Expand Down Expand Up @@ -206,8 +206,14 @@ export function useSquidCosmosSwap(squidSwapProps?: UseSquidCosmosSwapProps) {
const channelChain = useMemo(() => {
const asset = assets.data?.find((item) => item.channel === chainInfo.channelId && item.port === chainInfo.port);

return convertAssetNameToCosmos(asset?.origin_chain || '');
}, [assets.data, chainInfo.channelId, chainInfo.port]);
if (asset?.origin_chain) {
return convertAssetNameToCosmos(asset.origin_chain);
}

const transferMsg = parsedSquidSwapTx?.msgTypeUrl === '/ibc.applications.transfer.v1.MsgTransfer' ? parsedSquidSwapTx : undefined;

return findCosmosChainByAddress(transferMsg?.msg.receiver);
}, [assets.data, parsedSquidSwapTx, chainInfo.channelId, chainInfo.port]);

const channelChainLatestBlock = useBlockLatestSWR(channelChain);

Expand Down

0 comments on commit 7512d1c

Please sign in to comment.