Skip to content

Commit 504bf11

Browse files
author
Vadym Pavlov
committed
optional callOnBlock
1 parent ee733a8 commit 504bf11

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/Web3Core/Transaction/CodableTransaction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ extension CodableTransaction {
292292
/// - s: signature s parameter (default 0) - will get set properly once signed
293293
/// - parameters: EthereumParameters object containing additional parameters for the transaction like gas
294294
public init(type: TransactionType? = nil, to: EthereumAddress, nonce: BigUInt = 0,
295-
chainID: BigUInt = 0, value: BigUInt = 0, data: Data = Data(),
295+
chainID: BigUInt = 0, value: BigUInt = 0, data: Data = Data(), callOnBlock: BlockNumber? = .latest,
296296
gasLimit: BigUInt = 0, maxFeePerGas: BigUInt? = nil, maxPriorityFeePerGas: BigUInt? = nil, gasPrice: BigUInt? = nil,
297297
accessList: [AccessListEntry]? = nil, v: BigUInt = 1, r: BigUInt = 0, s: BigUInt = 0) {
298-
callOnBlock = .latest
298+
self.callOnBlock = callOnBlock
299299

300300
envelope = EnvelopeFactory.createEnvelope(type: type, to: to, nonce: nonce, chainID: chainID, value: value, data: data, gasLimit: gasLimit, maxFeePerGas: maxFeePerGas, maxPriorityFeePerGas: maxPriorityFeePerGas, gasPrice: gasPrice, accessList: accessList, v: v, r: r, s: s)
301301
}

Sources/web3swift/Web3/Web3+Resolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public class PolicyResolver {
8888

8989
extension PolicyResolver {
9090
private func estimateGas(for transaction: CodableTransaction) async throws -> BigUInt {
91-
let request: APIRequest = .estimateGas(transaction, transaction.callOnBlock ?? .latest)
91+
let request: APIRequest = .estimateGas(transaction, transaction.callOnBlock)
9292
let response: APIResponse<BigUInt> = try await APIRequest.sendRequest(with: provider, for: request)
9393
return response.result
9494
}

0 commit comments

Comments
 (0)