From 6140a7cadd25d4a1b4a4fdba5d73e3e47e84e034 Mon Sep 17 00:00:00 2001 From: Edgar Khanzadian Date: Thu, 14 Dec 2023 13:10:26 +0400 Subject: [PATCH] fix: serialize sip10 form memo before displaying it --- .../family/stacks/hooks/use-stacks-transaction-summary.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/pages/send/send-crypto-asset-form/family/stacks/hooks/use-stacks-transaction-summary.ts b/src/app/pages/send/send-crypto-asset-form/family/stacks/hooks/use-stacks-transaction-summary.ts index 303935fa552..bdcab79db67 100644 --- a/src/app/pages/send/send-crypto-asset-form/family/stacks/hooks/use-stacks-transaction-summary.ts +++ b/src/app/pages/send/send-crypto-asset-form/family/stacks/hooks/use-stacks-transaction-summary.ts @@ -1,10 +1,13 @@ +import { bytesToUtf8 } from '@stacks/common'; import { + ClarityType, ContractCallPayload, IntCV, StacksTransaction, TokenTransferPayload, addressToString, cvToString, + serializeCV, } from '@stacks/transactions'; import BigNumber from 'bignumber.js'; @@ -74,8 +77,9 @@ export function useStacksTransactionSummary(token: CryptoCurrencies) { const payload = tx.payload as ContractCallPayload; const fee = tx.auth.spendingCondition.fee; const txValue = Number((payload.functionArgs[0] as IntCV).value); - const memo = cvToString(payload.functionArgs[3]); - const memoDisplayText = memo === 'none' ? 'No memo' : memo; + const isSome = payload.functionArgs[3].type === ClarityType.OptionalSome; + const memo = bytesToUtf8(serializeCV(payload.functionArgs[3])); + const memoDisplayText = isSome ? memo : 'No memo'; const sendingValue = formatMoney( convertToMoneyTypeWithDefaultOfZero(symbol, txValue, decimals)