Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
donnyquixotic committed Jan 9, 2024
2 parents e064f17 + e7f5c74 commit 958b1d1
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/i18n/en-us/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ export default {
'LOSS OF FUNDS. THIS PRIVATE KEY IS NOT AVAILABLE.',
i_understand: 'I Understand',
copied_ok: 'Copied it to the clipboard successfully',
balance_fiat_tooltip: 'Total includes non-liquid TLOS, such as TLOS staked to resources',
},
dapps: {
title: 'Telos Native dApps',
Expand Down
19 changes: 18 additions & 1 deletion src/pages/native/BalanceInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export default {
)
.reduce((a, b) => a + b, 0);
},
telosBalance() {
return this.coins.find(coin => coin.symbol === 'TLOS' && coin.account === 'eosio.token').totalAmount;
},
availableHeight() {
return (
window.innerHeight - (this.isAuthenticated ? this.footerHeight : 0)
Expand Down Expand Up @@ -700,7 +703,7 @@ export default {
<!-- Account Amount -->
<div class="full-width items-center balance-div row">
<div class="full-width"></div>
<div class="full-width">
<div class="full-width balance-text">
<label
class="text-white items-center"
:style="`font-size: ${balanceTextSize}px; font-weight: 200; font-size: 50px; white-space: nowrap;`"
Expand All @@ -709,6 +712,13 @@ export default {
displayAmount.toFixed(2).slice(-2)
}}
</label>
<div>
<q-icon name="o_info" size="sm" />
<q-tooltip>{{ $t('balance.balance_fiat_tooltip') }}</q-tooltip>
</div>
</div>
<div v-if="typeof telosBalance === 'number'" class="full-width">
{{ getFixed(telosBalance, 4) }} TLOS
</div>
</div>
Expand Down Expand Up @@ -979,6 +989,13 @@ export default {
justify-content: space-between;
}
.balance-text {
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
}
.balanceBtn {
margin-right: 0.5vw;
margin-left: 0.5vw;
Expand Down
61 changes: 42 additions & 19 deletions src/pages/native/balance/CoinInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
'suggestTokens',
],
computed: {
...mapGetters('account', ['data']),
availableCoins() {
return this.coins.filter(
coin =>
Expand All @@ -43,6 +44,17 @@ export default {
withdrawEvm() {
this.$emit('update:showWithdrawEVMDlg', true);
},
coinIsTelosNative(coin) {
return coin.symbol === 'TLOS' && coin.account === 'eosio.token' && coin.network !== 'tevm';
},
formatLiquidBalance(balance) {
const [amount, symbol] = balance.split(' ');
return `${this.getFixed(amount, 4)} ${symbol}`;
},
getLiquidBalance(balance) {
const [amount] = balance.split(' ');
return Number(amount);
},
},
};
</script>
Expand Down Expand Up @@ -98,11 +110,7 @@ export default {
<img src="~assets/icons/networkArrows.svg" >
</q-btn>
<q-btn
v-if="
coin.symbol === 'TLOS' &&
coin.account === 'eosio.token' &&
coin.network !== 'tevm'
"
v-if="coinIsTelosNative(coin)"
class="tevmBtn"
flat
rounded
Expand All @@ -115,23 +123,38 @@ export default {
</div>
<q-item-section>
<div class="text-white text-right display-grid">
<label class="text-subtitle1 text-weight-small text-white h-20">{{
`${getFixed(
!coin.totalAmount ? coin.amount : coin.totalAmount,
8
)} ${coin.symbol}`
}}</label>
<label class="text-subtitle1 text-weight-small text-white h-20">
<template v-if="coinIsTelosNative(coin) && data">
{{ formatLiquidBalance(data.core_liquid_balance) }}
</template>
<template v-else>
{{
`${getFixed(
!coin.totalAmount ? coin.amount : coin.totalAmount,
8
)} ${coin.symbol}`
}}
</template>
</label>
<label
v-if="coin.price !== 0"
class="text-caption text-grey-6"
>${{
getFixed(
!coin.totalAmount
? coin.amount * coin.price
: coin.totalAmount * coin.price,
2
)
}}</label>
>
$
<template v-if="coinIsTelosNative(coin) && data">
{{ getFixed(coin.price * getLiquidBalance(data.core_liquid_balance), 2) }}
</template>
<template v-else>
{{
getFixed(
!coin.totalAmount
? coin.amount * coin.price
: coin.totalAmount * coin.price,
2
)
}}
</template>
</label>
</div>
</q-item-section>
</div>
Expand Down
21 changes: 20 additions & 1 deletion src/pages/native/balance/SendCoins.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,23 @@ export default {
));
},
availableCoins() {
return this.coins.filter(coin => coin.amount > 0);
let filteredCoins = this.coins.filter(coin => coin.amount > 0);
if (filteredCoins.findIndex(coin => coin.symbol === 'TLOS' && coin.account === 'eosio.token') === -1) {
filteredCoins = [{
name: 'Telos',
symbol: 'TLOS',
amount: 0,
price: 0,
icon: 'telos',
network: 'eos',
}, ...filteredCoins];
}
return filteredCoins;
},
showEmptyTelos() {
return this.availableCoins.findIndex(coin => coin.symbol === 'TLOS' && coin.account === 'eosio.token') === -1;
},
showDlg: {
get() {
Expand All @@ -34,6 +50,9 @@ export default {
},
methods: {
selectCoin(coin) {
if (this.showEmptyTelos) {
return;
}
this.$emit('update:showSendAmountDlg', true);
this.$emit('update:selectedCoin', coin);
},
Expand Down

0 comments on commit 958b1d1

Please sign in to comment.