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

Fix #7242: Bump Brave Core to 1.51.x #7243

Merged
merged 2 commits into from
Apr 14, 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
4 changes: 2 additions & 2 deletions BraveCore/build_in_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ mc_framework_args=""

if [ "$build_simulator" = 1 ]; then
npm run build -- $release_flag --target_os=ios --target_arch=$target_architecture --target_environment=simulator $other_flags
bc_framework_args="-framework $sim_dir/BraveCore.framework -debug-symbols $(pwd)/$sim_dir/BraveCore.dSYM"
bc_framework_args="-framework $sim_dir/BraveCore.framework"
mc_framework_args="-framework $sim_dir/MaterialComponents.framework"
fi

if [ "$build_device" = 1 ]; then
npm run build -- $release_flag --target_os=ios --target_arch=arm64 $other_flags
bc_framework_args="$bc_framework_args -framework $device_dir/BraveCore.framework -debug-symbols $(pwd)/$device_dir/BraveCore.dSYM"
bc_framework_args="$bc_framework_args -framework $device_dir/BraveCore.framework"
mc_framework_args="$mc_framework_args -framework $device_dir/MaterialComponents.framework"
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ extension BraveLedger {

self.minimumVisitDuration = 8
self.minimumNumberOfVisits = 1
self.allowVideoContributions = true
self.allowUnverifiedPublishers = false
self.contributionAmount = Double.greatestFiniteMagnitude

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public class BrowserViewController: UIViewController {

let configuration: BraveRewards.Configuration = .current()

let buildChannel = Ads.BuildChannelInfo().then {
let buildChannel = BraveAds.BuildChannelInfo().then {
$0.name = AppConstants.buildChannel.rawValue
$0.isRelease = AppConstants.buildChannel == .release
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ extension BrowserViewController {
ledger.minimumVisitDuration = 8
ledger.minimumNumberOfVisits = 1
ledger.allowUnverifiedPublishers = false
ledger.allowVideoContributions = true
ledger.contributionAmount = Double.greatestFiniteMagnitude

// Create ledger observer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class NewTabPageViewController: UIViewController {
backgroundView.updateImageXOffset(by: realisticXOffset)
}

private func reportSponsoredImageBackgroundEvent(_ event: Ads.NewTabPageAdEventType) {
private func reportSponsoredImageBackgroundEvent(_ event: BraveAds.NewTabPageAdEventType) {
guard let backgroundType = background.currentBackground?.type,
case .withBrandLogo = backgroundType,
let creativeInstanceId = background.currentBackground?.wallpaper.creativeInstanceId
Expand Down
4 changes: 2 additions & 2 deletions Sources/Brave/Frontend/Rewards/BraveRewards.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BraveRewards: NSObject {

private let configuration: Configuration

init(configuration: Configuration, buildChannel: Ads.BuildChannelInfo?) {
init(configuration: Configuration, buildChannel: BraveAds.BuildChannelInfo?) {
self.configuration = configuration

if let channel = buildChannel {
Expand Down Expand Up @@ -306,7 +306,7 @@ extension BraveRewards {

var storageURL: URL
public var environment: Environment
public var adsBuildChannel: Ads.BuildChannelInfo = .init()
public var adsBuildChannel: BraveAds.BuildChannelInfo = .init()
public var isDebug: Bool?
public var overridenNumberOfSecondsBetweenReconcile: Int?
public var retryInterval: Int?
Expand Down
1 change: 1 addition & 0 deletions Sources/BraveWallet/Crypto/AssetIconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct AssetIconView_Previews: PreviewProvider {
logo: "",
isErc20: true,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: "XYO",
decimals: 18,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ struct AddCustomAssetView: View {
logo: logo,
isErc20: network.coin != .sol,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: symbolInput,
decimals: Int32(decimalsInput) ?? Int32((networkSelectionStore.networkSelectionInForm?.decimals ?? 18)),
Expand Down Expand Up @@ -355,6 +356,7 @@ struct AddCustomAssetView: View {
logo: "",
isErc20: false,
isErc721: network.coin != .sol && !tokenIdToHex.isEmpty,
isErc1155: false,
isNft: true,
symbol: symbolInput,
decimals: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,7 @@ extension AccountActivityStore: BraveWalletBraveWalletServiceObserver {

func onDiscoverAssetsCompleted(_ discoveredAssets: [BraveWallet.BlockchainToken]) {
}

func onResetWallet() {
}
}
2 changes: 2 additions & 0 deletions Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,6 @@ extension AssetDetailStore: BraveWalletBraveWalletServiceObserver {

func onDiscoverAssetsCompleted(_ discoveredAssets: [BraveWallet.BlockchainToken]) {
}
func onResetWallet() {
}
}
3 changes: 3 additions & 0 deletions Sources/BraveWallet/Crypto/Stores/PortfolioStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,4 +435,7 @@ extension PortfolioStore: BraveWalletBraveWalletServiceObserver {
update()
}
}

public func onResetWallet() {
}
}
3 changes: 3 additions & 0 deletions Sources/BraveWallet/Crypto/Stores/SettingsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ extension SettingsStore: BraveWalletBraveWalletServiceObserver {

public func onDiscoverAssetsCompleted(_ discoveredAssets: [BraveWallet.BlockchainToken]) {
}

public func onResetWallet() {
}
}

struct CurrencyCode: Hashable, Identifiable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,4 +712,7 @@ extension TransactionConfirmationStore: BraveWalletBraveWalletServiceObserver {

public func onDiscoverAssetsCompleted(_ discoveredAssets: [BraveWallet.BlockchainToken]) {
}

public func onResetWallet() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension BraveWallet.NetworkInfo: Identifiable {
logo: nativeTokenLogo ?? "",
isErc20: false,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: symbol,
decimals: decimals,
Expand Down
4 changes: 2 additions & 2 deletions Sources/BraveWallet/Extensions/RpcServiceExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ extension BraveWalletJsonRpcService {
}
metaDataString = metaData
} else {
let (metaData, result, errMsg) = await self.solTokenMetadata(token.contractAddress)
let (_, metaData, result, errMsg) = await self.solTokenMetadata(token.chainId, tokenMintAddress: token.contractAddress)
if result != .success {
Logger.module.debug("Failed to load Solana NFT metadata: \(errMsg)")
}
Expand Down Expand Up @@ -316,7 +316,7 @@ extension BraveWalletJsonRpcService {
}
metaDataString = metaData
} else {
let (metaData, result, errMsg) = await self.solTokenMetadata(token.contractAddress)
let (_, metaData, result, errMsg) = await self.solTokenMetadata(token.chainId, tokenMintAddress: token.contractAddress)
if result != .success {
Logger.module.debug("Failed to load Solana NFT metadata: \(errMsg)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import BraveCore
/// - note: Do not use this directly, use ``TokenRegistryStore.previewStore``
class MockBlockchainRegistry: BraveWalletBlockchainRegistry {
static let testTokens: [BraveWallet.BlockchainToken] = [
.init(contractAddress: "0x0d8775f648430679a709e98d2b0cb6250d2887ef", name: "Basic Attention Token", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "BAT", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0xB8c77482e45F1F44dE1745F52C74426C631bDD52", name: "BNB", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "BNB", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0xdac17f958d2ee523a2206206994597c13d831ec7", name: "Tether USD", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "USDT", decimals: 6, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85", name: "Ethereum Name Service", logo: "", isErc20: false, isErc721: true, isNft: false, symbol: "ENS", decimals: 1, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0xad6d458402f60fd3bd25163575031acdce07538d", name: "DAI Stablecoin", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "DAI", decimals: 18, visible: false, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0", name: "MATIC", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "MATIC", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth)
.init(contractAddress: "0x0d8775f648430679a709e98d2b0cb6250d2887ef", name: "Basic Attention Token", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "BAT", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0xB8c77482e45F1F44dE1745F52C74426C631bDD52", name: "BNB", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "BNB", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0xdac17f958d2ee523a2206206994597c13d831ec7", name: "Tether USD", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "USDT", decimals: 6, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85", name: "Ethereum Name Service", logo: "", isErc20: false, isErc721: true, isErc1155: false, isNft: false, symbol: "ENS", decimals: 1, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0xad6d458402f60fd3bd25163575031acdce07538d", name: "DAI Stablecoin", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "DAI", decimals: 18, visible: false, tokenId: "", coingeckoId: "", chainId: "", coin: .eth),
.init(contractAddress: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0", name: "MATIC", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "MATIC", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth)
]

func token(byAddress chainId: String, coin: BraveWallet.CoinType, address: String, completion: @escaping (BraveWallet.BlockchainToken?) -> Void) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,11 @@ class MockBraveWalletService: BraveWalletBraveWalletService {

func discoverAssetsOnAllSupportedChains() {
}

func nftDiscoveryEnabled(_ completion: @escaping (Bool) -> Void) {
}

func setNftDiscoveryEnabled(_ enabled: Bool) {
}
}
#endif
22 changes: 17 additions & 5 deletions Sources/BraveWallet/Preview Content/MockContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: false,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: "ETH",
decimals: 18,
Expand All @@ -31,6 +32,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: true,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: "DAI",
decimals: 18,
Expand All @@ -47,6 +49,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: true,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: "USDC",
decimals: 6,
Expand All @@ -63,6 +66,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: false,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: "SOL",
decimals: 9,
Expand All @@ -79,6 +83,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: false,
isErc721: false,
isErc1155: false,
isNft: false,
symbol: "SPD",
decimals: 6,
Expand All @@ -95,6 +100,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: false,
isErc721: true,
isErc1155: false,
isNft: true,
symbol: "XENFT",
decimals: 0,
Expand All @@ -111,6 +117,7 @@ extension BraveWallet.BlockchainToken {
logo: "",
isErc20: false,
isErc721: false,
isErc1155: false,
isNft: true,
symbol: "SOLNFT",
decimals: 0,
Expand Down Expand Up @@ -163,7 +170,8 @@ extension BraveWallet.TransactionInfo {
submittedTime: Date(timeIntervalSince1970: 1636399673),
confirmedTime: Date(timeIntervalSince1970: 1636402508),
originInfo: .init(),
groupId: nil
groupId: nil,
chainId: ""
)
}
static var previewConfirmedSwap: BraveWallet.TransactionInfo {
Expand Down Expand Up @@ -200,7 +208,8 @@ extension BraveWallet.TransactionInfo {
submittedTime: Date(timeIntervalSince1970: 1636399673),
confirmedTime: Date(timeIntervalSince1970: 1636402508),
originInfo: .init(),
groupId: nil
groupId: nil,
chainId: ""
)
}
/// Approved Unlimited DAI
Expand Down Expand Up @@ -235,7 +244,8 @@ extension BraveWallet.TransactionInfo {
submittedTime: Date(timeIntervalSince1970: 1636399673),
confirmedTime: Date(timeIntervalSince1970: 1636402508),
originInfo: .init(),
groupId: nil
groupId: nil,
chainId: ""
)
}
/// Solana System Transfer
Expand Down Expand Up @@ -267,7 +277,8 @@ extension BraveWallet.TransactionInfo {
submittedTime: Date(timeIntervalSince1970: 1636399673),
confirmedTime: Date(timeIntervalSince1970: 1636402508),
originInfo: .init(),
groupId: nil
groupId: nil,
chainId: ""
)
}
/// Solana Token Transfer
Expand Down Expand Up @@ -299,7 +310,8 @@ extension BraveWallet.TransactionInfo {
submittedTime: Date(timeIntervalSince1970: 1636399673),
confirmedTime: Date(timeIntervalSince1970: 1636402508),
originInfo: .init(),
groupId: nil
groupId: nil,
chainId: ""
)
}
static private func _transactionBase64ToData(_ base64String: String) -> [NSNumber] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class MockJsonRpcService: BraveWalletJsonRpcService {
completion("", .internalError, "")
}

func solTokenMetadata(_ tokenMintAddress: String, completion: @escaping (String, BraveWallet.SolanaProviderError, String) -> Void) {
completion("", .internalError, "")
func solTokenMetadata(_ chainId: String, tokenMintAddress: String, completion: @escaping (String, String, BraveWallet.SolanaProviderError, String) -> Void) {
completion("", "", .internalError, "")
}

func erc721Metadata(_ contract: String, tokenId: String, chainId: String, completion: @escaping (String, String, BraveWallet.ProviderError, String) -> Void) {
Expand Down
8 changes: 4 additions & 4 deletions Tests/BraveWalletTests/AccountActivityStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ class AccountActivityStoreTests: XCTestCase {
"""
completion( "", metadata, .success, "")
}
rpcService._solTokenMetadata = { _, completion in
completion(
"""
rpcService._solTokenMetadata = { _, _, completion in
let metaData = """
{
"image": "sol.mock.image.url",
"name": "sol mock nft name",
"description": "sol mock nft description"
}
""", .success, "")
"""
completion("", metaData, .success, "")
}

let walletService = BraveWallet.TestBraveWalletService()
Expand Down
8 changes: 4 additions & 4 deletions Tests/BraveWalletTests/BraveWalletExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import BraveCore
class BraveWalletExtensionsTests: XCTestCase {

func testIsNativeAsset() {
let ethCoin: BraveWallet.BlockchainToken = .init(contractAddress: "", name: "Eth", logo: "", isErc20: false, isErc721: false, isNft: false, symbol: "Eth", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth)
let ethToken: BraveWallet.BlockchainToken = .init(contractAddress: "mock-eth-contract-address", name: "Eth Token", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "ETHTOKEN", decimals: 18, visible: false, tokenId: "", coingeckoId: "", chainId: "", coin: .eth)
let ethCoin: BraveWallet.BlockchainToken = .init(contractAddress: "", name: "Eth", logo: "", isErc20: false, isErc721: false, isErc1155: false, isNft: false, symbol: "Eth", decimals: 18, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .eth)
let ethToken: BraveWallet.BlockchainToken = .init(contractAddress: "mock-eth-contract-address", name: "Eth Token", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "ETHTOKEN", decimals: 18, visible: false, tokenId: "", coingeckoId: "", chainId: "", coin: .eth)
let ethNetwork = BraveWallet.NetworkInfo.mockMainnet

XCTAssertTrue(ethNetwork.isNativeAsset(ethCoin))
XCTAssertFalse(ethNetwork.isNativeAsset(ethToken))

let solCoin: BraveWallet.BlockchainToken = .init(contractAddress: "", name: "Sol", logo: "", isErc20: false, isErc721: false, isNft: false, symbol: "SOL", decimals: 9, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .sol)
let solToken: BraveWallet.BlockchainToken = .init(contractAddress: "mock-sol-contract-address", name: "Sol Token", logo: "", isErc20: true, isErc721: false, isNft: false, symbol: "SOLTOKEN", decimals: 9, visible: false, tokenId: "", coingeckoId: "", chainId: "", coin: .sol)
let solCoin: BraveWallet.BlockchainToken = .init(contractAddress: "", name: "Sol", logo: "", isErc20: false, isErc721: false, isErc1155: false, isNft: false, symbol: "SOL", decimals: 9, visible: true, tokenId: "", coingeckoId: "", chainId: "", coin: .sol)
let solToken: BraveWallet.BlockchainToken = .init(contractAddress: "mock-sol-contract-address", name: "Sol Token", logo: "", isErc20: true, isErc721: false, isErc1155: false, isNft: false, symbol: "SOLTOKEN", decimals: 9, visible: false, tokenId: "", coingeckoId: "", chainId: "", coin: .sol)
let solNetwork = BraveWallet.NetworkInfo.mockSolana

XCTAssertTrue(solNetwork.isNativeAsset(solCoin))
Expand Down
Loading