Skip to content

Commit

Permalink
Merge pull request #163 from Cerebellum-Network/release/0.33.0
Browse files Browse the repository at this point in the history
Release 0.33.0
  • Loading branch information
shamilkhan authored Sep 27, 2023
2 parents 21198af + a61bad8 commit 432585f
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
## vNext
...

## v0.33.0
- [FE] Token Metrics Enhancements:
- Express both the "Total Supply" and "Total Staked" values in USD.
- Present the proportion of the "Total Staked" as a percentage of the "Total Supply."
- [FE] Search Bar Redesign

## v0.32.0
- [BE] Add Resilient Network Initialization to Cere Stats API for Robust Handling of Network Failures

Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "0.32.0",
"version": "0.33.0",
"description": "PolkaStats API",
"author": "Mario Pino Uceda",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "0.32.0",
"version": "0.33.0",
"description": "PolkaStats NG Backend",
"author": "Mario Pino Uceda",
"license": "Apache-2.0",
Expand Down
52 changes: 52 additions & 0 deletions frontend/assets/scss/themes/polkastats.scss
Original file line number Diff line number Diff line change
Expand Up @@ -635,3 +635,55 @@ section .section-title {
background-position: 10% 20%;
}
}

// FIAT conversion component

.fiat-conversion {
font-size: 0.8rem;
margin-left: 0.4rem;
padding: 0.2rem 0.4rem;
background-color: rgb(192, 229, 243);
border-radius: 0.2rem;
cursor: pointer;
animation-duration: 0.6s;
color: rgb(11, 129, 168);
}
.fiat-conversion:hover {
background-color: rgb(11, 129, 168);
color: white;
animation-name: onHoverAnimation;
}

@keyframes onHoverAnimation {
0% {
background-color: rgb(192, 229, 243);
}
100% {
background-color: rgb(11, 129, 168);
}
}

.fiat-conversion-short {
cursor: pointer;
}
.fiat-conversion-short .fa-circle {
color: rgb(192, 229, 243) !important;
}
.fiat-conversion-short .fa-dollar-sign {
color: rgb(11, 129, 168);
}
.fiat-conversion-short:hover .fa-circle {
color: rgb(11, 129, 168) !important;
}
.fiat-conversion-short:hover .fa-dollar-sign {
color: white;
}

.dropdown-item {
color: rgba(0, 0, 0, 0.5);
font-size: 0.9rem;
}

