Skip to content

Commit

Permalink
Merge pull request #286 from argentlabs/issue/logging-cocoapods
Browse files Browse the repository at this point in the history
[FIX] Building with Cocoapods (no NIO/websocket feature)
  • Loading branch information
DarthMike authored Nov 30, 2022
2 parents 8fb7f3e + d0f2422 commit 9e837a2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions web3.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ Pod::Spec.new do |s|
s.dependency 'BigInt', '~> 5.0.0'
s.dependency 'secp256k1.swift', '~> 0.1'
s.dependency 'GenericJSON', '~> 2.0'
s.dependency 'Logging', '~> 1.0.0'

end
6 changes: 5 additions & 1 deletion web3swift/src/Client/EthereumClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import BigInt
import Foundation
import NIOWebSocket

public enum CallResolution {
case noOffchain(failOnExecutionError: Bool)
Expand Down Expand Up @@ -85,6 +84,9 @@ public protocol EthereumClientProtocol: AnyObject {
func eth_getBlockByNumber(_ block: EthereumBlock) async throws -> EthereumBlockInfo
}

#if canImport(NIO)
import NIOWebSocket

public protocol EthereumClientWebSocketProtocol: EthereumClientProtocol {
var delegate: EthereumWebSocketClientDelegate? { get set }
var currentState: WebSocketState { get }
Expand Down Expand Up @@ -125,3 +127,5 @@ extension EthereumWebSocketClientDelegate {

func onWebSocketReconnect() {}
}

#endif
4 changes: 3 additions & 1 deletion web3swift/src/Client/EthereumWebSocketClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright © 2022 Argent Labs Limited. All rights reserved.
//

#if canImport(NIO)
import BigInt
import Foundation
import GenericJSON
Expand All @@ -11,7 +12,6 @@ import NIO
import NIOCore
import NIOSSL
import NIOWebSocket
import WebSocketKit

#if canImport(FoundationNetworking)
import FoundationNetworking
Expand Down Expand Up @@ -225,3 +225,5 @@ extension EthereumWebSocketClient {
}
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
// Copyright © 2022 Argent Labs Limited. All rights reserved.
//

#if canImport(NIO)

import Foundation
import NIOCore

public enum EventLoopGroupProvider {
case shared(EventLoopGroup)
case createNew
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
// Copyright © 2022 Argent Labs Limited. All rights reserved.
//


import Foundation
#if canImport(NIO)
import NIOWebSocket
#endif

#if canImport(FoundationNetworking)
import FoundationNetworking
Expand All @@ -15,6 +18,7 @@ internal protocol NetworkProviderProtocol {
func send<P: Encodable, U: Decodable>(method: String, params: P, receive: U.Type) async throws -> Any
}

#if canImport(NIO)
internal protocol WebSocketNetworkProviderProtocol: NetworkProviderProtocol {
var delegate: EthereumWebSocketClientDelegate? { get set }
var onReconnectCallback: (() -> Void)? { get set }
Expand All @@ -26,3 +30,4 @@ internal protocol WebSocketNetworkProviderProtocol: NetworkProviderProtocol {
func addSubscription(_ subscription: EthereumSubscription, callback: @escaping (Any) -> Void)
func removeSubscription(_ subscription: EthereumSubscription)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Copyright © 2022 Argent Labs Limited. All rights reserved.
//

#if canImport(NIO)

import Foundation
import NIOSSL

Expand Down Expand Up @@ -38,3 +40,5 @@ public struct WebSocketConfiguration {
self.maxReconnectAttempts = maxReconnectAttempts
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Copyright © 2022 Argent Labs Limited. All rights reserved.
//

#if canImport(NIO)

import BigInt
import Foundation
import GenericJSON
Expand Down Expand Up @@ -421,3 +423,5 @@ class WebSocketNetworkProvider: WebSocketNetworkProviderProtocol {
}
}
}

#endif

0 comments on commit 9e837a2

Please sign in to comment.