From 48bac7eda4b9443668d2e1a76b6b5c3a69c92850 Mon Sep 17 00:00:00 2001 From: yuzushioh Date: Sat, 16 Jun 2018 18:14:33 +0900 Subject: [PATCH] caluculate ether value in wei unit by powering 10 by 18 --- EthereumKit/Helper/Converter.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EthereumKit/Helper/Converter.swift b/EthereumKit/Helper/Converter.swift index b0ee7bc..58f1e5d 100644 --- a/EthereumKit/Helper/Converter.swift +++ b/EthereumKit/Helper/Converter.swift @@ -3,7 +3,9 @@ public typealias Ether = Decimal public typealias Wei = BInt public final class Converter { - private static let etherInWei = Decimal(1000000000000000000) + + // NOTE: calculate wei by 10^18 + private static let etherInWei = pow(Decimal(10), 18) /// Convert Wei(BInt) unit to Ether(Decimal) unit public static func toEther(wei: Wei) throws -> Ether {