Skip to content

Commit

Permalink
feat: update transactions amount format
Browse files Browse the repository at this point in the history
  • Loading branch information
akhlopiachyi committed Jan 16, 2024
1 parent a33b4d5 commit 135fdd8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/web-coreum/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-coreum",
"version": "2.19.3-58",
"version": "2.19.3-59",
"license": "Apache-2.0",
"private": true,
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ const Desktop: FC<TransactionsListState> = ({
</div>
),
amount:
typeof x.amount === 'string' && (x.amount === '' || x.amount === '-') ? (
x.amount === '' ? (
(typeof x.amount === 'string' && (x.amount === '' || x.amount === '-')) ||
x.amount?.value === '' ? (
x.amount === '' || x.amount?.value === '' ? (
<Link
shallow
prefetch={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ const ListItem: FC<ListItemProps> = ({
</Link>
),
amount:
typeof transaction.amount === 'string' &&
(transaction.amount === '' || transaction.amount === '-') ? (
transaction.amount === '' ? (
(typeof transaction.amount === 'string' &&
(transaction.amount === '' || transaction.amount === '-')) ||
transaction.amount?.value === '' ? (
transaction.amount === '' || transaction.amount?.value === '' ? (
<Link shallow prefetch={false} href={TRANSACTION_DETAILS(transaction.hash)}>
{t('transactions:more')}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ const ListItem: FC<ListItemProps> = ({ index, style, setRowHeight, isItemLoaded,
</Tooltip>
),
amount:
typeof transaction.amount === 'string' &&
(transaction.amount === '' || transaction.amount === '-') ? (
transaction.amount === '' ? (
(typeof transaction.amount === 'string' &&
(transaction.amount === '' || transaction.amount === '-')) ||
transaction.amount?.value === '' ? (
transaction.amount === '' || transaction.amount?.value === '' ? (
<Link shallow prefetch={false} href={TRANSACTION_DETAILS(transaction.hash)}>
{t('transactions:more')}
</Link>
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/screens/account_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ export const useAccountDetails = () => {
// Fetch Data
// ==========================
const { address: withdrawalAddress, error } = useAccountWithdrawalAddress(address);
console.log({ error, withdrawalAddress });

useEffect(() => {
handleSetState((prevState) => ({
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/screens/account_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const AccountDetails = () => {
const { classes } = useStyles();
const { state } = useAccountDetails();

console.log({ exists: state.exists });

return (
<>
<NextSeo
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/screens/transactions/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const formatTransactions = (data: TransactionsListenerSubscription): Transaction
x.logs,
feeAmount.denom
);

const formatedAmount =
amount !== '' && amount !== '-'
? formatToken(amount.replace(feeAmount.denom, ''), feeAmount.denom)
Expand Down
10 changes: 9 additions & 1 deletion packages/ui/src/utils/format_token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ export const formatToken = (value: number | string | null | undefined, denom = '
}

const ratio = Big(10 ** selectedDenom.exponent);
results.value = !ratio.eq(0) ? Big(value).div(ratio).toFixed(selectedDenom.exponent) : '';

const isValidToken = value.includes('ibc/') || value.includes(',');

if (isValidToken) {
results.value = '';
} else {
results.value = !ratio.eq(0) ? Big(value).div(ratio).toFixed(selectedDenom.exponent) : '';
}

results.displayDenom = selectedDenom.display;
return results;
};
Expand Down

0 comments on commit 135fdd8

Please sign in to comment.