Skip to content

Commit dfe4f72

Browse files
Delete duplicate BlockNumber enum in FeeHistory.
1 parent 8c0e119 commit dfe4f72

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

Sources/web3swift/Web3/Web3+GasOracle.swift

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extension Web3 {
8989
// TODO: Disabled until 3.0 version, coz `distance` available from iOS 13.
9090
// guard feeHistory == nil, forceDropCache, feeHistory!.timestamp.distance(to: Date()) > cacheTimeout else { return feeHistory! }
9191

92-
return try await eth.feeHistory(blockCount: blockCount, block: block.hexValue, percentiles: percentiles)
92+
return try await eth.feeHistory(blockCount: blockCount, block: block.stringValue, percentiles: percentiles)
9393
}
9494

9595
/// Suggesting tip values
@@ -126,6 +126,9 @@ extension Web3 {
126126
switch block {
127127
case .latest: latestBlockNumber = try await eth.getBlockNumber()
128128
case let .exact(number): latestBlockNumber = number
129+
// FIXME: Make real error here
130+
// Error throws since pending and erliest are unable to be used in this method.
131+
default: throw Web3Error.unknownError
129132
}
130133

131134
/// checking if latest block number is greather than number of blocks to take in account
@@ -242,24 +245,3 @@ extension Web3.Oracle.FeeHistory: Decodable {
242245
self.reward = try values.decodeHex([[BigUInt]].self, forKey: .reward)
243246
}
244247
}
245-
246-
247-
public extension Web3 {
248-
/// Enum for convenient type safe work with block number
249-
enum BlockNumber {
250-
/// Latest block of a chain
251-
case latest
252-
/// Exact block number
253-
case exact(BigUInt)
254-
255-
/// Block number as a string
256-
///
257-
/// Could be `hexString` either `latest`
258-
internal var hexValue: String {
259-
switch self {
260-
case .latest: return "latest"
261-
case let .exact(number): return String(number, radix: 16).addHexPrefix()
262-
}
263-
}
264-
}
265-
}

Sources/web3swift/Web3/Web3+InfuraProviders.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ import Starscream
99

1010
public enum BlockNumber {
1111
case pending
12+
/// Latest block of a chain
1213
case latest
14+
/// Earliest block of a chain
1315
case earliest
16+
/// Exact block number
1417
case exact(BigUInt)
1518

19+
/// Block number as a hex string
1620
public var stringValue: String {
1721
switch self {
1822
case .pending:

0 commit comments

Comments
 (0)