Merge pull request #903 from zcash/release/0.20.1-beta

Release/0.20.1 beta
This commit is contained in:
Michal Fousek 2023-04-03 19:19:23 +02:00 committed by GitHub
commit e3bc06b694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 62 deletions

View File

@ -87,6 +87,6 @@ public protocol ClosureSynchronizer {
It can be missleading that these two methods are returning Publisher even this protocol is closure based. Reason is that Synchronizer doesn't
provide different implementations for these two methods. So Combine it is even here.
*/
func rewind(_ policy: RewindPolicy) -> Completable<Error>
func wipe() -> Completable<Error>
func rewind(_ policy: RewindPolicy) -> CompletablePublisher<Error>
func wipe() -> CompletablePublisher<Error>
}

View File

@ -11,9 +11,9 @@ import Foundation
/* These aliases are here to just make the API easier to read. */
// Publisher which emitts completed or error. No value is emitted.
public typealias Completable<E: Error> = AnyPublisher<Void, E>
public typealias CompletablePublisher<E: Error> = AnyPublisher<Void, E>
// Publisher that either emits one value and then finishes or it emits error.
public typealias Single = AnyPublisher
public typealias SinglePublisher = AnyPublisher
/// This defines a Combine-based API for the SDK. It's expected that the implementation of this protocol is only a very thin layer that translates
/// async API defined in `Synchronizer` to Combine-based API. And it doesn't do anything else. It's here so each client can choose the API that suits
@ -33,54 +33,54 @@ public protocol CombineSynchronizer {
with seed: [UInt8]?,
viewingKeys: [UnifiedFullViewingKey],
walletBirthday: BlockHeight
) -> Single<Initializer.InitializationResult, Error>
) -> SinglePublisher<Initializer.InitializationResult, Error>
func start(retry: Bool) -> Completable<Error>
func stop() -> Completable<Never>
func start(retry: Bool) -> CompletablePublisher<Error>
func stop() -> CompletablePublisher<Never>
func getSaplingAddress(accountIndex: Int) -> Single<SaplingAddress, Error>
func getUnifiedAddress(accountIndex: Int) -> Single<UnifiedAddress, Error>
func getTransparentAddress(accountIndex: Int) -> Single<TransparentAddress, Error>
func getSaplingAddress(accountIndex: Int) -> SinglePublisher<SaplingAddress, Error>
func getUnifiedAddress(accountIndex: Int) -> SinglePublisher<UnifiedAddress, Error>
func getTransparentAddress(accountIndex: Int) -> SinglePublisher<TransparentAddress, Error>
func sendToAddress(
spendingKey: UnifiedSpendingKey,
zatoshi: Zatoshi,
toAddress: Recipient,
memo: Memo?
) -> Single<PendingTransactionEntity, Error>
) -> SinglePublisher<PendingTransactionEntity, Error>
func shieldFunds(
spendingKey: UnifiedSpendingKey,
memo: Memo,
shieldingThreshold: Zatoshi
) -> Single<PendingTransactionEntity, Error>
) -> SinglePublisher<PendingTransactionEntity, Error>
func cancelSpend(transaction: PendingTransactionEntity) -> Single<Bool, Never>
func cancelSpend(transaction: PendingTransactionEntity) -> SinglePublisher<Bool, Never>
var pendingTransactions: Single<[PendingTransactionEntity], Never> { get }
var clearedTransactions: Single<[ZcashTransaction.Overview], Never> { get }
var sentTransactions: Single<[ZcashTransaction.Sent], Never> { get }
var receivedTransactions: Single<[ZcashTransaction.Received], Never> { get }
var pendingTransactions: SinglePublisher<[PendingTransactionEntity], Never> { get }
var clearedTransactions: SinglePublisher<[ZcashTransaction.Overview], Never> { get }
var sentTransactions: SinglePublisher<[ZcashTransaction.Sent], Never> { get }
var receivedTransactions: SinglePublisher<[ZcashTransaction.Received], Never> { get }
func paginatedTransactions(of kind: TransactionKind) -> PaginatedTransactionRepository
func getMemos(for transaction: ZcashTransaction.Overview) -> Single<[Memo], Error>
func getMemos(for receivedTransaction: ZcashTransaction.Received) -> Single<[Memo], Error>
func getMemos(for sentTransaction: ZcashTransaction.Sent) -> Single<[Memo], Error>
func getMemos(for transaction: ZcashTransaction.Overview) -> SinglePublisher<[Memo], Error>
func getMemos(for receivedTransaction: ZcashTransaction.Received) -> SinglePublisher<[Memo], Error>
func getMemos(for sentTransaction: ZcashTransaction.Sent) -> SinglePublisher<[Memo], Error>
func getRecipients(for transaction: ZcashTransaction.Overview) -> Single<[TransactionRecipient], Never>
func getRecipients(for transaction: ZcashTransaction.Sent) -> Single<[TransactionRecipient], Never>
func getRecipients(for transaction: ZcashTransaction.Overview) -> SinglePublisher<[TransactionRecipient], Never>
func getRecipients(for transaction: ZcashTransaction.Sent) -> SinglePublisher<[TransactionRecipient], Never>
func allConfirmedTransactions(from transaction: ZcashTransaction.Overview, limit: Int) -> Single<[ZcashTransaction.Overview], Error>
func allConfirmedTransactions(from transaction: ZcashTransaction.Overview, limit: Int) -> SinglePublisher<[ZcashTransaction.Overview], Error>
func latestHeight() -> Single<BlockHeight, Error>
func latestHeight() -> SinglePublisher<BlockHeight, Error>
func refreshUTXOs(address: TransparentAddress, from height: BlockHeight) -> Single<RefreshedUTXOs, Error>
func refreshUTXOs(address: TransparentAddress, from height: BlockHeight) -> SinglePublisher<RefreshedUTXOs, Error>
func getTransparentBalance(accountIndex: Int) -> Single<WalletBalance, Error>
func getShieldedBalance(accountIndex: Int) -> Single<Zatoshi, Error>
func getShieldedVerifiedBalance(accountIndex: Int) -> Single<Zatoshi, Error>
func getTransparentBalance(accountIndex: Int) -> SinglePublisher<WalletBalance, Error>
func getShieldedBalance(accountIndex: Int) -> SinglePublisher<Zatoshi, Error>
func getShieldedVerifiedBalance(accountIndex: Int) -> SinglePublisher<Zatoshi, Error>
func rewind(_ policy: RewindPolicy) -> Completable<Error>
func wipe() -> Completable<Error>
func rewind(_ policy: RewindPolicy) -> CompletablePublisher<Error>
func wipe() -> CompletablePublisher<Error>
}

