Skip to content

Commit

Permalink
fix: serialize sip10 form memo before displaying it
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarkhanzadian committed Dec 14, 2023
1 parent aae3221 commit 6140a7c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6140a7c

Please sign in to comment.