mirror of
https://github.com/lil-org/wallet.git
synced 2024-12-29 07:22:04 +03:00
display gwei better
This commit is contained in:
parent
0635215d80
commit
33af59bf09
@ -16,9 +16,9 @@ struct Transaction {
|
||||
return gas != nil && gasPrice != nil
|
||||
}
|
||||
|
||||
var gasPriceGwei: UInt? {
|
||||
var gasPriceGwei: String? {
|
||||
guard let gasPrice = gasPrice, let value = BigInt(hexString: gasPrice) else { return nil }
|
||||
return value.gweiUInt
|
||||
return value.gwei
|
||||
}
|
||||
|
||||
func description(chain: EthereumNetwork, price: Double?) -> String {
|
||||
|
@ -20,8 +20,17 @@ extension BigInt {
|
||||
return decimal.multiplying(byPowerOf10: -18).doubleValue
|
||||
}
|
||||
|
||||
var gweiUInt: UInt {
|
||||
return decimal.multiplying(byPowerOf10: -9).uintValue
|
||||
var gwei: String {
|
||||
let gweiDecimal = decimal.multiplying(byPowerOf10: -9)
|
||||
let uintValue = gweiDecimal.uintValue
|
||||
if uintValue > 0 {
|
||||
return String(uintValue)
|
||||
} else {
|
||||
let formatter = NumberFormatter()
|
||||
formatter.minimumSignificantDigits = 1
|
||||
formatter.maximumSignificantDigits = 1
|
||||
return formatter.string(from: gweiDecimal) ?? "0"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user