react-native-zcash 0.6.11 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/ios/ZCashLightClientKit/Block/Actions/Action.swift +98 -0
- package/ios/ZCashLightClientKit/Block/Actions/ClearAlreadyScannedBlocksAction.swift +35 -0
- package/ios/ZCashLightClientKit/Block/Actions/ClearCacheAction.swift +30 -0
- package/ios/ZCashLightClientKit/Block/Actions/DownloadAction.swift +67 -0
- package/ios/ZCashLightClientKit/Block/Actions/EnhanceAction.swift +97 -0
- package/ios/ZCashLightClientKit/Block/Actions/FetchUTXOsAction.swift +33 -0
- package/ios/ZCashLightClientKit/Block/Actions/MigrateLegacyCacheDBAction.swift +70 -0
- package/ios/ZCashLightClientKit/Block/Actions/ProcessSuggestedScanRangesAction.swift +60 -0
- package/ios/ZCashLightClientKit/Block/Actions/RewindAction.swift +48 -0
- package/ios/ZCashLightClientKit/Block/Actions/SaplingParamsAction.swift +33 -0
- package/ios/ZCashLightClientKit/Block/Actions/ScanAction.swift +95 -0
- package/ios/ZCashLightClientKit/Block/Actions/UpdateChainTipAction.swift +55 -0
- package/ios/ZCashLightClientKit/Block/Actions/UpdateSubtreeRootsAction.swift +58 -0
- package/ios/ZCashLightClientKit/Block/Actions/ValidateServerAction.swift +60 -0
- package/ios/ZCashLightClientKit/Block/CompactBlockProcessor.swift +425 -937
- package/ios/ZCashLightClientKit/Block/Download/BlockDownloader.swift +31 -17
- package/ios/ZCashLightClientKit/Block/Download/BlockDownloaderService.swift +2 -2
- package/ios/ZCashLightClientKit/Block/Enhance/BlockEnhancer.swift +46 -15
- package/ios/ZCashLightClientKit/Block/FetchUnspentTxOutputs/UTXOFetcher.swift +4 -15
- package/ios/ZCashLightClientKit/Block/FilesystemStorage/FSCompactBlockRepository.swift +4 -4
- package/ios/ZCashLightClientKit/Block/Scan/BlockScanner.swift +10 -35
- package/ios/ZCashLightClientKit/Block/Utils/CompactBlockProgress.swift +24 -0
- package/ios/ZCashLightClientKit/Block/Utils/SyncControlData.swift +25 -0
- package/ios/ZCashLightClientKit/ClosureSynchronizer.swift +1 -2
- package/ios/ZCashLightClientKit/CombineSynchronizer.swift +2 -5
- package/ios/ZCashLightClientKit/Constants/ZcashSDK.swift +13 -26
- package/ios/ZCashLightClientKit/DAO/TransactionDao.swift +40 -42
- package/ios/ZCashLightClientKit/DAO/UnspentTransactionOutputDao.swift +13 -4
- package/ios/ZCashLightClientKit/Entity/AccountEntity.swift +9 -0
- package/ios/ZCashLightClientKit/Entity/TransactionEntity.swift +7 -10
- package/ios/ZCashLightClientKit/Error/Sourcery/generateErrorCode.sh +1 -1
- package/ios/ZCashLightClientKit/Error/ZcashError.swift +121 -12
- package/ios/ZCashLightClientKit/Error/ZcashErrorCode.swift +43 -5
- package/ios/ZCashLightClientKit/Error/ZcashErrorCodeDefinition.swift +72 -6
- package/ios/ZCashLightClientKit/Extensions/Bool+ToData.swift +15 -0
- package/ios/ZCashLightClientKit/Extensions/Data+ToOtherTypes.swift +18 -0
- package/ios/ZCashLightClientKit/Extensions/Int+ToData.swift +15 -0
- package/ios/ZCashLightClientKit/Initializer.swift +47 -26
- package/ios/ZCashLightClientKit/Metrics/SDKMetrics.swift +0 -12
- package/ios/ZCashLightClientKit/Model/Checkpoint.swift +12 -0
- package/ios/ZCashLightClientKit/Model/ScanProgress.swift +29 -0
- package/ios/ZCashLightClientKit/Model/ScanRange.swift +31 -0
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/LightWalletGRPCService.swift +15 -0
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/compact_formats.pb.swift +150 -46
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/compact_formats.proto +30 -16
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/proto/service.proto +32 -6
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.grpc.swift +259 -22
- package/ios/ZCashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.pb.swift +193 -7
- package/ios/ZCashLightClientKit/Modules/Service/LightWalletService.swift +8 -0
- package/ios/ZCashLightClientKit/Providers/LatestBlocksDataProvider.swift +18 -28
- package/ios/ZCashLightClientKit/Repository/CompactBlockRepository.swift +1 -1
- package/ios/ZCashLightClientKit/Repository/TransactionRepository.swift +2 -6
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2092500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2095000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2097500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2102500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2105000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2107500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2112500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2115000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2117500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2122500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2125000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2127500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2132500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2135000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2137500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2142500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2145000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2147500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2152500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2155000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2157500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2162500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2165000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2167500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2172500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2175000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2177500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2182500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2185000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2187500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2192500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2195000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2197500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2202500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2205000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2207500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2212500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2215000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2217500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2222500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2225000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2227500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2232500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2235000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2237500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2242500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2245000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2247500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2252500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2255000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2257500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2262500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2265000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/mainnet/2267500.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2350000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2360000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2370000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2380000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2390000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2400000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2410000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2420000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2430000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2440000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2450000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2460000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2470000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2480000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2490000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2500000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2510000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2520000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2530000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2540000.json +8 -0
- package/ios/ZCashLightClientKit/Resources/checkpoints/testnet/2550000.json +8 -0
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackend.swift +293 -158
- package/ios/ZCashLightClientKit/Rust/ZcashRustBackendWelding.swift +58 -64
- package/ios/ZCashLightClientKit/Rust/zcashlc.h +618 -512
- package/ios/ZCashLightClientKit/Synchronizer/ClosureSDKSynchronizer.swift +2 -8
- package/ios/ZCashLightClientKit/Synchronizer/CombineSDKSynchronizer.swift +3 -15
- package/ios/ZCashLightClientKit/Synchronizer/Dependencies.swift +11 -30
- package/ios/ZCashLightClientKit/Synchronizer/SDKSynchronizer.swift +41 -50
- package/ios/ZCashLightClientKit/Synchronizer.swift +51 -65
- package/ios/ZCashLightClientKit/Transaction/TransactionEncoder.swift +2 -2
- package/ios/ZCashLightClientKit/Transaction/WalletTransactionEncoder.swift +7 -7
- package/ios/ZCashLightClientKit/Utils/OSLogger.swift +3 -3
- package/ios/ZCashLightClientKit/Utils/ZcashFileManager.swift +16 -0
- package/ios/libzcashlc.xcframework/Info.plist +9 -5
- package/ios/libzcashlc.xcframework/ios-arm64/libzcashlc.a +0 -0
- package/ios/libzcashlc.xcframework/ios-arm64_x86_64-simulator/libzcashlc.a +0 -0
- package/package.json +1 -1
|
@@ -42,13 +42,8 @@ public struct SynchronizerState: Equatable {
|
|
|
42
42
|
/// status of the whole sync process
|
|
43
43
|
var internalSyncStatus: InternalSyncStatus
|
|
44
44
|
public var syncStatus: SyncStatus
|
|
45
|
-
/// height of the latest scanned block known to this synchronizer.
|
|
46
|
-
public var latestScannedHeight: BlockHeight
|
|
47
45
|
/// height of the latest block on the blockchain known to this synchronizer.
|
|
48
46
|
public var latestBlockHeight: BlockHeight
|
|
49
|
-
/// timestamp of the latest scanned block on the blockchain known to this synchronizer.
|
|
50
|
-
/// The anchor point is timeIntervalSince1970
|
|
51
|
-
public var latestScannedTime: TimeInterval
|
|
52
47
|
|
|
53
48
|
/// Represents a synchronizer that has made zero progress hasn't done a sync attempt
|
|
54
49
|
public static var zero: SynchronizerState {
|
|
@@ -57,9 +52,7 @@ public struct SynchronizerState: Equatable {
|
|
|
57
52
|
shieldedBalance: .zero,
|
|
58
53
|
transparentBalance: .zero,
|
|
59
54
|
internalSyncStatus: .unprepared,
|
|
60
|
-
|
|
61
|
-
latestBlockHeight: .zero,
|
|
62
|
-
latestScannedTime: 0
|
|
55
|
+
latestBlockHeight: .zero
|
|
63
56
|
)
|
|
64
57
|
}
|
|
65
58
|
|
|
@@ -68,17 +61,13 @@ public struct SynchronizerState: Equatable {
|
|
|
68
61
|
shieldedBalance: WalletBalance,
|
|
69
62
|
transparentBalance: WalletBalance,
|
|
70
63
|
internalSyncStatus: InternalSyncStatus,
|
|
71
|
-
|
|
72
|
-
latestBlockHeight: BlockHeight,
|
|
73
|
-
latestScannedTime: TimeInterval
|
|
64
|
+
latestBlockHeight: BlockHeight
|
|
74
65
|
) {
|
|
75
66
|
self.syncSessionID = syncSessionID
|
|
76
67
|
self.shieldedBalance = shieldedBalance
|
|
77
68
|
self.transparentBalance = transparentBalance
|
|
78
69
|
self.internalSyncStatus = internalSyncStatus
|
|
79
|
-
self.latestScannedHeight = latestScannedHeight
|
|
80
70
|
self.latestBlockHeight = latestBlockHeight
|
|
81
|
-
self.latestScannedTime = latestScannedTime
|
|
82
71
|
self.syncStatus = internalSyncStatus.mapToSyncStatus()
|
|
83
72
|
}
|
|
84
73
|
}
|
|
@@ -119,7 +108,7 @@ public protocol Synchronizer: AnyObject {
|
|
|
119
108
|
|
|
120
109
|
/// An object that when enabled collects mertrics from the synchronizer
|
|
121
110
|
var metrics: SDKMetrics { get }
|
|
122
|
-
|
|
111
|
+
|
|
123
112
|
/// Initialize the wallet. The ZIP-32 seed bytes can optionally be passed to perform
|
|
124
113
|
/// database migrations. most of the times the seed won't be needed. If they do and are
|
|
125
114
|
/// not provided this will fail with `InitializationResult.seedRequired`. It could
|
|
@@ -131,9 +120,11 @@ public protocol Synchronizer: AnyObject {
|
|
|
131
120
|
/// do not already exist). These files can be given a prefix for scenarios where multiple wallets
|
|
132
121
|
///
|
|
133
122
|
/// - Parameters:
|
|
134
|
-
/// - seed: ZIP-32 Seed bytes for the wallet that will be initialized
|
|
135
|
-
/// - viewingKeys: Viewing key derived from seed.
|
|
123
|
+
/// - seed: ZIP-32 Seed bytes for the wallet that will be initialized
|
|
136
124
|
/// - walletBirthday: Birthday of wallet.
|
|
125
|
+
/// - for: [walletMode] Set `.newWallet` when preparing synchronizer for a brand new generated wallet,
|
|
126
|
+
/// `.restoreWallet` when wallet is about to be restored from a seed
|
|
127
|
+
/// and `.existingWallet` for all other scenarios.
|
|
137
128
|
/// - Throws:
|
|
138
129
|
/// - `aliasAlreadyInUse` if the Alias used to create this instance is already used by other instance.
|
|
139
130
|
/// - `cantUpdateURLWithAlias` if the updating of paths in `Initilizer` according to alias fails. When this happens it means that
|
|
@@ -142,8 +133,8 @@ public protocol Synchronizer: AnyObject {
|
|
|
142
133
|
/// - Some other `ZcashError` thrown by lower layer of the SDK.
|
|
143
134
|
func prepare(
|
|
144
135
|
with seed: [UInt8]?,
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
walletBirthday: BlockHeight,
|
|
137
|
+
for walletMode: WalletInitMode
|
|
147
138
|
) async throws -> Initializer.InitializationResult
|
|
148
139
|
|
|
149
140
|
/// Starts this synchronizer within the given scope.
|
|
@@ -199,9 +190,6 @@ public protocol Synchronizer: AnyObject {
|
|
|
199
190
|
shieldingThreshold: Zatoshi
|
|
200
191
|
) async throws -> ZcashTransaction.Overview
|
|
201
192
|
|
|
202
|
-
/// all outbound pending transactions that have been sent but are awaiting confirmations
|
|
203
|
-
var pendingTransactions: [ZcashTransaction.Overview] { get async }
|
|
204
|
-
|
|
205
193
|
/// all the transactions that are on the blockchain
|
|
206
194
|
var transactions: [ZcashTransaction.Overview] { get async }
|
|
207
195
|
|
|
@@ -242,10 +230,6 @@ public protocol Synchronizer: AnyObject {
|
|
|
242
230
|
/// - Returns: an array with the given Transactions or an empty array
|
|
243
231
|
func allTransactions(from transaction: ZcashTransaction.Overview, limit: Int) async throws -> [ZcashTransaction.Overview]
|
|
244
232
|
|
|
245
|
-
/// Fetch all pending transactions
|
|
246
|
-
/// - Returns: an array of transactions which are considered pending confirmation. can be empty
|
|
247
|
-
func allPendingTransactions() async throws -> [ZcashTransaction.Overview]
|
|
248
|
-
|
|
249
233
|
/// Returns the latest block height from the provided Lightwallet endpoint
|
|
250
234
|
func latestHeight() async throws -> BlockHeight
|
|
251
235
|
|
|
@@ -333,20 +317,32 @@ public enum SyncStatus: Equatable {
|
|
|
333
317
|
/// When set, a UI element may want to turn green.
|
|
334
318
|
case upToDate
|
|
335
319
|
|
|
320
|
+
/// Indicates that this Synchronizer was succesfully stopped via `stop()` method.
|
|
321
|
+
case stopped
|
|
322
|
+
|
|
336
323
|
case error(_ error: Error)
|
|
337
324
|
|
|
338
325
|
public var isSyncing: Bool {
|
|
339
|
-
|
|
326
|
+
if case .syncing = self {
|
|
327
|
+
return true
|
|
328
|
+
}
|
|
329
|
+
|
|
340
330
|
return false
|
|
341
331
|
}
|
|
342
332
|
|
|
343
333
|
public var isSynced: Bool {
|
|
344
|
-
|
|
334
|
+
if case .upToDate = self {
|
|
335
|
+
return true
|
|
336
|
+
}
|
|
337
|
+
|
|
345
338
|
return false
|
|
346
339
|
}
|
|
347
340
|
|
|
348
341
|
public var isPrepared: Bool {
|
|
349
|
-
|
|
342
|
+
if case .unprepared = self {
|
|
343
|
+
return false
|
|
344
|
+
}
|
|
345
|
+
|
|
350
346
|
return true
|
|
351
347
|
}
|
|
352
348
|
|
|
@@ -354,6 +350,7 @@ public enum SyncStatus: Equatable {
|
|
|
354
350
|
switch self {
|
|
355
351
|
case .unprepared: return "unprepared"
|
|
356
352
|
case .syncing: return "syncing"
|
|
353
|
+
case .stopped: return "stopped"
|
|
357
354
|
case .upToDate: return "up to date"
|
|
358
355
|
case .error: return "error"
|
|
359
356
|
}
|
|
@@ -366,15 +363,9 @@ enum InternalSyncStatus: Equatable {
|
|
|
366
363
|
/// taking other maintenance steps that need to occur after an upgrade.
|
|
367
364
|
case unprepared
|
|
368
365
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
/// with additional transaction details, fetched from the server.
|
|
373
|
-
case enhancing(_ progress: EnhancementProgress)
|
|
374
|
-
|
|
375
|
-
/// fetches the transparent balance and stores it locally
|
|
376
|
-
case fetching(_ progress: Float)
|
|
377
|
-
|
|
366
|
+
/// Indicates that this Synchronizer is actively processing new blocks (consists of fetch, scan and enhance operations)
|
|
367
|
+
case syncing(Float)
|
|
368
|
+
|
|
378
369
|
/// Indicates that this Synchronizer is fully up to date and ready for all wallet functions.
|
|
379
370
|
/// When set, a UI element may want to turn green.
|
|
380
371
|
case synced
|
|
@@ -389,35 +380,33 @@ enum InternalSyncStatus: Equatable {
|
|
|
389
380
|
case error(_ error: Error)
|
|
390
381
|
|
|
391
382
|
public var isSyncing: Bool {
|
|
392
|
-
|
|
393
|
-
case .syncing, .enhancing, .fetching:
|
|
383
|
+
if case .syncing = self {
|
|
394
384
|
return true
|
|
395
|
-
default:
|
|
396
|
-
return false
|
|
397
385
|
}
|
|
386
|
+
|
|
387
|
+
return false
|
|
398
388
|
}
|
|
399
389
|
|
|
400
390
|
public var isSynced: Bool {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
default: return false
|
|
391
|
+
if case .synced = self {
|
|
392
|
+
return true
|
|
404
393
|
}
|
|
394
|
+
|
|
395
|
+
return false
|
|
405
396
|
}
|
|
406
397
|
|
|
407
398
|
public var isPrepared: Bool {
|
|
408
399
|
if case .unprepared = self {
|
|
409
400
|
return false
|
|
410
|
-
} else {
|
|
411
|
-
return true
|
|
412
401
|
}
|
|
402
|
+
|
|
403
|
+
return true
|
|
413
404
|
}
|
|
414
405
|
|
|
415
406
|
public var briefDebugDescription: String {
|
|
416
407
|
switch self {
|
|
417
408
|
case .unprepared: return "unprepared"
|
|
418
409
|
case .syncing: return "syncing"
|
|
419
|
-
case .enhancing: return "enhancing"
|
|
420
|
-
case .fetching: return "fetching"
|
|
421
410
|
case .synced: return "synced"
|
|
422
411
|
case .stopped: return "stopped"
|
|
423
412
|
case .disconnected: return "disconnected"
|
|
@@ -426,6 +415,16 @@ enum InternalSyncStatus: Equatable {
|
|
|
426
415
|
}
|
|
427
416
|
}
|
|
428
417
|
|
|
418
|
+
/// Mode of the Synchronizer's initialization for the wallet.
|
|
419
|
+
public enum WalletInitMode: Equatable {
|
|
420
|
+
/// For brand new wallet - typically when users creates a new wallet.
|
|
421
|
+
case newWallet
|
|
422
|
+
/// For a wallet that is about to be restored. Typically when a user wants to restore a wallet from a seed.
|
|
423
|
+
case restoreWallet
|
|
424
|
+
/// All other cases - typically when clients just start the process e.g. every regular app start for mobile apps.
|
|
425
|
+
case existingWallet
|
|
426
|
+
}
|
|
427
|
+
|
|
429
428
|
/// Kind of transactions handled by a Synchronizer
|
|
430
429
|
public enum TransactionKind {
|
|
431
430
|
case sent
|
|
@@ -449,8 +448,6 @@ extension InternalSyncStatus {
|
|
|
449
448
|
switch (lhs, rhs) {
|
|
450
449
|
case (.unprepared, .unprepared): return true
|
|
451
450
|
case let (.syncing(lhsProgress), .syncing(rhsProgress)): return lhsProgress == rhsProgress
|
|
452
|
-
case let (.enhancing(lhsProgress), .enhancing(rhsProgress)): return lhsProgress == rhsProgress
|
|
453
|
-
case (.fetching, .fetching): return true
|
|
454
451
|
case (.synced, .synced): return true
|
|
455
452
|
case (.stopped, .stopped): return true
|
|
456
453
|
case (.disconnected, .disconnected): return true
|
|
@@ -461,15 +458,8 @@ extension InternalSyncStatus {
|
|
|
461
458
|
}
|
|
462
459
|
|
|
463
460
|
extension InternalSyncStatus {
|
|
464
|
-
init(_ blockProcessorProgress:
|
|
465
|
-
|
|
466
|
-
case .syncing(let progressReport):
|
|
467
|
-
self = .syncing(progressReport)
|
|
468
|
-
case .enhance(let enhancingReport):
|
|
469
|
-
self = .enhancing(enhancingReport)
|
|
470
|
-
case .fetch(let fetchingProgress):
|
|
471
|
-
self = .fetching(fetchingProgress)
|
|
472
|
-
}
|
|
461
|
+
init(_ blockProcessorProgress: Float) {
|
|
462
|
+
self = .syncing(blockProcessorProgress)
|
|
473
463
|
}
|
|
474
464
|
}
|
|
475
465
|
|
|
@@ -479,15 +469,11 @@ extension InternalSyncStatus {
|
|
|
479
469
|
case .unprepared:
|
|
480
470
|
return .unprepared
|
|
481
471
|
case .syncing(let progress):
|
|
482
|
-
return .syncing(
|
|
483
|
-
case .enhancing(let progress):
|
|
484
|
-
return .syncing(0.9 + 0.08 * progress.progress)
|
|
485
|
-
case .fetching(let progress):
|
|
486
|
-
return .syncing(0.98 + 0.02 * progress)
|
|
472
|
+
return .syncing(progress)
|
|
487
473
|
case .synced:
|
|
488
474
|
return .upToDate
|
|
489
475
|
case .stopped:
|
|
490
|
-
return .
|
|
476
|
+
return .stopped
|
|
491
477
|
case .disconnected:
|
|
492
478
|
return .error(ZcashError.synchronizerDisconnected)
|
|
493
479
|
case .error(let error):
|
|
@@ -10,8 +10,8 @@ import Foundation
|
|
|
10
10
|
typealias TransactionEncoderResultBlock = (_ result: Result<EncodedTransaction, Error>) -> Void
|
|
11
11
|
|
|
12
12
|
public enum TransactionEncoderError: Error {
|
|
13
|
-
case notFound(
|
|
14
|
-
case notEncoded(
|
|
13
|
+
case notFound(txId: Data)
|
|
14
|
+
case notEncoded(txId: Data)
|
|
15
15
|
case missingParams
|
|
16
16
|
case spendingKeyWrongNetwork
|
|
17
17
|
case couldNotExpand(txId: Data)
|
|
@@ -71,7 +71,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
logger.debug("transaction id: \(txId)")
|
|
74
|
-
return try await repository.find(
|
|
74
|
+
return try await repository.find(rawID: txId)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
func createSpend(
|
|
@@ -80,7 +80,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
80
80
|
to address: String,
|
|
81
81
|
memoBytes: MemoBytes?,
|
|
82
82
|
from accountIndex: Int
|
|
83
|
-
) async throws ->
|
|
83
|
+
) async throws -> Data {
|
|
84
84
|
guard ensureParams(spend: self.spendParamsURL, output: self.outputParamsURL) else {
|
|
85
85
|
throw ZcashError.walletTransEncoderCreateTransactionMissingSaplingParams
|
|
86
86
|
}
|
|
@@ -92,7 +92,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
92
92
|
memo: memoBytes
|
|
93
93
|
)
|
|
94
94
|
|
|
95
|
-
return
|
|
95
|
+
return txId
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
func createShieldingTransaction(
|
|
@@ -109,7 +109,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
109
109
|
)
|
|
110
110
|
|
|
111
111
|
logger.debug("transaction id: \(txId)")
|
|
112
|
-
return try await repository.find(
|
|
112
|
+
return try await repository.find(rawID: txId)
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
func createShieldingSpend(
|
|
@@ -117,7 +117,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
117
117
|
shieldingThreshold: Zatoshi,
|
|
118
118
|
memo: MemoBytes?,
|
|
119
119
|
accountIndex: Int
|
|
120
|
-
) async throws ->
|
|
120
|
+
) async throws -> Data {
|
|
121
121
|
guard ensureParams(spend: self.spendParamsURL, output: self.outputParamsURL) else {
|
|
122
122
|
throw ZcashError.walletTransEncoderShieldFundsMissingSaplingParams
|
|
123
123
|
}
|
|
@@ -128,7 +128,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
128
128
|
shieldingThreshold: shieldingThreshold
|
|
129
129
|
)
|
|
130
130
|
|
|
131
|
-
return
|
|
131
|
+
return txId
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
func submit(
|
|
@@ -157,7 +157,7 @@ class WalletTransactionEncoder: TransactionEncoder {
|
|
|
157
157
|
extension ZcashTransaction.Overview {
|
|
158
158
|
func encodedTransaction() throws -> EncodedTransaction {
|
|
159
159
|
guard let raw else {
|
|
160
|
-
throw TransactionEncoderError.notEncoded(
|
|
160
|
+
throw TransactionEncoderError.notEncoded(txId: self.rawID)
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
return EncodedTransaction(transactionId: self.rawID, raw: raw)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ZcashFileManager.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Lukáš Korba on 23.05.2023.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
protocol ZcashFileManager {
|
|
11
|
+
func isReadableFile(atPath path: String) -> Bool
|
|
12
|
+
func removeItem(at URL: URL) throws
|
|
13
|
+
func isDeletableFile(atPath path: String) -> Bool
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
extension FileManager: ZcashFileManager { }
|
|
@@ -5,31 +5,35 @@
|
|
|
5
5
|
<key>AvailableLibraries</key>
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>libzcashlc.a</string>
|
|
8
10
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
10
12
|
<key>LibraryPath</key>
|
|
11
13
|
<string>libzcashlc.a</string>
|
|
12
14
|
<key>SupportedArchitectures</key>
|
|
13
15
|
<array>
|
|
14
16
|
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
15
18
|
</array>
|
|
16
19
|
<key>SupportedPlatform</key>
|
|
17
20
|
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
18
23
|
</dict>
|
|
19
24
|
<dict>
|
|
25
|
+
<key>BinaryPath</key>
|
|
26
|
+
<string>libzcashlc.a</string>
|
|
20
27
|
<key>LibraryIdentifier</key>
|
|
21
|
-
<string>ios-
|
|
28
|
+
<string>ios-arm64</string>
|
|
22
29
|
<key>LibraryPath</key>
|
|
23
30
|
<string>libzcashlc.a</string>
|
|
24
31
|
<key>SupportedArchitectures</key>
|
|
25
32
|
<array>
|
|
26
33
|
<string>arm64</string>
|
|
27
|
-
<string>x86_64</string>
|
|
28
34
|
</array>
|
|
29
35
|
<key>SupportedPlatform</key>
|
|
30
36
|
<string>ios</string>
|
|
31
|
-
<key>SupportedPlatformVariant</key>
|
|
32
|
-
<string>simulator</string>
|
|
33
37
|
</dict>
|
|
34
38
|
</array>
|
|
35
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|