Skip to content

Commit

Permalink
Fix brave/brave-ios#7242: Bump BraveCore to v1.51.110 (brave/brave-io…
Browse files Browse the repository at this point in the history
  • Loading branch information
soner-yuksel authored May 3, 2023
1 parent 9dbd215 commit 6afca03
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
50 changes: 23 additions & 27 deletions Sources/Brave/Frontend/Rewards/BraveRewards.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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)
}
Expand All @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions Sources/BraveWallet/Preview Content/MockJsonRpcService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6afca03

Please sign in to comment.