diff --git a/Package.swift b/Package.swift index c276c2e4..9e4f7ccb 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,8 @@ let package = Package( name: "web3.swift", platforms: [ .iOS(SupportedPlatform.IOSVersion.v13), - .macOS(SupportedPlatform.MacOSVersion.v11) + .macOS(SupportedPlatform.MacOSVersion.v11), + .watchOS(.v7) ], products: [ .library(name: "web3.swift", targets: ["web3"]) diff --git a/web3.swift.podspec b/web3.swift.podspec index 367924e9..d247d974 100644 --- a/web3.swift.podspec +++ b/web3.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'web3.swift' - s.version = '1.4.0' + s.version = '1.4.1' s.license = 'MIT' s.summary = 'Ethereum API for Swift' s.homepage = 'https://github.com/argentlabs/web3.swift' @@ -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 diff --git a/web3swift/src/Client/EthereumClientProtocol.swift b/web3swift/src/Client/EthereumClientProtocol.swift index cf394b08..cc4077ea 100644 --- a/web3swift/src/Client/EthereumClientProtocol.swift +++ b/web3swift/src/Client/EthereumClientProtocol.swift @@ -5,7 +5,6 @@ import BigInt import Foundation -import NIOWebSocket public enum CallResolution { case noOffchain(failOnExecutionError: Bool) @@ -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 } @@ -125,3 +127,5 @@ extension EthereumWebSocketClientDelegate { func onWebSocketReconnect() {} } + +#endif diff --git a/web3swift/src/Client/EthereumWebSocketClient.swift b/web3swift/src/Client/EthereumWebSocketClient.swift index aee9ba7b..f8a5e08c 100644 --- a/web3swift/src/Client/EthereumWebSocketClient.swift +++ b/web3swift/src/Client/EthereumWebSocketClient.swift @@ -3,6 +3,7 @@ // Copyright © 2022 Argent Labs Limited. All rights reserved. // +#if canImport(NIO) import BigInt import Foundation import GenericJSON @@ -11,7 +12,6 @@ import NIO import NIOCore import NIOSSL import NIOWebSocket -import WebSocketKit #if canImport(FoundationNetworking) import FoundationNetworking @@ -225,3 +225,5 @@ extension EthereumWebSocketClient { } } } + +#endif diff --git a/web3swift/src/Client/NetworkProviders/EventLoopGroupProvider.swift b/web3swift/src/Client/NetworkProviders/EventLoopGroupProvider.swift index 6e53df5b..25114091 100644 --- a/web3swift/src/Client/NetworkProviders/EventLoopGroupProvider.swift +++ b/web3swift/src/Client/NetworkProviders/EventLoopGroupProvider.swift @@ -3,6 +3,8 @@ // Copyright © 2022 Argent Labs Limited. All rights reserved. // +#if canImport(NIO) + import Foundation import NIOCore @@ -10,3 +12,5 @@ public enum EventLoopGroupProvider { case shared(EventLoopGroup) case createNew } + +#endif diff --git a/web3swift/src/Client/NetworkProviders/NetworkProviderProtocol.swift b/web3swift/src/Client/NetworkProviders/NetworkProviderProtocol.swift index 298d89ef..86e9484b 100644 --- a/web3swift/src/Client/NetworkProviders/NetworkProviderProtocol.swift +++ b/web3swift/src/Client/NetworkProviders/NetworkProviderProtocol.swift @@ -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 @@ -15,6 +18,7 @@ internal protocol NetworkProviderProtocol { func send(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 } @@ -26,3 +30,4 @@ internal protocol WebSocketNetworkProviderProtocol: NetworkProviderProtocol { func addSubscription(_ subscription: EthereumSubscription, callback: @escaping (Any) -> Void) func removeSubscription(_ subscription: EthereumSubscription) } +#endif diff --git a/web3swift/src/Client/NetworkProviders/WebSocketConfiguration.swift b/web3swift/src/Client/NetworkProviders/WebSocketConfiguration.swift index f4f511d0..b5f1902d 100644 --- a/web3swift/src/Client/NetworkProviders/WebSocketConfiguration.swift +++ b/web3swift/src/Client/NetworkProviders/WebSocketConfiguration.swift @@ -3,6 +3,8 @@ // Copyright © 2022 Argent Labs Limited. All rights reserved. // +#if canImport(NIO) + import Foundation import NIOSSL @@ -38,3 +40,5 @@ public struct WebSocketConfiguration { self.maxReconnectAttempts = maxReconnectAttempts } } + +#endif diff --git a/web3swift/src/Client/NetworkProviders/WebSocketNetworkProvider.swift b/web3swift/src/Client/NetworkProviders/WebSocketNetworkProvider.swift index c42ee52f..aa904c04 100644 --- a/web3swift/src/Client/NetworkProviders/WebSocketNetworkProvider.swift +++ b/web3swift/src/Client/NetworkProviders/WebSocketNetworkProvider.swift @@ -3,6 +3,8 @@ // Copyright © 2022 Argent Labs Limited. All rights reserved. // +#if canImport(NIO) + import BigInt import Foundation import GenericJSON @@ -421,3 +423,5 @@ class WebSocketNetworkProvider: WebSocketNetworkProviderProtocol { } } } + +#endif