From 080372310197955a4526bc326234a3ab3fc71db2 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 26 Aug 2024 13:36:56 +0200 Subject: [PATCH] Metadata: show Notes Fixes #2174 --- lib/address/parseMetaPayload.ts | 3 ++ mocks/metadata/address.ts | 12 +++++ theme/components/Alert/Alert.ts | 2 +- types/api/addressMetadata.ts | 3 ++ .../details/AddressMetadataAlert.pw.tsx | 13 ++++++ ui/address/details/AddressMetadataAlert.tsx | 43 ++++++++++++++++++ ...tadataAlert.pw.tsx_default_base-view-1.png | Bin 0 -> 4407 bytes ui/pages/Address.tsx | 3 ++ 8 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 ui/address/details/AddressMetadataAlert.pw.tsx create mode 100644 ui/address/details/AddressMetadataAlert.tsx create mode 100644 ui/address/details/__screenshots__/AddressMetadataAlert.pw.tsx_default_base-view-1.png diff --git a/lib/address/parseMetaPayload.ts b/lib/address/parseMetaPayload.ts index e8b067b148..c02d2c4f20 100644 --- a/lib/address/parseMetaPayload.ts +++ b/lib/address/parseMetaPayload.ts @@ -27,6 +27,9 @@ export default function parseMetaPayload(meta: AddressMetadataTag['meta']): Addr 'appLogoURL', 'appActionButtonText', 'warpcastHandle', + 'data', + 'alertBgColor', + 'alertTextColor', ]; for (const stringField of stringFields) { diff --git a/mocks/metadata/address.ts b/mocks/metadata/address.ts index f708fcb319..93860f4b44 100644 --- a/mocks/metadata/address.ts +++ b/mocks/metadata/address.ts @@ -90,3 +90,15 @@ export const warpcastTag: AddressMetadataTagApi = { warpcastHandle: 'duckYduck', }, }; + +export const noteTag: AddressMetadataTagApi = { + slug: 'scam-tag', + name: 'Phish 🐟', + tagType: 'note', + ordinal: 100, + meta: { + alertBgColor: 'deeppink', + alertTextColor: 'white', + data: 'Warning! This is scam! See the report', + }, +}; diff --git a/theme/components/Alert/Alert.ts b/theme/components/Alert/Alert.ts index 457511c2d7..acce04ee0e 100644 --- a/theme/components/Alert/Alert.ts +++ b/theme/components/Alert/Alert.ts @@ -13,7 +13,7 @@ function getBg(props: StyleFunctionProps) { const { theme, colorScheme: c } = props; const darkBg = transparentize(`${ c }.200`, 0.16)(theme); return { - light: `colors.${ c }.${ c === 'red' ? '50' : '100' }`, + light: `colors.${ c }.100`, dark: darkBg, }; } diff --git a/types/api/addressMetadata.ts b/types/api/addressMetadata.ts index e433ca21ef..caabd8535a 100644 --- a/types/api/addressMetadata.ts +++ b/types/api/addressMetadata.ts @@ -32,6 +32,9 @@ export interface AddressMetadataTagApi extends Omit appLogoURL?: string; appActionButtonText?: string; warpcastHandle?: string; + data?: string; + alertBgColor?: string; + alertTextColor?: string; } | null; } diff --git a/ui/address/details/AddressMetadataAlert.pw.tsx b/ui/address/details/AddressMetadataAlert.pw.tsx new file mode 100644 index 0000000000..22db404125 --- /dev/null +++ b/ui/address/details/AddressMetadataAlert.pw.tsx @@ -0,0 +1,13 @@ +import { Box } from '@chakra-ui/react'; +import React from 'react'; + +import * as metadataMock from 'mocks/metadata/address'; +import { test, expect } from 'playwright/lib'; + +import AddressMetadataAlert from './AddressMetadataAlert'; + +test('base view', async({ render }) => { + const component = await render(); + + await expect(component).toHaveScreenshot(); +}); diff --git a/ui/address/details/AddressMetadataAlert.tsx b/ui/address/details/AddressMetadataAlert.tsx new file mode 100644 index 0000000000..707ba804d4 --- /dev/null +++ b/ui/address/details/AddressMetadataAlert.tsx @@ -0,0 +1,43 @@ +import { Alert } from '@chakra-ui/react'; +import React from 'react'; + +import type { AddressMetadataTagFormatted } from 'types/client/addressMetadata'; + +interface Props { + tags: Array | undefined; +} + +const AddressMetadataAlert = ({ tags }: Props) => { + const noteTag = tags?.find(({ tagType }) => tagType === 'note'); + if (!noteTag) { + return null; + } + + const content = noteTag.meta?.data; + + if (!content) { + return null; + } + + return ( + + ); +}; + +export default React.memo(AddressMetadataAlert); diff --git a/ui/address/details/__screenshots__/AddressMetadataAlert.pw.tsx_default_base-view-1.png b/ui/address/details/__screenshots__/AddressMetadataAlert.pw.tsx_default_base-view-1.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_Irq4_0=$UjBmaO6FV^!MER`xVVQlF^OtIwe^1T}^9LQA# z)XY4~odse=gG9Na+5D_WZ>DT5RNycSU`V7;N z@Tk@JcOzrRlY+HmVCYSLS454om_cR3tv-Is&z{fhA4Y{_l;vgE)Bn&&&;V662%?hX z51mG{X%!@+br_~mmq=BR8Sn zKt|L2f9l;%58S(57MqwmB^WFz2i=2)*A}dyn1A+n7L~E?JTJ zt3Kj5um$d6aVPw|2_scMW7cQIA<}l+rVW8(YrEdimF(RnlqYEYE9|B~c98IYTDh6@ z(^oEBN8?xD7&D%I=^aBEewMk>DkO8h-5LBY9#ObvBg^dy}rXY>9Q zd3&kKn5k-Fuefi!8!F}bzg$-Ot^oTVl9m>bErL8_c0Y5A0l)X^six1}h+7!@Ut(uw zMwQ!kXYl`1!zAWT{ZFntYD{O0kL^Uc6aT;}XP^J^S+FNjFC3zu8%VwKcgzB@I09J8Y+@^2>i?*hK|Bc_sk5-+;v2f(uwdq)bXre>hGzkz{`Ep5x< z0ez!1XGhzw##25|sn-`nmx-N=3sTfPbE4$)_tQAS9nG9B#)d;WD}GNC@D5}&i;)h2 z{chJ~?viI9t*s{Eb(tvi_=HV8BSv5Q-R$X~5P-gpk#@NzIQIVl D%tBq+ literal 0 HcmV?d00001 diff --git a/ui/pages/Address.tsx b/ui/pages/Address.tsx index c098700730..f834e3fee5 100644 --- a/ui/pages/Address.tsx +++ b/ui/pages/Address.tsx @@ -31,6 +31,7 @@ import AddressTxs from 'ui/address/AddressTxs'; import AddressUserOps from 'ui/address/AddressUserOps'; import AddressWithdrawals from 'ui/address/AddressWithdrawals'; import AddressFavoriteButton from 'ui/address/details/AddressFavoriteButton'; +import AddressMetadataAlert from 'ui/address/details/AddressMetadataAlert'; import AddressQrCode from 'ui/address/details/AddressQrCode'; import AddressEnsDomains from 'ui/address/ensDomains/AddressEnsDomains'; import SolidityscanReport from 'ui/address/SolidityscanReport'; @@ -345,6 +346,8 @@ const AddressPageContent = () => { secondRow={ titleSecondRow } isLoading={ isLoading } /> + { !addressMetadataQuery.isPending && + } { config.features.metasuites.isEnabled && } { /* should stay before tabs to scroll up with pagination */ }