change limit to maxGas to prevent confusion with block limit, change to 100

pull/930/head
James Sangalli 6 years ago
parent 0903196b59
commit 6ae68e1916
  1. 2
      AlphaWallet/InCoordinator.swift
  2. 14
      AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift
  3. 2
      AlphaWallet/Transfer/Types/GasPriceConfiguration.swift
  4. 8
      AlphaWallet/Transfer/ViewControllers/ConfigureTransactionViewController.swift
  5. 2
      AlphaWalletTests/Transfer/Controllers/TransactionConfiguratorTests.swift
  6. 2
      AlphaWalletTests/Transfer/Types/GasPriceConfigurationTests.swift

@ -414,7 +414,7 @@ class InCoordinator: Coordinator {
value: BigInt(signedOrder.order.price),
to: address,
data: Data(bytes: payload.hexa2Bytes),
gasLimit: GasPriceConfiguration.limit,
gasLimit: GasPriceConfiguration.maxGas,
tokenId: .none,
gasPrice: GasPriceConfiguration.default,
nonce: .none,

@ -51,8 +51,8 @@ class TransactionConfigurator {
self.transaction = transaction
self.configuration = TransactionConfiguration(
gasPrice: min(max(transaction.gasPrice ?? GasPriceConfiguration.default, GasPriceConfiguration.min), GasPriceConfiguration.limit),
gasLimit: transaction.gasLimit ?? GasPriceConfiguration.limit,
gasPrice: min(max(transaction.gasPrice ?? GasPriceConfiguration.default, GasPriceConfiguration.min), GasPriceConfiguration.maxGas),
gasLimit: transaction.gasLimit ?? GasPriceConfiguration.maxGas,
data: transaction.data ?? Data()
)
}
@ -106,7 +106,7 @@ class TransactionConfigurator {
estimateGasLimit()
configuration = TransactionConfiguration(
gasPrice: calculatedGasPrice,
gasLimit: GasPriceConfiguration.limit,
gasLimit: GasPriceConfiguration.maxGas,
data: transaction.data ?? configuration.data
)
completion(.success(()))
@ -117,7 +117,7 @@ class TransactionConfigurator {
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: GasPriceConfiguration.limit,
gasLimit: GasPriceConfiguration.maxGas,
data: data
)
completion(.success(()))
@ -137,7 +137,7 @@ class TransactionConfigurator {
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: GasPriceConfiguration.limit,
gasLimit: GasPriceConfiguration.maxGas,
data: data
)
completion(.success(()))
@ -154,7 +154,7 @@ class TransactionConfigurator {
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: GasPriceConfiguration.limit,
gasLimit: GasPriceConfiguration.maxGas,
data: data
)
completion(.success(()))
@ -171,7 +171,7 @@ class TransactionConfigurator {
let data = Data(hex: res.drop0x)
self.configuration = TransactionConfiguration(
gasPrice: self.calculatedGasPrice,
gasLimit: GasPriceConfiguration.limit,
gasLimit: GasPriceConfiguration.maxGas,
data: data
)
completion(.success(()))

@ -6,5 +6,5 @@ import BigInt
public struct GasPriceConfiguration {
static let `default` = BigInt(90_000)
static let min = BigInt(21_000)
static let limit = BigInt(4_712_388) //geth default limit
static let maxGas = BigInt(100_000) //geth default limit
}

@ -97,8 +97,8 @@ class ConfigureTransactionViewController: FormViewController {
$0.title = R.string.localizable.configureTransactionGasPriceGweiLabelTitle()
$0.value = Float(gasPriceGwei) ?? 1
$0.minimumValue = Float(GasPriceConfiguration.min / BigInt(UnitConfiguration.gasPriceUnit.rawValue))
$0.maximumValue = Float(GasPriceConfiguration.limit / BigInt(UnitConfiguration.gasPriceUnit.rawValue))
$0.steps = UInt((GasPriceConfiguration.limit / GasPriceConfiguration.min))
$0.maximumValue = Float(GasPriceConfiguration.maxGas / BigInt(UnitConfiguration.gasPriceUnit.rawValue))
$0.steps = UInt((GasPriceConfiguration.maxGas / GasPriceConfiguration.min))
$0.displayValueFor = { (rowValue: Float?) in
return "\(Int(rowValue ?? 1))"
}
@ -115,8 +115,8 @@ class ConfigureTransactionViewController: FormViewController {
$0.title = R.string.localizable.configureTransactionGasLimitLabelTitle()
$0.value = Float(configuration.gasLimit.description) ?? 21000
$0.minimumValue = Float(GasPriceConfiguration.min)
$0.maximumValue = Float(GasPriceConfiguration.limit)
$0.steps = UInt((GasPriceConfiguration.limit - GasPriceConfiguration.min) / 1000)
$0.maximumValue = Float(GasPriceConfiguration.maxGas)
$0.steps = UInt((GasPriceConfiguration.maxGas - GasPriceConfiguration.min) / 1000)
$0.displayValueFor = { (rowValue: Float?) in
return "\(Int(rowValue ?? 1))"
}

@ -28,7 +28,7 @@ class TransactionConfiguratorTests: XCTestCase {
func testMaxGasPrice() {
let configurator = TransactionConfigurator(session: .make(), account: .make(), transaction: .make(gasPrice: BigInt(990000000000)))
XCTAssertEqual(GasPriceConfiguration.limit, configurator.configuration.gasPrice)
XCTAssertEqual(GasPriceConfiguration.maxGas, configurator.configuration.gasPrice)
}
func testLoadEtherConfiguration() {

@ -9,6 +9,6 @@ class GasPriceConfigurationTests: XCTestCase {
func testDefault() {
XCTAssertEqual(BigInt(90000), GasPriceConfiguration.default)
XCTAssertEqual(BigInt(21000), GasPriceConfiguration.min)
XCTAssertEqual(BigInt(4712388), GasPriceConfiguration.limit)
XCTAssertEqual(BigInt(4712388), GasPriceConfiguration.maxGas)
}
}

Loading…
Cancel
Save