Skip to content

Commit 0b19af3

Browse files
committed
fix: correct formatting for api url
Signed-off-by: Ricky Saechao <ricky@launchbadge.com>
1 parent 86f519b commit 0b19af3

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Sources/Hedera/MirrorNodeGateway.swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ internal struct MirrorNodeGateway {
6868
let fullApiUrl = MirrorNodeRouter.buildApiUrl(
6969
self.mirrorNodeUrl, MirrorNodeRouter.contractsRoute, idOrAliasOrEvmAddress)
7070

71-
print("ContractfullApiUrl: \(fullApiUrl)")
72-
7371
let responseBody = try await queryFromMirrorNode(fullApiUrl)
7472

7573
guard let jsonData = responseBody.data(using: .utf8) else {
@@ -89,9 +87,9 @@ internal struct MirrorNodeGateway {
8987
internal func getAccountTokens(_ idOrAliasOrEvmAddress: String) async throws -> [String: Any] {
9088
let fullApiUrl = MirrorNodeRouter.buildApiUrl(
9189
self.mirrorNodeUrl, MirrorNodeRouter.accountTokensRoute, idOrAliasOrEvmAddress)
92-
90+
9391
let responseBody = try await queryFromMirrorNode(fullApiUrl)
94-
92+
9593
guard let jsonData = responseBody.data(using: .utf8) else {
9694
throw NSError(
9795
domain: "InvalidResponseError", code: -1,
@@ -113,10 +111,9 @@ internal struct MirrorNodeGateway {
113111
try? httpClient.syncShutdown()
114112
}
115113

116-
var request = HTTPClientRequest(url: apiUrl)
117-
request.method = .GET
114+
let request = HTTPClientRequest(url: apiUrl)
118115

119-
let response = try await httpClient.execute(request, timeout: .seconds(30))
116+
let response: HTTPClientResponse = try await httpClient.execute(request, timeout: .seconds(30))
120117

121118
let body = try await response.body.collect(upTo: 1024 * 1024)
122119
let bodyString = String(decoding: body.readableBytesView, as: UTF8.self)

Sources/Hedera/MirrorNodeRouter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ internal struct MirrorNodeRouter {
6363
}
6464

6565
static func buildApiUrl(_ mirrorNodeUrl: String, _ route: String, _ id: String) -> String {
66-
return String("\(mirrorNodeUrl)\(apiVersion)\(String(format: "\(String(describing: routes[route]))", id))!")
66+
return String("\(mirrorNodeUrl)\(apiVersion)\(String(format: "\(String(describing: routes[route]!))", id))")
6767
}
6868
}

Sources/Hedera/MirrorNodeService.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ internal final class MirrorNodeService {
6464

6565
let contractIdNum = ContractId(String(describing: contractId))?.num
6666

67-
fatalError("contract id: \(contractIdNum)")
68-
6967
return contractIdNum!
7068
}
7169

@@ -106,7 +104,12 @@ internal final class MirrorNodeService {
106104
let accountTokensResponse = try await self.mirrorNodeGateway.getAccountTokens(evmAddress)
107105

108106
guard let tokens = accountTokensResponse["tokens"] else {
109-
fatalError("Error while processing getTokenRelationshipsForAccount mirror node query: \(accountTokensResponse)")
107+
throw NSError(
108+
domain: "InvalidResponseError", code: -1,
109+
userInfo: [
110+
NSLocalizedDescriptionKey:
111+
"Error while processing getTokenRelationshipsForAccount mirror node query"
112+
])
110113
}
111114

112115
var tokenBalances: [Proto_TokenRelationship] = []

0 commit comments

Comments
 (0)