Skip to content

Commit 56d0a27

Browse files
committed
Rename 'API' to 'Arweave'
1 parent e4a902d commit 56d0a27

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Sources/API/API.swift Sources/API/Arweave.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

3-
public struct API {
4-
static let shared = API()
3+
public struct Arweave {
4+
static let shared = Arweave()
55
private init() {}
66
static var baseUrl = URL(string: "https://arweave.net")!
77

@@ -21,7 +21,7 @@ enum Route {
2121
case commit(Transaction)
2222
}
2323

24-
extension API {
24+
extension Arweave {
2525

2626
struct Request {
2727

Sources/API/HttpClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct HttpResponse {
99

1010
struct HttpClient {
1111

12-
static func request(_ target: API.Request) async throws -> HttpResponse {
12+
static func request(_ target: Arweave.Request) async throws -> HttpResponse {
1313

1414
var request = URLRequest(url: target.url)
1515
request.httpMethod = target.method

Sources/Transaction.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public extension Transaction {
8282
throw "Missing signature on transaction."
8383
}
8484

85-
let commit = API.shared.request(for: .commit(self))
85+
let commit = Arweave.shared.request(for: .commit(self))
8686
_ = try await HttpClient.request(commit)
8787
}
8888

@@ -104,20 +104,20 @@ public extension Transaction {
104104
public extension Transaction {
105105

106106
static func find(_ txId: TransactionId) async throws -> Transaction {
107-
let findEndpoint = API.shared.request(for: .transaction(id: txId))
107+
let findEndpoint = Arweave.shared.request(for: .transaction(id: txId))
108108
let response = try await HttpClient.request(findEndpoint)
109109
return try JSONDecoder().decode(Transaction.self, from: response.data)
110110
}
111111

112112
static func data(for txId: TransactionId) async throws -> Base64EncodedString {
113-
let target = API.shared.request(for: .transactionData(id: txId))
113+
let target = Arweave.shared.request(for: .transactionData(id: txId))
114114
let response = try await HttpClient.request(target)
115115
return String(decoding: response.data, as: UTF8.self)
116116
}
117117

118118
static func status(of txId: TransactionId) async throws -> Transaction.Status {
119119

120-
let target = API.shared.request(for: .transactionStatus(id: txId))
120+
let target = Arweave.shared.request(for: .transactionStatus(id: txId))
121121
let response = try await HttpClient.request(target)
122122

123123
var status: Transaction.Status
@@ -131,7 +131,7 @@ public extension Transaction {
131131
}
132132

133133
static func price(for request: Transaction.PriceRequest) async throws -> Amount {
134-
let target = API.shared.request(for: .reward(request))
134+
let target = Arweave.shared.request(for: .reward(request))
135135
let response = try await HttpClient.request(target)
136136

137137
let costString = String(decoding: response.data, as: UTF8.self)
@@ -142,7 +142,7 @@ public extension Transaction {
142142
}
143143

144144
static func anchor() async throws -> String {
145-
let target = API.shared.request(for: .txAnchor)
145+
let target = Arweave.shared.request(for: .txAnchor)
146146
let response = try await HttpClient.request(target)
147147

148148
let anchor = String(decoding: response.data, as: UTF8.self)

Sources/Wallet.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct Wallet: Codable, Hashable, Comparable {
4040
}
4141

4242
public func balance() async throws -> Amount {
43-
let target = API.shared.request(for: .walletBalance(walletAddress: address))
43+
let target = Arweave.shared.request(for: .walletBalance(walletAddress: address))
4444
let response = try await HttpClient.request(target)
4545

4646
let respString = String(decoding: response.data, as: UTF8.self)
@@ -53,7 +53,7 @@ public struct Wallet: Codable, Hashable, Comparable {
5353
}
5454

5555
public func lastTransactionId() async throws -> TransactionId {
56-
let target = API.shared.request(for: .lastTransactionId(walletAddress: address))
56+
let target = Arweave.shared.request(for: .lastTransactionId(walletAddress: address))
5757
let response = try await HttpClient.request(target)
5858

5959
let lastTx = String(decoding: response.data, as: UTF8.self)

Tests/WalletTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class WalletTests: XCTestCase {
3030
}
3131

3232
func testCheckWalletBalance_UsingCustomHost() async throws {
33-
API.baseUrl = URL(string: "https://arweave.net:443")!
33+
Arweave.baseUrl = URL(string: "https://arweave.net:443")!
3434
let balance = try await WalletTests.wallet?.balance()
3535
XCTAssertNotNil(balance?.value)
3636
}

0 commit comments

Comments
 (0)