From aa3f9d2224ae36484a0b3a76a537a3d934c27164 Mon Sep 17 00:00:00 2001 From: heisenberg Date: Wed, 22 May 2024 12:28:32 +0800 Subject: [PATCH] feat: text & typeddata header --- src/ui/views/Approval/components/SignText.tsx | 1 + .../Approval/components/SignTypedData.tsx | 1 + .../Approval/components/TextActions/index.tsx | 138 +++--- .../components/TypedDataActions/index.tsx | 432 +++++++++--------- 4 files changed, 289 insertions(+), 283 deletions(-) diff --git a/src/ui/views/Approval/components/SignText.tsx b/src/ui/views/Approval/components/SignText.tsx index 8a5fc7fb374..d51e26b03d7 100644 --- a/src/ui/views/Approval/components/SignText.tsx +++ b/src/ui/views/Approval/components/SignText.tsx @@ -360,6 +360,7 @@ const SignText = ({ params }: { params: SignTextProps }) => { raw={hexData} message={signText} origin={params.session.origin} + originLogo={params.session.icon} /> )} diff --git a/src/ui/views/Approval/components/SignTypedData.tsx b/src/ui/views/Approval/components/SignTypedData.tsx index d0f6ad234fb..dbf7643a137 100644 --- a/src/ui/views/Approval/components/SignTypedData.tsx +++ b/src/ui/views/Approval/components/SignTypedData.tsx @@ -538,6 +538,7 @@ const SignTypedData = ({ params }: { params: SignTypedDataProps }) => { raw={isSignTypedDataV1 ? data[0] : signTypedData || data[1]} message={parsedMessage} origin={params.session.origin} + originLogo={params.session.icon} /> )} {!isLoading && chain?.isTestnet ? ( diff --git a/src/ui/views/Approval/components/TextActions/index.tsx b/src/ui/views/Approval/components/TextActions/index.tsx index 4c57a34dd26..dcd6ce42fce 100644 --- a/src/ui/views/Approval/components/TextActions/index.tsx +++ b/src/ui/views/Approval/components/TextActions/index.tsx @@ -10,7 +10,7 @@ import IconArrowRight, { import CreateKey from './CreateKey'; import VerifyAddress from './VerifyAddress'; import { TooltipWithMagnetArrow } from '@/ui/component/Tooltip/TooltipWithMagnetArrow'; -import IconQuestionMark from 'ui/assets/sign/question-mark-24.svg'; +import { ReactComponent as IconQuestionMark } from 'ui/assets/sign/question-mark.svg'; import IconRabbyDecoded from 'ui/assets/sign/rabby-decoded.svg'; import IconCheck, { ReactComponent as RcIconCheck, @@ -21,6 +21,8 @@ import { NoActionAlert } from '../NoActionAlert/NoActionAlert'; import ThemeIcon from '@/ui/component/ThemeMode/ThemeIcon'; import { CommonAction } from '../CommonAction'; import { ActionWrapper } from '../ActionWrapper'; +import { Card } from '../Card'; +import { OriginInfo } from '../OriginInfo'; const { TabPane } = Tabs; @@ -104,12 +106,14 @@ const Actions = ({ raw, message, origin, + originLogo, }: { data: TextActionData | null; engineResults: Result[]; raw: string; message: string; origin: string; + originLogo?: string; }) => { const actionName = useMemo(() => { return getActionTypeText(data); @@ -120,7 +124,8 @@ const Actions = ({ const handleViewRawClick = () => { Popup.info({ closable: true, - height: 720, + height: 520, + isNew: true, content: ( {raw && ( @@ -138,70 +143,77 @@ const Actions = ({ return ( <> - -
{t('page.signText.title')}
-
- {t('page.signTx.viewRaw')} - -
-
-
-
{actionName}
-
- - ) : ( - - - {t('page.signTx.decodedTooltip')} - - ) - } - > - {isUnknown ? ( - - ) : ( - + + + + + +
+
+ {actionName} + {isUnknown && ( + + } + > + + )} - -
-
- {data && ( -
- {data.createKey && ( - - )} - {data.verifyAddress && ( - - )} - {data.common && ( - - )} +
+
+
+ {t('page.signTx.viewRaw')} + +
+
- )} + + {data && ( +
+ {data.createKey && ( + + )} + {data.verifyAddress && ( + + )} + {data.common && ( + + )} +
+ )} + ; message: string; origin: string; + originLogo?: string; }) => { const { t } = useTranslation(); @@ -160,229 +164,217 @@ const Actions = ({ return ( <> - -
- {t('page.signTypedData.signTypeDataOnChain', { - chain: chain ? chain.name : '', - })} -
-
- {t('page.signTx.viewRaw')} - -
-
- -
-
- {data?.brand ? ( - - ) : null} - {actionName} -
-
- - ) : ( - - - {t('page.signTx.decodedTooltip')} - - ) - } - > - {isUnknown ? ( - - ) : ( - + + + + + +
+
+ {actionName} + {isUnknown && ( + + } + > + + )} - -
-
- {chain?.isTestnet ? ( - <> -
- {JSON.stringify(raw, null, 2)}
- - ) : ( - <> - {(data?.actionType || data?.actionType === null) && ( -
- {data.permit && ( - - )} - {data.revokePermit && chain && ( - - )} - {data.permit2 && chain && ( - - )} - {data.approveNFT && chain && ( - - )} - {data.batchPermit2 && chain && ( - - )} - {data.swapTokenOrder && chain && ( - - )} - {data.buyNFT && chain && ( - - )} - {data.batchSellNFT && chain && ( - - )} - {data.sellNFT && chain && ( - - )} - {data.assetOrder && chain && ( - - )} - {data.signMultiSig && ( - - )} - {data.send && chain && ( - - )} - {data.createKey && ( - - )} - {data.verifyAddress && ( - - )} - {data.contractCall && chain && ( - - )} - {data.coboSafeCreate && ( - - )} - {data.coboSafeModificationRole && ( - - )} - {data.coboSafeModificationDelegatedAddress && ( - - )} - {data.coboSafeModificationTokenApproval && ( - - )} - {data.common && ( - - )} +
+
+ {t('page.signTx.viewRaw')} +
- )} - - )} +
+
+ + {chain?.isTestnet ? ( + <> +
+ {JSON.stringify(raw, null, 2)} +
+ + ) : ( + <> + {(data?.actionType || data?.actionType === null) && ( +
+ {data.permit && ( + + )} + {data.revokePermit && chain && ( + + )} + {data.permit2 && chain && ( + + )} + {data.approveNFT && chain && ( + + )} + {data.batchPermit2 && chain && ( + + )} + {data.swapTokenOrder && chain && ( + + )} + {data.buyNFT && chain && ( + + )} + {data.batchSellNFT && chain && ( + + )} + {data.sellNFT && chain && ( + + )} + {data.assetOrder && chain && ( + + )} + {data.signMultiSig && ( + + )} + {data.send && chain && ( + + )} + {data.createKey && ( + + )} + {data.verifyAddress && ( + + )} + {data.contractCall && chain && ( + + )} + {data.coboSafeCreate && ( + + )} + {data.coboSafeModificationRole && ( + + )} + {data.coboSafeModificationDelegatedAddress && ( + + )} + {data.coboSafeModificationTokenApproval && ( + + )} + {data.common && ( + + )} +
+ )} + + )} +