Skip to content

Commit 24cc14d

Browse files
APplying review fixes.
1 parent 2b5f65b commit 24cc14d

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

Sources/Core/Oracle/GasOracle.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ final public class Oracle {
136136
let block: BigUInt = try await combineRequest(request: .blockNumber)
137137
latestBlockNumber = block
138138
case let .exact(number): latestBlockNumber = number
139-
// Error throws since pending and erliest are unable to be used in this method.
140-
default: throw Web3Error.valueError()
139+
default: throw Web3Error.valueError(desc: "Unable to use '\(block)' policy to resolve block number to calculate gas fee suggestion.")
141140
}
142141

143142
/// checking if latest block number is greather than number of blocks to take in account

Sources/Core/Transaction/Policies.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ public struct Policies {
5353
self.maxPriorityFeePerGasPolicy = maxPriorityFeePerGasPolicy
5454
}
5555

56-
public private(set) static var auto = Policies()
56+
public static let auto = Policies()
5757
}

Sources/web3swift/Operations/ReadOperation.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class ReadOperation {
3636

3737
// TODO: Remove type erasing here, some broad wide protocol should be added instead
3838
public func callContractMethod() async throws -> [String: Any] {
39-
try await policyResolver.resolveAll(for: &transaction)
4039
// MARK: Read data from ABI flow
4140
// FIXME: This should be dropped, and after `execute()` call, just to decode raw data.
4241
let data: Data = try await self.web3.eth.callTransaction(transaction)

Sources/web3swift/Web3/Web3+Resolver.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ public class PolicyResolver {
3636
}
3737

3838
public func resolveGasBaseFee(for policy: FeePerGasPolicy) async -> BigUInt {
39-
let oracle = Oracle(provider)
4039
switch policy {
4140
case .automatic:
42-
return await oracle.baseFeePercentiles().max() ?? 0
41+
return await Oracle(provider).baseFeePercentiles().max() ?? 0
4342
case .manual(let value):
4443
return value
4544
}
@@ -62,20 +61,18 @@ public class PolicyResolver {
6261
}
6362

6463
public func resolveGasPrice(for policy: GasPricePolicy) async -> BigUInt {
65-
let oracle = Oracle(provider)
6664
switch policy {
6765
case .automatic, .withMargin:
68-
return await oracle.gasPriceLegacyPercentiles().max() ?? 0
66+
return await Oracle(provider).gasPriceLegacyPercentiles().max() ?? 0
6967
case .manual(let value):
7068
return value
7169
}
7270
}
7371

7472
public func resolveGasPriorityFee(for policy: PriorityFeePerGasPolicy) async -> BigUInt {
75-
let oracle = Oracle(provider)
7673
switch policy {
7774
case .automatic:
78-
return await oracle.tipFeePercentiles().max() ?? 0
75+
return await Oracle(provider).tipFeePercentiles().max() ?? 0
7976
case .manual(let value):
8077
return value
8178
}

0 commit comments

Comments
 (0)