Skip to content

Commit

Permalink
Remove Starscream and migrate to native classes for the WS-RPC client…
Browse files Browse the repository at this point in the history
… for finer-granularity error handling.
  • Loading branch information
kukabi committed Jul 26, 2022
1 parent cdf7689 commit 2eb73b0
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 176 deletions.
5 changes: 0 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ let package = Package(
url: "https://github.com/GigaBitcoin/secp256k1.swift.git",
.upToNextMinor(from: "0.4.0")
),
.package(
url: "https://github.com/daltoniam/Starscream.git",
.upToNextMinor(from: "4.0.4")
),
.package(
url: "https://github.com/SwiftyBeaver/SwiftyBeaver.git",
.upToNextMajor(from: "1.9.0")
Expand All @@ -71,7 +67,6 @@ let package = Package(
"BigInt",
"KeychainAccess",
"secp256k1",
"Starscream",
"SwiftyBeaver"
],
resources: [
Expand Down
5 changes: 4 additions & 1 deletion Sources/SubVTData/Model/API/RPC.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
/**
Generic RPC request.
*/
Expand Down Expand Up @@ -103,9 +104,11 @@ struct RPCBackendErrorResponse: Codable {
/**
RPC error body inner error data.
*/
struct RPCBackendError: Codable {
struct RPCBackendError: Codable, Error, CustomStringConvertible, LocalizedError {
let code: Int
let message: String
var description: String { self.message }
var errorDescription: String { self.message }

private enum CodingKeys: String, CodingKey {
case code
Expand Down
4 changes: 2 additions & 2 deletions Sources/SubVTData/Model/Substrate/AccountId.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public struct AccountId: CustomStringConvertible, Hashable {
checksumData.append(addressData as Data)
let hash = try Blake2.hash(.b2b, size: blake2bMaxLength, data: checksumData as Data)
addressData.append(hash.subdata(in: 0..<checksumLength))
let bytes = Array(addressData as Data)
return Base58.base58Encode(bytes)
let addressBytes = Array(addressData as Data)
return Base58.base58Encode(addressBytes)
}
}

Expand Down
Loading

0 comments on commit 2eb73b0

Please sign in to comment.