[#653] Adopt SDK initialisation changes (#671)

Closes #653
This commit is contained in:
Michal Fousek 2023-03-14 13:14:52 +01:00 committed by GitHub
parent 88f81e774a
commit f46eaf69c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 43 additions and 36 deletions

View File

@ -283,7 +283,6 @@
0DACFA9A27209FA70039EEA5 /* Roboto-Light.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0DACFA8D27209FA70039EEA5 /* Roboto-Light.ttf */; };
0DACFA9C27209FA70039EEA5 /* Roboto-ThinItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0DACFA8F27209FA70039EEA5 /* Roboto-ThinItalic.ttf */; };
0DB4E0B12881F2DB00947B78 /* WalletBalance+testing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DB4E0B02881F2DB00947B78 /* WalletBalance+testing.swift */; };
0DB4E0B42881FD9100947B78 /* ZcashLightClientKit in Frameworks */ = {isa = PBXBuildFile; productRef = 0DB4E0B32881FD9100947B78 /* ZcashLightClientKit */; };
0DB8AA81271DC7520035BC9D /* DesignGuide.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DB8AA80271DC7520035BC9D /* DesignGuide.swift */; };
0DC487C32772574C00BE6A63 /* RecoveryPhraseBackupSucceededView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DC487C22772574C00BE6A63 /* RecoveryPhraseBackupSucceededView.swift */; };
0DDB6A5127737D4A0012A410 /* RecoveryPhraseBackupFailedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DDB6A5027737D4A0012A410 /* RecoveryPhraseBackupFailedView.swift */; };
@ -309,6 +308,7 @@
2EDA07A227EDE1AE00D6F09B /* TextFieldFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EDA07A127EDE1AE00D6F09B /* TextFieldFooter.swift */; };
2EDA07A427EDE2A900D6F09B /* DebugFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EDA07A327EDE2A900D6F09B /* DebugFrame.swift */; };
341B30BB29B78D1000697081 /* HomeFeatureFlagTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 341B30BA29B78D1000697081 /* HomeFeatureFlagTests.swift */; };
343CF3F629BB5A14009E44DF /* ZcashLightClientKit in Frameworks */ = {isa = PBXBuildFile; productRef = 343CF3F529BB5A14009E44DF /* ZcashLightClientKit */; };
34429C6E28E703CD00F2B929 /* TransactionSendingSnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34429C6D28E703CD00F2B929 /* TransactionSendingSnapshotTests.swift */; };
3448CB3228E47666006ADEDB /* NotEnoughFreeSpaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3448CB3128E47666006ADEDB /* NotEnoughFreeSpaceView.swift */; };
3448CB3728E485CB006ADEDB /* NotEnoughFeeSpaceSnapshots.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3448CB3628E485CB006ADEDB /* NotEnoughFeeSpaceSnapshots.swift */; };
@ -332,6 +332,7 @@
34C5658329B60C1C002F3A7C /* UIShareDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C5658129B60C1C002F3A7C /* UIShareDialog.swift */; };
34C5658529B60C8B002F3A7C /* ExportLogsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C5658429B60C8B002F3A7C /* ExportLogsStore.swift */; };
34C5658629B60C8B002F3A7C /* ExportLogsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34C5658429B60C8B002F3A7C /* ExportLogsStore.swift */; };
34CE032B29C0938600A6626B /* ZcashLightClientKit in Frameworks */ = {isa = PBXBuildFile; productRef = 34CE032A29C0938600A6626B /* ZcashLightClientKit */; };
34DA414728E4385800F8CC61 /* TransactionSendingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34DA414628E4385800F8CC61 /* TransactionSendingView.swift */; };
34DA414928E439CD00F8CC61 /* sendingTransaction.json in Resources */ = {isa = PBXBuildFile; fileRef = 34DA414828E439CD00F8CC61 /* sendingTransaction.json */; };
34E0AF1128DEE5220034CF37 /* Wedge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34E0AF1028DEE5220034CF37 /* Wedge.swift */; };
@ -899,9 +900,10 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
343CF3F629BB5A14009E44DF /* ZcashLightClientKit in Frameworks */,
9E6612312878337F00C75B70 /* Lottie in Frameworks */,
0D5D9B8F2914620700DBD03F /* URLRouting in Frameworks */,
0DB4E0B42881FD9100947B78 /* ZcashLightClientKit in Frameworks */,
34CE032B29C0938600A6626B /* ZcashLightClientKit in Frameworks */,
0D26103A298C3DCD00CC9DE9 /* FirebaseCrashlytics in Frameworks */,
9E2AC0FF27D8EC120042AA47 /* MnemonicSwift in Frameworks */,
6654C73A2715A38000901167 /* ComposableArchitecture in Frameworks */,
@ -971,6 +973,7 @@
0D4E7A1926B364180058B01E /* secantTests */,
0D4E7A2426B364180058B01E /* secantUITests */,
0D4E7A0626B364170058B01E /* Products */,
343CF3F429BB5A14009E44DF /* Frameworks */,
);
sourceTree = "<group>";
};
@ -1176,6 +1179,13 @@
path = Components;
sourceTree = "<group>";
};
343CF3F429BB5A14009E44DF /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
3448CB3028E4764E006ADEDB /* NotEnoughFreeSpace */ = {
isa = PBXGroup;
children = (
@ -2232,9 +2242,10 @@
9E2AC0FE27D8EC120042AA47 /* MnemonicSwift */,
9EAB466C285A0468002904A0 /* Parsing */,
9E6612302878337F00C75B70 /* Lottie */,
0DB4E0B32881FD9100947B78 /* ZcashLightClientKit */,
0D5D9B8E2914620700DBD03F /* URLRouting */,
0D261039298C3DCD00CC9DE9 /* FirebaseCrashlytics */,
343CF3F529BB5A14009E44DF /* ZcashLightClientKit */,
34CE032A29C0938600A6626B /* ZcashLightClientKit */,
);
productName = secant;
productReference = 0D4E7A0526B364170058B01E /* secant-testnet.app */;
@ -2314,9 +2325,9 @@
9E2AC0FD27D8EC120042AA47 /* XCRemoteSwiftPackageReference "MnemonicSwift" */,
9EAB466B285A0468002904A0 /* XCRemoteSwiftPackageReference "swift-parsing" */,
9E66122F2878337F00C75B70 /* XCRemoteSwiftPackageReference "lottie-ios" */,
0DB4E0B22881FD9100947B78 /* XCRemoteSwiftPackageReference "ZcashLightClientKit" */,
0D5D9B8D2914620700DBD03F /* XCRemoteSwiftPackageReference "swift-url-routing" */,
0D261038298C3DCD00CC9DE9 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
34CE032929C0938600A6626B /* XCRemoteSwiftPackageReference "ZcashLightClientKit" */,
);
productRefGroup = 0D4E7A0626B364170058B01E /* Products */;
projectDirPath = "";
@ -3561,12 +3572,12 @@
minimumVersion = 0.3.1;
};
};
0DB4E0B22881FD9100947B78 /* XCRemoteSwiftPackageReference "ZcashLightClientKit" */ = {
34CE032929C0938600A6626B /* XCRemoteSwiftPackageReference "ZcashLightClientKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/zcash/ZcashLightClientKit/";
repositoryURL = "https://github.com/zcash/ZcashLightClientKit.git";
requirement = {
kind = exactVersion;
version = "0.19.1-beta";
kind = revision;
revision = b34ae033ae868f8abfa343a53ac6b0f2264047c8;
};
};
6654C7382715A38000901167 /* XCRemoteSwiftPackageReference "swift-composable-architecture" */ = {
@ -3649,9 +3660,13 @@
package = 0D5D9B8D2914620700DBD03F /* XCRemoteSwiftPackageReference "swift-url-routing" */;
productName = URLRouting;
};
0DB4E0B32881FD9100947B78 /* ZcashLightClientKit */ = {
343CF3F529BB5A14009E44DF /* ZcashLightClientKit */ = {
isa = XCSwiftPackageProductDependency;
package = 0DB4E0B22881FD9100947B78 /* XCRemoteSwiftPackageReference "ZcashLightClientKit" */;
productName = ZcashLightClientKit;
};
34CE032A29C0938600A6626B /* ZcashLightClientKit */ = {
isa = XCSwiftPackageProductDependency;
package = 34CE032929C0938600A6626B /* XCRemoteSwiftPackageReference "ZcashLightClientKit" */;
productName = ZcashLightClientKit;
};
6654C7392715A38000901167 /* ComposableArchitecture */ = {

View File

@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"state" : {
"revision" : "a20cac0cad4e0da457de687c45cb55aee9a45e19",
"version" : "1.14.1"
"revision" : "f09cfb4d36315e2b48dbba1359179abf3cb2e6ac",
"version" : "1.14.2"
}
},
{
@ -327,7 +327,7 @@
{
"identity" : "zcash-light-client-ffi",
"kind" : "remoteSourceControl",
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi.git",
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
"state" : {
"revision" : "c2dd0eff1defbe6dfb6197c3a42ab21ea2db2fc2",
"version" : "0.2.0"
@ -336,10 +336,9 @@
{
"identity" : "zcashlightclientkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/zcash/ZcashLightClientKit/",
"location" : "https://github.com/zcash/ZcashLightClientKit.git",
"state" : {
"revision" : "f600a3f066b66df7c264ac59cdf7c3421caad95c",
"version" : "0.19.1-beta"
"revision" : "b34ae033ae868f8abfa343a53ac6b0f2264047c8"
}
}
],

View File

@ -36,7 +36,7 @@ protocol SDKSynchronizerClient {
var walletBirthday: BlockHeight? { get }
var latestScannedSynchronizerState: SDKSynchronizer.SynchronizerState? { get }
func prepareWith(initializer: Initializer, seedBytes: [UInt8]) throws
func prepareWith(initializer: Initializer, seedBytes: [UInt8], viewingKey: UnifiedFullViewingKey, walletBirthday: BlockHeight) throws
func start(retry: Bool) throws
func stop()
func synchronizerSynced(_ synchronizerState: SDKSynchronizer.SynchronizerState?)

View File

@ -34,8 +34,8 @@ class LiveSDKSynchronizerClient: SDKSynchronizerClient {
synchronizer?.stop()
}
func prepareWith(initializer: Initializer, seedBytes: [UInt8]) throws {
let synchronizer = try SDKSynchronizer(initializer: initializer)
func prepareWith(initializer: Initializer, seedBytes: [UInt8], viewingKey: UnifiedFullViewingKey, walletBirthday: BlockHeight) throws {
let synchronizer = SDKSynchronizer(initializer: initializer)
notificationCenter.publisherFor(.synchronizerStarted)?
.receive(on: DispatchQueue.main)
@ -63,12 +63,12 @@ class LiveSDKSynchronizerClient: SDKSynchronizerClient {
.sink { [weak self] _ in self?.synchronizerStopped() }
.store(in: &cancellables)
guard try synchronizer.prepare(with: seedBytes) == .success else {
guard try synchronizer.prepare(with: seedBytes, viewingKeys: [viewingKey], walletBirthday: walletBirthday) == .success else {
throw SynchronizerError.initFailed(message: "")
}
self.synchronizer = synchronizer
walletBirthday = initializer.walletBirthday
self.walletBirthday = initializer.walletBirthday
}
func start(retry: Bool) throws {

View File

@ -36,7 +36,7 @@ class MockSDKSynchronizerClient: SDKSynchronizerClient {
self.snapshot = snapshot
}
func prepareWith(initializer: Initializer, seedBytes: [UInt8]) throws { }
func prepareWith(initializer: Initializer, seedBytes: [UInt8], viewingKey: UnifiedFullViewingKey, walletBirthday: BlockHeight) throws { }
func start(retry: Bool) throws { }

View File

@ -26,7 +26,7 @@ class NoopSDKSynchronizer: SDKSynchronizerClient {
self.stateChanged = CurrentValueSubject<SDKSynchronizerState, Never>(.unknown)
}
func prepareWith(initializer: Initializer, seedBytes: [UInt8]) throws { }
func prepareWith(initializer: Initializer, seedBytes: [UInt8], viewingKey: UnifiedFullViewingKey, walletBirthday: BlockHeight) throws { }
func start(retry: Bool) throws { }
@ -98,7 +98,7 @@ class TestSDKSynchronizerClient: SDKSynchronizerClient {
self.stateChanged = CurrentValueSubject<SDKSynchronizerState, Never>(.unknown)
}
func prepareWith(initializer: Initializer, seedBytes: [UInt8]) throws { }
func prepareWith(initializer: Initializer, seedBytes: [UInt8], viewingKey: UnifiedFullViewingKey, walletBirthday: BlockHeight) throws { }
func start(retry: Bool) throws { }

View File

@ -136,15 +136,16 @@ extension RootReducer {
let birthday = state.storedWallet?.birthday?.value() ?? zcashSDKEnvironment.latestCheckpoint
let initializer = try RootReducer.prepareInitializer(
for: storedWallet.seedPhrase.value(),
birthday: birthday,
databaseFiles: databaseFiles,
derivationTool: derivationTool,
mnemonic: mnemonic,
zcashSDKEnvironment: zcashSDKEnvironment
)
let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0)
let viewingKey = try spendingKey.deriveFullViewingKey()
try sdkSynchronizer.prepareWith(initializer: initializer, seedBytes: seedBytes)
try sdkSynchronizer.prepareWith(initializer: initializer, seedBytes: seedBytes, viewingKey: viewingKey, walletBirthday: birthday)
try sdkSynchronizer.start()
return .none
} catch {

View File

@ -139,20 +139,14 @@ extension RootReducer {
return .uninitialized
}
// swiftlint:disable function_parameter_count
static func prepareInitializer(
for seedPhrase: String,
birthday: BlockHeight,
databaseFiles: DatabaseFilesClient,
derivationTool: DerivationToolClient,
mnemonic: MnemonicClient,
zcashSDKEnvironment: ZcashSDKEnvironment
) throws -> Initializer {
do {
let seedBytes = try mnemonic.toSeed(seedPhrase)
let spendingKey = try derivationTool.deriveSpendingKey(seedBytes, 0)
let viewingKey = try spendingKey.deriveFullViewingKey()
let network = zcashSDKEnvironment.network
let initializer = Initializer(
@ -165,8 +159,6 @@ extension RootReducer {
spendParamsURL: try databaseFiles.spendParamsURLFor(network),
outputParamsURL: try databaseFiles.outputParamsURLFor(network),
saplingParamsSourceURL: SaplingParamsSourceURL.default,
viewingKeys: [viewingKey],
walletBirthday: birthday,
loggerProxy: OSLogger(logLevel: .debug, category: LoggerConstants.sdkLogs)
)