Skip to content

Commit

Permalink
sync with master
Browse files Browse the repository at this point in the history
  • Loading branch information
pqv199x committed Feb 27, 2019
2 parents c3789e1 + eaf2f7b commit 23dff52
Show file tree
Hide file tree
Showing 15 changed files with 690 additions and 574 deletions.
9 changes: 9 additions & 0 deletions client/assets/scss/trumps/_custom.scss
Expand Up @@ -128,3 +128,12 @@
margin: 1em;
}
}
.token-transfer {
.hash-tag {
max-width: 135px !important;
display: inline-block !important;
}
.internal-color {
color: $color-text-2;
}
}
5 changes: 4 additions & 1 deletion client/components/TableTokenHolder.vue
Expand Up @@ -30,7 +30,10 @@

<template
slot="quantity"
slot-scope="props">{{ toTomo(convertHexToFloat(props.item.quantity, 16)) }}</template>
slot-scope="props">
{{ formatUnit(toTokenQuantity(props.item.quantity, props.item.tokenObj.decimals),
props.item.tokenObj.symbol) }}
</template>
</table-base>

<b-pagination-nav
Expand Down
4 changes: 2 additions & 2 deletions client/components/TableTokensByAccount.vue
Expand Up @@ -32,8 +32,8 @@
<template
slot="quantity"
slot-scope="props">
{{ formatUnit(toTomo(convertHexToFloat(props.item.quantity, 16)), props.item.tokenObj ?
props.item.tokenObj.symbol : '') }}
{{ formatUnit(toTokenQuantity(props.item.quantity, props.item.tokenObj.decimals),
props.item.tokenObj.symbol) }}
</template>

</table-base>
Expand Down
30 changes: 17 additions & 13 deletions client/pages/txs/_slug.vue
Expand Up @@ -161,12 +161,24 @@
<tr v-if="tx.tokenTxs && tx.tokenTxs.length">
<td>Token Transfer</td>
<td>
<ul class="list-unstyled">
<li
<span class="token-transfer">
<p
v-for="(tokenTx, index) in tx.tokenTxs"
:key="index"
class="mb-3">
<span>{{ toTomo(tokenTx.value) }}</span>
<span class="text-secondary">From </span>
<nuxt-link
:to="{name: 'address-slug', params: {slug: tokenTx.from}}"
class="hash-tag text-truncate">
{{ tokenTx.from }}</nuxt-link>
<span class="text-secondary"> To </span>
<nuxt-link
:to="{name: 'address-slug', params: {slug: tokenTx.to}}"
class="hash-tag text-truncate">
{{ tokenTx.to }}</nuxt-link>
<span class="text-secondary"> For </span>
<span class="internal-color">{{
toTokenQuantity(tokenTx.value, tokenTx.decimals) }}</span>
<nuxt-link
:to="{
name: 'tokens-slug',
Expand All @@ -176,16 +188,8 @@
v-if="tokenTx.symbol"
v-html="'TRC20 (' + tokenTx.symbol + ')'"/>
</nuxt-link>
<span>&nbsp;from&nbsp;</span>
<nuxt-link
:to="{name: 'address-slug', params: {slug: tokenTx.from}}"
class="text-truncate">{{ tokenTx.from }}</nuxt-link>
<i class="fa fa-arrow-right ml-1 mr-2 text-success"/>
<nuxt-link
:to="{name: 'address-slug', params: {slug: tokenTx.to}}"
class="text-truncate">{{ tokenTx.to }}</nuxt-link>
</li>
</ul>
</p>
</span>
</td>
</tr>
<tr>
Expand Down
20 changes: 20 additions & 0 deletions client/plugins/mixin.js
Expand Up @@ -89,6 +89,26 @@ const mixin = {
return mixin.methods.formatNumber(weiNumber, limitComma)
},

toTokenQuantity: (wei, decimal) => {
if (isNaN(wei)) {
return '0'
}

if (typeof (wei) !== 'string') {
wei = wei.toString()
}

// Set bignumber config.
BigNumber.config({ EXPONENTIAL_AT: [-100, 100] })

let weiNumber = new BigNumber(wei)
let divided = 10 ** decimal

weiNumber = weiNumber.dividedBy(divided).toString()

return mixin.methods.formatNumber(weiNumber, decimal)
},

toEtherNumber: (wei) => web3.utils.fromWei(wei, 'ether'),

unformatAddress: (address) => address.replace(
Expand Down

0 comments on commit 23dff52

Please sign in to comment.