Skip to content

Commit 7c5126a

Browse files
Refactor code a bit.
1 parent 351b671 commit 7c5126a

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import BigInt
1010

1111
extension web3.Eth {
1212
public func block(by hash: Data, fullTransactions: Bool = false) async throws -> Block {
13-
let hashString = hash.toHexString().addHexPrefix()
14-
return try await block(by: hashString, fullTransactions: fullTransactions)
13+
try await block(by: hashString.toHexString().addHexPrefix(), fullTransactions: fullTransactions)
1514
}
1615

1716
public func block(by hash: String, fullTransactions: Bool = false) async throws -> Block {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import BigInt
1010

1111
extension web3.Eth {
1212
public func block(by number: UInt, fullTransactions: Bool = false) async throws -> Block {
13-
let blockNumber = BlockNumber.exact(number)
14-
return try await block(by: blockNumber, fullTransactions: fullTransactions)
13+
try await block(by: BlockNumber.exact(number), fullTransactions: fullTransactions)
1514
}
1615

1716
public func block(by number: BlockNumber, fullTransactions: Bool = false) async throws -> Block {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import BigInt
1010

1111
extension web3.Eth {
1212
public func blockNumber() async throws -> UInt {
13-
let requestCall: APIRequest = .blockNumber
14-
15-
let response: APIResponse<UInt> = try await APIRequest.sendRequest(with: web3.provider, for: requestCall)
16-
13+
let response: APIResponse<UInt> = try await APIRequest.sendRequest(with: web3.provider, for: .blockNumber)
1714
return response.result
1815
}
1916
}

Sources/web3swift/Transaction/EthereumTransaction.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ public struct EthereumTransaction: CustomStringConvertible {
177177
/// - Returns: a TransactionParameters object suitable for passing to Web3+JSONRPC provider
178178
public func encodeAsDictionary(from: EthereumAddress? = nil) -> TransactionParameters? { self.envelope.encodeAsDictionary(from: from) }
179179

180+
181+
// FIXME: Move this logic into place where it supposed to be.
180182
/// create a JSON RPC Request object for the given transacton
181183
/// - Parameters:
182184
/// - method: RPC request method
@@ -207,6 +209,7 @@ public struct EthereumTransaction: CustomStringConvertible {
207209
return self.envelope.encode(for: type)
208210
}
209211

212+
// FIXME: Move this logic into place where it supposed to be.
210213
/// creates a Raw RPC request transaction for the given Transaction
211214
/// - Parameter transaction: EthereumTransaction to encode
212215
/// - Returns: a JSONRPCrequest object

0 commit comments

Comments
 (0)