mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-12 01:34:09 +03:00
28 lines
592 B
Swift
28 lines
592 B
Swift
// Copyright © 2023 Tokenary. All rights reserved.
|
|
|
|
import BigInt
|
|
|
|
extension BigInt {
|
|
|
|
init?(hexString: String) {
|
|
self.init(hexString.cleanHex, radix: 16)
|
|
}
|
|
|
|
private var decimal: NSDecimalNumber {
|
|
return NSDecimalNumber(string: String(self))
|
|
}
|
|
|
|
var eth: String {
|
|
return decimal.multiplying(byPowerOf10: -18).stringValue
|
|
}
|
|
|
|
var ethDouble: Double {
|
|
return decimal.multiplying(byPowerOf10: -18).doubleValue
|
|
}
|
|
|
|
var gweiUInt: UInt {
|
|
return decimal.multiplying(byPowerOf10: -9).uintValue
|
|
}
|
|
|
|
}
|