Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add appStatus for Zcash adapter #5313

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,12 @@ extension ZcashAdapter: IAdapter {
}

var statusInfo: [(String, Any)] {
[]
[
("Last Block Info", lastBlockHeight),
("Sync State", state.description),
("Birthday Height", birthday.description),
("Init Mode", initMode.description),
]
}

var debugInfo: String {
Expand Down Expand Up @@ -799,8 +804,6 @@ enum ZCashAdapterState: Equatable {
case syncing(progress: Int?, lastBlockDate: Date?)
case downloadingSapling(progress: Int)
case downloadingBlocks(progress: Float, lastBlock: Int)
case scanningBlocks(number: Int, lastBlock: Int)
case enhancingTransactions(number: Int, count: Int)
case notSynced(error: Error)

public static func == (lhs: ZCashAdapterState, rhs: ZCashAdapterState) -> Bool {
Expand All @@ -811,8 +814,6 @@ enum ZCashAdapterState: Equatable {
case let (.syncing(lProgress, lLastBlockDate), .syncing(rProgress, rLastBlockDate)): return lProgress == rProgress && lLastBlockDate == rLastBlockDate
case let (.downloadingSapling(lProgress), .downloadingSapling(rProgress)): return lProgress == rProgress
case let (.downloadingBlocks(lNumber, lLast), .downloadingBlocks(rNumber, rLast)): return lNumber == rNumber && lLast == rLast
case let (.scanningBlocks(lNumber, lLast), .scanningBlocks(rNumber, rLast)): return lNumber == rNumber && lLast == rLast
case let (.enhancingTransactions(lNumber, lCount), .enhancingTransactions(rNumber, rCount)): return lNumber == rNumber && lCount == rCount
case (.notSynced, .notSynced): return true
default: return false
}
Expand All @@ -829,25 +830,27 @@ enum ZCashAdapterState: Equatable {
case let .downloadingBlocks(progress, _):
let percentValue = ValueFormatter.instance.format(percentValue: Decimal(Double(progress * 100)), showSign: false)
return .customSyncing(main: "balance.downloading_blocks".localized, secondary: percentValue, progress: Int(progress * 100))
case let .scanningBlocks(number, lastBlock):
return .customSyncing(main: "Scanning Blocks", secondary: "\(number)/\(lastBlock)", progress: nil)
case let .enhancingTransactions(number, count):
let progress: String? = count == 0 ? nil : "\(number)/\(count)"
return .customSyncing(main: "Enhancing Transactions", secondary: progress, progress: nil)
case let .notSynced(error): return .notSynced(error: error)
}
}

var isDownloading: Bool {
var description: String {
switch self {
case .downloadingBlocks: return true
default: return false
case .idle: return "Idle"
case .preparing: return "Preparing..."
case .synced: return "Synced"
case let .syncing(progress, lastDate): return "Syncing: progress = \(progress?.description ?? "N/A"), lastBlockDate: \(lastDate?.description ?? "N/A")"
case let .downloadingSapling(progress): return "downloadingSapling: progress = \(progress)"
case let .downloadingBlocks(progress, _):
let percentValue = ValueFormatter.instance.format(percentValue: Decimal(Double(progress * 100)), showSign: false)
return "Downloading Blocks: \(percentValue?.description ?? "N/A") : \(Int(progress * 100))"
case let .notSynced(error): return "Not synced \(error.localizedDescription)"
}
}

var isScanning: Bool {
var isDownloading: Bool {
switch self {
case .scanningBlocks: return true
case .downloadingBlocks: return true
default: return false
}
}
Expand All @@ -858,11 +861,14 @@ enum ZCashAdapterState: Equatable {
default: return false
}
}
}

var lastProcessedBlockHeight: Int? {
extension WalletInitMode {
var description: String {
switch self {
case let .downloadingBlocks(_, last), let .scanningBlocks(_, last): return last
default: return nil
case .newWallet: return "New Wallet"
case .existingWallet: return "Existing Wallet"
case .restoreWallet: return "Restored Wallet"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ class RateAppManager {
}

private func show() {
SKStoreReviewController.requestReview()

if let scene = UIApplication.shared.connectedScenes
.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
DispatchQueue.main.async {
SKStoreReviewController.requestReview(in: scene)
}
}
localStorage.rateAppLastRequestDate = Date()
isRequestAllowed = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class RestoreCloudService {
}

self.fullBackupItems = items.sorted { (item1: Item, item2: Item) in
if item1.source.timestamp == nil, item2.source == nil {
if item1.source.timestamp == nil, item2.source.timestamp == nil {
return item1.name > item2.name
}
return (item1.source.timestamp ?? 0) > (item2.source.timestamp ?? 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ extension SendTronService.AddressError: LocalizedError {
var errorDescription: String? {
switch self {
case .ownAddress: return "send.address_error.own_address".localized
default: return "\(self)"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ class WalletConnectMainViewModel {
reconnectButtonRelay.accept(stateForReconnectButton ? (connectionState == .disconnected ? .enabled : .hidden) : .hidden)
closeVisibleRelay.accept(state == .ready)

var address: String?
var network: String?
var networkEditable = false
var blockchains: [BlockchainViewItem]?

blockchains = allowedBlockchains
let blockchains = allowedBlockchains
.map { item in
BlockchainViewItem(
chainId: item.chainId,
Expand All @@ -96,9 +91,9 @@ class WalletConnectMainViewModel {
dAppMeta: service.appMetaItem.map { dAppMetaViewItem(appMetaItem: $0) },
status: status(connectionState: connectionState),
activeAccountName: service.activeAccountName,
address: address,
network: network,
networkEditable: networkEditable,
address: nil,
network: nil,
networkEditable: false,
blockchains: blockchains,
hint: service.hint
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct InputTextView: View {
}

extension InputTextView {
@ViewBuilder func secure(_ secured: Binding<Bool>) -> some View {
func secure(_ secured: Binding<Bool>) -> some View {
var selfView = self
selfView._secured = secured

Expand Down