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

Commit

Permalink
Fix #8076: Bump BraveCore to v1.59.x (#8077)
Browse files Browse the repository at this point in the history
* Update BraveCore to v1.59.41

* [v1.59] Fix #7866: AccountId Transaction Refactor, BraveCore v1.59.59 (#7997)

* Update BraveCore to v1.59.44. Apply AccountId for Transaction refactor updates.

* Update BraveCore to v1.59.59

* Disable failing `testCompilationofResources` test.

* upgrade brave core to 1.59.84

---------

Co-authored-by: Nuo Xu <nuoxu.nx@gmail.com>
  • Loading branch information
StephenHeaps and nuo-xu authored Sep 19, 2023
1 parent 9ae432e commit feccfd7
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 91 deletions.
2 changes: 1 addition & 1 deletion Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class AssetDetailStore: ObservableObject {
await self.txService.allTransactionInfo(
network.coin,
chainId: network.chainId,
from: account.address
from: account.accountId
)
}
}
Expand Down
27 changes: 18 additions & 9 deletions Sources/BraveWallet/Crypto/Stores/CryptoStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,24 @@ enum PendingRequest: Equatable {
extension PendingRequest: Identifiable {
var id: String {
switch self {
case let .transactions(transactions): return "transactions-\(transactions.map(\.id))"
case let .addChain(request): return "addChain-\(request.networkInfo.chainId)"
case let .switchChain(chainRequest): return "switchChain-\(chainRequest.chainId)"
case let .addSuggestedToken(tokenRequest): return "addSuggestedToken-\(tokenRequest.token.id)"
case let .signMessage(signRequests): return "signMessage-\(signRequests.map(\.id))"
case let .getEncryptionPublicKey(request): return "getEncryptionPublicKey-\(request.address)-\(request.requestId)"
case let .decrypt(request): return "decrypt-\(request.address)-\(request.requestId)"
case let .signTransaction(requests): return "signTransaction-\(requests.map(\.id))"
case let .signAllTransactions(requests): return "signAllTransactions-\(requests.map(\.id))"
case let .transactions(transactions):
return "transactions-\(transactions.map(\.id))"
case let .addChain(request):
return "addChain-\(request.networkInfo.chainId)"
case let .switchChain(chainRequest):
return "switchChain-\(chainRequest.chainId)"
case let .addSuggestedToken(tokenRequest):
return "addSuggestedToken-\(tokenRequest.token.id)"
case let .signMessage(signRequests):
return "signMessage-\(signRequests.map(\.id))"
case let .getEncryptionPublicKey(request):
return "getEncryptionPublicKey-\(request.accountId.uniqueKey)-\(request.requestId)"
case let .decrypt(request):
return "decrypt-\(request.accountId.uniqueKey)-\(request.requestId)"
case let .signTransaction(requests):
return "signTransaction-\(requests.map(\.id))"
case let .signAllTransactions(requests):
return "signAllTransactions-\(requests.map(\.id))"
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions Sources/BraveWallet/Crypto/Stores/SendTokenStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ public class SendTokenStore: ObservableObject {
private func makeEIP1559Tx(
chainId: String,
baseData: BraveWallet.TxData,
from address: String,
from accountId: BraveWallet.AccountId,
completion: @escaping (_ success: Bool, _ errMsg: String?) -> Void
) {
let eip1559Data = BraveWallet.TxData1559(baseData: baseData, chainId: chainId, maxPriorityFeePerGas: "", maxFeePerGas: "", gasEstimation: nil)
let txDataUnion = BraveWallet.TxDataUnion(ethTxData1559: eip1559Data)
self.txService.addUnapprovedTransaction(txDataUnion, from: address, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, from: accountId, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
completion(success, errorMessage)
}
}
Expand Down Expand Up @@ -494,11 +494,11 @@ public class SendTokenStore: ObservableObject {
}
switch selectedAccount.coin {
case .eth:
self.sendTokenOnEth(amount: amount, token: token, fromAddress: selectedAccount.address, completion: completion)
self.sendTokenOnEth(amount: amount, token: token, from: selectedAccount.accountId, completion: completion)
case .sol:
self.sendTokenOnSol(amount: amount, token: token, fromAddress: selectedAccount.address, completion: completion)
self.sendTokenOnSol(amount: amount, token: token, from: selectedAccount.accountId, completion: completion)
case .fil:
self.sendTokenOnFil(amount: amount, token: token, fromAddress: selectedAccount.address, completion: completion)
self.sendTokenOnFil(amount: amount, token: token, from: selectedAccount.accountId, completion: completion)
default:
completion(false, Strings.Wallet.internalErrorMessage)
}
Expand All @@ -508,7 +508,7 @@ public class SendTokenStore: ObservableObject {
func sendTokenOnEth(
amount: String,
token: BraveWallet.BlockchainToken,
fromAddress: String,
from fromAccountId: BraveWallet.AccountId,
completion: @escaping (_ success: Bool, _ errMsg: String?) -> Void
) {
let weiFormatter = WeiFormatter(decimalFormatStyle: .decimals(precision: 18))
Expand All @@ -525,26 +525,26 @@ public class SendTokenStore: ObservableObject {
if network.isNativeAsset(token) {
let baseData = BraveWallet.TxData(nonce: "", gasPrice: "", gasLimit: "", to: sendToAddress, value: "0x\(weiHexString)", data: .init(), signOnly: false, signedTransaction: nil)
if network.isEip1559 {
self.makeEIP1559Tx(chainId: network.chainId, baseData: baseData, from: fromAddress) { success, errorMessage in
self.makeEIP1559Tx(chainId: network.chainId, baseData: baseData, from: fromAccountId) { success, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
} else {
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAddress, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
}
} else if token.isErc721 {
self.ethTxManagerProxy.makeErc721Transfer(fromData: fromAddress, to: sendToAddress, tokenId: token.tokenId, contractAddress: token.contractAddress) { success, data in
self.ethTxManagerProxy.makeErc721Transfer(fromData: fromAccountId.address, to: sendToAddress, tokenId: token.tokenId, contractAddress: token.contractAddress) { success, data in
guard success else {
completion(false, nil)
return
}
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: fromAddress, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
Expand All @@ -557,13 +557,13 @@ public class SendTokenStore: ObservableObject {
}
let baseData = BraveWallet.TxData(nonce: "", gasPrice: "", gasLimit: "", to: token.contractAddress, value: "0x0", data: data, signOnly: false, signedTransaction: nil)
if network.isEip1559 {
self.makeEIP1559Tx(chainId: network.chainId, baseData: baseData, from: fromAddress) { success, errorMessage in
self.makeEIP1559Tx(chainId: network.chainId, baseData: baseData, from: fromAccountId) { success, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
} else {
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAddress, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
Expand All @@ -576,7 +576,7 @@ public class SendTokenStore: ObservableObject {
private func sendTokenOnSol(
amount: String,
token: BraveWallet.BlockchainToken,
fromAddress: String,
from fromAccountId: BraveWallet.AccountId,
completion: @escaping (_ success: Bool, _ errMsg: String?) -> Void
) {
guard let amount = WeiFormatter.decimalToAmount(amount.normalizedDecimals, tokenDecimals: Int(token.decimals)) else {
Expand All @@ -590,7 +590,7 @@ public class SendTokenStore: ObservableObject {
guard let self = self else { return }
if network.isNativeAsset(token) {
self.solTxManagerProxy.makeSystemProgramTransferTxData(
fromAddress,
fromAccountId.address,
to: sendToAddress,
lamports: amount
) { solTxData, error, errMsg in
Expand All @@ -599,15 +599,15 @@ public class SendTokenStore: ObservableObject {
return
}
let txDataUnion = BraveWallet.TxDataUnion(solanaTxData: solanaTxData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAddress, origin: nil, groupId: nil) { success, txMetaId, errMsg in
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId, origin: nil, groupId: nil) { success, txMetaId, errMsg in
completion(success, errMsg)
}
}
} else {
self.solTxManagerProxy.makeTokenProgramTransferTxData(
network.chainId,
splTokenMintAddress: token.contractAddress,
fromWalletAddress: fromAddress,
fromWalletAddress: fromAccountId.address,
toWalletAddress: sendToAddress,
amount: amount
) { solTxData, error, errMsg in
Expand All @@ -616,7 +616,7 @@ public class SendTokenStore: ObservableObject {
return
}
let txDataUnion = BraveWallet.TxDataUnion(solanaTxData: solanaTxData)
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAddress, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(txDataUnion, from: fromAccountId, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
completion(success, errorMessage)
}
}
Expand All @@ -627,7 +627,7 @@ public class SendTokenStore: ObservableObject {
private func sendTokenOnFil(
amount: String,
token: BraveWallet.BlockchainToken,
fromAddress: String,
from fromAccountId: BraveWallet.AccountId,
completion: @escaping (_ success: Bool, _ errMsg: String?) -> Void
) {
let weiFormatter = WeiFormatter(decimalFormatStyle: .decimals(precision: Int(token.decimals)))
Expand All @@ -646,7 +646,7 @@ public class SendTokenStore: ObservableObject {
to: sendAddress,
value: weiString
)
self.txService.addUnapprovedTransaction(BraveWallet.TxDataUnion(filTxData: filTxData), from: fromAddress, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.txService.addUnapprovedTransaction(BraveWallet.TxDataUnion(filTxData: filTxData), from: fromAccountId, origin: nil, groupId: nil) { success, txMetaId, errorMessage in
self.isMakingTx = false
completion(success, errorMessage)
}
Expand Down
12 changes: 7 additions & 5 deletions Sources/BraveWallet/Crypto/Stores/SwapTokenStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public class SwapTokenStore: ObservableObject {
signedTransaction: nil
)
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: accountInfo.address, origin: nil, groupId: nil)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: accountInfo.accountId, origin: nil, groupId: nil)
if !success {
self.state = .error(Strings.Wallet.unknownError)
self.clearAllAmount()
Expand Down Expand Up @@ -401,7 +401,7 @@ public class SwapTokenStore: ObservableObject {
return success
} else {
let txDataUnion = BraveWallet.TxDataUnion(ethTxData: baseData)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: accountInfo.address, origin: nil, groupId: nil)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: accountInfo.accountId, origin: nil, groupId: nil)
if !success {
self.state = .error(Strings.Wallet.unknownError)
self.clearAllAmount()
Expand Down Expand Up @@ -431,7 +431,7 @@ public class SwapTokenStore: ObservableObject {
}
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.address, origin: nil, groupId: nil)
let (success, _, _) = await txService.addUnapprovedTransaction(txDataUnion, from: account.accountId, origin: nil, groupId: nil)
if !success {
self.state = .error(Strings.Wallet.unknownError)
self.clearAllAmount()
Expand Down Expand Up @@ -601,13 +601,15 @@ public class SwapTokenStore: ObservableObject {
guard let jupiterQuote,
let route = jupiterQuote.routes.first,
let accountInfo = self.accountInfo,
let selectedToToken else {
let selectedToToken,
let selectedFromToken else {
return false
}
let network = await rpcService.network(.sol, origin: nil)
let jupiterSwapParams: BraveWallet.JupiterSwapParams = .init(
route: route,
userPublicKey: accountInfo.address,
inputMint: selectedFromToken.contractAddress(in: network),
outputMint: selectedToToken.contractAddress(in: network)
)
let (swapTransactions, errorResponse, _) = await swapService.jupiterSwapTransactions(jupiterSwapParams)
Expand Down Expand Up @@ -651,7 +653,7 @@ public class SwapTokenStore: ObservableObject {
}
let (success, _, _) = await txService.addUnapprovedTransaction(
.init(solanaTxData: solTxData),
from: accountInfo.address,
from: accountInfo.accountId,
origin: nil,
groupId: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct EditPermissionsView: View {
}

private var accountName: String {
NamedAddresses.name(for: activeTransaction.fromAddress, accounts: keyringStore.allAccounts)
NamedAddresses.name(for: activeTransaction.fromAccountId.address, accounts: keyringStore.allAccounts)
}

init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct TransactionSummary: Equatable, Identifiable {
/// The transaction
let txInfo: BraveWallet.TransactionInfo
/// From address of the transaction
var fromAddress: String { txInfo.fromAddress }
var fromAddress: String { txInfo.fromAccountId.address }
/// Account name for the from address of the transaction
let namedFromAddress: String
/// To address of the transaction
Expand Down Expand Up @@ -69,7 +69,7 @@ extension TransactionParser {
}
return .init(
txInfo: transaction,
namedFromAddress: NamedAddresses.name(for: transaction.fromAddress, accounts: accountInfos),
namedFromAddress: NamedAddresses.name(for: transaction.fromAccountId.address, accounts: accountInfos),
toAddress: toAddress,
namedToAddress: NamedAddresses.name(for: transaction.ethTxToAddress, accounts: accountInfos),
title: "",
Expand Down
Loading

0 comments on commit feccfd7

Please sign in to comment.