Skip to content

Commit

Permalink
chore: Update Sources/Web3Core/EthereumNetwork/Request/APIRequest+Met…
Browse files Browse the repository at this point in the history
…hods.swift
  • Loading branch information
JeneaVranceanu authored Jan 8, 2024
1 parent d4f6678 commit 56fc498
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ extension APIRequest {
return APIResponse(id: 2, result: result)
}

/// This bit of code is purposed to work with literal types that come in ``Response`` in hexString type.
/// Currently it's just `Data` and any kind of Integers `(U)Int`, `Big(U)Int`.
/// Checks if `Result` type can be initialized from HEX-encoded bytes.
/// If it can - we attempt initializing a value of `Result` type.
if let LiteralType = Result.self as? LiteralInitiableFromString.Type {
guard let responseAsString = try? JSONDecoder().decode(APIResponse<String>.self, from: data) else { throw Web3Error.dataError }
guard let literalValue = LiteralType.init(from: responseAsString.result) else { throw Web3Error.dataError }
Expand Down

0 comments on commit 56fc498

Please sign in to comment.