From 2578ffef14fe7cc5296a0439c7dde26b962b12cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bego=C3=B1a=20=C3=81lvarez=20de=20la=20Cruz?= Date: Sun, 3 Nov 2024 12:27:21 +0100 Subject: [PATCH] fix(wallet): stringify json nft metadata to avoid nft details crash (#3675) --- .../ui/app/pages/home/nft-details/index.tsx | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/wallet/src/ui/app/pages/home/nft-details/index.tsx b/apps/wallet/src/ui/app/pages/home/nft-details/index.tsx index 290838d951f..0b37bcc2198 100644 --- a/apps/wallet/src/ui/app/pages/home/nft-details/index.tsx +++ b/apps/wallet/src/ui/app/pages/home/nft-details/index.tsx @@ -72,19 +72,26 @@ function NFTDetailsPage() { navigate(`/nft-transfer/${nftId}`); } - function formatMetaValue(value: string) { - if (value.includes('http')) { + function formatMetaValue(value: string | object) { + if (typeof value === 'object') { return { - value: value.startsWith('http') - ? truncateString(value, 20, 8) - : formatAddress(value), - valueLink: value, + value: JSON.stringify(value), + valueLink: undefined, + }; + } else { + if (value.includes('http')) { + return { + value: value.startsWith('http') + ? truncateString(value, 20, 8) + : formatAddress(value), + valueLink: value, + }; + } + return { + value: value, + valueLink: undefined, }; } - return { - value: value, - valueLink: undefined, - }; } return (