diff --git a/src/screens/Home/Browser/BrowserTab.tsx b/src/screens/Home/Browser/BrowserTab.tsx index a87263eaf..6046347d2 100644 --- a/src/screens/Home/Browser/BrowserTab.tsx +++ b/src/screens/Home/Browser/BrowserTab.tsx @@ -418,7 +418,6 @@ const Component = ({ tabId, onOpenBrowserTabs, connectionTrigger }: Props, ref: return false; } const urlParsed = new urlParse(url); - if (url.startsWith('wc:')) { if (urlParsed.query.startsWith('?requestId')) { return false; @@ -442,6 +441,10 @@ const Component = ({ tabId, onOpenBrowserTabs, connectionTrigger }: Props, ref: return false; } + if (urlParsed.href.includes('wc?requestId')) { + return false; + } + if (urlParsed.href.startsWith('itms-appss://')) { return false; } diff --git a/src/screens/Home/History/Detail/index.tsx b/src/screens/Home/History/Detail/index.tsx index 32b0065d2..5f1f82fc0 100644 --- a/src/screens/Home/History/Detail/index.tsx +++ b/src/screens/Home/History/Detail/index.tsx @@ -63,7 +63,7 @@ export function HistoryDetailModal({ if (link) { return ( - + diff --git a/src/screens/Home/History/index.tsx b/src/screens/Home/History/index.tsx index 00c862cd9..cadcd17a8 100644 --- a/src/screens/Home/History/index.tsx +++ b/src/screens/Home/History/index.tsx @@ -31,7 +31,7 @@ import { TxTypeNameMap } from 'screens/Home/History/shared'; import i18n from 'utils/i18n/i18n'; import { FlatListScreen } from 'components/FlatListScreen'; import { FontMedium } from 'styles/sharedStyles'; -import { ListRenderItemInfo, View } from 'react-native'; +import { Keyboard, ListRenderItemInfo, View } from 'react-native'; import { SectionListData } from 'react-native/Libraries/Lists/SectionList'; import Typography from '../../../components/design-system-ui/typography'; import { useSubWalletTheme } from 'hooks/useSubWalletTheme'; @@ -320,8 +320,9 @@ function History({ const onOpenDetail = useCallback((item: TransactionHistoryDisplayItem) => { return () => { + Keyboard.dismiss(); setSelectedItem(item); - setDetailModalVisible(true); + setTimeout(() => setDetailModalVisible(true), 200); }; }, []); diff --git a/src/screens/Transaction/Stake/index.tsx b/src/screens/Transaction/Stake/index.tsx index 7ac97ed74..6cd836af7 100644 --- a/src/screens/Transaction/Stake/index.tsx +++ b/src/screens/Transaction/Stake/index.tsx @@ -48,6 +48,8 @@ import useFetchChainState from 'hooks/screen/useFetchChainState'; import i18n from 'utils/i18n/i18n'; import { ModalRef } from 'types/modalRef'; import { AccountSelector } from 'components/Modal/common/AccountSelector'; +import { BN, BN_ZERO } from '@polkadot/util'; +import { isSameAddress } from '@subwallet/extension-base/utils'; export const Stake = ({ route: { @@ -169,6 +171,28 @@ export const Stake = ({ return '0'; }, [assetRegistry, asset]); + const getSelectedValidators = useCallback( + (nominations: string[]) => { + const validatorList = validatorInfoMap[chain]; + + if (!validatorList) { + return []; + } + + const result: ValidatorInfo[] = []; + + validatorList.forEach(validator => { + if (nominations.some(nomination => isSameAddress(nomination, validator.address))) { + // remember the format of the address + result.push(validator); + } + }); + + return result; + }, + [chain, validatorInfoMap], + ); + const maxValue = useMemo(() => { const balance = new BigN(nativeTokenBalance.value); const ed = new BigN(existentialDeposit); @@ -262,13 +286,44 @@ export const Stake = ({ return undefined; }, [nominationPoolInfoMap, chain, currentPool]); - const minStake = useMemo( - () => - (currentStakingType === StakingType.POOLED - ? chainStakingMetadata?.minJoinNominationPool - : chainStakingMetadata?.minStake) || '0', - [chainStakingMetadata?.minJoinNominationPool, chainStakingMetadata?.minStake, currentStakingType], - ); + const getValidatorMinStake = useCallback((validatorInfos: ValidatorInfo[]) => { + let minStake = BN_ZERO; + + validatorInfos.forEach(validatorInfo => { + const bnMinBond = new BN(validatorInfo?.minBond); + + if (bnMinBond.gt(minStake)) { + minStake = bnMinBond; + } + }); + + return minStake.toString(); + }, []); + + const chainMinStake = useMemo(() => { + return currentStakingType === StakingType.NOMINATED + ? chainStakingMetadata?.minStake || '0' + : chainStakingMetadata?.minJoinNominationPool || '0'; + }, [chainStakingMetadata?.minJoinNominationPool, chainStakingMetadata?.minStake, currentStakingType]); + + const minStake = useMemo(() => { + if (currentStakingType === StakingType.NOMINATED) { + const validatorInfos = getSelectedValidators(parseNominations(currentValidator)); + const validatorMinStake = getValidatorMinStake(validatorInfos); + + const nominatedMinStake = BN.max(new BN(validatorMinStake), new BN(chainStakingMetadata?.minStake || '0')); + return nominatedMinStake.toString(); + } + + return chainStakingMetadata?.minJoinNominationPool || '0'; + }, [ + chainStakingMetadata?.minJoinNominationPool, + chainStakingMetadata?.minStake, + currentStakingType, + currentValidator, + getSelectedValidators, + getValidatorMinStake, + ]); const getMetaInfo = useCallback(() => { if (chainStakingMetadata) { @@ -426,13 +481,7 @@ export const Stake = ({ defaultValue={asset} acceptDefaultValue={true} renderSelected={() => ( - + )} /> @@ -507,7 +556,7 @@ export const Stake = ({ modalVisible={detailNetworkModalVisible} chainStakingMetadata={chainStakingMetadata} stakingType={currentStakingType as StakingType} - minimumActive={{ decimals, value: minStake, symbol }} + minimumActive={{ decimals, value: chainMinStake, symbol }} setVisible={setDetailNetworkModalVisible} /> )}