Merge pull request #1395 from LukasKorba/public-isSeedRelevantToWallet
Public API isSeedRelevantToWallet
This commit is contained in:
commit
730aee0c5f
|
@ -351,6 +351,11 @@ public protocol Synchronizer: AnyObject {
|
||||||
/// - Throws: ZcashError when failures occur and related to `synchronizer.start(retry: Bool)`, it's the only throwing operation
|
/// - Throws: ZcashError when failures occur and related to `synchronizer.start(retry: Bool)`, it's the only throwing operation
|
||||||
/// during the whole endpoint change.
|
/// during the whole endpoint change.
|
||||||
func switchTo(endpoint: LightWalletEndpoint) async throws
|
func switchTo(endpoint: LightWalletEndpoint) async throws
|
||||||
|
|
||||||
|
/// Checks whether the given seed is relevant to any of the accounts in the wallet.
|
||||||
|
///
|
||||||
|
/// - parameter seed: byte array of the seed
|
||||||
|
func isSeedRelevantToWallet(seed: [UInt8]) async throws -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SyncStatus: Equatable {
|
public enum SyncStatus: Equatable {
|
||||||
|
|
|
@ -303,8 +303,8 @@ public class SDKSynchronizer: Synchronizer {
|
||||||
uri,
|
uri,
|
||||||
accountIndex: accountIndex
|
accountIndex: accountIndex
|
||||||
)
|
)
|
||||||
} catch ZcashError.rustCreateToAddress(let e) {
|
} catch ZcashError.rustCreateToAddress(let error) {
|
||||||
throw ZcashError.rustProposeTransferFromURI(e)
|
throw ZcashError.rustProposeTransferFromURI(error)
|
||||||
} catch {
|
} catch {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
@ -604,6 +604,10 @@ public class SDKSynchronizer: Synchronizer {
|
||||||
return subject.eraseToAnyPublisher()
|
return subject.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func isSeedRelevantToWallet(seed: [UInt8]) async throws -> Bool {
|
||||||
|
try await initializer.rustBackend.isSeedRelevantToWallet(seed: seed)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Server switch
|
// MARK: Server switch
|
||||||
|
|
||||||
public func switchTo(endpoint: LightWalletEndpoint) async throws {
|
public func switchTo(endpoint: LightWalletEndpoint) async throws {
|
||||||
|
|
|
@ -315,6 +315,7 @@ class PaymentURIFulfillmentTests: ZcashTestCase {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let memo = "VGhpcyBpcyBhIHNpbXBsZSBtZW1vLg" // "This is a simple memo."
|
let memo = "VGhpcyBpcyBhIHNpbXBsZSBtZW1vLg" // "This is a simple memo."
|
||||||
|
// swiftlint:disable:next line_length
|
||||||
let paymentURI = "zcash:zecIsGreat17mg40levjezevuhdp5pqrd52zere7r7vrjgdwn5sj4xsqtm20euwahv9anxmwr3y3kmwuz8k55a?amount=0.0002&memo=\(memo)&message=Thank%20you%20for%20your%20purchase&label=Your%20Purchase"
|
let paymentURI = "zcash:zecIsGreat17mg40levjezevuhdp5pqrd52zere7r7vrjgdwn5sj4xsqtm20euwahv9anxmwr3y3kmwuz8k55a?amount=0.0002&memo=\(memo)&message=Thank%20you%20for%20your%20purchase&label=Your%20Purchase"
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -1800,6 +1800,30 @@ class SynchronizerMock: Synchronizer {
|
||||||
try await switchToEndpointClosure!(endpoint)
|
try await switchToEndpointClosure!(endpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - isSeedRelevantToWallet
|
||||||
|
|
||||||
|
var isSeedRelevantToWalletSeedThrowableError: Error?
|
||||||
|
var isSeedRelevantToWalletSeedCallsCount = 0
|
||||||
|
var isSeedRelevantToWalletSeedCalled: Bool {
|
||||||
|
return isSeedRelevantToWalletSeedCallsCount > 0
|
||||||
|
}
|
||||||
|
var isSeedRelevantToWalletSeedReceivedSeed: [UInt8]?
|
||||||
|
var isSeedRelevantToWalletSeedReturnValue: Bool!
|
||||||
|
var isSeedRelevantToWalletSeedClosure: (([UInt8]) async throws -> Bool)?
|
||||||
|
|
||||||
|
func isSeedRelevantToWallet(seed: [UInt8]) async throws -> Bool {
|
||||||
|
if let error = isSeedRelevantToWalletSeedThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
isSeedRelevantToWalletSeedCallsCount += 1
|
||||||
|
isSeedRelevantToWalletSeedReceivedSeed = seed
|
||||||
|
if let closure = isSeedRelevantToWalletSeedClosure {
|
||||||
|
return try await closure(seed)
|
||||||
|
} else {
|
||||||
|
return isSeedRelevantToWalletSeedReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class TransactionRepositoryMock: TransactionRepository {
|
class TransactionRepositoryMock: TransactionRepository {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue