Removed some warnings, added xconfig to fix pod lint issues, updated protobufs

This commit is contained in:
Francisco Gindre 2020-09-23 15:39:00 -03:00
parent 142c385058
commit 49e3300692
9 changed files with 205 additions and 144 deletions

View File

@ -10,6 +10,7 @@ target 'ZcashLightClientSample' do
pod 'PaginatedTableView'
pod 'NotificationBubbles'
pod 'MnemonicSwift'
pod 'gRPC-Swift-Plugins', '= 1.0.0-alpha.19'
target 'ZcashLightClientSampleTests' do
use_frameworks!
inherit! :search_paths
@ -39,7 +40,7 @@ post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
if target.name == 'ZcashLightClientKit-Unit-Tests'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "13.0"
end

View File

@ -16,6 +16,8 @@ PODS:
- SwiftNIOSSL (< 3, >= 2.8.0)
- SwiftNIOTransportServices (< 2, >= 1.6.0)
- SwiftProtobuf (< 2, >= 1.9.0)
- gRPC-Swift-Plugins (1.0.0-alpha.19):
- gRPC-Swift (= 1.0.0-alpha.19)
- KRActivityIndicatorView (3.0.5)
- KRProgressHUD (3.4.5):
- KRActivityIndicatorView (= 3.0.5)
@ -64,15 +66,16 @@ PODS:
- SwiftNIOFoundationCompat (< 3, >= 2.22.0)
- SwiftNIOTLS (< 3, >= 2.22.0)
- SwiftProtobuf (1.12.0)
- ZcashLightClientKit (0.6.3):
- ZcashLightClientKit (0.6.4):
- gRPC-Swift (= 1.0.0-alpha.19)
- SQLite.swift (~> 0.12.2)
- ZcashLightClientKit/Tests (0.6.3):
- ZcashLightClientKit/Tests (0.6.4):
- gRPC-Swift (= 1.0.0-alpha.19)
- SQLite.swift (~> 0.12.2)
DEPENDENCIES:
- gRPC-Swift (= 1.0.0-alpha.19)
- gRPC-Swift-Plugins (= 1.0.0-alpha.19)
- KRProgressHUD
- MnemonicSwift
- NotificationBubbles
@ -91,6 +94,7 @@ SPEC REPOS:
- CNIOLinux
- CNIOSHA1
- gRPC-Swift
- gRPC-Swift-Plugins
- KRActivityIndicatorView
- KRProgressHUD
- Logging
@ -123,6 +127,7 @@ SPEC CHECKSUMS:
CNIOLinux: 11f69f76c12087a0752fa8a53f32f9853ef3f4f2
CNIOSHA1: ff4d77269adcb89f9a962abcbee55256a29b8a36
gRPC-Swift: 75a7a8d7cd08177165ef971159afb84e5130cfc9
gRPC-Swift-Plugins: 5827cb75fe1f6e24423635fa1ec85fd67a529aef
KRActivityIndicatorView: 912bc0413d98340f384b12a4e1e6aa8f42fb377d
KRProgressHUD: df4cdc3a1baf708d4276a089ee34d133fa9a6f3e
Logging: beeb016c9c80cf77042d62e83495816847ef108b
@ -140,8 +145,8 @@ SPEC CHECKSUMS:
SwiftNIOTLS: 46bb3a0ff37d6b52ae6baf5207ec3cd411da327c
SwiftNIOTransportServices: 801923921fbecdcde1e1c1ff38e812167d01ead1
SwiftProtobuf: 4ef85479c18ca85b5482b343df9c319c62bda699
ZcashLightClientKit: 6a7a724d5c249bc15983327157fe5ade6600dbcb
ZcashLightClientKit: da23702d76723911cd52fbd033db240ea0b4e3a4
PODFILE CHECKSUM: 712888df93841f6c9ab12b3b6db3edf7c2cac776
PODFILE CHECKSUM: dc66de93ef2abbd39ca1595dd3020a5fbd62c9bd
COCOAPODS: 1.9.3

