From dd61dda27f6cd2384fe5e752febc449d81f07346 Mon Sep 17 00:00:00 2001 From: dominhquang Date: Sat, 28 Sep 2024 14:42:07 +0700 Subject: [PATCH] [Issue-1726] Handle popup update metadata --- .../Confirmations/parts/Sign/Substrate.tsx | 112 +++++++++--------- 1 file changed, 59 insertions(+), 53 deletions(-) diff --git a/src/screens/Confirmations/parts/Sign/Substrate.tsx b/src/screens/Confirmations/parts/Sign/Substrate.tsx index 6eb39e1af..3d9452c4a 100644 --- a/src/screens/Confirmations/parts/Sign/Substrate.tsx +++ b/src/screens/Confirmations/parts/Sign/Substrate.tsx @@ -11,8 +11,8 @@ import { AccountSignMode } from 'types/signer'; import { SigData } from 'types/signer'; import { getSignMode } from 'utils/account'; import { isSubstrateMessage } from 'utils/confirmation/confirmation'; -import { CheckCircle, IconProps, QrCode, Swatches, XCircle } from 'phosphor-react-native'; -import { Button } from 'components/design-system-ui'; +import { CheckCircle, IconProps, QrCode, Swatches, Warning, XCircle } from 'phosphor-react-native'; +import { Button, Icon, PageIcon, SwModal } from 'components/design-system-ui'; import i18n from 'utils/i18n/i18n'; import { getButtonIcon } from 'utils/button'; import { DeviceEventEmitter, Linking, Platform, Text, View } from 'react-native'; @@ -65,7 +65,7 @@ const migrationFAQUrl = const modeCanSignMessage: AccountSignMode[] = [AccountSignMode.QR, AccountSignMode.PASSWORD]; export const SubstrateSignArea = (props: Props) => { - const { account, id, request, txExpirationTime, navigation } = props; + const { account, id, request, txExpirationTime, navigation, isInternal } = props; const { chainInfoMap } = useSelector((state: RootState) => state.chainStore); const genesisHash = useMemo(() => { const _payload = request.payload; @@ -93,6 +93,7 @@ export const SubstrateSignArea = (props: Props) => { isLedger, ); const [showQuoteExpired, setShowQuoteExpired] = useState(false); + const [isShowWarningModal, setIsShowWarningModal] = useState(false); const isMessage = isSubstrateMessage(payload); const dispatch = useDispatch(); const networkName = useMemo( @@ -108,15 +109,14 @@ export const SubstrateSignArea = (props: Props) => { return _isRuntimeUpdated(_payload.signedExtensions); } }, [request.payload]); - // const requireMetadata = useMemo( - // () => - // signMode === AccountSignMode.GENERIC_LEDGER || (signMode === AccountSignMode.LEGACY_LEDGER && isRuntimeUpdated), - // [isRuntimeUpdated, signMode], - // ); + const requireMetadata = useMemo( + () => + signMode === AccountSignMode.GENERIC_LEDGER || (signMode === AccountSignMode.LEGACY_LEDGER && isRuntimeUpdated), + [isRuntimeUpdated, signMode], + ); const isMetadataOutdated = useMemo(() => { const _payload = request.payload; - if (isRawPayload(_payload)) { return false; } else { @@ -127,12 +127,12 @@ export const SubstrateSignArea = (props: Props) => { } }, [request.payload, chain?.specVersion]); - // const isOpenAlert = - // !isMessage && - // !loadingChain && - // !requireMetadata && - // !isInternal && - // (!chain || !chain.hasMetadata || isMetadataOutdated); + const isOpenAlert = + !isMessage && + !loadingChain && + !requireMetadata && + !isInternal && + (!chain || !chain.hasMetadata || isMetadataOutdated); const alertData = useMemo((): AlertData | undefined => { const _requireMetadata = @@ -368,6 +368,12 @@ export const SubstrateSignArea = (props: Props) => { }; }, [txExpirationTime]); + useEffect(() => { + if (isOpenAlert) { + setIsShowWarningModal(true); + } + }, [isOpenAlert]); + useHandleInternetConnectionForConfirmation(onCancel); return ( @@ -378,44 +384,44 @@ export const SubstrateSignArea = (props: Props) => { )} - {/**/} - {/* <>*/} - {/* */} - {/* */} - {/* */} - {/* */} - {/* {`${networkName} network's metadata is out of date, which may cause the transaction to fail. Update metadata using `}*/} - {/* Linking.openURL(metadataFAQUrl)}>*/} - {/* {i18n.attachAccount.readThisInstructionForMoreDetailsP2}*/} - {/* */} - {/* {' or approve transaction at your own risk'}*/} - {/* */} - {/* */} - {/* }*/} - {/* type="primary"*/} - {/* onPress={() => setIsShowWarningModal(false)}>*/} - {/* {'I understand'}*/} - {/* */} - {/* */} - {/* */} - {/**/} + + <> + + + + + {`${networkName} network's metadata is out of date, which may cause the transaction to fail. Update metadata using `} + Linking.openURL(metadataFAQUrl)}> + {i18n.attachAccount.readThisInstructionForMoreDetailsP2} + + {' or approve transaction at your own risk'} + + + + + +