Skip to content

Commit

Permalink
fix: hasReceiver
Browse files Browse the repository at this point in the history
  • Loading branch information
heisenberg-2077 committed Apr 3, 2024
1 parent a9323a3 commit dde330a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/ui/views/Approval/components/CommonAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type CommonActions = {
is_asset_changed: boolean;
is_involving_privacy: boolean;
receiver?: string;
from?: string;
};

export const CommonAction = ({
Expand Down Expand Up @@ -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 (
<div className="relative">
Expand Down Expand Up @@ -156,22 +164,24 @@ export const CommonAction = ({
}
</Col>
)}
{data?.receiver && addressInfo && (
{hasReceiver && actionData.receiver && addressInfo && (
<Col>
<Row isTitle className="w-[100px]">
{t('page.signTx.swap.receiver')}
</Row>
<Row>
<Values.Address address={data.receiver} chain={chain} />
<Values.Address address={actionData.receiver} chain={chain} />
<ul className="desc-list">
<li>
<Values.AddressMemo address={data.receiver} />
<Values.AddressMemo address={actionData.receiver} />
</li>
<SecurityListItem
engineResult={engineResultMap['1139']}
id="1139"
dangerText={t('page.signTx.swap.unknownAddress')}
defaultText={<Values.KnownAddress address={data.receiver} />}
defaultText={
<Values.KnownAddress address={actionData.receiver} />
}
/>
<li>
<ViewMore
Expand All @@ -195,7 +205,7 @@ export const CommonAction = ({
</Row>
</Col>
)}
{!data?.receiver && addressInfo && (
{!hasReceiver && !actionData.receiver && addressInfo && (
<Col>
<Row isTitle className="w-[100px]">
{t('page.signTx.contractCall.suspectedReceiver')}
Expand Down

0 comments on commit dde330a

Please sign in to comment.