From dde330a08d9354aa1037f66ba4ed44a57c3e25f4 Mon Sep 17 00:00:00 2001 From: heisenberg Date: Wed, 3 Apr 2024 15:57:10 +0800 Subject: [PATCH] fix: hasReceiver --- .../Approval/components/CommonAction.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/ui/views/Approval/components/CommonAction.tsx b/src/ui/views/Approval/components/CommonAction.tsx index e61d8f52d14..11b9efab4ce 100644 --- a/src/ui/views/Approval/components/CommonAction.tsx +++ b/src/ui/views/Approval/components/CommonAction.tsx @@ -20,6 +20,7 @@ type CommonActions = { is_asset_changed: boolean; is_involving_privacy: boolean; receiver?: string; + from?: string; }; export const CommonAction = ({ @@ -60,7 +61,14 @@ export const CommonAction = ({ dispatch.securityEngine.init(); }, []); - const addressInfo = (requireData as ContractCallRequireData).unexpectedAddr; + const addressInfo = requireData + ? (requireData as ContractCallRequireData).unexpectedAddr + : undefined; + + const hasReceiver = useMemo(() => { + if (!actionData.receiver || !actionData.from) return false; + return !isSameAddress(actionData.receiver, actionData.from); + }, [actionData]); return (
@@ -156,22 +164,24 @@ export const CommonAction = ({ } )} - {data?.receiver && addressInfo && ( + {hasReceiver && actionData.receiver && addressInfo && ( {t('page.signTx.swap.receiver')} - +
  • - +
  • } + defaultText={ + + } />
  • )} - {!data?.receiver && addressInfo && ( + {!hasReceiver && !actionData.receiver && addressInfo && ( {t('page.signTx.contractCall.suspectedReceiver')}