|
|
|
@ -11,6 +11,7 @@ protocol TransactionConfiguratorDelegate: class { |
|
|
|
|
func configurationChanged(in configurator: TransactionConfigurator) |
|
|
|
|
func gasLimitEstimateUpdated(to estimate: BigInt, in configurator: TransactionConfigurator) |
|
|
|
|
func gasPriceEstimateUpdated(to estimate: BigInt, in configurator: TransactionConfigurator) |
|
|
|
|
func updateNonce(to nonce: Int, in configurator: TransactionConfigurator) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class TransactionConfigurator { |
|
|
|
@ -295,6 +296,18 @@ class TransactionConfigurator { |
|
|
|
|
if !isGasLimitSpecifiedByTransaction { |
|
|
|
|
estimateGasLimit() |
|
|
|
|
} |
|
|
|
|
firstly { |
|
|
|
|
GetNextNonce(server: session.server, wallet: session.account.address).promise() |
|
|
|
|
}.done { |
|
|
|
|
var customConfig = self.configurations.custom |
|
|
|
|
if let existingNonce = customConfig.nonce, existingNonce > 0 { |
|
|
|
|
//no-op |
|
|
|
|
} else { |
|
|
|
|
customConfig.set(nonce: $0) |
|
|
|
|
self.configurations.custom = customConfig |
|
|
|
|
self.delegate?.updateNonce(to: $0, in: self) |
|
|
|
|
} |
|
|
|
|
}.cauterize() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func formUnsignedTransaction() -> UnsignedTransaction { |
|
|
|
|