From 6afca03467a032634d37da5186eaea565ac24fda Mon Sep 17 00:00:00 2001 From: Soner YUKSEL Date: Wed, 3 May 2023 10:46:11 -0400 Subject: [PATCH] Fix brave/brave-ios#7242: Bump BraveCore to v1.51.110 (brave/brave-ios#7377) --- .../Brave/Frontend/Rewards/BraveRewards.swift | 50 +++++++++---------- .../Preview Content/MockJsonRpcService.swift | 4 ++ package-lock.json | 12 ++--- package.json | 2 +- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Sources/Brave/Frontend/Rewards/BraveRewards.swift b/Sources/Brave/Frontend/Rewards/BraveRewards.swift index 797099ba932f..e94f6cf23b77 100644 --- a/Sources/Brave/Frontend/Rewards/BraveRewards.swift +++ b/Sources/Brave/Frontend/Rewards/BraveRewards.swift @@ -64,37 +64,40 @@ public class BraveRewards: NSObject { ledger?.initializeLedgerService { [weak self] in guard let self = self, let ledger = self.ledger else { return } if self.ads.isEnabled { - if self.ads.isAdsServiceRunning() { - self.updateAdsWithWalletInfo() - } else { - self.ads.initialize { success in - if success { - self.updateAdsWithWalletInfo() - } - } - } + self.fetchWalletAndInitializeAds() } self.ledgerServiceDidStart?(ledger) completion?() } } - private func updateAdsWithWalletInfo() { + private(set) var isAdsInitialized: Bool = false + private func fetchWalletAndInitializeAds() { + if isAdsInitialized { + return + } + isAdsInitialized = true guard let ledger = ledger else { return } ledger.currentWalletInfo { wallet in - guard let wallet = wallet else { return } - let seed = wallet.recoverySeed.map(\.uint8Value) - self.ads.updateWalletInfo( - wallet.paymentId, - base64Seed: Data(seed).base64EncodedString() - ) + if let wallet = wallet { + let seed = wallet.recoverySeed.map(\.uint8Value) + self.ads.updateWalletInfo( + wallet.paymentId, + base64Seed: Data(seed).base64EncodedString() + ) + } + self.ads.initialize() { success in + if !success { + self.isAdsInitialized = false + } + } } } private var braveNewsObservation: AnyCancellable? private var shouldShutdownAds: Bool { - ads.isAdsServiceRunning() && !ads.isEnabled && !Preferences.BraveNews.isEnabled.value + ads.isAdsServiceRunning() && isAdsInitialized && !ads.isEnabled && !Preferences.BraveNews.isEnabled.value } /// Propose that the ads service should be shutdown based on whether or not that all features @@ -103,6 +106,7 @@ public class BraveRewards: NSObject { if !shouldShutdownAds { return } ads.shutdown { self.ads = BraveAds(stateStoragePath: self.configuration.storageURL.appendingPathComponent("ads").path) + self.isAdsInitialized = false } } @@ -130,15 +134,7 @@ public class BraveRewards: NSObject { if !newValue { self.proposeAdsShutdown() } else { - if self.ads.isAdsServiceRunning() { - self.updateAdsWithWalletInfo() - } else { - self.ads.initialize { success in - if success { - self.updateAdsWithWalletInfo() - } - } - } + self.fetchWalletAndInitializeAds() } self.didChangeValue(for: \.isEnabled) } @@ -165,7 +161,7 @@ public class BraveRewards: NSObject { try? FileManager.default.removeItem( at: configuration.storageURL.appendingPathComponent("ledger") ) - if ads.isAdsServiceRunning(), !Preferences.BraveNews.isEnabled.value { + if ads.isAdsServiceRunning(), isAdsInitialized, !Preferences.BraveNews.isEnabled.value { ads.shutdown { [self] in try? FileManager.default.removeItem( at: configuration.storageURL.appendingPathComponent("ads") diff --git a/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift b/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift index 4a6f709a50c3..37feef616655 100644 --- a/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift +++ b/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift @@ -214,6 +214,10 @@ class MockJsonRpcService: BraveWalletJsonRpcService { func ensGetContentHash(_ domain: String, completion: @escaping ([NSNumber], Bool, BraveWallet.ProviderError, String) -> Void) { completion([], false, .internalError, "Error Message") } + + func isSolanaBlockhashValid(_ chainId: String, blockhash: String, commitment: String?, completion: @escaping (Bool, BraveWallet.SolanaProviderError, String) -> Void) { + completion(true, .success, "") + } } extension BraveWallet.NetworkInfo { diff --git a/package-lock.json b/package-lock.json index c4448aa3d005..e16f5578b03d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MPL-2.0", "dependencies": { "@mozilla/readability": "^0.4.2", - "brave-core-ios": "https://github.com/brave/brave-browser/releases/download/v1.51.104/brave-core-ios-1.51.104.tgz", + "brave-core-ios": "https://github.com/brave/brave-browser/releases/download/v1.51.110/brave-core-ios-1.51.110.tgz", "leo-sf-symbols": "github:brave/leo-sf-symbols#b66549a239c5d4d9db1bdcc0b847d5b1f1762e10", "page-metadata-parser": "^1.1.3", "webpack-cli": "^4.8.0" @@ -356,9 +356,9 @@ } }, "node_modules/brave-core-ios": { - "version": "1.51.104", - "resolved": "https://github.com/brave/brave-browser/releases/download/v1.51.104/brave-core-ios-1.51.104.tgz", - "integrity": "sha512-mImDCniMroqEsqjoWgxyEWYtu8bUcvwn8u+gUiM5i0MysVjLBn2jcryRwwqnjekM3RqCNLKRUmKfHZ6If7p2ew==", + "version": "1.51.110", + "resolved": "https://github.com/brave/brave-browser/releases/download/v1.51.110/brave-core-ios-1.51.110.tgz", + "integrity": "sha512-W6E4BM3aJF5eZG8bSSPzmjL2Tkhxr35sQJHRpVR+uZfWpeQ+yCw+bRCt7qXgY1Cu/ltBbIKqEiP4CXlfk/4NMg==", "license": "ISC" }, "node_modules/browserslist": { @@ -1738,8 +1738,8 @@ } }, "brave-core-ios": { - "version": "https://github.com/brave/brave-browser/releases/download/v1.51.104/brave-core-ios-1.51.104.tgz", - "integrity": "sha512-mImDCniMroqEsqjoWgxyEWYtu8bUcvwn8u+gUiM5i0MysVjLBn2jcryRwwqnjekM3RqCNLKRUmKfHZ6If7p2ew==" + "version": "https://github.com/brave/brave-browser/releases/download/v1.51.110/brave-core-ios-1.51.110.tgz", + "integrity": "sha512-W6E4BM3aJF5eZG8bSSPzmjL2Tkhxr35sQJHRpVR+uZfWpeQ+yCw+bRCt7qXgY1Cu/ltBbIKqEiP4CXlfk/4NMg==" }, "browserslist": { "version": "4.17.1", diff --git a/package.json b/package.json index 5cf34ecf5850..fc377a27eb95 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "license": "MPL-2.0", "dependencies": { "@mozilla/readability": "^0.4.2", - "brave-core-ios": "https://github.com/brave/brave-browser/releases/download/v1.51.104/brave-core-ios-1.51.104.tgz", + "brave-core-ios": "https://github.com/brave/brave-browser/releases/download/v1.51.110/brave-core-ios-1.51.110.tgz", "leo-sf-symbols": "github:brave/leo-sf-symbols#b66549a239c5d4d9db1bdcc0b847d5b1f1762e10", "page-metadata-parser": "^1.1.3", "webpack-cli": "^4.8.0"