From 0e8de9e1d686b268a3bc5fea056caae0c248f8b8 Mon Sep 17 00:00:00 2001 From: Hjort Date: Mon, 6 Nov 2023 11:39:02 +0100 Subject: [PATCH 1/2] Fix sign message rendered message display --- packages/browser-wallet/CHANGELOG.md | 7 +++++++ .../src/popup/pages/SignMessage/SignMessage.tsx | 5 +++-- .../browser-wallet/src/popup/pages/SignMessage/i18n/da.ts | 1 + .../browser-wallet/src/popup/pages/SignMessage/i18n/en.ts | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/browser-wallet/CHANGELOG.md b/packages/browser-wallet/CHANGELOG.md index 6bbe58fd..ed4cc459 100644 --- a/packages/browser-wallet/CHANGELOG.md +++ b/packages/browser-wallet/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.1.11 + +### Fixed + +- Sign message's rendered view displaying 'a' when deserialization failed. +- Sign message deserialization failing with new `deserializeTypeValue`. + ## 1.1.10 ### Changed diff --git a/packages/browser-wallet/src/popup/pages/SignMessage/SignMessage.tsx b/packages/browser-wallet/src/popup/pages/SignMessage/SignMessage.tsx index 6a1e185b..b48f6992 100644 --- a/packages/browser-wallet/src/popup/pages/SignMessage/SignMessage.tsx +++ b/packages/browser-wallet/src/popup/pages/SignMessage/SignMessage.tsx @@ -20,6 +20,7 @@ import { addToastAtom } from '@popup/state'; import ExternalRequestLayout from '@popup/page-layouts/ExternalRequestLayout'; import TabBar from '@popup/shared/TabBar'; import clsx from 'clsx'; +import { stringify } from 'json-bigint'; type Props = { onSubmit(signature: AccountTransactionSignature): void; @@ -47,13 +48,13 @@ function BinaryDisplay({ message, url }: { message: MessageObject; url: string } const parsedMessage = useMemo(() => { try { - return JSON.stringify( + return stringify( deserializeTypeValue(Buffer.from(message.data, 'hex'), Buffer.from(message.schema, 'base64')), undefined, 2 ); } catch (e) { - return 'a'; + return t('unableToDeserialize'); } }, []); diff --git a/packages/browser-wallet/src/popup/pages/SignMessage/i18n/da.ts b/packages/browser-wallet/src/popup/pages/SignMessage/i18n/da.ts index 22177d1e..092f02b9 100644 --- a/packages/browser-wallet/src/popup/pages/SignMessage/i18n/da.ts +++ b/packages/browser-wallet/src/popup/pages/SignMessage/i18n/da.ts @@ -5,6 +5,7 @@ const t: typeof en = { descriptionWithSchema: '{{ dApp }} har sendt en rå besked og et schema til at oversætte den. Vi har oversat beskeden, men du burde kun underskrive hvis du stoler på {{ dApp }}', deserializedDisplay: 'Oversat', + unableToDeserialize: 'Det var ikke muligt at oversætte beskeden', rawDisplay: 'Rå', sign: 'Signér', reject: 'Afvis', diff --git a/packages/browser-wallet/src/popup/pages/SignMessage/i18n/en.ts b/packages/browser-wallet/src/popup/pages/SignMessage/i18n/en.ts index 149dcd15..ea94ae09 100644 --- a/packages/browser-wallet/src/popup/pages/SignMessage/i18n/en.ts +++ b/packages/browser-wallet/src/popup/pages/SignMessage/i18n/en.ts @@ -3,6 +3,7 @@ const t = { descriptionWithSchema: "{{ dApp }} has provided the raw message and a schema to render it. We've rendered the message but you should only sign it if you trust {{ dApp }}.", deserializedDisplay: 'Rendered', + unableToDeserialize: 'Unable to render message', rawDisplay: 'Raw', sign: 'Sign', reject: 'Reject', From 94882007aeb261e8f7311e4fc84fb0126967b8de Mon Sep 17 00:00:00 2001 From: Hjort Date: Mon, 6 Nov 2023 14:36:10 +0100 Subject: [PATCH 2/2] Fix changelog entry --- packages/browser-wallet/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser-wallet/CHANGELOG.md b/packages/browser-wallet/CHANGELOG.md index ed4cc459..7ec51869 100644 --- a/packages/browser-wallet/CHANGELOG.md +++ b/packages/browser-wallet/CHANGELOG.md @@ -5,7 +5,7 @@ ### Fixed - Sign message's rendered view displaying 'a' when deserialization failed. -- Sign message deserialization failing with new `deserializeTypeValue`. +- Sign message's stringification failing with new `deserializeTypeValue`. ## 1.1.10