Skip to content

Commit

Permalink
Fix brave/brave-ios#8504: Bump BraveCore to v1.62.x (brave/brave-ios#…
Browse files Browse the repository at this point in the history
…8505)

* Update BraveCore to v1.62.93

---------

Co-authored-by: Kyle Hickinson <git@kylehickinson.com>
  • Loading branch information
StephenHeaps and kylehickinson authored Nov 30, 2023
1 parent df27de5 commit 789624a
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 37 deletions.
41 changes: 21 additions & 20 deletions Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
) {
let eip1559Data = BraveWallet.TxData1559(baseData: baseData, chainId: chainId, maxPriorityFeePerGas: "", maxFeePerGas: "", gasEstimation: nil)
let txDataUnion = BraveWallet.TxDataUnion(ethTxData1559: eip1559Data)
self.txService.addUnapprovedTransaction(txDataUnion, from: accountId) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, chainId: chainId, from: accountId) { success, txMetaId, errorMessage in
completion(success, errorMessage)
}
}
Expand Down Expand Up @@ -573,7 +573,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
}
} else {
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: fromAccountId) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
Expand All @@ -586,7 +586,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
}
let baseData = BraveWallet.TxData(nonce: "", gasPrice: "", gasLimit: "", to: token.contractAddress, value: "0x0", data: data, signOnly: false, signedTransaction: nil)
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: fromAccountId) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
Expand All @@ -605,7 +605,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
}
} else {
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: fromAccountId) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
Expand Down Expand Up @@ -641,7 +641,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
return
}
let txDataUnion = BraveWallet.TxDataUnion(solanaTxData: solanaTxData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId) { success, txMetaId, errMsg in
self.txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: fromAccountId) { success, txMetaId, errMsg in
completion(success, errMsg)
}
}
Expand All @@ -658,7 +658,7 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
return
}
let txDataUnion = BraveWallet.TxDataUnion(solanaTxData: solanaTxData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: fromAccountId) { success, txMetaId, errorMessage in
completion(success, errorMessage)
}
}
Expand All @@ -679,24 +679,25 @@ public class SendTokenStore: ObservableObject, WalletObserverStore {
}

isMakingTx = true
let filTxData = BraveWallet.FilTxData(
nonce: "",
gasPremium: "",
gasFeeCap: "",
gasLimit: "",
maxFee: "0",
to: sendAddress,
value: weiString
)
self.txService.addUnapprovedTransaction(BraveWallet.TxDataUnion(filTxData: filTxData), from: fromAccountId) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
rpcService.network(.fil, origin: nil) { [weak self] network in
guard let self = self else { return }
let filTxData = BraveWallet.FilTxData(
nonce: "",
gasPremium: "",
gasFeeCap: "",
gasLimit: "",
maxFee: "0",
to: sendAddress,
value: weiString
)
self.txService.addUnapprovedTransaction(BraveWallet.TxDataUnion(filTxData: filTxData), chainId: network.chainId, from: fromAccountId) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
}
}

@MainActor func fetchNFTMetadata(tokens: [BraveWallet.BlockchainToken]) async -> [String: NFTMetadata] {
return await rpcService.fetchNFTMetadata(tokens: tokens, ipfsApi: ipfsApi)
}
}


