From 3f16dfe54b130f5de56ecd15933b73aff07693a9 Mon Sep 17 00:00:00 2001 From: Nuo Xu Date: Mon, 13 Apr 2026 10:26:19 -0400 Subject: [PATCH] [iOS][Wallet][CodeHealth] fix some wallet warnings (#35433) fix some wallet warnings --- .../BraveWallet/Chart/LineChartView.swift | 4 ++-- .../Crypto/FiltersDisplaySettingsView.swift | 19 +++++++-------- .../Crypto/NFT/NFTDetailView.swift | 24 +++++++------------ .../Crypto/Onboarding/CreateWalletView.swift | 8 +++++-- .../Onboarding/VerifyRecoveryPhraseView.swift | 11 ++++----- .../Crypto/Portfolio/AddCustomAssetView.swift | 13 ++++------ .../Crypto/Stores/SendTokenStore.swift | 2 +- .../TransactionConfirmationView.swift | 17 ++++++------- .../Transactions/TransactionParser.swift | 2 ++ .../Extensions/BraveWalletExtensions.swift | 22 ++++++++++++----- .../Extensions/RpcServiceExtensions.swift | 14 ++++------- 11 files changed, 64 insertions(+), 72 deletions(-) diff --git a/ios/brave-ios/Sources/BraveWallet/Chart/LineChartView.swift b/ios/brave-ios/Sources/BraveWallet/Chart/LineChartView.swift index e085f15aa9d..5f279291924 100644 --- a/ios/brave-ios/Sources/BraveWallet/Chart/LineChartView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Chart/LineChartView.swift @@ -113,10 +113,10 @@ struct LineChartView: View { } } - private struct DragContext { + private struct DragContext { var location: CGPoint var size: CGSize - var dataPoint: DataType? + var dataPoint: DragContextDataType? } @State private var dragContext: DragContext? diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift index 63a5fb518ed..ef12d2f06f5 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/FiltersDisplaySettingsView.swift @@ -204,19 +204,16 @@ struct FiltersDisplaySettingsView: View { } .padding(.horizontal) } - .onChange( - of: groupBy, - perform: { newValue in - if isNFTFilters { - if newValue == .accounts { - isHidingUnownedNFTs = true - isHidingUnownedNFTsDisabled = true - } else { - isHidingUnownedNFTsDisabled = false - } + .onChange(of: groupBy) { _, newValue in + if isNFTFilters { + if newValue == .accounts { + isHidingUnownedNFTs = true + isHidingUnownedNFTsDisabled = true + } else { + isHidingUnownedNFTsDisabled = false } } - ) + } .background(Color(uiColor: WalletV2Design.containerBackground)) .safeAreaInset( edge: .bottom, diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/NFT/NFTDetailView.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/NFT/NFTDetailView.swift index e945f0555ba..af700197753 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/NFT/NFTDetailView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/NFT/NFTDetailView.swift @@ -211,23 +211,17 @@ struct NFTDetailView: View { } .scrollContentBackground(.hidden) .background(Color(UIColor.braveGroupedBackground)) - .onChange( - of: nftDetailStore.nftMetadata, - perform: { newValue in - if let newMetadata = newValue { - onNFTMetadataRefreshed?(newMetadata) - } + .onChange(of: nftDetailStore.nftMetadata) { _, newValue in + if let newMetadata = newValue { + onNFTMetadataRefreshed?(newMetadata) } - ) - .onChange( - of: keyringStore.isWalletLocked, - perform: { isLocked in - guard isLocked else { return } - if isPresentingRemoveAlert { - isPresentingRemoveAlert = false - } + } + .onChange(of: keyringStore.isWalletLocked) { _, isLocked in + guard isLocked else { return } + if isPresentingRemoveAlert { + isPresentingRemoveAlert = false } - ) + } .background(Color(UIColor.braveGroupedBackground).ignoresSafeArea()) .navigationBarTitle(nftDetailStore.nft.nftDetailTitle) .toolbar { diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/CreateWalletView.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/CreateWalletView.swift index 91105136582..6998aaf6152 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/CreateWalletView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/CreateWalletView.swift @@ -219,8 +219,12 @@ struct CreateWalletView: View { EmptyView() } ) - .onChange(of: password, perform: handleInputChange) - .onChange(of: repeatedPassword, perform: handleInputChange) + .onChange(of: password) { _, newValue in + handleInputChange(newValue) + } + .onChange(of: repeatedPassword) { _, newValue in + handleInputChange(newValue) + } .navigationBarBackButtonHidden(isShowingCreatingWallet) .frame(maxWidth: .infinity, maxHeight: .infinity) .overlay { diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/VerifyRecoveryPhraseView.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/VerifyRecoveryPhraseView.swift index 340236a4904..678734f131b 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/VerifyRecoveryPhraseView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/VerifyRecoveryPhraseView.swift @@ -156,14 +156,11 @@ struct VerifyRecoveryPhraseView: View { ) ) .transparentNavigationBar(backButtonDisplayMode: .generic) - .onChange( - of: input, - perform: { newValue in - if newValue.isEmpty { - isShowingError = false - } + .onChange(of: input) { _, newValue in + if newValue.isEmpty { + isShowingError = false } - ) + } .onAppear { isFieldFocused = true } diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/Portfolio/AddCustomAssetView.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/Portfolio/AddCustomAssetView.swift index 3447bdf2ff3..09d7bc048e6 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/Portfolio/AddCustomAssetView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/Portfolio/AddCustomAssetView.swift @@ -292,14 +292,11 @@ struct AddCustomAssetView: View { } .scrollContentBackground(.hidden) .background(Color(UIColor.braveGroupedBackground)) - .onChange( - of: selectedTokenType, - perform: { _ in - guard tokenNeedsTokenId == nil else { return } - resignFirstResponder() - clearInput() - } - ) + .onChange(of: selectedTokenType) { _, _ in + guard tokenNeedsTokenId == nil else { return } + resignFirstResponder() + clearInput() + } .navigationTitle(Strings.Wallet.customTokenTitle) .navigationBarTitleDisplayMode(.inline) .toolbar { diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift index 84ced1ce180..b3b4d0da221 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift @@ -461,7 +461,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore { fromAccount: selectedAccount, recipient: sendAddress ) - case .ada: + case .ada, .dot: break @unknown default: break diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/TransactionConfirmations/TransactionConfirmationView.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/TransactionConfirmations/TransactionConfirmationView.swift index ede50ad76b9..f12e213196a 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/TransactionConfirmations/TransactionConfirmationView.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/TransactionConfirmations/TransactionConfirmationView.swift @@ -101,17 +101,14 @@ struct TransactionConfirmationView: View { .navigationBarTitleDisplayMode(.inline) .foregroundColor(Color(.braveLabel)) .background(Color(.braveGroupedBackground).edgesIgnoringSafeArea(.all)) - .onChange( - of: confirmationStore.activeTransactionId, - perform: { newValue in - // we are looking for `activeTransactionId` value - // when the value is an empty string meaning there is no active transaction - // aka there is no remaining pending transations - if newValue == "" { - onDismiss() - } + .onChange(of: confirmationStore.activeTransactionId) { _, newValue in + // we are looking for `activeTransactionId` value + // when the value is an empty string meaning there is no active transaction + // aka there is no remaining pending transations + if newValue == "" { + onDismiss() } - ) + } .onAppear { Task { await confirmationStore.prepare() diff --git a/ios/brave-ios/Sources/BraveWallet/Crypto/Transactions/TransactionParser.swift b/ios/brave-ios/Sources/BraveWallet/Crypto/Transactions/TransactionParser.swift index 8d8c8142d36..cf349520a8b 100644 --- a/ios/brave-ios/Sources/BraveWallet/Crypto/Transactions/TransactionParser.swift +++ b/ios/brave-ios/Sources/BraveWallet/Crypto/Transactions/TransactionParser.swift @@ -1603,6 +1603,8 @@ extension BraveWallet.TransactionInfo { break case .ethFilForwarderTransfer: break + case .cardanoSendLovelace, .cardanoSendToken: + break @unknown default: break } diff --git a/ios/brave-ios/Sources/BraveWallet/Extensions/BraveWalletExtensions.swift b/ios/brave-ios/Sources/BraveWallet/Extensions/BraveWalletExtensions.swift index f935cf55cb3..eb347cbbeab 100644 --- a/ios/brave-ios/Sources/BraveWallet/Extensions/BraveWalletExtensions.swift +++ b/ios/brave-ios/Sources/BraveWallet/Extensions/BraveWalletExtensions.swift @@ -34,7 +34,9 @@ extension BraveWallet.TransactionInfo { .solanaSplTokenTransferWithAssociatedTokenAccountCreation, .solanaDappSignAndSendTransaction, .solanaDappSignTransaction, - .ethFilForwarderTransfer: + .ethFilForwarderTransfer, + .cardanoSendLovelace, + .cardanoSendToken: return true case .other: // Filecoin or Bitcoin send @@ -174,8 +176,8 @@ extension BraveWallet.AccountInfo { return Strings.Wallet.btcAccountDescription case .zec: return Strings.Wallet.zecAccountDescription - case .ada: - return "" + case .ada, .dot: + fallthrough @unknown default: return "" } @@ -270,6 +272,8 @@ extension BraveWallet.CoinType { return [.zCashMainnet, .zCashTestnet] case .ada: return [.cardanoMainnet, .cardanoTestnet] + case .dot: + return [.polkadotMainnet, .polkadotTestnet] @unknown default: return [.default] } @@ -308,7 +312,7 @@ extension BraveWallet.CoinType { return Strings.Wallet.coinTypeBitcoinDescription case .zec: return Strings.Wallet.coinTypeZCashDescription - case .ada: + case .ada, .dot: fallthrough @unknown default: return Strings.Wallet.coinTypeUnknown @@ -327,7 +331,7 @@ extension BraveWallet.CoinType { return "bitcoin-asset-icon" case .zec: return "zcash-asset-icon" - case .ada: + case .ada, .dot: fallthrough @unknown default: return "" @@ -347,7 +351,7 @@ extension BraveWallet.CoinType { return 4 case .zec: return 5 - case .ada: + case .ada, .dot: fallthrough @unknown default: return 10 @@ -590,6 +594,8 @@ extension BraveWallet.KeyringId { return chainId == BraveWallet.ZCashMainnet ? .zCashMainnet : .zCashTestnet case .ada: return chainId == BraveWallet.CardanoMainnet ? .cardanoMainnet : .cardanoTestnet + case .dot: + return chainId == BraveWallet.PolkadotMainnet ? .polkadotMainnet : .polkadotTestnet @unknown default: return .default } @@ -743,6 +749,8 @@ extension BraveWallet.TransactionType { return Strings.Wallet.txFunctionTypeOther case .solanaDappSignTransaction: return Strings.Wallet.txFunctionTypeSignDappTransaction + case .cardanoSendLovelace, .cardanoSendToken: // not used in tx details + fallthrough @unknown default: return Strings.Wallet.txFunctionTypeOther } @@ -764,6 +772,8 @@ extension BraveWallet.ZCashAddressError { return Strings.Wallet.sendErrorZecAddressOrchardPartMissing case .invalidAddressNetworkMismatch: return Strings.Wallet.sendErrorZecAddressNetworkMissmatch + case .notZCashAccount, .invalidSenderType: + fallthrough @unknown default: return Strings.Wallet.unknownError } diff --git a/ios/brave-ios/Sources/BraveWallet/Extensions/RpcServiceExtensions.swift b/ios/brave-ios/Sources/BraveWallet/Extensions/RpcServiceExtensions.swift index 3763c46cefe..b61ddb4d58f 100644 --- a/ios/brave-ios/Sources/BraveWallet/Extensions/RpcServiceExtensions.swift +++ b/ios/brave-ios/Sources/BraveWallet/Extensions/RpcServiceExtensions.swift @@ -124,10 +124,8 @@ extension BraveWalletJsonRpcService { completion(nil) } } - case .btc: - completion(nil) - case .zec: - completion(nil) + case .btc, .zec, .ada, .dot: + fallthrough @unknown default: completion(nil) } @@ -247,12 +245,8 @@ extension BraveWalletJsonRpcService { completion(nil) } } - case .btc: - // Bitcoin balance should be fetched using `BraveWallet.BitcoinWalletService` - completion(nil) - case .zec: - // Zcash balance should be fetched using `BraveWallet.ZCashWalletService` - completion(nil) + case .btc, .zec, .ada, .dot: + fallthrough @unknown default: completion(nil) }