Skip to content

Commit d7953dc

Browse files
Change UInt64 to UInt.
ABI API left unchanged.
1 parent 9f79702 commit d7953dc

12 files changed

+39
-33
lines changed

Sources/web3swift/Contract/ContractProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public struct EventFilter {
4444
public enum Block {
4545
case latest
4646
case pending
47-
case blockNumber(UInt64)
47+
case blockNumber(UInt)
4848

4949
var encoded: String {
5050
switch self {

Sources/web3swift/Convenience/Decodable+Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ extension Date: DecodableFromHex {
146146
public init?(fromHex hexString: String) {
147147
self.init()
148148
let stripedHexString = hexString.stripHexPrefix()
149-
guard let timestampInt = UInt64(stripedHexString, radix: 16) else { return nil }
149+
guard let timestampInt = UInt(stripedHexString, radix: 16) else { return nil }
150150
self = Date(timeIntervalSince1970: TimeInterval(timestampInt))
151151
}
152152
}

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 blockBy(number: UInt64, fullTransactions: Bool = false) async throws -> Block {
12+
public func blockBy(number: UInt, fullTransactions: Bool = false) async throws -> Block {
1313
let block = String(number, radix: 16).addHexPrefix()
1414
return try await blockBy(number: block, fullTransactions: fullTransactions)
1515
}

Sources/web3swift/Promises/Promise+Web3+Personal+UnlockAccount.swift

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

1010

1111
extension web3.Personal {
12-
public func unlock(account: EthereumAddress, password: String = "web3swift", seconds: UInt64 = 300) async throws -> Bool {
12+
public func unlock(account: EthereumAddress, password: String = "web3swift", seconds: UInt = 300) async throws -> Bool {
1313
let addr = account.address
1414
return try await unlock(account: addr, password: password, seconds: seconds)
1515
}
1616

17-
public func unlock(account: String, password: String = "web3swift", seconds: UInt64 = 300) async throws -> Bool {
17+
public func unlock(account: String, password: String = "web3swift", seconds: UInt = 300) async throws -> Bool {
1818

1919
guard self.web3.provider.attachedKeystoreManager == nil else {
2020
throw Web3Error.inputError(desc: "Can not unlock a local keystore")

Sources/web3swift/Web3/Web3+Eth.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ extension web3.Eth {
208208
/// This function is synchronous!
209209
///
210210
/// Returns the Result object that indicates either success of failure.
211-
public func getBlockByNumber(_ number: UInt64, fullTransactions: Bool = false) async throws -> Block {
211+
public func getBlockByNumber(_ number: UInt, fullTransactions: Bool = false) async throws -> Block {
212212
let result = try await self.blockBy(number: number, fullTransactions: fullTransactions)
213213
return result
214214
}

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: UInt64) async throws -> [EventParserResultProtocol] {
39+
public func parseBlockByNumber(_ blockNumber: UInt) 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: UInt64) async throws -> [EventParserResultProtocol] {
115+
public func parseBlockByNumberPromise(_ blockNumber: UInt) 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+JSONRPC.swift

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

1212
/// Global counter object to enumerate JSON RPC requests.
1313
public struct Counter {
14-
public static var counter = UInt(1)
14+
public static var counter: UInt = 1
1515
public static var lockQueue = DispatchQueue(label: "counterQueue")
1616
public static func increment() -> UInt {
1717
var c: UInt = 0

Sources/web3swift/Web3/Web3+JSONRPCParameter.swift

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ extension Int: JSONRPCParameter { }
2020

2121
extension UInt: JSONRPCParameter { }
2222

23-
// FIXME: Drop all non default types support
24-
extension UInt64: JSONRPCParameter { }
25-
2623
extension Double: JSONRPCParameter { }
2724

2825
extension String: JSONRPCParameter { }
@@ -35,15 +32,16 @@ extension TransactionParameters: JSONRPCParameter { }
3532

3633
extension EventFilterParameters: JSONRPCParameter { }
3734

38-
extension Double: JSONParameterElement { }
39-
4035
extension Int: JSONParameterElement { }
4136

42-
// FIXME: Drop all non default types support
43-
extension UInt64: JSONParameterElement { }
37+
extension UInt: JSONParameterElement { }
38+
39+
extension Double: JSONParameterElement { }
4440

4541
extension String: JSONParameterElement { }
4642

43+
extension Bool: JSONParameterElement { }
44+
4745
/**
4846
Enum to compose request to the node params.
4947

@@ -76,8 +74,8 @@ public enum RPCParameter {
7674
case int(Int)
7775
case intArray([Int])
7876

79-
case uint(UInt64)
80-
case uintArray([UInt64])
77+
case uint(UInt)
78+
case uintArray([UInt])
8179

8280
case double(Double)
8381
case doubleArray([Double])
@@ -86,6 +84,8 @@ public enum RPCParameter {
8684
case stringArray([String])
8785

8886
case bool(Bool)
87+
case boolArray([Bool])
88+
8989
case transaction(TransactionParameters)
9090
case eventFilter(EventFilterParameters)
9191
}
@@ -108,8 +108,8 @@ extension RPCParameter: RawRepresentable {
108108
case is Int.Type: self = .int(rawValue as! Int)
109109
case is [Int].Type: self = .intArray(rawValue as! [Int])
110110

111-
case is UInt64.Type: self = .uint(rawValue as! UInt64)
112-
case is [UInt64].Type: self = .uintArray(rawValue as! [UInt64])
111+
case is UInt.Type: self = .uint(rawValue as! UInt)
112+
case is [UInt].Type: self = .uintArray(rawValue as! [UInt])
113113

114114
case is String.Type: self = .string(rawValue as! String)
115115
case is [String].Type: self = .stringArray(rawValue as! [String])
@@ -118,6 +118,8 @@ extension RPCParameter: RawRepresentable {
118118
case is [Double].Type: self = .doubleArray(rawValue as! [Double])
119119

120120
case is Bool.Type: self = .bool(rawValue as! Bool)
121+
case is [Bool].Type: self = .boolArray(rawValue as! [Bool])
122+
121123
case is TransactionParameters.Type: self = .transaction(rawValue as! TransactionParameters)
122124
case is EventFilterParameters.Type: self = .eventFilter(rawValue as! EventFilterParameters)
123125
default: return nil
@@ -142,6 +144,8 @@ extension RPCParameter: RawRepresentable {
142144
case let .doubleArray(value): return value
143145

144146
case let .bool(value): return value
147+
case let .boolArray(value): return value
148+
145149
case let .transaction(value): return value
146150
case let .eventFilter(value): return value
147151
}
@@ -175,8 +179,8 @@ extension RPCParameter: Encodable {
175179
case is Int.Type: try enumContainer.encode(rawValue as! Int)
176180
case is [Int].Type: try enumContainer.encode(rawValue as! [Int])
177181

178-
case is UInt64.Type: try enumContainer.encode(rawValue as! UInt64)
179-
case is [UInt64].Type: try enumContainer.encode(rawValue as! [UInt64])
182+
case is UInt.Type: try enumContainer.encode(rawValue as! UInt)
183+
case is [UInt].Type: try enumContainer.encode(rawValue as! [UInt])
180184

181185
case is String.Type: try enumContainer.encode(rawValue as! String)
182186
case is [String].Type: try enumContainer.encode(rawValue as! [String])
@@ -185,6 +189,8 @@ extension RPCParameter: Encodable {
185189
case is [Double].Type: try enumContainer.encode(rawValue as! [Double])
186190

187191
case is Bool.Type: try enumContainer.encode(rawValue as! Bool)
192+
case is [Bool].Type: try enumContainer.encode(rawValue as! [Bool])
193+
188194
case is TransactionParameters.Type: try enumContainer.encode(rawValue as! TransactionParameters)
189195
case is EventFilterParameters.Type: try enumContainer.encode(rawValue as! EventFilterParameters)
190196
default: break /// can't be executed, coz possible `self.rawValue` types are strictly defined in it's inplementation.`

Sources/web3swift/Web3/Web3+Personal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension web3.Personal {
4242
- important: This call is synchronous. Does nothing if private keys are stored locally.
4343

4444
*/
45-
public func unlockAccount(account: EthereumAddress, password: String = "web3swift", seconds: UInt64 = 300) async throws -> Bool {
45+
public func unlockAccount(account: EthereumAddress, password: String = "web3swift", seconds: UInt = 300) async throws -> Bool {
4646
let result = try await self.unlock(account: account)
4747
return result
4848
}

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: UInt64) async throws -> [EventParserResultProtocol]
24+
func parseBlockByNumber(_ blockNumber: UInt) async throws -> [EventParserResultProtocol]
2525
func parseTransactionPromise(_ transaction: EthereumTransaction) async throws -> [EventParserResultProtocol]
2626
func parseTransactionByHashPromise(_ hash: Data) async throws -> [EventParserResultProtocol]
27-
func parseBlockByNumberPromise(_ blockNumber: UInt64) async throws -> [EventParserResultProtocol]
27+
func parseBlockByNumberPromise(_ blockNumber: UInt) async throws -> [EventParserResultProtocol]
2828
func parseBlockPromise(_ block: Block) async throws -> [EventParserResultProtocol]
2929
}
3030

0 commit comments

Comments
 (0)