diff --git a/packages/checkout/widgets-lib/src/widgets/sale/functions/utils.ts b/packages/checkout/widgets-lib/src/widgets/sale/functions/utils.ts index f56ccbdcd1..8e3f94b86a 100644 --- a/packages/checkout/widgets-lib/src/widgets/sale/functions/utils.ts +++ b/packages/checkout/widgets-lib/src/widgets/sale/functions/utils.ts @@ -12,3 +12,10 @@ export const sanitizeToLatin1 = (str: string): string => { const regex = /[^\u0000-\u00FF]/g; // eslint-disable-line no-control-regex return str.replace(regex, ''); }; + +export const hexToText = (hex: string): string => { + if (hex.length === 0) return ''; + + const hexStr = hex.startsWith('0x') ? hex.slice(2) : hex; + return Buffer.from(hexStr, 'hex').toString('utf8'); +}; diff --git a/packages/checkout/widgets-lib/src/widgets/sale/hooks/useSignOrder.ts b/packages/checkout/widgets-lib/src/widgets/sale/hooks/useSignOrder.ts index beea6dc4b2..bd8c2cbe56 100644 --- a/packages/checkout/widgets-lib/src/widgets/sale/hooks/useSignOrder.ts +++ b/packages/checkout/widgets-lib/src/widgets/sale/hooks/useSignOrder.ts @@ -13,6 +13,7 @@ import { SignPaymentTypes, } from '../types'; import { PRIMARY_SALES_API_BASE_URL } from '../utils/config'; +import { hexToText } from '../functions/utils'; type SignApiTransaction = { contract_address: string; @@ -141,7 +142,11 @@ const toSignResponse = ( }, rawData: transaction.raw_data, })), - transactionId: transactions.find((txn) => txn.method_call.startsWith('execute'))?.params.reference || '', + transactionId: hexToText( + transactions + .find((txn) => txn.method_call.startsWith('execute')) + ?.params.reference || '', + ), }; };