Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display all testnet tokens #739

Closed
wants to merge 14 commits into from
1 change: 1 addition & 0 deletions src/components/ContractDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
:contract-id="contractDetails.id"
class="contract-details-panel__icon"/>
{{ contractDetails.tokenDetails.symbol }}
<not-available-label v-if="!contractDetails.tokenDetails.symbol"/>
</app-link>
</div>
<app-link
Expand Down
17 changes: 14 additions & 3 deletions src/components/CopyChip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
<div class="copy-chip__container">
<div class="copy-chip__text">
{{ textToDisplay }}
<not-available-label
v-if="!textToDisplay"
class="copy-chip__not-available-label"/>
</div>

<copy-button
v-if="!!textToDisplay"
v-show="!isCopyAnimationActive"
class="copy-chip__copy-button"
:clipboard-text="clipboardText || label"
variant="light"
@copy:started="activateCopyAnimation"
Expand Down Expand Up @@ -54,17 +58,24 @@ function deactivateCopyAnimation() {

<style scoped>
.copy-chip {
min-width: 72px;
min-width: 39px;

&__container {
display: flex;
}

&__text {
margin-right: var(--space-1);
display: flex;
flex-grow: 1;
justify-content: center;
}

&__not-available-label {
color: var(--color-white) !important;
}

&__copy-button {
margin-left: var(--space-1);
}
}
</style>
16 changes: 16 additions & 0 deletions src/components/NotAvailableLabel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<app-tooltip class="not-available-label">
N/A
<template #tooltip>
Value is empty
</template>
</app-tooltip>
</template>

<style scoped>
.not-available-label {
display: inline-flex;
color: var(--color-midnight-55);
font-style: italic;
}
</style>
6 changes: 3 additions & 3 deletions src/components/TheFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@
class="footer__version">
ÆSCAN VERSION
<app-link :to="APP_RELEASES_URL">
v{{ APP_VERSION }}
{{ APP_VERSION }}
</app-link>
</div>
<div
class="footer__version">
NODE VERSION
<app-link :to="NODE_RELEASES_URL">
v{{ nodeStatus.nodeVersion }}
{{ formatNullable(nodeStatus?.nodeVersion) }}
</app-link>
</div>
<div
class="footer__version">
MIDDLEWARE VERSION
<app-link :to="MDW_RELEASES_URL">
v{{ middlewareStatus.mdwVersion }}
{{ formatNullable(middlewareStatus?.mdwVersion) }}
</app-link>
<span
v-if="isSyncing"
Expand Down
1 change: 1 addition & 0 deletions src/components/TokenDetailsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</th>
<td class="token-details-panel__data">
{{ tokenDetails.name }}
<not-available-label v-if="!tokenDetails.name"/>
</td>
</tr>
<tr
Expand Down
20 changes: 13 additions & 7 deletions src/components/TokenHoldersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@
{{ formatNumber(holder.amount, 0, tokenDetails.decimals) }} {{ tokenDetails.symbol }}
</td>
<td>
<template v-if="Math.abs(holder.percentage) >= 0.00001">
{{ formatNumber(Math.abs(holder.percentage)) }}
</template>
<template v-else>
~0
</template>
%
{{ formatPercentage(holder.percentage) }}
</td>
</tr>
</tbody>
Expand All @@ -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 %'
}
}
</script>
20 changes: 13 additions & 7 deletions src/components/TokenHoldersTableCondensed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,7 @@
</app-tooltip>
</th>
<td class="token-holders-table-condensed__data">
<template v-if="Math.abs(holder.percentage) >= 0.00001">
{{ formatNumber(Math.abs(holder.percentage)) }}
</template>
<template v-else>
~0
</template>
%
{{ formatPercentage(holder.percentage) }}
</td>
</tr>
</table>
Expand All @@ -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 %'
}
}
</script>

<style scoped>
Expand Down
7 changes: 6 additions & 1 deletion src/components/TokensPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
@prev-clicked="loadPrevTokens"
@next-clicked="loadNextTokens">
<template #header>
<token-select v-model="selectedTokenName"/>
<token-select
v-if="NETWORK_NAME !== 'TESTNET'"
v-model="selectedTokenName"/>
</template>
<tokens-table
v-if="selectedTokens"
Expand All @@ -25,6 +27,7 @@
<script setup>
import { storeToRefs } from 'pinia'
import { computed, watch } from 'vue'
import { useRuntimeConfig } from 'nuxt/app'
import { useTokensStore } from '@/stores/tokens'
import TokensTableCondensed from '@/components/TokensTableCondensed'
import TokensTable from '@/components/TokensTable'
Expand All @@ -36,6 +39,8 @@ const tokensStore = useTokensStore()
const { selectedTokens, selectedTokenName, selectedTokensCount } = storeToRefs(tokensStore)
const { fetchTokens, fetchTokensCount } = useTokensStore()

const { NETWORK_NAME } = useRuntimeConfig().public

const pageIndex = ref(1)

async function loadPrevTokens() {
Expand Down
6 changes: 5 additions & 1 deletion src/components/TokensTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
:contract-id="token.contractId"
class="tokens-table__icon"/>
{{ token.symbol }}
<not-available-label v-if="!token.symbol"/>
</app-link>
</td>
<td>{{ token.name }}</td>
<td>
{{ token.name }}
<not-available-label v-if="!token.name"/>
</td>
<td>
<value-hash-ellipsed
:link-to="`/contracts/${token.contractId}`"
Expand Down
2 changes: 2 additions & 0 deletions src/components/TokensTableCondensed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:contract-id="token.contractId"
class="tokens-table-condensed__icon"/>
{{ token.symbol }}
<not-available-label v-if="!token.symbol"/>
</app-link>
</td>
</tr>
Expand All @@ -37,6 +38,7 @@
</th>
<td class="tokens-table-condensed__data">
{{ token.name }}
<not-available-label v-if="!token.name"/>
</td>
</tr>
<tr class="tokens-table-condensed__row">
Expand Down
2 changes: 1 addition & 1 deletion src/stores/tokenDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/stores/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export const useTokensStore = defineStore('tokens', () => {
const allTokens = ref(null)
const selectedTokenName = ref(null)
const allTokensCount = ref(null)
const { NETWORK_NAME } = useRuntimeConfig().public

const selectedTokens = computed(() => {
return selectedTokenName.value?.key === 'listedTokens' ? listedTokens.value : allTokens.value
return selectedTokenName.value?.key === 'listedTokens' && NETWORK_NAME !== 'TESTNET' ? listedTokens.value : allTokens.value
})

const selectedTokensCount = computed(() => {
return selectedTokenName.value?.key === 'listedTokens' ? listedTokens.value?.data.length : allTokensCount.value
})
Expand Down
3 changes: 1 addition & 2 deletions src/utils/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,9 @@ 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()
}

return tokenDetails
}

Expand Down
Loading