diff --git a/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift b/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift index 97e67fca1f6..bdd6a027990 100644 --- a/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift +++ b/Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift @@ -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) } } @@ -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) } @@ -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) } @@ -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) } @@ -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) } } @@ -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) } } @@ -679,18 +679,21 @@ 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) + } } } @@ -698,5 +701,3 @@ public class SendTokenStore: ObservableObject, WalletObserverStore { return await rpcService.fetchNFTMetadata(tokens: tokens, ipfsApi: ipfsApi) } } - - diff --git a/Sources/BraveWallet/Crypto/Stores/SwapTokenStore.swift b/Sources/BraveWallet/Crypto/Stores/SwapTokenStore.swift index a8c0d4a43b0..362c8e1a81a 100644 --- a/Sources/BraveWallet/Crypto/Stores/SwapTokenStore.swift +++ b/Sources/BraveWallet/Crypto/Stores/SwapTokenStore.swift @@ -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, @@ -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() @@ -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() @@ -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() @@ -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, @@ -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), @@ -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 diff --git a/Sources/BraveWallet/Preview Content/MockEthTxService.swift b/Sources/BraveWallet/Preview Content/MockEthTxService.swift index dae9b47b5f8..1f06bc9b479 100644 --- a/Sources/BraveWallet/Preview Content/MockEthTxService.swift +++ b/Sources/BraveWallet/Preview Content/MockEthTxService.swift @@ -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", "") } diff --git a/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift b/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift index 678a8ced0b0..ad240b19efc 100644 --- a/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift +++ b/Sources/BraveWallet/Preview Content/MockJsonRpcService.swift @@ -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 { diff --git a/Tests/BraveWalletTests/SwapTokenStoreTests.swift b/Tests/BraveWalletTests/SwapTokenStoreTests.swift index 49c2f2e107d..ddab6d5ecb9 100644 --- a/Tests/BraveWalletTests/SwapTokenStoreTests.swift +++ b/Tests/BraveWalletTests/SwapTokenStoreTests.swift @@ -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 @@ -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", "") } @@ -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", "") } @@ -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", "") } @@ -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", "") } @@ -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", "") } diff --git a/package-lock.json b/package-lock.json index ed5028d554d..001892b34ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,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", @@ -514,9 +514,9 @@ } }, "node_modules/brave-core-ios": { - "version": "1.61.84", - "resolved": "https://github.com/brave/brave-browser/releases/download/v1.61.84/brave-core-ios-1.61.84.tgz", - "integrity": "sha512-KNS95k6gUCWRYdQOa07VD7W4nIJRUPbCe5RqYdodwwpCipqTNeX4Nx8gyJygN6EhMoQEMzH45LAVJ/ZWmBxgfQ==", + "version": "1.62.93", + "resolved": "https://github.com/brave/brave-browser/releases/download/v1.62.93/brave-core-ios-1.62.93.tgz", + "integrity": "sha512-9hQObFDNMUCJIlvLan4tdT49hLuXTf8qa8JQ9GBK2BrwdLhEbL3ShL2BwaiBtujRFGhWOUzK4XCK2VZSZdCHZQ==", "license": "ISC" }, "node_modules/browserslist": { @@ -3214,8 +3214,8 @@ } }, "brave-core-ios": { - "version": "https://github.com/brave/brave-browser/releases/download/v1.61.84/brave-core-ios-1.61.84.tgz", - "integrity": "sha512-KNS95k6gUCWRYdQOa07VD7W4nIJRUPbCe5RqYdodwwpCipqTNeX4Nx8gyJygN6EhMoQEMzH45LAVJ/ZWmBxgfQ==" + "version": "https://github.com/brave/brave-browser/releases/download/v1.62.93/brave-core-ios-1.62.93.tgz", + "integrity": "sha512-9hQObFDNMUCJIlvLan4tdT49hLuXTf8qa8JQ9GBK2BrwdLhEbL3ShL2BwaiBtujRFGhWOUzK4XCK2VZSZdCHZQ==" }, "browserslist": { "version": "4.17.1", diff --git a/package.json b/package.json index 29c56fd15e4..79e3e7dc906 100644 --- a/package.json +++ b/package.json @@ -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",