Skip to content

Commit 2de0d21

Browse files
Revert BigUInt to UInt type changes.
This changes will follow that every math operation within Transaction either Block properties will require to cast type back and forth, so such pedantic behavior didn't worth it.
1 parent 412972b commit 2de0d21

9 files changed

+19
-18
lines changed

Sources/web3swift/API/Web3+APIMethod.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public enum APIRequest {
5858
/// - [Double]: A monotonically increasing list of percentile values.
5959
/// For each block in the requested range, the transactions will be sorted in ascending order
6060
/// by effective tip per gas and the coresponding effective tip for the percentile will be determined, accounting for gas consumed."
61-
case feeHistory(UInt, BlockNumber, [Double])
61+
case feeHistory(BigUInt, BlockNumber, [Double])
6262

6363
// MARK: - Additional API
6464
/// Creates new account.
@@ -97,14 +97,14 @@ extension APIRequest {
9797

9898
public var responseType: APIResultType.Type {
9999
switch self {
100-
case .blockNumber: return UInt.self
100+
case .blockNumber: return BigUInt.self
101101
case .getAccounts: return [EthereumAddress].self
102102
case .getBalance: return BigUInt.self
103103
case .getBlockByHash: return Block.self
104104
case .getBlockByNumber: return Block.self
105105
case .gasPrice: return BigUInt.self
106106
case .feeHistory: return Web3.Oracle.FeeHistory.self
107-
case .getTransactionCount: return UInt.self
107+
case .getTransactionCount: return BigUInt.self
108108
case .getCode: return Hash.self
109109
case .getTransactionReceipt: return TransactionReceipt.self
110110
case .createAccount: return EthereumAddress.self

Sources/web3swift/Promises/Promise+Web3+Eth+FeeHistory.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import BigInt
1212
extension Web3.Oracle.FeeHistory: APIResultType { }
1313

1414
extension web3.Eth {
15-
func feeHistory(blockCount: UInt, block: BlockNumber, percentiles:[Double]) async throws -> Web3.Oracle.FeeHistory {
15+
func feeHistory(blockCount: BigUInt, block: BlockNumber, percentiles:[Double]) async throws -> Web3.Oracle.FeeHistory {
1616
let requestCall: APIRequest = .feeHistory(blockCount, block, percentiles)
1717
let response: APIResponse<Web3.Oracle.FeeHistory> = try await APIRequest.sendRequest(with: web3.provider, for: requestCall)
1818
return response.result

Sources/web3swift/Promises/Promise+Web3+Eth+GetBlockByNumber.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import BigInt
99

1010

1111
extension web3.Eth {
12-
public func block(by number: UInt, fullTransactions: Bool = false) async throws -> Block {
12+
public func block(by number: BigUInt, fullTransactions: Bool = false) async throws -> Block {
1313
try await block(by: BlockNumber.exact(number), fullTransactions: fullTransactions)
1414
}
1515

Sources/web3swift/Promises/Promise+Web3+Eth+GetBlockNumber.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import BigInt
99

1010

1111
extension web3.Eth {
12-
public func blockNumber() async throws -> UInt {
13-
let response: APIResponse<UInt> = try await APIRequest.sendRequest(with: web3.provider, for: .blockNumber)
12+
public func blockNumber() async throws -> BigUInt {
13+
let response: APIResponse<BigUInt> = try await APIRequest.sendRequest(with: web3.provider, for: .blockNumber)
1414
return response.result
1515
}
1616
}

Sources/web3swift/Promises/Promise+Web3+Eth+GetTransactionCount.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
//
66

77
import Foundation
8+
import BigInt
89

910

1011
extension web3.Eth {
11-
public func getTransactionCount(for address: EthereumAddress, onBlock: BlockNumber) async throws -> UInt {
12+
public func getTransactionCount(for address: EthereumAddress, onBlock: BlockNumber) async throws -> BigUInt {
1213
try await getTransactionCount(address: address.address, onBlock: onBlock)
1314
}
1415

15-
public func getTransactionCount(address: Address, onBlock: BlockNumber) async throws -> UInt {
16+
public func getTransactionCount(address: Address, onBlock: BlockNumber) async throws -> BigUInt {
1617
let requestCall: APIRequest = .getTransactionCount(address, onBlock)
17-
let response: APIResponse<UInt> = try await APIRequest.sendRequest(with: self.provider, for: requestCall)
18+
let response: APIResponse<BigUInt> = try await APIRequest.sendRequest(with: self.provider, for: requestCall)
1819
return response.result
1920
}
2021
}

Sources/web3swift/Web3/Web3+EventParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension web3.web3contract {
3636
- important: This call is synchronous
3737

3838
*/
39-
public func parseBlockByNumber(_ blockNumber: UInt) async throws -> [EventParserResultProtocol] {
39+
public func parseBlockByNumber(_ blockNumber: BigUInt) async throws -> [EventParserResultProtocol] {
4040
let result = try await self.parseBlockByNumberPromise(blockNumber)
4141
return result
4242
}
@@ -112,7 +112,7 @@ extension web3.web3contract.EventParser {
112112

113113
}
114114

115-
public func parseBlockByNumberPromise(_ blockNumber: UInt) async throws -> [EventParserResultProtocol] {
115+
public func parseBlockByNumberPromise(_ blockNumber: BigUInt) async throws -> [EventParserResultProtocol] {
116116

117117
guard filter == nil || filter?.fromBlock == nil && filter?.toBlock == nil else {
118118
throw Web3Error.inputError(desc: "Can not mix parsing specific block and using block range filter")

Sources/web3swift/Web3/Web3+GasOracle.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension Web3 {
2525
var block: BlockNumber
2626

2727
/// Count of blocks to include in dataset
28-
var blockCount: UInt
28+
var blockCount: BigUInt
2929

3030
/// Percentiles
3131
///
@@ -48,7 +48,7 @@ extension Web3 {
4848
/// - block: Number of block from which counts starts backward
4949
/// - blockCount: Count of block to calculate statistics
5050
/// - percentiles: Percentiles of fees to which result of predictions will be split in
51-
public init(_ provider: web3, block: BlockNumber = .latest, blockCount: UInt = 20, percentiles: [Double] = [25, 50, 75]) {
51+
public init(_ provider: web3, block: BlockNumber = .latest, blockCount: BigUInt = 20, percentiles: [Double] = [25, 50, 75]) {
5252
self.web3Provider = provider
5353
self.block = block
5454
self.blockCount = blockCount
@@ -122,7 +122,7 @@ extension Web3 {
122122
}
123123

124124
private func suggestGasFeeLegacy() async throws -> [BigUInt] {
125-
var latestBlockNumber: UInt = 0
125+
var latestBlockNumber: BigUInt = 0
126126
switch block {
127127
case .latest: latestBlockNumber = try await eth.getBlockNumber()
128128
case let .exact(number): latestBlockNumber = number

Sources/web3swift/Web3/Web3+Protocols.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public protocol EventParserProtocol {
2121
func parseTransaction(_ transaction: EthereumTransaction) async throws -> [EventParserResultProtocol]
2222
func parseTransactionByHash(_ hash: Data) async throws -> [EventParserResultProtocol]
2323
func parseBlock(_ block: Block) async throws -> [EventParserResultProtocol]
24-
func parseBlockByNumber(_ blockNumber: UInt) async throws -> [EventParserResultProtocol]
24+
func parseBlockByNumber(_ blockNumber: BigUInt) async throws -> [EventParserResultProtocol]
2525
func parseTransactionPromise(_ transaction: EthereumTransaction) async throws -> [EventParserResultProtocol]
2626
func parseTransactionByHashPromise(_ hash: Data) async throws -> [EventParserResultProtocol]
27-
func parseBlockByNumberPromise(_ blockNumber: UInt) async throws -> [EventParserResultProtocol]
27+
func parseBlockByNumberPromise(_ blockNumber: BigUInt) async throws -> [EventParserResultProtocol]
2828
func parseBlockPromise(_ block: Block) async throws -> [EventParserResultProtocol]
2929
}
3030

Tests/web3swiftTests/remoteTests/GasOracleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import BigInt
1313
// MARK: Works only with network connection
1414
class OracleTests: XCTestCase {
1515

16-
let blockNumber: UInt = 14571792
16+
let blockNumber: BigUInt = 14571792
1717

1818
func testPretictBaseFee() async throws {
1919
let web3 = await Web3.InfuraMainnetWeb3(accessToken: Constants.infuraToken)

0 commit comments

Comments
 (0)