Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
prevetal committed Jan 25, 2024
1 parent 8a99c87 commit 0c50e15
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 40 deletions.
22 changes: 9 additions & 13 deletions src/components/account/Stats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@
// Set network info
await fetch(`${store.networks[network.name].index_api}/account/account_info/${generateAddress(store.networks[network.name].address_prefix, wallet.address)}`)
.then(res => res.json())
.then(response => {
// Set network info
network.info = response
})
.then(response => network.info = response)
} catch (error) {
console.error(error)
}
Expand All @@ -128,19 +125,18 @@
wallet.RPDE += network.name == 'bostrom' ? network.info.rpde.amount / Math.pow(10, store.networks.bostrom.exponent) : network.info.rpde.amount / Math.pow(10, network.info.rpde.exponent)
}
// Set current data
if (store.currentNetwork != 'all') {
let currentWallet = store.account.wallets.find(el => el.address == store.account.currentWallet),
currentNetwork = currentWallet.networks.find(el => el.name == store.currentNetwork)
// Set current APR
APR.value = currentNetwork.info.apr
}
// Calc account RPDE
store.account.info.RPDE += wallet.RPDE
}
// Set current APR
if (store.currentNetwork != 'all') {
let currentWallet = store.account.wallets.find(el => el.address == store.account.currentWallet),
currentNetwork = currentWallet.networks.find(el => el.name == store.currentNetwork)
// Set current APR
APR.value = currentNetwork.info.apr
}
// Set current RPDE
if(store.account.currentWallet != 'all') {
Expand Down
28 changes: 16 additions & 12 deletions src/components/account/charts/ChartAssets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


<div class="chart">
<Doughnut ref="chart" :data="chartData" :options="chartOptions" />
<Doughnut ref="chart" :data="chartData" :options="chartOptions" v-if="!chartLoading" />

<div class="total">
<div class="label">
Expand Down Expand Up @@ -75,6 +75,7 @@
const store = useGlobalStore()
var chart = ref(null),
chartLoading = ref(true),
chartDatasets = reactive([]),
chartActiveLegend = ref(null),
chartColors = reactive([]),
Expand Down Expand Up @@ -113,13 +114,15 @@
: chartActiveLegend.value = null
}
}),
currentData = {}
currentData = ref({})
onBeforeMount(() => init())
watch(computed(() => store.currentNetwork), () => {
// Reset chart
chartLoading.value = true
chartDatasets = reactive([])
chartColors = reactive([])
Expand All @@ -134,7 +137,7 @@
let currentWallet = store.account.wallets.find(el => el.address == store.account.currentWallet)
// Get current data
currentData = currentWallet.networks.find(el => el.name == store.currentNetwork)
currentData.value = currentWallet.networks.find(el => el.name == store.currentNetwork)
} else {
let allGroupByDenom = []
Expand Down Expand Up @@ -167,15 +170,14 @@
})
// Set data
currentData.groupByDenom = allGroupByDenom
currentData.value.groupByDenom = allGroupByDenom
// Total tokens
currentData.totalTokensPrice = store.account.totalTokensPrice
currentData.value.totalTokensPrice = store.account.totalTokensPrice
}
// Set data for chart
currentData.groupByDenom.forEach(el => {
currentData.value.groupByDenom.forEach(el => {
chartDatasets.push(el.amountCurrentDenom)
let color = store.networkColors[el.symbol]
Expand All @@ -195,9 +197,11 @@
chartColors.push(color)
})
// Sum chart total
currentData.groupByDenom.forEach(el => chartTotal.value += el.amountCurrentDenom)
currentData.value.groupByDenom.forEach(el => chartTotal.value += el.amountCurrentDenom)
// Show chart
chartLoading.value = false
}
Expand Down Expand Up @@ -230,10 +234,10 @@
// Calc percents
function calcPercents(symbol) {
let result = 0,
token = currentData.groupByDenom.find(e => e.symbol == symbol)
token = currentData.value.groupByDenom.find(e => e.symbol == symbol)
if(currentData.totalTokensPrice) {
result = currencyСonversion(token.symbol == 'BOOT' ? token.amount / Math.pow(10, store.networks.bostrom.exponent) : token.amount, token.symbol) / currentData.totalTokensPrice * 100
if(currentData.value.totalTokensPrice) {
result = currencyСonversion(token.symbol == 'BOOT' ? token.amount / Math.pow(10, store.networks.bostrom.exponent) : token.amount, token.symbol) / currentData.value.totalTokensPrice * 100
}
return result
Expand Down
20 changes: 10 additions & 10 deletions src/components/account/charts/ChartStakeLiquide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@
emitter = inject('emitter')
var chartStake = ref(null),
chartDatasetsStake = reactive([]),
chartDatasetsStake = [],
chartActiveLegendStake = ref(null),
chartTotalStake = ref(0),
chartDataStake = computed(() => ({
chartDataStake = ref({
datasets: [{
data: chartDatasetsStake,
data: computed(() => chartDatasetsStake),
backgroundColor: ['#950FFF', '#0343E8', '#EB5757'],
borderColor: '#0d0d0d',
borderWidth: 4,
Expand All @@ -352,7 +352,7 @@
borderAlign: 'inner',
cutout: '84%',
}]
})),
}),
chartOptionsStake = reactive({
responsive: true,
plugins: {
Expand All @@ -377,12 +377,12 @@
}),
chartLiquide = ref(null),
chartDatasetsLiquide = reactive([]),
chartDatasetsLiquide = [],
chartActiveLegendLiquide = ref(null),
chartTotalLiquide = ref(0),
chartDataLiquide = computed(() => ({
chartDataLiquide = ref({
datasets: [{
data: chartDatasetsLiquide,
data: computed(() => chartDatasetsLiquide),
backgroundColor: ['#7879F1', '#EF5DA8', '#1BC562'],
borderColor: '#0d0d0d',
borderWidth: 4,
Expand All @@ -391,7 +391,7 @@
borderAlign: 'inner',
cutout: '80%'
}]
})),
}),
chartOptionsLiquide = reactive({
responsive: true,
plugins: {
Expand Down Expand Up @@ -436,10 +436,10 @@
watch(computed(() => store.currentNetwork), () => {
// Reset chart
chartDatasetsStake = reactive([])
chartDatasetsStake = [],
chartTotalStake = ref(0)
chartDatasetsLiquide = reactive([])
chartDatasetsLiquide = [],
chartTotalLiquide = ref(0)
init()
Expand Down
2 changes: 1 addition & 1 deletion src/stores/networks/bostrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const network = {
index_api: 'https://rpc.index.bostrom.bronbro.io',

denom: 'boot',
token_name: 'MBOOT',
token_name: 'BOOT',
chainId: 'bostrom',
prefix: 'bostrom',
mintscanAlias: null,
Expand Down
4 changes: 0 additions & 4 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ export const sendTx = async ({ txRaw, client }) => {
export const currencyСonversion = (amount, currency) => {
let store = useGlobalStore()

if (currency == 'MBOOT') {
currency = 'BOOT'
}

let tokenPrice = store.prices.find(el => el.symbol == currency).price,
toPrice = 1

Expand Down

0 comments on commit 0c50e15

Please sign in to comment.