From 8136ea7ae2967e7696c56d1802bd84dab905ff41 Mon Sep 17 00:00:00 2001 From: tunghp2002 Date: Wed, 25 Dec 2024 18:43:58 +0700 Subject: [PATCH] [Update] Fix UI for POS -> ETH --- .../balance-service/transfer/xcm/posBridge.ts | 10 +++++++++ .../Popup/Transaction/variants/SendFund.tsx | 18 ++++++++++++++- .../src/components/Field/AddressInputNew.tsx | 2 ++ .../Popup/Transaction/variants/SendFund.tsx | 22 ++++++++++++++++++- .../src/components/Field/AddressInput.tsx | 1 + 5 files changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/extension-base/src/services/balance-service/transfer/xcm/posBridge.ts b/packages/extension-base/src/services/balance-service/transfer/xcm/posBridge.ts index 186b8f996b..4b64c45437 100644 --- a/packages/extension-base/src/services/balance-service/transfer/xcm/posBridge.ts +++ b/packages/extension-base/src/services/balance-service/transfer/xcm/posBridge.ts @@ -168,3 +168,13 @@ export function _isPosChainBridge (srcChain: string, destChain: string): boolean return false; } + +export function _isPosChainL2Bridge (srcChain: string, destChain: string): boolean { + if (srcChain === 'polygon_amoy' && destChain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) { + return true; + } else if (srcChain === 'polygon' && destChain === COMMON_CHAIN_SLUGS.ETHEREUM) { + return true; + } + + return false; +} diff --git a/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx b/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx index 912e427020..b1949c6e61 100644 --- a/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx +++ b/packages/extension-koni-ui/src/Popup/Transaction/variants/SendFund.tsx @@ -10,7 +10,7 @@ import { ActionType } from '@subwallet/extension-base/core/types'; import { getAvailBridgeGatewayContract, getSnowBridgeGatewayContract } from '@subwallet/extension-base/koni/api/contract-handler/utils'; import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge'; import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge'; -import { _isPosChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge'; +import { _isPosChainBridge, _isPosChainL2Bridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge'; import { _getAssetDecimals, _getAssetName, _getAssetOriginChain, _getAssetSymbol, _getContractAddressOfToken, _getMultiChainAsset, _getOriginChainOfAsset, _getTokenMinAmount, _isChainEvmCompatible, _isNativeToken, _isTokenTransferredByEvm } from '@subwallet/extension-base/services/chain-service/utils'; import { TON_CHAINS } from '@subwallet/extension-base/services/earning-service/constants'; import { SWTransactionResponse } from '@subwallet/extension-base/services/transaction-service/types'; @@ -180,6 +180,14 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone return !!chainInfo && !!assetInfo && _isChainEvmCompatible(chainInfo) && destChainValue === chainValue && _isNativeToken(assetInfo); }, [chainInfoMap, chainValue, destChainValue, assetInfo]); + const disabledToAddressInput = useMemo(() => { + if (_isPosChainL2Bridge(chainValue, destChainValue)) { + return true; + } + + return false; + }, [chainValue, destChainValue]); + const [loading, setLoading] = useState(false); const [isTransferAll, setIsTransferAll] = useState(false); @@ -378,6 +386,13 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone } if (part.from || part.destChain) { + const destChain = part.destChain || ''; + const chainValue = values.chain || ''; + + if (_isPosChainL2Bridge(chainValue, destChain)) { + form.setFieldValue('to', values.from); + } + setForceUpdateMaxValue(isTransferAll ? {} : undefined); } @@ -883,6 +898,7 @@ const Component = ({ className = '', isAllAccount, targetAccountProxy }: Compone > ): React.Rea <>
): React.Rea showAddressBook && (