From 921229274da991621f5a7bf124038f593b323b23 Mon Sep 17 00:00:00 2001 From: janmichek Date: Tue, 14 May 2024 10:06:14 +0200 Subject: [PATCH 1/4] improve printing holder percentage --- src/components/TokenHoldersTable.vue | 20 ++++++++++++------- src/components/TokenHoldersTableCondensed.vue | 20 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/components/TokenHoldersTable.vue b/src/components/TokenHoldersTable.vue index a451cd2df..d84b9198e 100644 --- a/src/components/TokenHoldersTable.vue +++ b/src/components/TokenHoldersTable.vue @@ -35,13 +35,7 @@ {{ formatNumber(holder.amount, 0, tokenDetails.decimals) }} {{ tokenDetails.symbol }} - - - % + {{ formatPercentage(holder.percentage) }} @@ -62,4 +56,16 @@ defineProps({ required: true, }, }) + +function formatPercentage(percentage) { + if (percentage >= 0.00001) { + return `${formatNumber(percentage)} %` + } + if (percentage === 0) { + return '0 %' + } + if (percentage < 0.00001) { + return '~0 %' + } +} diff --git a/src/components/TokenHoldersTableCondensed.vue b/src/components/TokenHoldersTableCondensed.vue index 058ce7556..218ee0bef 100644 --- a/src/components/TokenHoldersTableCondensed.vue +++ b/src/components/TokenHoldersTableCondensed.vue @@ -42,13 +42,7 @@ - - - % + {{ formatPercentage(holder.percentage) }} @@ -69,6 +63,18 @@ defineProps({ required: true, }, }) + +function formatPercentage(percentage) { + if (percentage >= 0.00001) { + return `${formatNumber(percentage)} %` + } + if (percentage === 0) { + return '0 %' + } + if (percentage < 0.00001) { + return '~0 %' + } +} diff --git a/src/components/NotAvailableLabel.vue b/src/components/NotAvailableLabel.vue new file mode 100644 index 000000000..64a9c842d --- /dev/null +++ b/src/components/NotAvailableLabel.vue @@ -0,0 +1,16 @@ + + + diff --git a/src/components/TokenDetailsPanel.vue b/src/components/TokenDetailsPanel.vue index d944e700f..46348b9c4 100644 --- a/src/components/TokenDetailsPanel.vue +++ b/src/components/TokenDetailsPanel.vue @@ -23,6 +23,7 @@ {{ tokenDetails.name }} + - {{ formatNumber(tokenDetails.totalSupply) }} {{ tokenDetails.symbol }} + + diff --git a/src/components/TokensTable.vue b/src/components/TokensTable.vue index 71754f0c0..4c8b7cd94 100644 --- a/src/components/TokensTable.vue +++ b/src/components/TokensTable.vue @@ -34,9 +34,13 @@ :contract-id="token.contractId" class="tokens-table__icon"/> {{ token.symbol }} + - {{ token.name }} + + {{ token.name }} + + {{ token.symbol }} + @@ -37,6 +38,7 @@ {{ token.name }} + From 3f787300726443601846399efe84d5834812708f Mon Sep 17 00:00:00 2001 From: janmichek Date: Tue, 14 May 2024 11:57:53 +0200 Subject: [PATCH 4/4] fix null condition --- src/components/TokenDetailsPanel.vue | 5 +---- src/stores/tokenDetails.js | 2 +- src/utils/adapters.js | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/TokenDetailsPanel.vue b/src/components/TokenDetailsPanel.vue index 46348b9c4..4900736ca 100644 --- a/src/components/TokenDetailsPanel.vue +++ b/src/components/TokenDetailsPanel.vue @@ -47,10 +47,7 @@ - - + {{ formatNumber(tokenDetails.totalSupply) }} {{ tokenDetails.symbol }} diff --git a/src/stores/tokenDetails.js b/src/stores/tokenDetails.js index 36ae8db9d..9ddd731d9 100644 --- a/src/stores/tokenDetails.js +++ b/src/stores/tokenDetails.js @@ -31,7 +31,7 @@ export const useTokenDetailsStore = defineStore('tokenDetails', () => { ) const tokenHolders = computed(() => - tokenDetails.value?.totalSupply && rawTokenHolders.value + tokenDetails.value && rawTokenHolders.value ? adaptTokenHolders( rawTokenHolders.value, tokenDetails.value, diff --git a/src/utils/adapters.js b/src/utils/adapters.js index 860a4e647..a07c83bff 100644 --- a/src/utils/adapters.js +++ b/src/utils/adapters.js @@ -396,7 +396,7 @@ export function adaptTokenDetails(token, totalSupply = null, price = null) { ...(price && { price }), } - if (token && totalSupply) { + if (token && totalSupply !== null) { tokenDetails.totalSupply = (new BigNumber(totalSupply)).dividedBy(10 ** token.decimals).toNumber() }