10 changes: 7 additions & 3 deletions Sources/BraveWallet/Crypto/Stores/SwapTokenStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
buyAmountInWei = weiFormatter.weiString(from: buyAmount.normalizedDecimals, radix: .decimal, decimals: Int(buyToken.decimals)) ?? "0"
}
let swapParams = BraveWallet.SwapParams(
chainId: network.chainId,
takerAddress: accountInfo.address,
sellAmount: sellAmountInWei,
buyAmount: buyAmountInWei,
Expand Down Expand Up @@ -407,7 +408,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
signedTransaction: nil
)
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: accountInfo.accountId)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: accountInfo.accountId)
if !success {
self.state = .error(Strings.Wallet.unknownError)
self.clearAllAmount()
Expand Down Expand Up @@ -529,7 +530,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
return success
} else {
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: accountInfo.accountId)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, chainId: network.chainId, from: accountInfo.accountId)
if !success {
self.state = .error(Strings.Wallet.unknownError)
self.clearAllAmount()
Expand Down Expand Up @@ -559,7 +560,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
}
let eip1559Data = BraveWallet.TxData1559(baseData: baseData, chainId: chainId, maxPriorityFeePerGas: maxPriorityFeePerGas, maxFeePerGas: maxFeePerGas, gasEstimation: gasEstimation)
let txDataUnion = BraveWallet.TxDataUnion(ethTxData1559: eip1559Data)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: account.accountId)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, chainId: chainId, from: account.accountId)
if !success {
self.state = .error(Strings.Wallet.unknownError)
self.clearAllAmount()
Expand Down Expand Up @@ -650,6 +651,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
// 0.5% is 50bps. We store 0.5% as 0.005, so multiply by 10_000
let slippageBps = Int32(swapParams.slippagePercentage * 10_000)
let jupiterQuoteParams: BraveWallet.JupiterQuoteParams = .init(
chainId: network.chainId,
inputMint: swapParams.sellToken,
outputMint: swapParams.buyToken,
amount: swapParams.sellAmount,
Expand Down Expand Up @@ -748,6 +750,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
}
let network = await rpcService.network(.sol, origin: nil)
let jupiterSwapParams: BraveWallet.JupiterSwapParams = .init(
chainId: network.chainId,
route: route,
userPublicKey: accountInfo.address,
inputMint: selectedFromToken.contractAddress(in: network),
Expand Down Expand Up @@ -785,6 +788,7 @@ public class SwapTokenStore: ObservableObject, WalletObserverStore {
}
let (success, _, _) = await txService.addUnapprovedTransaction(
.init(solanaTxData: solTxData),
chainId: network.chainId,
from: accountInfo.accountId
)
return success
Expand Down
2 changes: 1 addition & 1 deletion Sources/BraveWallet/Preview Content/MockEthTxService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MockTxService: BraveWalletTxService {
completion(txs.first(where: { $0.id == txMetaId }))
}

func addUnapprovedTransaction(_ txDataUnion: BraveWallet.TxDataUnion, from: BraveWallet.AccountId, completion: @escaping (Bool, String, String) -> Void) {
func addUnapprovedTransaction(_ txDataUnion: BraveWallet.TxDataUnion, chainId: String, from: BraveWallet.AccountId, completion: @escaping (Bool, String, String) -> Void) {
completion(true, "txMetaId", "")
}

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 @@ -256,6 +256,10 @@ class MockJsonRpcService: BraveWalletJsonRpcService {
func ethTokenDecimals(_ contractAddress: String, chainId: String, completion: @escaping (String, BraveWallet.ProviderError, String) -> Void) {
completion("", .internalError, "Error Message")
}

func ankrGetAccountBalances(_ accountAddress: String, chainIds: [String], completion: @escaping ([BraveWallet.AnkrAssetBalance], BraveWallet.ProviderError, String) -> Void) {
completion([], .internalError, "Error Message")
}
}

extension BraveWallet.NetworkInfo {
Expand Down
12 changes: 6 additions & 6 deletions Tests/BraveWalletTests/SwapTokenStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class SwapStoreTests: XCTestCase {
completion(nil, "")
}
let txService = BraveWallet.TestTxService()
txService._addUnapprovedTransaction = { $2(true, "tx-meta-id", "") }
txService._addUnapprovedTransaction = { $3(true, "tx-meta-id", "") }
let walletService = BraveWallet.TestBraveWalletService()
let mockAssetManager = TestableWalletUserAssetManager()
mockAssetManager._getAllUserAssetsInNetworkAssets = { _, _ in
Expand Down Expand Up @@ -545,7 +545,7 @@ class SwapStoreTests: XCTestCase {
@MainActor func testSwapERC20EIP1559Transaction() async {
let (keyringService, blockchainRegistry, rpcService, swapService, txService, walletService, ethTxManagerProxy, solTxManagerProxy, mockAssetManager) = setupServices()
var submittedTxData: BraveWallet.TxDataUnion?
txService._addUnapprovedTransaction = { txData, _, completion in
txService._addUnapprovedTransaction = { txData, _, _, completion in
submittedTxData = txData
completion(true, "tx-meta-id", "")
}
Expand Down Expand Up @@ -575,7 +575,7 @@ class SwapStoreTests: XCTestCase {
// Celo Mainnet / `.mockCelo` is not EIP1559
let (keyringService, blockchainRegistry, rpcService, swapService, txService, walletService, ethTxManagerProxy, solTxManagerProxy, mockAssetManager) = setupServices(network: .mockCelo)
var submittedTxData: BraveWallet.TxDataUnion?
txService._addUnapprovedTransaction = { txData, _, completion in
txService._addUnapprovedTransaction = { txData, _, _, completion in
submittedTxData = txData
completion(true, "tx-meta-id", "")
}
Expand Down Expand Up @@ -605,7 +605,7 @@ class SwapStoreTests: XCTestCase {
@MainActor func testSwapETHSwapEIP1559Transaction() async {
let (keyringService, blockchainRegistry, rpcService, swapService, txService, walletService, ethTxManagerProxy, solTxManagerProxy, mockAssetManager) = setupServices()
var submittedTxData: BraveWallet.TxDataUnion?
txService._addUnapprovedTransaction = { txData, _, completion in
txService._addUnapprovedTransaction = { txData, _, _, completion in
submittedTxData = txData
completion(true, "tx-meta-id", "")
}
Expand Down Expand Up @@ -636,7 +636,7 @@ class SwapStoreTests: XCTestCase {
// Celo Mainnet / `.mockCelo` is not EIP1559
let (keyringService, blockchainRegistry, rpcService, swapService, txService, walletService, ethTxManagerProxy, solTxManagerProxy, mockAssetManager) = setupServices(network: .mockCelo)
var submittedTxData: BraveWallet.TxDataUnion?
txService._addUnapprovedTransaction = { txData, _, completion in
txService._addUnapprovedTransaction = { txData, _, _, completion in
submittedTxData = txData
completion(true, "tx-meta-id", "")
}
Expand Down Expand Up @@ -685,7 +685,7 @@ class SwapStoreTests: XCTestCase {
completion(.init(), .success, "")
}
var submittedTxData: BraveWallet.TxDataUnion?
txService._addUnapprovedTransaction = { txData, _, completion in
txService._addUnapprovedTransaction = { txData, _, _, completion in
submittedTxData = txData
completion(true, "tx-meta-id", "")
}
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.61.84/brave-core-ios-1.61.84.tgz",
"brave-core-ios": "https://github.com/brave/brave-browser/releases/download/v1.62.93/brave-core-ios-1.62.93.tgz",
"leo": "github:brave/leo#792ab5c9f82784578e8f8fc14b9eaa24fa1956d2",
"leo-sf-symbols": "github:brave/leo-sf-symbols#775bb8fca9df76679b9b272545e162418127c5de",
"page-metadata-parser": "^1.1.3",
Expand Down

0 comments on commit 789624a

Please sign in to comment.