Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #7608: Turn Sardine on for all wallet users (#7735)
Browse files Browse the repository at this point in the history
Remove US-only restriction for Sardine
  • Loading branch information
StephenHeaps authored Jul 14, 2023
1 parent feb95c9 commit 849324c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
7 changes: 1 addition & 6 deletions Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,7 @@ class AssetDetailStore: ObservableObject {
}

@MainActor private func isBuyButtonSupported(in network: BraveWallet.NetworkInfo, for symbol: String) async -> Bool {
let buyOptions: [BraveWallet.OnRampProvider]
if Locale.preferredLanguages.first?.caseInsensitiveCompare("en-us") == .orderedSame {
buyOptions = [.ramp, .sardine, .transak]
} else {
buyOptions = [.ramp, .transak]
}
let buyOptions: [BraveWallet.OnRampProvider] = [.ramp, .sardine, .transak]
self.allBuyTokensAllOptions = await blockchainRegistry.allBuyTokens(in: network, for: buyOptions)
let buyTokens = allBuyTokensAllOptions.flatMap { $0.value }
return buyTokens.first(where: { $0.symbol.caseInsensitiveCompare(symbol) == .orderedSame }) != nil
Expand Down
7 changes: 1 addition & 6 deletions Sources/BraveWallet/Crypto/Stores/BuyTokenStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,7 @@ public class BuyTokenStore: ObservableObject {

@MainActor
func updateInfo() async {
// check device language to determine if we support `Sardine`
if Locale.preferredLanguages.first?.caseInsensitiveCompare("en-us") == .orderedSame {
orderedSupportedBuyOptions = [.ramp, .sardine, .transak]
} else {
orderedSupportedBuyOptions = [.ramp, .transak]
}
orderedSupportedBuyOptions = [.ramp, .sardine, .transak]

let coin = await walletService.selectedCoin()
selectedNetwork = await rpcService.network(coin, origin: nil)
Expand Down
8 changes: 5 additions & 3 deletions Tests/BraveWalletTests/BuyTokenStoreTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ class BuyTokenStoreTests: XCTestCase {

await store.updateInfo()

XCTAssertEqual(store.orderedSupportedBuyOptions.count, 2)
XCTAssertEqual(store.orderedSupportedBuyOptions.count, 3)
XCTAssertNotNil(store.orderedSupportedBuyOptions.first)
XCTAssertEqual(store.orderedSupportedBuyOptions.first!, .ramp)
XCTAssertEqual(store.orderedSupportedBuyOptions.first, .ramp)
XCTAssertNotNil(store.orderedSupportedBuyOptions[safe: 1])
XCTAssertEqual(store.orderedSupportedBuyOptions[safe: 1], .sardine)
XCTAssertNotNil(store.orderedSupportedBuyOptions.last)
XCTAssertEqual(store.orderedSupportedBuyOptions.last!, .transak)
XCTAssertEqual(store.orderedSupportedBuyOptions.last, .transak)
}

@MainActor
Expand Down

0 comments on commit 849324c

Please # to comment.