View File

@ -201,8 +201,8 @@ extension ClosureSDKSynchronizer: ClosureSynchronizer {
It can be missleading that these two methods are returning Publisher even this protocol is closure based. Reason is that Synchronizer doesn't
provide different implementations for these two methods. So Combine it is even here.
*/
public func rewind(_ policy: RewindPolicy) -> Completable<Error> { synchronizer.rewind(policy) }
public func wipe() -> Completable<Error> { synchronizer.wipe() }
public func rewind(_ policy: RewindPolicy) -> CompletablePublisher<Error> { synchronizer.rewind(policy) }
public func wipe() -> CompletablePublisher<Error> { synchronizer.wipe() }
}
extension ClosureSDKSynchronizer {

View File

@ -35,37 +35,37 @@ extension CombineSDKSynchronizer: CombineSynchronizer {
with seed: [UInt8]?,
viewingKeys: [UnifiedFullViewingKey],
walletBirthday: BlockHeight
) -> Single<Initializer.InitializationResult, Error> {
) -> SinglePublisher<Initializer.InitializationResult, Error> {
return executeThrowingAction() {
return try await self.synchronizer.prepare(with: seed, viewingKeys: viewingKeys, walletBirthday: walletBirthday)
}
}
public func start(retry: Bool) -> Completable<Error> {
public func start(retry: Bool) -> CompletablePublisher<Error> {
return executeThrowingAction() {
try await self.synchronizer.start(retry: retry)
}
}
public func stop() -> Completable<Never> {
public func stop() -> CompletablePublisher<Never> {
return executeAction() {
await self.synchronizer.stop()
}
}
public func getSaplingAddress(accountIndex: Int) -> Single<SaplingAddress, Error> {
public func getSaplingAddress(accountIndex: Int) -> SinglePublisher<SaplingAddress, Error> {
return executeThrowingAction() {
try await self.synchronizer.getSaplingAddress(accountIndex: accountIndex)
}
}
public func getUnifiedAddress(accountIndex: Int) -> Single<UnifiedAddress, Error> {
public func getUnifiedAddress(accountIndex: Int) -> SinglePublisher<UnifiedAddress, Error> {
return executeThrowingAction() {
try await self.synchronizer.getUnifiedAddress(accountIndex: accountIndex)
}
}
public func getTransparentAddress(accountIndex: Int) -> Single<TransparentAddress, Error> {
public func getTransparentAddress(accountIndex: Int) -> SinglePublisher<TransparentAddress, Error> {
return executeThrowingAction() {
try await self.synchronizer.getTransparentAddress(accountIndex: accountIndex)
}
@ -76,7 +76,7 @@ extension CombineSDKSynchronizer: CombineSynchronizer {
zatoshi: Zatoshi,
toAddress: Recipient,
memo: Memo?
) -> Single<PendingTransactionEntity, Error> {
) -> SinglePublisher<PendingTransactionEntity, Error> {
return executeThrowingAction() {
try await self.synchronizer.sendToAddress(spendingKey: spendingKey, zatoshi: zatoshi, toAddress: toAddress, memo: memo)
}
@ -86,37 +86,37 @@ extension CombineSDKSynchronizer: CombineSynchronizer {
spendingKey: UnifiedSpendingKey,
memo: Memo,
shieldingThreshold: Zatoshi
) -> Single<PendingTransactionEntity, Error> {
) -> SinglePublisher<PendingTransactionEntity, Error> {
return executeThrowingAction() {
try await self.synchronizer.shieldFunds(spendingKey: spendingKey, memo: memo, shieldingThreshold: shieldingThreshold)
}
}
public func cancelSpend(transaction: PendingTransactionEntity) -> Single<Bool, Never> {
public func cancelSpend(transaction: PendingTransactionEntity) -> SinglePublisher<Bool, Never> {
executeAction() {
await self.synchronizer.cancelSpend(transaction: transaction)
}
}
public var pendingTransactions: Single<[PendingTransactionEntity], Never> {
public var pendingTransactions: SinglePublisher<[PendingTransactionEntity], Never> {
executeAction() {
await self.synchronizer.pendingTransactions
}
}
public var clearedTransactions: Single<[ZcashTransaction.Overview], Never> {
public var clearedTransactions: SinglePublisher<[ZcashTransaction.Overview], Never> {
executeAction() {
await self.synchronizer.clearedTransactions
}
}
public var sentTransactions: Single<[ZcashTransaction.Sent], Never> {
public var sentTransactions: SinglePublisher<[ZcashTransaction.Sent], Never> {
executeAction() {
await self.synchronizer.sentTransactions
}
}
public var receivedTransactions: Single<[ZcashTransaction.Received], Never> {
public var receivedTransactions: SinglePublisher<[ZcashTransaction.Received], Never> {
executeAction() {
await self.synchronizer.receivedTransactions
}
@ -124,78 +124,78 @@ extension CombineSDKSynchronizer: CombineSynchronizer {
public func paginatedTransactions(of kind: TransactionKind) -> PaginatedTransactionRepository { synchronizer.paginatedTransactions(of: kind) }
public func getMemos(for transaction: ZcashTransaction.Overview) -> Single<[Memo], Error> {
public func getMemos(for transaction: ZcashTransaction.Overview) -> SinglePublisher<[Memo], Error> {
executeThrowingAction() {
try await self.synchronizer.getMemos(for: transaction)
}
}
public func getMemos(for receivedTransaction: ZcashTransaction.Received) -> Single<[Memo], Error> {
public func getMemos(for receivedTransaction: ZcashTransaction.Received) -> SinglePublisher<[Memo], Error> {
executeThrowingAction() {
try await self.synchronizer.getMemos(for: receivedTransaction)
}
}
public func getMemos(for sentTransaction: ZcashTransaction.Sent) -> Single<[Memo], Error> {
public func getMemos(for sentTransaction: ZcashTransaction.Sent) -> SinglePublisher<[Memo], Error> {
executeThrowingAction() {
try await self.synchronizer.getMemos(for: sentTransaction)
}
}
public func getRecipients(for transaction: ZcashTransaction.Overview) -> Single<[TransactionRecipient], Never> {
public func getRecipients(for transaction: ZcashTransaction.Overview) -> SinglePublisher<[TransactionRecipient], Never> {
executeAction() {
await self.synchronizer.getRecipients(for: transaction)
}
}
public func getRecipients(for transaction: ZcashTransaction.Sent) -> Single<[TransactionRecipient], Never> {
public func getRecipients(for transaction: ZcashTransaction.Sent) -> SinglePublisher<[TransactionRecipient], Never> {
executeAction() {
await self.synchronizer.getRecipients(for: transaction)
}
}
public func allConfirmedTransactions(from transaction: ZcashTransaction.Overview, limit: Int) -> Single<[ZcashTransaction.Overview], Error> {
public func allConfirmedTransactions(from transaction: ZcashTransaction.Overview, limit: Int) -> SinglePublisher<[ZcashTransaction.Overview], Error> {
executeThrowingAction() {
try await self.synchronizer.allConfirmedTransactions(from: transaction, limit: limit)
}
}
public func latestHeight() -> Single<BlockHeight, Error> {
public func latestHeight() -> SinglePublisher<BlockHeight, Error> {
return executeThrowingAction() {
try await self.synchronizer.latestHeight()
}
}
public func refreshUTXOs(address: TransparentAddress, from height: BlockHeight) -> Single<RefreshedUTXOs, Error> {
public func refreshUTXOs(address: TransparentAddress, from height: BlockHeight) -> SinglePublisher<RefreshedUTXOs, Error> {
return executeThrowingAction() {
try await self.synchronizer.refreshUTXOs(address: address, from: height)
}
}
public func getTransparentBalance(accountIndex: Int) -> Single<WalletBalance, Error> {
public func getTransparentBalance(accountIndex: Int) -> SinglePublisher<WalletBalance, Error> {
return executeThrowingAction() {
try await self.synchronizer.getTransparentBalance(accountIndex: accountIndex)
}
}
public func getShieldedBalance(accountIndex: Int = 0) -> Single<Zatoshi, Error> {
public func getShieldedBalance(accountIndex: Int = 0) -> SinglePublisher<Zatoshi, Error> {
return executeThrowingAction() {
try await synchronizer.getShieldedBalance(accountIndex: accountIndex)
}
}
public func getShieldedVerifiedBalance(accountIndex: Int = 0) -> Single<Zatoshi, Error> {
public func getShieldedVerifiedBalance(accountIndex: Int = 0) -> SinglePublisher<Zatoshi, Error> {
return executeThrowingAction() {
try await synchronizer.getShieldedVerifiedBalance(accountIndex: accountIndex)
}
}
public func rewind(_ policy: RewindPolicy) -> Completable<Error> { synchronizer.rewind(policy) }
public func wipe() -> Completable<Error> { synchronizer.wipe() }
public func rewind(_ policy: RewindPolicy) -> CompletablePublisher<Error> { synchronizer.rewind(policy) }
public func wipe() -> CompletablePublisher<Error> { synchronizer.wipe() }
}
extension CombineSDKSynchronizer {
private func executeAction(action: @escaping () async -> Void) -> Completable<Never> {
private func executeAction(action: @escaping () async -> Void) -> CompletablePublisher<Never> {
let subject = PassthroughSubject<Void, Never>()
Task {
await action()
@ -204,7 +204,7 @@ extension CombineSDKSynchronizer {
return subject.eraseToAnyPublisher()
}
private func executeAction<R>(action: @escaping () async -> R) -> Single<R, Never> {
private func executeAction<R>(action: @escaping () async -> R) -> SinglePublisher<R, Never> {
let subject = PassthroughSubject<R, Never>()
Task {
let result = await action()
@ -214,7 +214,7 @@ extension CombineSDKSynchronizer {
return subject.eraseToAnyPublisher()
}
private func executeThrowingAction(action: @escaping () async throws -> Void) -> Completable<Error> {
private func executeThrowingAction(action: @escaping () async throws -> Void) -> CompletablePublisher<Error> {
let subject = PassthroughSubject<Void, Error>()
Task {
do {
@ -228,7 +228,7 @@ extension CombineSDKSynchronizer {
return subject.eraseToAnyPublisher()
}
private func executeThrowingAction<R>(action: @escaping () async throws -> R) -> Single<R, Error> {
private func executeThrowingAction<R>(action: @escaping () async throws -> R) -> SinglePublisher<R, Error> {
let subject = PassthroughSubject<R, Error>()
Task {
do {