Skip to content

Commit 06035a2

Browse files
author
Vadym Pavlov
committed
Optional blocknumber for estimate_gas
1 parent 710451b commit 06035a2

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Sources/Web3Core/EthereumNetwork/Request/APIRequest+ComputedProperties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension APIRequest {
2222
return [RequestParameter]()
2323

2424
case .estimateGas(let transactionParameters, let blockNumber):
25-
return [.transaction(transactionParameters), .string(blockNumber.description)]
25+
return [.transaction(transactionParameters), blockNumber.map { .string($0.description) }].compactMap { $0 }
2626

2727
case let .sendRawTransaction(hash):
2828
return [.string(hash)]

Sources/Web3Core/EthereumNetwork/Request/APIRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public enum APIRequest {
9696
/// - Parameters:
9797
/// - TransactionParameters: parameters of planned transaction
9898
/// - BlockNumber: block where it should be evaluated
99-
case estimateGas(CodableTransaction, BlockNumber)
99+
case estimateGas(CodableTransaction, BlockNumber?)
100100

101101
/// Send raw transaction
102102
/// - Parameters:

Sources/web3swift/EthereumAPICalls/Ethereum/IEth+Defaults.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public extension IEth {
2020
try await estimateGas(for: transaction, onBlock: .latest)
2121
}
2222

23-
func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber) async throws -> BigUInt {
23+
func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber?) async throws -> BigUInt {
2424
let request = APIRequest.estimateGas(transaction, onBlock)
2525
return try await APIRequest.sendRequest(with: provider, for: request).result
2626
}

Sources/web3swift/EthereumAPICalls/Ethereum/IEth.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public protocol IEth {
1313
func send(_ transaction: CodableTransaction) async throws -> TransactionSendingResult
1414
func send(raw data: Data) async throws -> TransactionSendingResult
1515

16-
func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber) async throws -> BigUInt
16+
func estimateGas(for transaction: CodableTransaction, onBlock: BlockNumber?) async throws -> BigUInt
1717
func feeHistory(blockCount: BigUInt, block: BlockNumber, percentiles: [Double]) async throws -> Oracle.FeeHistory
1818
func ownedAccounts() async throws -> [EthereumAddress]
1919
func getBalance(for address: EthereumAddress, onBlock: BlockNumber) async throws -> BigUInt

0 commit comments

Comments
 (0)