Skip to content
23 changes: 17 additions & 6 deletions src/components/payment-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ export const columns: ColumnDef<Payment>[] = [
{
accessorKey: 'amountInCrypto',
header: 'Amount',
cell: ({ row }) =>
getAmountWithCurrencySymbol(
row.getValue('amountInCrypto'),
row.original?.tokenAddress,
),
cell: ({ row }) => {
const data= row.original

return getAmountWithCurrencySymbol(
BigInt(data.amountInCrypto || data.amount),
data.tokenAddress,
)
},
},
{
accessorKey: 'networkFee',
Expand All @@ -117,7 +120,15 @@ export const columns: ColumnDef<Payment>[] = [
{
accessorKey: 'feeAmount',
header: 'Service Fee',
cell: ({ row }) => row.getValue('feeAmount'),
cell: ({ row }) => {
const data = row.original

return getAmountWithCurrencySymbol(
BigInt(data.feeAmountInCrypto || data.feeAmount),
data.tokenAddress,
)

},
},
{
accessorKey: 'feeAddress',
Expand Down
8 changes: 5 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ export const getAmountWithCurrencySymbol = (
currency: string
) => {
const currencyDetails: { symbol: string; decimals: number } | undefined =
isAddress(currency)
currency && isAddress(currency)
? currencyManager.fromAddress(currency)
: currencyManager.fromSymbol(currency);
: currency
? currencyManager.fromSymbol(currency)
: undefined;

return `${formatUnits(amount, currencyDetails?.decimals || 18)} ${currencyDetails?.symbol || ""}`;
return `${formatUnits(amount, currencyDetails?.decimals || 18)} ${currencyDetails?.symbol || ""}`.trim();
};

/**
Expand Down