Add TransactionCost

pull/2/head
Michael Scoff 7 years ago
parent 50677f6755
commit a1fd0580cc
  1. 5
      Trust/EtherClient/EtherKeystore.swift
  2. 25
      Trust/Transactions/Types/TransactionCost.swift

@ -115,14 +115,13 @@ class EtherKeystore: Keystore {
account: Account,
address: Address,
nonce: Int64,
gasPrice: GethBigInt = GethNewBigInt(50000000000),
gasLimit: GethBigInt = GethNewBigInt(90000),
cost: TransactionCost,
data: Data = Data(),
chainID: GethBigInt = GethNewBigInt(1)
) -> Result<Data, KeyStoreError> {
let gethAddress = GethNewAddressFromHex(address.address, nil)
let transaction = GethNewTransaction(nonce, gethAddress, amount, gasLimit, gasPrice, data)
let transaction = GethNewTransaction(nonce, gethAddress, amount, cost.gasLimit, cost.gasPrice, data)
let password = getPassword(for: account)
let gethAccount = getGethAccount(for: account.address)

@ -0,0 +1,25 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import Geth
enum TransactionCost {
case fast
case cheap
case custom(gasPrice: GethBigInt, gasLimit: GethBigInt)
var gasPrice: GethBigInt {
switch self {
case .fast: return GethNewBigInt(40000000000)
case .cheap: return GethNewBigInt(15000000000)
case .custom(let gasPrice, _): return gasPrice
}
}
var gasLimit: GethBigInt {
switch self {
case .cheap, .fast: return GethNewBigInt(90000)
case .custom(_, let gasLimit): return gasLimit
}
}
}
Loading…
Cancel
Save