Skip to content

Commit

Permalink
Update 28.01.2024
Browse files Browse the repository at this point in the history
  • Loading branch information
prevetal committed Jan 28, 2024
1 parent 0c50e15 commit 25fd481
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 56 deletions.
3 changes: 2 additions & 1 deletion src/components/account/Charts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
outside: 0,
ibc: 0,
liquid_rewards: 0
}),
})
network.totalTokensPrice = 0
network.groupByDenom = []
Expand Down
11 changes: 8 additions & 3 deletions src/components/account/Stats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@
// 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)
let currentWallet = {}
store.account.currentWallet != 'all'
? currentWallet = store.account.wallets.find(el => el.address == store.account.currentWallet)
: currentWallet = store.account.wallets[0]
let 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') {
if (store.account.currentWallet != 'all') {
// Current wallet
let currentWallet = store.account.wallets.find(el => el.address == store.account.currentWallet)
Expand Down
33 changes: 18 additions & 15 deletions src/components/account/charts/ChartAssets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,24 @@
// Group by denom
for (let wallet of store.account.wallets) {
for (let network of wallet.networks) {
network.groupByDenom.forEach(el => {
let duplicate = allGroupByDenom.find(e => e.symbol == el.symbol)
if(duplicate) {
duplicate.amount += el.amount
duplicate.amountCurrentDenom += el.amountCurrentDenom
} else {
allGroupByDenom.push({
'amount': el.amount,
'amountCurrentDenom': el.amountCurrentDenom,
'logo': el.logo,
'symbol': el.symbol
})
}
})
// Calc if one network
if (store.currentNetwork != 'all' && network.name == store.currentNetwork) {
network.groupByDenom.forEach(el => {
let duplicate = allGroupByDenom.find(e => e.symbol == el.symbol)
if(duplicate) {
duplicate.amount += el.amount
duplicate.amountCurrentDenom += el.amountCurrentDenom
} else {
allGroupByDenom.push({
'amount': el.amount,
'amountCurrentDenom': el.amountCurrentDenom,
'logo': el.logo,
'symbol': el.symbol
})
}
})
}
}
}
Expand Down
30 changes: 16 additions & 14 deletions src/components/account/charts/ChartLiquide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,22 @@
} else {
for (let wallet of store.account.wallets) {
for (let network of wallet.networks) {
// Calc totals
currentData.value.total.liquid += network.total.liquid,
currentData.value.total.ibc += network.total.ibc,
currentData.value.total.rewards += network.total.rewards
// Balance - Concat ibc tokens
if(network.balance.liquid.ibc != null) {
network.balance.liquid.ibc.forEach(el => {
let duplicate = currentData.value.balance.liquid.ibc.find(e => e.symbol == el.symbol)
duplicate
? duplicate.amount += el.amount
: currentData.value.balance.liquid.ibc.push(el)
})
// Calc if one network
if (store.currentNetwork != 'all' && network.name == store.currentNetwork) {
currentData.value.total.liquid += network.total.liquid,
currentData.value.total.ibc += network.total.ibc,
currentData.value.total.rewards += network.total.rewards
// Balance - Concat ibc tokens
if(network.balance.liquid.ibc != null) {
network.balance.liquid.ibc.forEach(el => {
let duplicate = currentData.value.balance.liquid.ibc.find(e => e.symbol == el.symbol)
duplicate
? duplicate.amount += el.amount
: currentData.value.balance.liquid.ibc.push(el)
})
}
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/components/account/charts/ChartNetworks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
: chartActiveLegend.value = null
}
}),
currentData = {}
currentData = {
networks: []
}
onBeforeMount(() => init())
Expand All @@ -132,12 +134,12 @@
let duplicate = currentData.networks.find(e => e.name == network.name)
if(duplicate) {
duplicate.totalTokens += network.totalTokens
duplicate.totalTokensPrice += network.totalTokensPrice
} else {
currentData.networks.push({
name: network.name,
color: network.color,
totalTokens: network.totalTokens
totalTokensPrice: network.totalTokensPrice
})
}
}
Expand Down
37 changes: 20 additions & 17 deletions src/components/account/charts/ChartStakeLiquide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -457,23 +457,26 @@
// Sum totals
for (let wallet of store.account.wallets) {
for (let network of wallet.networks) {
currentData.value.total.staked += network.total.staked,
currentData.value.total.unbonding += network.total.unbonding,
currentData.value.total.liquid_rewards += network.total.liquid_rewards
currentData.value.total.liquid += network.total.liquid,
currentData.value.total.ibc += network.total.ibc,
currentData.value.total.rewards += network.total.rewards
// Balance - Concat ibc tokens
if(network.balance.liquid.ibc != null) {
network.balance.liquid.ibc.forEach(el => {
let duplicate = currentData.value.balance.liquid.ibc.find(e => e.symbol == el.symbol)
duplicate
? duplicate.amount += el.amount
: currentData.value.balance.liquid.ibc.push(el)
})
// Calc if one network
if (store.currentNetwork != 'all' && network.name == store.currentNetwork) {
currentData.value.total.staked += network.total.staked,
currentData.value.total.unbonding += network.total.unbonding,
currentData.value.total.liquid_rewards += network.total.liquid_rewards
currentData.value.total.liquid += network.total.liquid,
currentData.value.total.ibc += network.total.ibc,
currentData.value.total.rewards += network.total.rewards
// Balance - Concat ibc tokens
if(network.balance.liquid.ibc != null) {
network.balance.liquid.ibc.forEach(el => {
let duplicate = currentData.value.balance.liquid.ibc.find(e => e.symbol == el.symbol)
duplicate
? duplicate.amount += el.amount
: currentData.value.balance.liquid.ibc.push(el)
})
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useGlobalStore = defineStore('global', {
demo: false,
tour: useLocalStorage('tour', true),

currentNetwork: null,
currentNetwork: 'cosmoshub',
currentProposalId: null,
currentDeleteAddress: null,
currentCurrency: useLocalStorage('currency', 'USDT'),
Expand Down Expand Up @@ -342,7 +342,7 @@ export const useGlobalStore = defineStore('global', {
if (updateAvatar) {
// Start IPFS
if (!this.IPFSNode) {
// this.IPFSNode = await Ipfs.create()
this.IPFSNode = await Ipfs.create()
}


Expand Down
2 changes: 1 addition & 1 deletion src/views/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
})
watch(() => store.account.currentWallet, () => {
watch(() => [store.account.currentWallet, store.currentNetwork], () => {
chartsKey.value += 1
statsKey.value += 1
validatorsKey.value += 1
Expand Down

0 comments on commit 25fd481

Please sign in to comment.