View File

@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
</dict>

View File

@ -12,7 +12,6 @@ import NIO
import NIOHPACK
public typealias Channel = GRPC.GRPCChannel
extension TimeAmount {
static let singleCallTimeout = TimeAmount.seconds(10)
static let streamingCallTimeout = TimeAmount.seconds(90)
@ -151,8 +150,6 @@ extension LightWalletGRPCService: LightWalletService {
default:
throw LightWalletServiceError.mapCode(status)
}
}
public func latestBlockHeight(result: @escaping (Result<BlockHeight, LightWalletServiceError>) -> Void) {

View File

@ -50,9 +50,9 @@ extension LightWalletServiceError: Equatable {
default:
return false
}
case .sentFailed(_):
case .sentFailed:
switch rhs {
case .sentFailed(_):
case .sentFailed:
return true
default:
return false

View File

@ -1,4 +1,5 @@
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: compact_formats.proto

View File

@ -20,26 +20,203 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import GRPC
import NIO
import NIOHTTP1
import SwiftProtobuf
/// Usage: instantiate CompactTxStreamerClient, then call methods of this protocol to make API calls.
internal protocol CompactTxStreamerClientProtocol {
func getLatestBlock(_ request: ChainSpec, callOptions: CallOptions?) -> UnaryCall<ChainSpec, BlockID>
func getBlock(_ request: BlockID, callOptions: CallOptions?) -> UnaryCall<BlockID, CompactBlock>
func getBlockRange(_ request: BlockRange, callOptions: CallOptions?, handler: @escaping (CompactBlock) -> Void) -> ServerStreamingCall<BlockRange, CompactBlock>
func getTransaction(_ request: TxFilter, callOptions: CallOptions?) -> UnaryCall<TxFilter, RawTransaction>
func sendTransaction(_ request: RawTransaction, callOptions: CallOptions?) -> UnaryCall<RawTransaction, SendResponse>
func getAddressTxids(_ request: TransparentAddressBlockFilter, callOptions: CallOptions?, handler: @escaping (RawTransaction) -> Void) -> ServerStreamingCall<TransparentAddressBlockFilter, RawTransaction>
func getLightdInfo(_ request: Empty, callOptions: CallOptions?) -> UnaryCall<Empty, LightdInfo>
func ping(_ request: Duration, callOptions: CallOptions?) -> UnaryCall<Duration, PingResponse>
internal protocol CompactTxStreamerClientProtocol: GRPCClient {
func getLatestBlock(
_ request: ChainSpec,
callOptions: CallOptions?
) -> UnaryCall<ChainSpec, BlockID>
func getBlock(
_ request: BlockID,
callOptions: CallOptions?
) -> UnaryCall<BlockID, CompactBlock>
func getBlockRange(
_ request: BlockRange,
callOptions: CallOptions?,
handler: @escaping (CompactBlock) -> Void
) -> ServerStreamingCall<BlockRange, CompactBlock>
func getTransaction(
_ request: TxFilter,
callOptions: CallOptions?
) -> UnaryCall<TxFilter, RawTransaction>
func sendTransaction(
_ request: RawTransaction,
callOptions: CallOptions?
) -> UnaryCall<RawTransaction, SendResponse>
func getAddressTxids(
_ request: TransparentAddressBlockFilter,
callOptions: CallOptions?,
handler: @escaping (RawTransaction) -> Void
) -> ServerStreamingCall<TransparentAddressBlockFilter, RawTransaction>
func getLightdInfo(
_ request: Empty,
callOptions: CallOptions?
) -> UnaryCall<Empty, LightdInfo>
func ping(
_ request: Duration,
callOptions: CallOptions?
) -> UnaryCall<Duration, PingResponse>
}
internal final class CompactTxStreamerClient: GRPCClient, CompactTxStreamerClientProtocol {
extension CompactTxStreamerClientProtocol {
/// Return the height of the tip of the best chain
///
/// - Parameters:
/// - request: Request to send to GetLatestBlock.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getLatestBlock(
_ request: ChainSpec,
callOptions: CallOptions? = nil
) -> UnaryCall<ChainSpec, BlockID> {
return self.makeUnaryCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLatestBlock",
request: request,
callOptions: callOptions ?? self.defaultCallOptions
)
}
/// Return the compact block corresponding to the given block identifier
///
/// - Parameters:
/// - request: Request to send to GetBlock.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getBlock(
_ request: BlockID,
callOptions: CallOptions? = nil
) -> UnaryCall<BlockID, CompactBlock> {
return self.makeUnaryCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlock",
request: request,
callOptions: callOptions ?? self.defaultCallOptions
)
}
/// Return a list of consecutive compact blocks
///
/// - Parameters:
/// - request: Request to send to GetBlockRange.
/// - callOptions: Call options.
/// - handler: A closure called when each response is received from the server.
/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
internal func getBlockRange(
_ request: BlockRange,
callOptions: CallOptions? = nil,
handler: @escaping (CompactBlock) -> Void
) -> ServerStreamingCall<BlockRange, CompactBlock> {
return self.makeServerStreamingCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlockRange",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler
)
}
/// Return the requested full (not compact) transaction (as from zcashd)
///
/// - Parameters:
/// - request: Request to send to GetTransaction.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getTransaction(
_ request: TxFilter,
callOptions: CallOptions? = nil
) -> UnaryCall<TxFilter, RawTransaction> {
return self.makeUnaryCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTransaction",
request: request,
callOptions: callOptions ?? self.defaultCallOptions
)
}
/// Submit the given transaction to the zcash network
///
/// - Parameters:
/// - request: Request to send to SendTransaction.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func sendTransaction(
_ request: RawTransaction,
callOptions: CallOptions? = nil
) -> UnaryCall<RawTransaction, SendResponse> {
return self.makeUnaryCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/SendTransaction",
request: request,
callOptions: callOptions ?? self.defaultCallOptions
)
}
/// Return the txids corresponding to the given t-address within the given block range
///
/// - Parameters:
/// - request: Request to send to GetAddressTxids.
/// - callOptions: Call options.
/// - handler: A closure called when each response is received from the server.
/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
internal func getAddressTxids(
_ request: TransparentAddressBlockFilter,
callOptions: CallOptions? = nil,
handler: @escaping (RawTransaction) -> Void
) -> ServerStreamingCall<TransparentAddressBlockFilter, RawTransaction> {
return self.makeServerStreamingCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetAddressTxids",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler
)
}
/// Return information about this lightwalletd instance and the blockchain
///
/// - Parameters:
/// - request: Request to send to GetLightdInfo.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getLightdInfo(
_ request: Empty,
callOptions: CallOptions? = nil
) -> UnaryCall<Empty, LightdInfo> {
return self.makeUnaryCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLightdInfo",
request: request,
callOptions: callOptions ?? self.defaultCallOptions
)
}
/// Testing-only
///
/// - Parameters:
/// - request: Request to send to Ping.
/// - callOptions: Call options.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func ping(
_ request: Duration,
callOptions: CallOptions? = nil
) -> UnaryCall<Duration, PingResponse> {
return self.makeUnaryCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/Ping",
request: request,
callOptions: callOptions ?? self.defaultCallOptions
)
}
}
internal final class CompactTxStreamerClient: CompactTxStreamerClientProtocol {
internal let channel: GRPCChannel
internal var defaultCallOptions: CallOptions
@ -52,120 +229,5 @@ internal final class CompactTxStreamerClient: GRPCClient, CompactTxStreamerClien
self.channel = channel
self.defaultCallOptions = defaultCallOptions
}
/// Return the height of the tip of the best chain
///
/// - Parameters:
/// - request: Request to send to GetLatestBlock.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getLatestBlock(_ request: ChainSpec, callOptions: CallOptions? = nil) -> UnaryCall<ChainSpec, BlockID> {
return self.makeUnaryCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLatestBlock",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
/// Return the compact block corresponding to the given block identifier
///
/// - Parameters:
/// - request: Request to send to GetBlock.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getBlock(_ request: BlockID, callOptions: CallOptions? = nil) -> UnaryCall<BlockID, CompactBlock> {
return self.makeUnaryCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlock",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
/// Return a list of consecutive compact blocks
///
/// - Parameters:
/// - request: Request to send to GetBlockRange.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - handler: A closure called when each response is received from the server.
/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
internal func getBlockRange(_ request: BlockRange, callOptions: CallOptions? = nil, handler: @escaping (CompactBlock) -> Void) -> ServerStreamingCall<BlockRange, CompactBlock> {
return self.makeServerStreamingCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlockRange",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler)
}
/// Return the requested full (not compact) transaction (as from zcashd)
///
/// - Parameters:
/// - request: Request to send to GetTransaction.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getTransaction(_ request: TxFilter, callOptions: CallOptions? = nil) -> UnaryCall<TxFilter, RawTransaction> {
return self.makeUnaryCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTransaction",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
/// Submit the given transaction to the zcash network
///
/// - Parameters:
/// - request: Request to send to SendTransaction.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func sendTransaction(_ request: RawTransaction, callOptions: CallOptions? = nil) -> UnaryCall<RawTransaction, SendResponse> {
return self.makeUnaryCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/SendTransaction",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
/// Return the txids corresponding to the given t-address within the given block range
///
/// - Parameters:
/// - request: Request to send to GetAddressTxids.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - handler: A closure called when each response is received from the server.
/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
internal func getAddressTxids(_ request: TransparentAddressBlockFilter, callOptions: CallOptions? = nil, handler: @escaping (RawTransaction) -> Void) -> ServerStreamingCall<TransparentAddressBlockFilter, RawTransaction> {
return self.makeServerStreamingCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetAddressTxids",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler)
}
/// Return information about this lightwalletd instance and the blockchain
///
/// - Parameters:
/// - request: Request to send to GetLightdInfo.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func getLightdInfo(_ request: Empty, callOptions: CallOptions? = nil) -> UnaryCall<Empty, LightdInfo> {
return self.makeUnaryCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLightdInfo",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
/// Testing-only
///
/// - Parameters:
/// - request: Request to send to Ping.
/// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
/// - Returns: A `UnaryCall` with futures for the metadata, status and response.
internal func ping(_ request: Duration, callOptions: CallOptions? = nil) -> UnaryCall<Duration, PingResponse> {
return self.makeUnaryCall(path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/Ping",
request: request,
callOptions: callOptions ?? self.defaultCallOptions)
}
}
// Provides conformance to `GRPCPayload` for request and response messages
extension ChainSpec: GRPCProtobufPayload {}
extension BlockID: GRPCProtobufPayload {}
extension CompactBlock: GRPCProtobufPayload {}
extension BlockRange: GRPCProtobufPayload {}
extension TxFilter: GRPCProtobufPayload {}
extension SendResponse: GRPCProtobufPayload {}
extension TransparentAddressBlockFilter: GRPCProtobufPayload {}
extension LightdInfo: GRPCProtobufPayload {}
extension Duration: GRPCProtobufPayload {}
extension PingResponse: GRPCProtobufPayload {}
extension RawTransaction: GRPCProtobufPayload {}
extension Empty: GRPCProtobufPayload {}

View File

@ -1,4 +1,5 @@
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: service.proto

View File

@ -368,11 +368,7 @@ public class SDKSynchronizer: Synchronizer {
@objc func applicationDidEnterBackground(_ notification: Notification) {
if !self.isBackgroundAllowed {
do {
try self.stop()
} catch {
self.status = .disconnected
}
self.stop()
}
}