Skip to content

Commit

Permalink
fix: [GASBT-7][Sale Widget] Fix transaction end events details (#1599)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhesgodi authored Mar 18, 2024
1 parent 7d735bf commit 863442d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 || '',
),
};
};

Expand Down

0 comments on commit 863442d

Please sign in to comment.