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

Fix #8583: Bump Brave Core to 1.63.x #8584

Merged
merged 2 commits into from
Dec 20, 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 @@ -819,12 +819,12 @@ class SettingsViewController: TableViewController {
Row(
text: "View Brave Histogram (p3a) Logs",
selection: { [unowned self] in
let histogramsController = self.p3aUtilities.histogramsController().then {
let histogramsController = ChromeWebViewController(privateBrowsing: false).then {
$0.title = "Histograms (p3a)"
$0.loadURL("brave://histograms")
}
if #available(iOS 16.0, *) {
// TODO: Replace this with property access when exposed from brave-core side
let webView = histogramsController.value(forKey: "_webView") as! WKWebView // swiftlint:disable:this force_cast
let webView = histogramsController.webView
webView.isFindInteractionEnabled = true
histogramsController.navigationItem.rightBarButtonItem = UIBarButtonItem(
systemItem: .search,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ class SyncSettingsTableViewController: SyncViewController, UITableViewDelegate,
askForAuthentication(viewType: .sync) { [weak self] status, error in
guard let self = self, status else { return }

let syncInternalsController = self.syncAPI.createSyncInternalsController().then {
let syncInternalsController = ChromeWebViewController(privateBrowsing: false).then {
$0.title = Strings.braveSyncInternalsTitle
$0.loadURL("brave://sync-internals")
}

self.navigationController?.pushViewController(syncInternalsController, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ class SyncWelcomeViewController: SyncViewController {
askForAuthentication(viewType: .sync) { [weak self] status, error in
guard let self = self, status else { return }

let syncInternalsController = syncAPI.createSyncInternalsController().then {
let syncInternalsController = ChromeWebViewController(privateBrowsing: false).then {
$0.title = Strings.braveSyncInternalsTitle
$0.loadURL("brave://sync-internals")
}

navigationController?.pushViewController(syncInternalsController, animated: true)
Expand Down
59 changes: 11 additions & 48 deletions Sources/BraveWallet/Crypto/Portfolio/AddCustomAssetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,8 @@ struct AddCustomAssetView: View {
header: WalletListHeaderView(title: networkSelectionStore.networkSelectionInForm?.coin == .sol ? Text(Strings.Wallet.tokenMintAddress) : Text(Strings.Wallet.tokenAddress))
) {
TextField(Strings.Wallet.enterAddress, text: $addressInput)
.onChange(of: addressInput) { newValue in
guard !newValue.isEmpty else { return }
userAssetStore.tokenInfo(address: newValue) { token in
guard let token else { return }
if nameInput.isEmpty {
nameInput = token.name
}
if symbolInput.isEmpty {
symbolInput = token.symbol
}
if !token.isErc721, !token.isNft, decimalsInput.isEmpty {
decimalsInput = "\(token.decimals)"
}
if let network = networkStore.allChains.first(where: { $0.chainId == token.chainId }) {
networkSelectionStore.networkSelectionInForm = network
}
}
}
.autocapitalization(.none)
.autocorrectionDisabled()
.disabled(userAssetStore.isSearchingToken)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
Section(
Expand All @@ -123,45 +104,27 @@ struct AddCustomAssetView: View {
Section(
header: WalletListHeaderView(title: Text(Strings.Wallet.tokenName))
) {
HStack {
TextField(Strings.Wallet.enterTokenName, text: $nameInput)
.autocapitalization(.none)
.autocorrectionDisabled()
.disabled(userAssetStore.isSearchingToken)
if userAssetStore.isSearchingToken && nameInput.isEmpty {
ProgressView()
}
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))
TextField(Strings.Wallet.enterTokenName, text: $nameInput)
.autocapitalization(.none)
.autocorrectionDisabled()
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
Section(
header: WalletListHeaderView(title: Text(Strings.Wallet.tokenSymbol))
) {
HStack {
TextField(Strings.Wallet.enterTokenSymbol, text: $symbolInput)
.autocapitalization(.none)
.autocorrectionDisabled()
.disabled(userAssetStore.isSearchingToken)
if userAssetStore.isSearchingToken && symbolInput.isEmpty {
ProgressView()
}
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))
TextField(Strings.Wallet.enterTokenSymbol, text: $symbolInput)
.autocapitalization(.none)
.autocorrectionDisabled()
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
switch selectedTokenType {
case .token:
Section(
header: WalletListHeaderView(title: Text(Strings.Wallet.decimalsPrecision))
) {
HStack {
TextField(NumberFormatter().string(from: NSNumber(value: 0)) ?? "0", text: $decimalsInput)
.keyboardType(.numberPad)
.disabled(userAssetStore.isSearchingToken)
if userAssetStore.isSearchingToken && decimalsInput.isEmpty {
ProgressView()
}
}
.listRowBackground(Color(.secondaryBraveGroupedBackground))
TextField(NumberFormatter().string(from: NSNumber(value: 0)) ?? "0", text: $decimalsInput)
.keyboardType(.numberPad)
.listRowBackground(Color(.secondaryBraveGroupedBackground))
}
Section {
Button(
Expand Down
27 changes: 0 additions & 27 deletions Sources/BraveWallet/Crypto/Stores/UserAssetsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class AssetStore: ObservableObject, Equatable, WalletObserverStore {

public class UserAssetsStore: ObservableObject, WalletObserverStore {
@Published private(set) var assetStores: [AssetStore] = []
@Published var isSearchingToken: Bool = false
@Published var networkFilters: [Selectable<BraveWallet.NetworkInfo>] = [] {
didSet {
guard !oldValue.isEmpty else { return } // initial assignment to `networkFilters`
Expand Down Expand Up @@ -199,32 +198,6 @@ public class UserAssetsStore: ObservableObject, WalletObserverStore {
completion(true)
}
}

func tokenInfo(
address: String,
completion: @escaping (BraveWallet.BlockchainToken?) -> Void
) {
// First check user's visible assets
if let assetStore = assetStores.first(where: { $0.token.contractAddress.caseInsensitiveCompare(address) == .orderedSame }) {
completion(assetStore.token)
} // else check full tokens list
else if let token = allTokens.first(where: { $0.contractAddress.caseInsensitiveCompare(address) == .orderedSame }) {
completion(token)
} // else use network request to get token info
else if address.isETHAddress { // only Eth Mainnet supported, require ethereum address
timer?.invalidate()
timer = Timer.scheduledTimer(
withTimeInterval: 0.25, repeats: false,
block: { [weak self] _ in
guard let self = self else { return }
self.isSearchingToken = true
self.assetRatioService.tokenInfo(address) { token in
self.isSearchingToken = false
completion(token)
}
})
}
}

@MainActor func networkInfo(by chainId: String, coin: BraveWallet.CoinType) async -> BraveWallet.NetworkInfo? {
let allNetworks = await rpcService.allNetworks(coin)
Expand Down
43 changes: 23 additions & 20 deletions Sources/BraveWallet/Extensions/RpcServiceExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,26 +392,29 @@ extension BraveWalletJsonRpcService {
contractAddress: String,
chainId: String
) async -> BraveWallet.BlockchainToken? {
let (symbol, symbolStatus, _) = await ethTokenSymbol(contractAddress, chainId: chainId)
let (decimals, decimalsStatus, _) = await ethTokenDecimals(contractAddress, chainId: chainId)
guard symbolStatus == .success || decimalsStatus == .success else { return nil }
return .init(
contractAddress: contractAddress,
name: "",
logo: "",
isErc20: false, // rpcService.getSupportsInterface() is private / internal.
isErc721: false, // rpcService.getSupportsInterface() is private / internal.
isErc1155: false, // rpcService.getSupportsInterface() is private / internal.
isNft: false,
isSpam: false,
symbol: symbol,
decimals: Int32(decimals.removingHexPrefix, radix: 16) ?? 0,
visible: false,
tokenId: "",
coingeckoId: "", // blockchainRegistry can fetch this for us, but not needed in Tx Confirmation.
chainId: chainId,
coin: .eth
)
// Fetches token info by contract address and chain ID. The returned token
// has the following fields populated:
// - contract_address
// - chain_id
// - coin
// - name
// - symbol
// - decimals
// - coingecko_id
//
// The following fields are always set to false, and callers must NOT rely
// on them:
// - is_erc721
// - is_erc1155
// - is_erc20
// - is_nft
let (token, status, _) = await ethTokenInfo(contractAddress, chainId: chainId)
guard status == .success else { return nil }
token?.logo = ""
token?.isSpam = false
token?.visible = false
token?.tokenId = ""
return token
}

/// Fetches the BlockchainToken for the given contract addresses. The token for a given contract
Expand Down
10 changes: 3 additions & 7 deletions Sources/BraveWallet/Preview Content/MockJsonRpcService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class MockJsonRpcService: BraveWalletJsonRpcService {
completion(BraveWallet.FilecoinMainnet)
case .btc:
fallthrough
@unknown default:
default:
completion("")
}
}
Expand All @@ -249,12 +249,8 @@ class MockJsonRpcService: BraveWalletJsonRpcService {
completion(true, .success, "")
}

func ethTokenSymbol(_ contractAddress: String, chainId: String, completion: @escaping (String, BraveWallet.ProviderError, String) -> Void) {
completion("", .internalError, "Error Message")
}

func ethTokenDecimals(_ contractAddress: String, chainId: String, completion: @escaping (String, BraveWallet.ProviderError, String) -> Void) {
completion("", .internalError, "Error Message")
func ethTokenInfo(_ contractAddress: String, chainId: String, completion: @escaping (BraveWallet.BlockchainToken?, BraveWallet.ProviderError, String) -> Void) {
completion(nil, .internalError, "Error Message")
}

func ankrGetAccountBalances(_ accountAddress: String, chainIds: [String], completion: @escaping ([BraveWallet.AnkrAssetBalance], BraveWallet.ProviderError, String) -> Void) {
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.62.114/brave-core-ios-1.62.114.tgz",
"brave-core-ios": "https://github.com/brave/brave-browser/releases/download/v1.63.53/brave-core-ios-1.63.53.tgz",
"leo": "github:brave/leo#792ab5c9f82784578e8f8fc14b9eaa24fa1956d2",
"leo-sf-symbols": "github:brave/leo-sf-symbols#775bb8fca9df76679b9b272545e162418127c5de",
"page-metadata-parser": "^1.1.3",
Expand Down