.dropdown-item.active, .dropdown-item:active {
color: rgba(0, 0, 0, 0.9);
}
7 changes: 6 additions & 1 deletion frontend/components/Chain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
</h4>
<h6 class="d-inline-block">
{{ formatAmount(totalIssuance) }}
<FIATConversion :units="totalIssuance.toString()" :short="true" />
</h6>
</div>
</div>
Expand All @@ -126,7 +127,9 @@
{{ $t('components.network.total_staked') }}
</h4>
<h6 class="d-inline-block">
{{ formatAmount(totalStaked) }}
{{ formatAmount(totalStaked, 0, true) }}
<FIATConversion :units="totalStaked.toString()" :short="true" />
({{ formatNumber(totalStakedPercentage) }}%)
</h6>
</div>
</div>
Expand Down Expand Up @@ -176,8 +179,10 @@ import { gql } from 'graphql-tag'
import BN from 'bn.js'
import commonMixin from '../mixins/commonMixin.js'
import { network } from '../frontend.config.js'
import FIATConversion from '@/components/FIATConversion'
export default {
components: [FIATConversion],
mixins: [commonMixin],
data() {
return {
Expand Down
121 changes: 121 additions & 0 deletions frontend/components/FIATConversion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<template>
<div class="d-inline-block">
<div v-if="!timestamp || sameDay">
<span
v-if="short"
v-b-tooltip.hover
:title="`$${formatNumber(FIATValue.toFixed(2))}`"
>
<font-awesome-layers class="fa-lg align-middle fiat-conversion-short">
<font-awesome-icon icon="circle" />
<font-awesome-icon icon="dollar-sign" transform="shrink-6" />
</font-awesome-layers>
</span>
<div
v-else
v-b-tooltip.hover
class="fiat-conversion"
:title="$t('components.fiat_conversion.current_value')"
>
(${{ formatNumber(FIATValue.toFixed(2)) }})
</div>
</div>
<div v-else @click="historical = !historical">
<div
v-if="historical"
v-b-tooltip.hover
class="fiat-conversion"
:title="$t('components.fiat_conversion.historic_value')"
>
(${{ formatNumber(historicalFIATValue.toFixed(2)) }})
</div>
<div
v-else
v-b-tooltip.hover
class="fiat-conversion"
:title="$t('components.fiat_conversion.current_value')"
>
(${{ formatNumber(FIATValue.toFixed(2)) }})
</div>
</div>
</div>
</template>
<script>
import axios from 'axios'
import { BigNumber } from 'bignumber.js'
import commonMixin from '@/mixins/commonMixin.js'
import { network } from '@/frontend.config.js'
export default {
mixins: [commonMixin],
props: {
units: {
type: String,
default: '0',
required: true,
},
timestamp: {
type: Number,
default: 0,
},
short: {
type: Boolean,
default: false,
},
},
data() {
return {
historical: false,
network,
historicalFIATValue: 0,
}
},
computed: {
date() {
return this.getDateFromTimestampDDMMYYYY(this.timestamp)
},
USDConversion() {
return parseFloat(this.$store.state.fiat.usd)
},
FIATValue() {
return (
this.USDConversion *
new BigNumber(this.units).div(
new BigNumber(10).pow(network.tokenDecimals)
)
)
},
sameDay() {
return this.date === this.getDateFromTimestampDDMMYYYY(Date.now())
},
},
async mounted() {
this.historicalFIATValue = this.timestamp
? await this.getHistoricalFIATValue()
: 0
},
methods: {
async getHistoricalFIATValue() {
if (network.coinGeckoDenom) {
const response = await axios
.get(
`https://api.coingecko.com/api/v3/coins/${network.coinGeckoDenom}/history?date=${this.date}`
)
.catch((error) => {
// eslint-disable-next-line no-console
console.log('Error fetching historical fiat value: ', error)
})
.finally(() => {
return 0
})
return (
response.data.market_data.current_price.usd *
new BigNumber(this.units).div(
new BigNumber(10).pow(network.tokenDecimals)
)
)
}
},
},
}
</script>
20 changes: 12 additions & 8 deletions frontend/components/Ranking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,18 @@
<!-- Filter -->
<b-row>
<b-col cols="12">
<b-form-input
id="filterInput"
v-model="filter"
type="search"
placeholder="Search validator by address or name"
debounce="500"
class="mb-3"
/>
<b-input-group class="mt-3 mb-4">
<b-input-group-prepend is-text>
<font-awesome-icon icon="search" />
</b-input-group-prepend>
<b-form-input
id="filterInput"
v-model="filter"
type="search"
placeholder="Search validator by address or name"
debounce="500"
/>
</b-input-group>
</b-col>
</b-row>
<!-- Search results -->
Expand Down
30 changes: 18 additions & 12 deletions frontend/components/Search.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<template>
<!-- Filter -->
<!-- Search -->
<b-row class="mb-4">
<b-col cols="12">
<b-form-input
id="searchInput"
v-model="searchInput"
type="search"
placeholder="Search by block number, block hash, extrinsic hash or account address"
@keydown.native="doSearch"
/>
<b-input-group size="xl" class="mb-2">
<b-input-group-prepend is-text>
<font-awesome-icon icon="search" />
</b-input-group-prepend>
<b-form-input
id="searchInput"
v-model="searchInput"
type="search"
:placeholder="$t('components.search.caption')"
@keydown.native="doSearch"
/>
</b-input-group>
</b-col>
</b-row>
</template>

<script>
import commonMixin from '@/mixins/commonMixin.js'
export default {
mixins: [commonMixin],
data() {
Expand All @@ -27,19 +33,19 @@ export default {
if (event.keyCode === 13) {
if (await this.isExtrinsicHash(this.searchInput)) {
this.$router.push({
path: `/extrinsic/${this.searchInput}`,
path: this.localePath(`/extrinsic/${this.searchInput}`),
})
} else if (await this.isBlockHash(this.searchInput)) {
this.$router.push({
path: `/block/${this.searchInput}`,
path: this.localePath(`/block/${this.searchInput}`),
})
} else if (this.isAddress(this.searchInput)) {
this.$router.push({
path: `/account/${this.searchInput}`,
path: this.localePath(`/account/${this.searchInput}`),
})
} else if (this.isBlockNumber(this.searchInput)) {
this.$router.push({
path: `/block?blockNumber=${this.searchInput}`,
path: this.localePath(`/block?blockNumber=${this.searchInput}`),
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
},
"loading": {
"loading_data": "Loading data, please be patient..."
},
"search": {
"caption": "Search by block number, block hash, extrinsic hash or account address"
}
},
"layout": {
Expand Down
3 changes: 3 additions & 0 deletions frontend/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
},
"loading": {
"loading_data": "Cargando datos, por favor sea paciente..."
},
"search": {
"caption": "Buscar por bloque, hash de bloque, hash de extrinsic o dirección"
}
},
"layout": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.32.0",
"version": "0.33.0",
"description": "PolkaStats NG frontend",
"author": "Mario Pino Uceda",
"license": "Apache-2.0",
Expand Down
17 changes: 11 additions & 6 deletions frontend/pages/accounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@
<!-- Filter -->
<b-row>
<b-col lg="12" class="mb-3">
<b-form-input
id="filterInput"
v-model="filter"
type="search"
:placeholder="$t('pages.accounts.search_placeholder')"
/>
<b-input-group size="xl" class="mb-2">
<b-input-group-prepend is-text>
<font-awesome-icon icon="search" />
</b-input-group-prepend>
<b-form-input
id="filterInput"
v-model="filter"
type="search"
:placeholder="$t('pages.accounts.search_placeholder')"
/>
</b-input-group>
</b-col>
</b-row>
<!-- Mobile sorting -->
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div>
<section>
<b-container class="main py-5 dashboard">
<Chain />
<Search />
<Chain />
<div class="row">
<div class="col-md-6 mb-4">
<h3>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "cerestats",
"version": "0.32.0",
"version": "0.33.0",
"description": "Cere Stats mono repo",
"repository": {
"type": "git",
Expand Down

0 comments on commit 432585f

Please sign in to comment.