Skip to content

Commit

Permalink
fix gas used and tx fee (converting and displaying issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramilexe committed Jul 14, 2021
1 parent 46100fd commit 5f74ca7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion newclient/src/core/helper/number-format-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class NumberFormatHelper {
*/
if (gweiBN.isLessThan(SmallGweiBreakpoint)) {
return {
value: value.toFormat(),
value: gweiBN.toFormat(),
unit,
tooltipText: `${gweiBN.toFormat()} ${unit}`
}
Expand Down
15 changes: 7 additions & 8 deletions newclient/src/modules/txs/handlers/TxDetails/TxDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ export default class TxDetails extends Mixins(NumberFormatMixin) {
row.detail = this.formatNumber(new BN(tx.gas || 0, 16).toNumber())
break
case 'gas.used':
row.detail = this.formatNumber(new BN(tx.gasUsed || 0, 16).toNumber())
row.detail = this.formatNumber(new BN(tx.gasUsed || 0, 10).toNumber())
break
case 'gas.price':
row.detail = `${this.gasPrice.value} ${this.$t(`common.${this.gasPrice.unit}`)}`
row.tooltip = this.gasPrice.tooltipText
break
case 'tx.status':
row.detail = this.$i18n.t(this.status).toString()
Expand Down Expand Up @@ -225,7 +226,7 @@ export default class TxDetails extends Mixins(NumberFormatMixin) {
* @return {FormattedNumber}
*/
get gasPrice(): FormattedNumber {
return this.formatNonVariableGWeiValue(new BN(this.ethTransaction.gasPrice))
return this.formatNonVariableGWeiValue(new BN(this.ethTransaction.gasPrice, 16))
}
/**
Expand Down Expand Up @@ -270,12 +271,10 @@ export default class TxDetails extends Mixins(NumberFormatMixin) {
*/
get txFee(): FormattedNumber {
if (this.ethTransaction && this.ethTransaction.gas && this.ethTransaction.gasPrice) {
// const price = new BN(this.ethTransaction.gasPrice)
// const used = new BN(this.ethTransaction.gas)
// const fee = price.times(used)
// return this.formatVariableUnitEthValue(fee)
const fee = new BN(this.ethTransaction.gasPrice, 16).multipliedBy(new BN(this.ethTransaction.gasUsed as string, 16))
return this.formatVariableUnitEthValue(fee)
const price = new BN(this.ethTransaction.gasPrice, 16)
const used = new BN(this.ethTransaction.gasUsed as string, 10)
const fee = price.times(used)
return this.formatNonVariableEthValue(fee)
}
// if (!this.isReplaced && this.txStatus === 'pending') {
// // const fee = new BN(this.transaction.gas).multipliedBy(this.transaction.gasPrice)
Expand Down

0 comments on commit 5f74ca7

Please sign in to comment.