mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-02 09:33:49 +03:00
validate status code getting function signature
This commit is contained in:
parent
e5ae1cf72f
commit
f99da5968b
@ -16,8 +16,13 @@ struct TransactionInspector {
|
||||
guard nameHex.count == length,
|
||||
let url = URL(string: "https://raw.githubusercontent.com/ethereum-lists/4bytes/master/signatures/\(nameHex)")
|
||||
else { return }
|
||||
let dataTask = urlSession.dataTask(with: url) { (data, _, _) in
|
||||
if let data = data, let name = String(data: data, encoding: .utf8), !name.isEmpty {
|
||||
let dataTask = urlSession.dataTask(with: url) { (data, response, error) in
|
||||
let statusCode = (response as? HTTPURLResponse)?.statusCode ?? 0
|
||||
if error == nil,
|
||||
(200...299).contains(statusCode),
|
||||
let data = data,
|
||||
let name = String(data: data, encoding: .utf8),
|
||||
!name.isEmpty {
|
||||
DispatchQueue.main.async { completion(name) }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user