From e39a6daf35a63eed13d8049bfa121506e07b75ac Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 6 Sep 2023 15:53:15 +0700 Subject: [PATCH 1/5] removed group_id from transaction --- ..._button_notification_source_browsertest.cc | 6 +- .../browser/bitcoin/bitcoin_tx_manager.cc | 1 - .../browser/bitcoin/bitcoin_tx_manager.h | 1 - .../browser/bitcoin/bitcoin_tx_meta.cc | 4 +- .../bitcoin/bitcoin_tx_meta_unittest.cc | 1 - .../brave_wallet/browser/eth_tx_manager.cc | 83 ++++------ .../brave_wallet/browser/eth_tx_manager.h | 8 - .../browser/eth_tx_manager_unittest.cc | 155 ++---------------- .../brave_wallet/browser/eth_tx_meta.cc | 4 +- .../browser/eth_tx_meta_unittest.cc | 2 - .../browser/ethereum_provider_impl.cc | 4 +- .../brave_wallet/browser/fil_tx_manager.cc | 12 +- .../brave_wallet/browser/fil_tx_manager.h | 3 - .../browser/fil_tx_manager_unittest.cc | 43 +---- .../brave_wallet/browser/fil_tx_meta.cc | 4 +- .../browser/fil_tx_meta_unittest.cc | 2 - .../simulation_request_helper_unittest.cc | 4 - .../browser/simulation_service_unittest.cc | 1 - .../browser/solana_provider_impl.cc | 2 +- .../brave_wallet/browser/solana_tx_manager.cc | 2 - .../brave_wallet/browser/solana_tx_manager.h | 1 - .../browser/solana_tx_manager_unittest.cc | 37 +---- .../brave_wallet/browser/solana_tx_meta.cc | 4 +- .../browser/solana_tx_meta_unittest.cc | 2 - .../solana_tx_state_manager_unittest.cc | 2 - components/brave_wallet/browser/tx_manager.h | 1 - components/brave_wallet/browser/tx_meta.cc | 5 +- components/brave_wallet/browser/tx_meta.h | 5 - components/brave_wallet/browser/tx_service.cc | 3 +- components/brave_wallet/browser/tx_service.h | 1 - .../brave_wallet/browser/tx_state_manager.cc | 5 - .../brave_wallet/common/brave_wallet.mojom | 3 +- .../brave_wallet_ui/common/async/lib.ts | 7 +- .../brave_wallet_ui/common/constants/mocks.ts | 2 - .../common/hooks/use-pending-transaction.ts | 39 +---- .../common/slices/api.slice.ts | 5 - .../confirm-bitcoin-transaction-panel.tsx | 41 ----- .../confirm-solana-transaction-panel.tsx | 40 ----- .../confirm-transaction-panel/style.ts | 62 ------- components/brave_wallet_ui/constants/types.ts | 1 - 40 files changed, 86 insertions(+), 522 deletions(-) diff --git a/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc b/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc index d0449424245a..47b4b26ea2a5 100644 --- a/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc +++ b/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc @@ -194,7 +194,6 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, "100" /* gas_limit */, "" /* max_fee */, to_account, "11")); tx_service()->AddUnapprovedTransaction( std::move(tx_data), from_account->account_id.Clone(), absl::nullopt, - absl::nullopt, base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { first_tx_meta_id = id; @@ -237,7 +236,7 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, std::vector(), false, absl::nullopt); tx_service()->AddUnapprovedTransaction( brave_wallet::mojom::TxDataUnion::NewEthTxData(std::move(tx_data)), - from_account->account_id.Clone(), absl::nullopt, absl::nullopt, + from_account->account_id.Clone(), absl::nullopt, base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { second_tx_meta_id = id; @@ -270,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, tx_service()->AddUnapprovedTransaction( brave_wallet::mojom::TxDataUnion::NewSolanaTxData(std::move(tx_data)), - from_account->account_id.Clone(), absl::nullopt, absl::nullopt, + from_account->account_id.Clone(), absl::nullopt, base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { third_tx_meta_id = id; @@ -368,7 +367,6 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, "100" /* gas_limit */, "" /* max_fee */, to_account, "11")); tx_service()->AddUnapprovedTransaction( std::move(tx_data), from_account->account_id.Clone(), absl::nullopt, - absl::nullopt, base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { tx_meta_id = id; diff --git a/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc b/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc index ddd5cde44c2b..eee7dc127622 100644 --- a/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc +++ b/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc @@ -53,7 +53,6 @@ void BitcoinTxManager::AddUnapprovedTransaction( mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { const auto& btc_tx_data = tx_data_union->get_btc_tx_data(); diff --git a/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.h b/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.h index 4d7cabe25226..0270fe134eec 100644 --- a/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.h +++ b/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.h @@ -50,7 +50,6 @@ class BitcoinTxManager : public TxManager, mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback) override; void ApproveTransaction(const std::string& chain_id, const std::string& tx_meta_id, diff --git a/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta.cc b/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta.cc index b7076177f339..c785882e0042 100644 --- a/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta.cc +++ b/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta.cc @@ -59,8 +59,8 @@ mojom::TransactionInfoPtr BitcoinTxMeta::ToTransactionInfo() const { base::Milliseconds(created_time_.ToJavaTime()), base::Milliseconds(submitted_time_.ToJavaTime()), base::Milliseconds(confirmed_time_.ToJavaTime()), - origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, group_id_, - chain_id_, tx_->to()); + origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, chain_id_, + tx_->to()); } } // namespace brave_wallet diff --git a/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta_unittest.cc b/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta_unittest.cc index 742ca6a993cb..8c9400b40bef 100644 --- a/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta_unittest.cc +++ b/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta_unittest.cc @@ -46,7 +46,6 @@ TEST(BitcoinTxMeta, ToTransactionInfo) { EXPECT_EQ(ti->from_account_id, btc_account_id); EXPECT_EQ(ti->tx_status, meta.status()); EXPECT_TRUE(ti->tx_data_union->is_btc_tx_data()); - EXPECT_EQ(ti->group_id, meta.group_id()); EXPECT_EQ(meta.created_time().ToJavaTime(), ti->created_time.InMilliseconds()); EXPECT_EQ(meta.submitted_time().ToJavaTime(), diff --git a/components/brave_wallet/browser/eth_tx_manager.cc b/components/brave_wallet/browser/eth_tx_manager.cc index 13fe0c006c44..8237de76d164 100644 --- a/components/brave_wallet/browser/eth_tx_manager.cc +++ b/components/brave_wallet/browser/eth_tx_manager.cc @@ -140,20 +140,19 @@ void EthTxManager::AddUnapprovedTransaction( mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { DCHECK(tx_data_union->is_eth_tx_data() || tx_data_union->is_eth_tx_data_1559()); auto origin_val = origin.value_or(url::Origin::Create(GURL("chrome://wallet"))); if (tx_data_union->is_eth_tx_data()) { - AddUnapprovedTransaction( - chain_id, std::move(tx_data_union->get_eth_tx_data()), from, - std::move(origin_val), group_id, std::move(callback)); + AddUnapprovedTransaction(chain_id, + std::move(tx_data_union->get_eth_tx_data()), from, + std::move(origin_val), std::move(callback)); } else { AddUnapproved1559Transaction( chain_id, std::move(tx_data_union->get_eth_tx_data_1559()), from, - std::move(origin_val), group_id, std::move(callback)); + std::move(origin_val), std::move(callback)); } } @@ -162,7 +161,6 @@ void EthTxManager::AddUnapprovedTransaction( mojom::TxDataPtr tx_data, const mojom::AccountIdPtr& from, const url::Origin& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { std::string error; if (!EthTxManager::ValidateTxData(tx_data, &error)) { @@ -189,22 +187,20 @@ void EthTxManager::AddUnapprovedTransaction( chain_id, base::BindOnce(&EthTxManager::OnGetGasPrice, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), origin, tx_data->to, - tx_data->value, data, gas_limit, group_id, - std::move(tx_ptr), std::move(callback), - tx_data->sign_only)); + tx_data->value, data, gas_limit, std::move(tx_ptr), + std::move(callback), tx_data->sign_only)); } else if (!tx_ptr->gas_limit()) { json_rpc_service_->GetEstimateGas( chain_id, from->address, tx_data->to, "" /* gas */, "" /* gas_price */, tx_data->value, data, base::BindOnce(&EthTxManager::ContinueAddUnapprovedTransaction, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), - origin, group_id, std::move(tx_ptr), std::move(callback), + origin, std::move(tx_ptr), std::move(callback), tx_data->sign_only)); } else { - ContinueAddUnapprovedTransaction(chain_id, from, origin, group_id, - std::move(tx_ptr), std::move(callback), - tx_data->sign_only, gas_limit, - mojom::ProviderError::kSuccess, ""); + ContinueAddUnapprovedTransaction( + chain_id, from, origin, std::move(tx_ptr), std::move(callback), + tx_data->sign_only, gas_limit, mojom::ProviderError::kSuccess, ""); } } @@ -215,7 +211,6 @@ void EthTxManager::OnGetGasPrice(const std::string& chain_id, const std::string& value, const std::string& data, const std::string& gas_limit, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, bool sign_only, @@ -239,12 +234,11 @@ void EthTxManager::OnGetGasPrice(const std::string& chain_id, data, base::BindOnce(&EthTxManager::ContinueAddUnapprovedTransaction, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), - origin, group_id, std::move(tx), std::move(callback), - sign_only)); + origin, std::move(tx), std::move(callback), sign_only)); } else { - ContinueAddUnapprovedTransaction( - chain_id, from, origin, group_id, std::move(tx), std::move(callback), - sign_only, gas_limit, mojom::ProviderError::kSuccess, ""); + ContinueAddUnapprovedTransaction(chain_id, from, origin, std::move(tx), + std::move(callback), sign_only, gas_limit, + mojom::ProviderError::kSuccess, ""); } } @@ -252,7 +246,6 @@ void EthTxManager::ContinueAddUnapprovedTransaction( const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, bool sign_only, @@ -288,7 +281,6 @@ void EthTxManager::ContinueAddUnapprovedTransaction( EthTxMeta meta(from, std::move(tx)); meta.set_id(TxMeta::GenerateMetaID()); meta.set_origin(origin); - meta.set_group_id(group_id); meta.set_created_time(base::Time::Now()); meta.set_status(mojom::TransactionStatus::Unapproved); meta.set_sign_only(sign_only); @@ -306,7 +298,6 @@ void EthTxManager::AddUnapproved1559Transaction( mojom::TxData1559Ptr tx_data, const mojom::AccountIdPtr& from, const url::Origin& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { std::string error; if (!EthTxManager::ValidateTxData1559(tx_data, &error)) { @@ -336,7 +327,7 @@ void EthTxManager::AddUnapproved1559Transaction( base::BindOnce(&EthTxManager::OnGetGasOracleForUnapprovedTransaction, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), origin, tx_data->base_data->to, - tx_data->base_data->value, data, gas_limit, group_id, + tx_data->base_data->value, data, gas_limit, std::move(tx_ptr), std::move(callback), sign_only)); } else if (gas_limit.empty()) { json_rpc_service_->GetEstimateGas( @@ -344,12 +335,11 @@ void EthTxManager::AddUnapproved1559Transaction( "" /* gas_price */, tx_data->base_data->value, data, base::BindOnce(&EthTxManager::ContinueAddUnapprovedTransaction, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), - origin, group_id, std::move(tx_ptr), std::move(callback), + origin, std::move(tx_ptr), std::move(callback), sign_only)); } else { - ContinueAddUnapprovedTransaction(chain_id, from, origin, group_id, - std::move(tx_ptr), std::move(callback), - sign_only, gas_limit, + ContinueAddUnapprovedTransaction(chain_id, from, origin, std::move(tx_ptr), + std::move(callback), sign_only, gas_limit, mojom::ProviderError::kSuccess, ""); } } @@ -362,7 +352,6 @@ void EthTxManager::OnGetGasOracleForUnapprovedTransaction( const std::string& value, const std::string& data, const std::string& gas_limit, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, bool sign_only, @@ -387,12 +376,11 @@ void EthTxManager::OnGetGasOracleForUnapprovedTransaction( data, base::BindOnce(&EthTxManager::ContinueAddUnapprovedTransaction, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), - origin, group_id, std::move(tx), std::move(callback), - sign_only)); + origin, std::move(tx), std::move(callback), sign_only)); } else { - ContinueAddUnapprovedTransaction( - chain_id, from, origin, group_id, std::move(tx), std::move(callback), - sign_only, gas_limit, mojom::ProviderError::kSuccess, ""); + ContinueAddUnapprovedTransaction(chain_id, from, origin, std::move(tx), + std::move(callback), sign_only, gas_limit, + mojom::ProviderError::kSuccess, ""); } } @@ -1021,7 +1009,7 @@ void EthTxManager::SpeedupOrCancelTransaction( meta->chain_id(), base::BindOnce(&EthTxManager::ContinueSpeedupOrCancel1559Transaction, weak_factory_.GetWeakPtr(), meta->chain_id(), - meta->from().Clone(), meta->origin(), meta->group_id(), + meta->from().Clone(), meta->origin(), Uint256ValueToHex(meta->tx()->gas_limit()), std::move(tx), std::move(callback))); } else { @@ -1044,7 +1032,7 @@ void EthTxManager::SpeedupOrCancelTransaction( meta->chain_id(), base::BindOnce(&EthTxManager::ContinueSpeedupOrCancelTransaction, weak_factory_.GetWeakPtr(), meta->chain_id(), - meta->from().Clone(), meta->origin(), meta->group_id(), + meta->from().Clone(), meta->origin(), Uint256ValueToHex(meta->tx()->gas_limit()), std::move(tx), std::move(callback))); } @@ -1054,7 +1042,6 @@ void EthTxManager::ContinueSpeedupOrCancelTransaction( const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, const std::string& gas_limit, std::unique_ptr tx, SpeedupOrCancelTransactionCallback callback, @@ -1087,16 +1074,15 @@ void EthTxManager::ContinueSpeedupOrCancelTransaction( static_cast(tx->gas_price()) * 11ULL / 10ULL; tx->set_gas_price(std::max(latest_estimate_gas_price, increased_gas_price)); - ContinueAddUnapprovedTransaction( - chain_id, from, origin, group_id, std::move(tx), std::move(callback), - false, gas_limit, mojom::ProviderError::kSuccess, ""); + ContinueAddUnapprovedTransaction(chain_id, from, origin, std::move(tx), + std::move(callback), false, gas_limit, + mojom::ProviderError::kSuccess, ""); } void EthTxManager::ContinueSpeedupOrCancel1559Transaction( const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, const std::string& gas_limit, std::unique_ptr tx, SpeedupOrCancelTransactionCallback callback, @@ -1135,9 +1121,9 @@ void EthTxManager::ContinueSpeedupOrCancel1559Transaction( std::max(estimation->avg_max_priority_fee_per_gas, increased_max_priority_fee_per_gas)); - ContinueAddUnapprovedTransaction( - chain_id, from, origin, group_id, std::move(tx), std::move(callback), - false, gas_limit, mojom::ProviderError::kSuccess, ""); + ContinueAddUnapprovedTransaction(chain_id, from, origin, std::move(tx), + std::move(callback), false, gas_limit, + mojom::ProviderError::kSuccess, ""); } void EthTxManager::RetryTransaction(const std::string& chain_id, @@ -1160,11 +1146,10 @@ void EthTxManager::RetryTransaction(const std::string& chain_id, tx = std::make_unique(*meta->tx()); } - ContinueAddUnapprovedTransaction(meta->chain_id(), meta->from(), - meta->origin(), meta->group_id(), - std::move(tx), std::move(callback), false, - Uint256ValueToHex(meta->tx()->gas_limit()), - mojom::ProviderError::kSuccess, ""); + ContinueAddUnapprovedTransaction( + meta->chain_id(), meta->from(), meta->origin(), std::move(tx), + std::move(callback), false, Uint256ValueToHex(meta->tx()->gas_limit()), + mojom::ProviderError::kSuccess, ""); } void EthTxManager::GetGasEstimation1559(const std::string& chain_id, diff --git a/components/brave_wallet/browser/eth_tx_manager.h b/components/brave_wallet/browser/eth_tx_manager.h index 92343ee71a37..acca8ef20237 100644 --- a/components/brave_wallet/browser/eth_tx_manager.h +++ b/components/brave_wallet/browser/eth_tx_manager.h @@ -49,7 +49,6 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback) override; void ApproveTransaction(const std::string& chain_id, const std::string& tx_meta_id, @@ -176,13 +175,11 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { mojom::TxDataPtr tx_data, const mojom::AccountIdPtr& from, const url::Origin& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback); void AddUnapproved1559Transaction(const std::string& chain_id, mojom::TxData1559Ptr tx_data, const mojom::AccountIdPtr& from, const url::Origin& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback); void NotifyUnapprovedTxUpdated(TxMeta* meta); @@ -213,7 +210,6 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { const std::string& value, const std::string& data, const std::string& gas_limit, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, bool sign_only, @@ -224,7 +220,6 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, bool sign_only, @@ -248,7 +243,6 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { const std::string& value, const std::string& data, const std::string& gas_limit, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, bool sign_only, @@ -260,7 +254,6 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, const std::string& gas_limit, std::unique_ptr tx, SpeedupOrCancelTransactionCallback callback, @@ -271,7 +264,6 @@ class EthTxManager : public TxManager, public EthBlockTracker::Observer { const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, const std::string& gas_limit, std::unique_ptr tx, SpeedupOrCancelTransactionCallback callback, diff --git a/components/brave_wallet/browser/eth_tx_manager_unittest.cc b/components/brave_wallet/browser/eth_tx_manager_unittest.cc index 85843e10ec77..1c8b26e77efc 100644 --- a/components/brave_wallet/browser/eth_tx_manager_unittest.cc +++ b/components/brave_wallet/browser/eth_tx_manager_unittest.cc @@ -318,16 +318,14 @@ class EthTxManagerUnitTest : public testing::Test { })); } - void DoSpeedupOrCancelTransactionSuccess( - const std::string& chain_id, - const std::string& nonce, - const std::string& gas_price, - const std::vector& data, - const std::string& orig_meta_id, - mojom::TransactionStatus status, - bool cancel, - std::string* tx_meta_id, - const absl::optional& group_id = absl::nullopt) { + void DoSpeedupOrCancelTransactionSuccess(const std::string& chain_id, + const std::string& nonce, + const std::string& gas_price, + const std::vector& data, + const std::string& orig_meta_id, + mojom::TransactionStatus status, + bool cancel, + std::string* tx_meta_id) { auto tx_data = mojom::TxData::New(nonce, gas_price, "0x0974", "0xbe862ad9abfe6f22bcb087716c7d89a26051f74c", @@ -339,7 +337,6 @@ class EthTxManagerUnitTest : public testing::Test { meta.set_id(orig_meta_id); meta.set_chain_id(chain_id); meta.set_status(status); - meta.set_group_id(group_id); ASSERT_TRUE(eth_tx_manager()->tx_state_manager_->AddOrUpdateTx(meta)); bool callback_called = false; @@ -360,8 +357,7 @@ class EthTxManagerUnitTest : public testing::Test { const std::string& orig_meta_id, mojom::TransactionStatus status, bool cancel, - std::string* tx_meta_id, - const absl::optional& group_id = absl::nullopt) { + std::string* tx_meta_id) { auto tx_data1559 = mojom::TxData1559::New( mojom::TxData::New(nonce, "", "0x0974", "0xbe862ad9abfe6f22bcb087716c7d89a26051f74c", @@ -376,7 +372,6 @@ class EthTxManagerUnitTest : public testing::Test { meta.set_id(orig_meta_id); meta.set_chain_id(chain_id); meta.set_status(status); - meta.set_group_id(group_id); ASSERT_TRUE(eth_tx_manager()->tx_state_manager_->AddOrUpdateTx(meta)); bool callback_called = false; @@ -406,31 +401,26 @@ class EthTxManagerUnitTest : public testing::Test { const mojom::AccountIdPtr& from, const absl::optional& origin, EthTxManager::AddUnapprovedTransactionCallback callback) { - eth_tx_manager()->AddUnapprovedTransaction(chain_id, std::move(tx_data), - from, origin, absl::nullopt, - std::move(callback)); + eth_tx_manager()->AddUnapprovedTransaction( + chain_id, std::move(tx_data), from, origin, std::move(callback)); } void AddUnapprovedTransaction( const std::string& chain_id, mojom::TxDataPtr tx_data, const mojom::AccountIdPtr& from, - EthTxManager::AddUnapprovedTransactionCallback callback, - const absl::optional& group_id = absl::nullopt) { - eth_tx_manager()->AddUnapprovedTransaction(chain_id, std::move(tx_data), - from, GetOrigin(), group_id, - std::move(callback)); + EthTxManager::AddUnapprovedTransactionCallback callback) { + eth_tx_manager()->AddUnapprovedTransaction( + chain_id, std::move(tx_data), from, GetOrigin(), std::move(callback)); } void AddUnapproved1559Transaction( const std::string& chain_id, mojom::TxData1559Ptr tx_data, const mojom::AccountIdPtr& from, - EthTxManager::AddUnapprovedTransactionCallback callback, - const absl::optional& group_id = absl::nullopt) { - eth_tx_manager()->AddUnapproved1559Transaction(chain_id, std::move(tx_data), - from, GetOrigin(), group_id, - std::move(callback)); + EthTxManager::AddUnapprovedTransactionCallback callback) { + eth_tx_manager()->AddUnapproved1559Transaction( + chain_id, std::move(tx_data), from, GetOrigin(), std::move(callback)); } void TestMakeERC1155TransferFromDataTxType( @@ -567,75 +557,6 @@ TEST_F(EthTxManagerUnitTest, SomeSiteOrigin) { url::Origin::Create(GURL("https://some.site.com"))); } -TEST_F(EthTxManagerUnitTest, - AddUnapprovedLegacyOrEIP1559TransactionWithGroupId) { - auto tx_data = - mojom::TxData::New("0x06", "0x09184e72a000", "0x0974", - "0xbe862ad9abfe6f22bcb087716c7d89a26051f74c", - "0x016345785d8a0000", data_, false, absl::nullopt); - bool callback_called = false; - std::string tx_meta_id; - - // Legacy transaction with group_id - AddUnapprovedTransaction( - mojom::kLocalhostChainId, tx_data.Clone(), from(), - base::BindOnce(&AddUnapprovedTransactionSuccessCallback, &callback_called, - &tx_meta_id), - "mockGroupId"); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(callback_called); - auto tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - EXPECT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); - - // Legacy transaction with empty group_id - callback_called = false; - AddUnapprovedTransaction( - mojom::kLocalhostChainId, std::move(tx_data), from(), - base::BindOnce(&AddUnapprovedTransactionSuccessCallback, &callback_called, - &tx_meta_id)); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(callback_called); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - EXPECT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), absl::nullopt); - - auto tx_data_1559 = mojom::TxData1559::New( - mojom::TxData::New("0x1", "", "0x0974", - "0xbe862ad9abfe6f22bcb087716c7d89a26051f74c", - "0x016345785d8a0000", data_, false, absl::nullopt), - "0x04", "0x77359400" /* 2 Gwei */, "0xb2d05e000" /* 48 Gwei */, nullptr); - - // EIP-1559 transaction with group_id - callback_called = false; - AddUnapproved1559Transaction( - mojom::kLocalhostChainId, tx_data_1559.Clone(), from(), - base::BindOnce(&AddUnapprovedTransactionSuccessCallback, &callback_called, - &tx_meta_id), - "mockGroupId1559"); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(callback_called); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - EXPECT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId1559"); - - // EIP-1559 transaction with empty group_id - callback_called = false; - AddUnapproved1559Transaction( - mojom::kLocalhostChainId, std::move(tx_data_1559), from(), - base::BindOnce(&AddUnapprovedTransactionSuccessCallback, &callback_called, - &tx_meta_id)); - base::RunLoop().RunUntilIdle(); - EXPECT_TRUE(callback_called); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - EXPECT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), absl::nullopt); -} - TEST_F(EthTxManagerUnitTest, AddUnapprovedTransactionWithoutGasLimit) { std::string gas_price = "0x09184e72a000"; auto tx_data = @@ -2098,17 +2019,6 @@ TEST_F(EthTxManagerUnitTest, SpeedupTransaction) { ASSERT_TRUE(tx_meta); EXPECT_EQ(*expected_tx_meta->tx(), *tx_meta->tx()); - // Speedup should reuse group_id - orig_meta_id = "004"; - DoSpeedupOrCancelTransactionSuccess(mojom::kLocalhostChainId, "0x05", "0xa", - std::vector(), orig_meta_id, - mojom::TransactionStatus::Submitted, - false, &tx_meta_id, "mockGroupId"); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); - // Non-exist transaction should fail. DoSpeedupOrCancelTransactionFailure(mojom::kLocalhostChainId, "123", false); @@ -2166,17 +2076,6 @@ TEST_F(EthTxManagerUnitTest, Speedup1559Transaction) { tx1559_ptr = static_cast(tx_meta->tx()); EXPECT_EQ(*expected_tx1559_ptr, *tx1559_ptr); - // Speedup should reuse group_id - orig_meta_id = "003"; - DoSpeedupOrCancel1559TransactionSuccess( - mojom::kLocalhostChainId, "0x05", data_, "0x77359400" /* 2 Gwei */, - "0xb2d05e000" /* 48 Gwei */, orig_meta_id, - mojom::TransactionStatus::Submitted, false, &tx_meta_id, "mockGroupId"); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); - // Non-exist transaction should fail. DoSpeedupOrCancelTransactionFailure(mojom::kLocalhostChainId, "123", false); @@ -2241,16 +2140,6 @@ TEST_F(EthTxManagerUnitTest, CancelTransaction) { EXPECT_EQ(tx_meta->tx()->value(), 0u); EXPECT_TRUE(tx_meta->tx()->data().empty()); - // Cancel should reuse group_id - orig_meta_id = "003"; - DoSpeedupOrCancelTransactionSuccess( - mojom::kLocalhostChainId, "0x07", "0x1", data_, orig_meta_id, - mojom::TransactionStatus::Submitted, true, &tx_meta_id, "mockGroupId"); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); - // EIP1559 // Cancel with original gas fees + 10% > avg gas fees should use // original gas fees + 10%. @@ -2278,16 +2167,6 @@ TEST_F(EthTxManagerUnitTest, CancelTransaction) { EXPECT_EQ(tx_meta->tx()->value(), 0u); EXPECT_TRUE(tx_meta->tx()->data().empty()); - // Cancel should reuse group_id - DoSpeedupOrCancel1559TransactionSuccess( - mojom::kLocalhostChainId, "0x08", data_, "0x77359400" /* 2 Gwei */, - "0xb2d05e000" /* 48 Gwei */, orig_meta_id, - mojom::TransactionStatus::Submitted, true, &tx_meta_id, "mockGroupId"); - tx_meta = - eth_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, tx_meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); - // Non-exist transaction should fail. DoSpeedupOrCancelTransactionFailure(mojom::kLocalhostChainId, "123", true); diff --git a/components/brave_wallet/browser/eth_tx_meta.cc b/components/brave_wallet/browser/eth_tx_meta.cc index e7396b78294a..fb5f64f36713 100644 --- a/components/brave_wallet/browser/eth_tx_meta.cc +++ b/components/brave_wallet/browser/eth_tx_meta.cc @@ -149,8 +149,8 @@ mojom::TransactionInfoPtr EthTxMeta::ToTransactionInfo() const { base::Milliseconds(created_time_.ToJavaTime()), base::Milliseconds(submitted_time_.ToJavaTime()), base::Milliseconds(confirmed_time_.ToJavaTime()), - origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, group_id_, - chain_id_, final_recepient); + origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, chain_id_, + final_recepient); } } // namespace brave_wallet diff --git a/components/brave_wallet/browser/eth_tx_meta_unittest.cc b/components/brave_wallet/browser/eth_tx_meta_unittest.cc index 08ffaf1ea5e6..02f3602fbeca 100644 --- a/components/brave_wallet/browser/eth_tx_meta_unittest.cc +++ b/components/brave_wallet/browser/eth_tx_meta_unittest.cc @@ -37,7 +37,6 @@ TEST(EthTxMetaUnitTest, ToTransactionInfo) { EXPECT_TRUE(base::Time::FromUTCExploded(x, &confirmed_time)); meta.set_submitted_time(confirmed_time - base::Seconds(3)); meta.set_created_time(confirmed_time - base::Minutes(1)); - meta.set_group_id("mockGroupId"); mojom::TransactionInfoPtr ti = meta.ToTransactionInfo(); EXPECT_EQ(ti->id, meta.id()); @@ -45,7 +44,6 @@ TEST(EthTxMetaUnitTest, ToTransactionInfo) { EXPECT_EQ(ti->from_account_id, meta.from()); EXPECT_EQ(ti->tx_hash, meta.tx_hash()); EXPECT_EQ(ti->tx_status, meta.status()); - EXPECT_EQ(ti->group_id, meta.group_id()); ASSERT_TRUE(ti->tx_data_union->is_eth_tx_data_1559()); EXPECT_EQ(ti->tx_data_union->get_eth_tx_data_1559()->base_data->nonce, diff --git a/components/brave_wallet/browser/ethereum_provider_impl.cc b/components/brave_wallet/browser/ethereum_provider_impl.cc index 161f83514178..45d8d7800f12 100644 --- a/components/brave_wallet/browser/ethereum_provider_impl.cc +++ b/components/brave_wallet/browser/ethereum_provider_impl.cc @@ -303,14 +303,14 @@ void EthereumProviderImpl::OnGetNetworkAndDefaultKeyringInfo( tx_data_1559->chain_id = chain->chain_id; tx_service_->AddUnapprovedTransaction( mojom::TxDataUnion::NewEthTxData1559(std::move(tx_data_1559)), - account_id.Clone(), origin, absl::nullopt, + account_id.Clone(), origin, base::BindOnce(&EthereumProviderImpl::OnAddUnapprovedTransactionAdapter, weak_factory_.GetWeakPtr(), std::move(callback), std::move(id))); } else { tx_service_->AddUnapprovedTransaction( mojom::TxDataUnion::NewEthTxData(std::move(tx_data_1559->base_data)), - account_id.Clone(), origin, absl::nullopt, + account_id.Clone(), origin, base::BindOnce(&EthereumProviderImpl::OnAddUnapprovedTransactionAdapter, weak_factory_.GetWeakPtr(), std::move(callback), std::move(id))); diff --git a/components/brave_wallet/browser/fil_tx_manager.cc b/components/brave_wallet/browser/fil_tx_manager.cc index 9aaf01bc2480..71325dfcf2a7 100644 --- a/components/brave_wallet/browser/fil_tx_manager.cc +++ b/components/brave_wallet/browser/fil_tx_manager.cc @@ -53,7 +53,6 @@ FilTxManager::~FilTxManager() { void FilTxManager::GetEstimatedGas(const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback) { const std::string gas_premium = tx->gas_premium(); @@ -68,14 +67,13 @@ void FilTxManager::GetEstimatedGas(const std::string& chain_id, max_fee, value, base::BindOnce(&FilTxManager::ContinueAddUnapprovedTransaction, weak_factory_.GetWeakPtr(), chain_id, from.Clone(), origin, - group_id, std::move(tx), std::move(callback))); + std::move(tx), std::move(callback))); } void FilTxManager::ContinueAddUnapprovedTransaction( const std::string& chain_id, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, const std::string& gas_premium, @@ -95,7 +93,6 @@ void FilTxManager::ContinueAddUnapprovedTransaction( meta.set_id(TxMeta::GenerateMetaID()); meta.set_origin( origin.value_or(url::Origin::Create(GURL("chrome://wallet")))); - meta.set_group_id(group_id); meta.set_created_time(base::Time::Now()); meta.set_status(mojom::TransactionStatus::Unapproved); meta.set_chain_id(chain_id); @@ -113,7 +110,6 @@ void FilTxManager::AddUnapprovedTransaction( mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { DCHECK(tx_data_union->is_fil_tx_data()); const bool is_mainnet = chain_id == mojom::kFilecoinMainnet; @@ -137,12 +133,12 @@ void FilTxManager::AddUnapprovedTransaction( const std::string gas_premium = tx->gas_premium(); auto gas_limit = tx->gas_limit(); if (!gas_limit || gas_fee_cap.empty() || gas_premium.empty()) { - GetEstimatedGas(chain_id, from, origin, group_id, std::move(tx_ptr), + GetEstimatedGas(chain_id, from, origin, std::move(tx_ptr), std::move(callback)); } else { ContinueAddUnapprovedTransaction( - chain_id, from, origin, group_id, std::move(tx_ptr), - std::move(callback), gas_premium, gas_fee_cap, gas_limit, + chain_id, from, origin, std::move(tx_ptr), std::move(callback), + gas_premium, gas_fee_cap, gas_limit, mojom::FilecoinProviderError::kSuccess, ""); } } diff --git a/components/brave_wallet/browser/fil_tx_manager.h b/components/brave_wallet/browser/fil_tx_manager.h index 1c31806f4a7f..99dac3667269 100644 --- a/components/brave_wallet/browser/fil_tx_manager.h +++ b/components/brave_wallet/browser/fil_tx_manager.h @@ -45,7 +45,6 @@ class FilTxManager : public TxManager, public FilBlockTracker::Observer { mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback) override; void ApproveTransaction(const std::string& chain_id, const std::string& tx_meta_id, @@ -75,7 +74,6 @@ class FilTxManager : public TxManager, public FilBlockTracker::Observer { void GetEstimatedGas(const std::string& chain_id, const mojom::AccountIdPtr& from_account_id, const absl::optional& origin, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback); std::unique_ptr GetTxForTesting(const std::string& chain_id, @@ -104,7 +102,6 @@ class FilTxManager : public TxManager, public FilBlockTracker::Observer { const std::string& chain_id, const mojom::AccountIdPtr& from_account_id, const absl::optional& origin, - const absl::optional& group_id, std::unique_ptr tx, AddUnapprovedTransactionCallback callback, const std::string& gas_premium, diff --git a/components/brave_wallet/browser/fil_tx_manager_unittest.cc b/components/brave_wallet/browser/fil_tx_manager_unittest.cc index 12e286747b6b..6640b44b72ea 100644 --- a/components/brave_wallet/browser/fil_tx_manager_unittest.cc +++ b/components/brave_wallet/browser/fil_tx_manager_unittest.cc @@ -164,18 +164,16 @@ class FilTxManagerUnitTest : public testing::Test { return url::Origin::Create(GURL("https://brave.com")); } - void AddUnapprovedTransaction( - const std::string& chain_id, - mojom::FilTxDataPtr tx_data, - const mojom::AccountIdPtr& from, - const absl::optional& origin, - std::string* meta_id, - const absl::optional& group_id = absl::nullopt) { + void AddUnapprovedTransaction(const std::string& chain_id, + mojom::FilTxDataPtr tx_data, + const mojom::AccountIdPtr& from, + const absl::optional& origin, + std::string* meta_id) { auto tx_data_union = mojom::TxDataUnion::NewFilTxData(std::move(tx_data)); base::RunLoop run_loop; fil_tx_manager()->AddUnapprovedTransaction( - chain_id, std::move(tx_data_union), from, origin, group_id, + chain_id, std::move(tx_data_union), from, origin, base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { ASSERT_TRUE(success); @@ -477,35 +475,6 @@ TEST_F(FilTxManagerUnitTest, SomeSiteOrigin) { EXPECT_EQ(tx_meta->chain_id(), mojom::kLocalhostChainId); } -TEST_F(FilTxManagerUnitTest, AddUnapprovedTransactionWithGroupId) { - const auto from_account = FilTestAcc(0); - const std::string to_account = "t1lqarsh4nkg545ilaoqdsbtj4uofplt6sto26ziy"; - SetGasEstimateInterceptor(from_account, to_account); - auto tx_data = mojom::FilTxData::New("" /* nonce */, "" /* gas_premium */, - "" /* gas_fee_cap */, "" /* gas_limit */, - "" /* max_fee */, to_account, "11"); - std::string meta_id; - - // Transaction with group_id - AddUnapprovedTransaction(mojom::kLocalhostChainId, tx_data.Clone(), - from_account, absl::nullopt, &meta_id, - "mockGroupId"); - auto tx_meta = - fil_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); - EXPECT_EQ(tx_meta->chain_id(), mojom::kLocalhostChainId); - - // Transaction with empty group_id - AddUnapprovedTransaction(mojom::kLocalhostChainId, tx_data.Clone(), - from_account, absl::nullopt, &meta_id); - tx_meta = - fil_tx_manager()->GetTxForTesting(mojom::kLocalhostChainId, meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->group_id(), absl::nullopt); - EXPECT_EQ(tx_meta->chain_id(), mojom::kLocalhostChainId); -} - TEST_F(FilTxManagerUnitTest, GetTransactionMessageToSign) { const auto from_account = FilTestAcc(0); EXPECT_EQ(from_account->address, "t1dca7adhz5lbvin5n3qlw67munu6xhn5fpb77nly"); diff --git a/components/brave_wallet/browser/fil_tx_meta.cc b/components/brave_wallet/browser/fil_tx_meta.cc index e54f043bc908..f8e6574d6359 100644 --- a/components/brave_wallet/browser/fil_tx_meta.cc +++ b/components/brave_wallet/browser/fil_tx_meta.cc @@ -44,8 +44,8 @@ mojom::TransactionInfoPtr FilTxMeta::ToTransactionInfo() const { base::Milliseconds(created_time_.ToJavaTime()), base::Milliseconds(submitted_time_.ToJavaTime()), base::Milliseconds(confirmed_time_.ToJavaTime()), - origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, group_id_, - chain_id_, tx_->ToFilTxData()->to); + origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, chain_id_, + tx_->ToFilTxData()->to); } } // namespace brave_wallet diff --git a/components/brave_wallet/browser/fil_tx_meta_unittest.cc b/components/brave_wallet/browser/fil_tx_meta_unittest.cc index 7c276f2ab0a8..a3c942912f20 100644 --- a/components/brave_wallet/browser/fil_tx_meta_unittest.cc +++ b/components/brave_wallet/browser/fil_tx_meta_unittest.cc @@ -32,7 +32,6 @@ TEST(FilTxMeta, ToTransactionInfo) { EXPECT_TRUE(base::Time::FromUTCExploded(x, &confirmed_time)); meta.set_submitted_time(confirmed_time - base::Seconds(3)); meta.set_created_time(confirmed_time - base::Minutes(1)); - meta.set_group_id("mockGroupId"); mojom::TransactionInfoPtr ti = meta.ToTransactionInfo(); EXPECT_EQ(ti->id, meta.id()); @@ -41,7 +40,6 @@ TEST(FilTxMeta, ToTransactionInfo) { EXPECT_EQ(ti->from_account_id, fil_account_id); EXPECT_EQ(ti->tx_status, meta.status()); EXPECT_TRUE(ti->tx_data_union->is_fil_tx_data()); - EXPECT_EQ(ti->group_id, meta.group_id()); const auto& tx_data = ti->tx_data_union->get_fil_tx_data(); EXPECT_EQ(tx_data->nonce, "1"); diff --git a/components/brave_wallet/browser/simulation_request_helper_unittest.cc b/components/brave_wallet/browser/simulation_request_helper_unittest.cc index b8efebf67435..e6e39d8dc2b4 100644 --- a/components/brave_wallet/browser/simulation_request_helper_unittest.cc +++ b/components/brave_wallet/browser/simulation_request_helper_unittest.cc @@ -7,8 +7,6 @@ #include #include -#include "base/strings/stringprintf.h" -#include "base/test/gtest_util.h" #include "base/test/values_test_util.h" #include "brave/components/brave_wallet/browser/eip1559_transaction.h" #include "brave/components/brave_wallet/browser/eth_transaction.h" @@ -106,8 +104,6 @@ mojom::TransactionInfoPtr GetCannedScanSolanaTransactionParams( meta.set_origin(url::Origin::Create(GURL(*origin))); } - meta.set_group_id("mockGroupId"); - return meta.ToTransactionInfo(); } diff --git a/components/brave_wallet/browser/simulation_service_unittest.cc b/components/brave_wallet/browser/simulation_service_unittest.cc index a52319ae4cfa..e5eefa251cd2 100644 --- a/components/brave_wallet/browser/simulation_service_unittest.cc +++ b/components/brave_wallet/browser/simulation_service_unittest.cc @@ -154,7 +154,6 @@ class SimulationServiceUnitTest : public testing::Test { meta.set_origin(url::Origin::Create(GURL(*origin))); } - meta.set_group_id("mockGroupId"); meta.set_chain_id(chain_id); return meta.ToTransactionInfo(); diff --git a/components/brave_wallet/browser/solana_provider_impl.cc b/components/brave_wallet/browser/solana_provider_impl.cc index abb23db77bab..1b651a9a7769 100644 --- a/components/brave_wallet/browser/solana_provider_impl.cc +++ b/components/brave_wallet/browser/solana_provider_impl.cc @@ -522,7 +522,7 @@ void SolanaProviderImpl::SignAndSendTransaction( tx_service_->AddUnapprovedTransaction( mojom::TxDataUnion::NewSolanaTxData(tx.ToSolanaTxData()), - account->account_id.Clone(), delegate_->GetOrigin(), absl::nullopt, + account->account_id.Clone(), delegate_->GetOrigin(), base::BindOnce(&SolanaProviderImpl::OnAddUnapprovedTransaction, weak_factory_.GetWeakPtr(), std::move(callback))); } diff --git a/components/brave_wallet/browser/solana_tx_manager.cc b/components/brave_wallet/browser/solana_tx_manager.cc index a043e5e1c089..adea6490640f 100644 --- a/components/brave_wallet/browser/solana_tx_manager.cc +++ b/components/brave_wallet/browser/solana_tx_manager.cc @@ -59,7 +59,6 @@ void SolanaTxManager::AddUnapprovedTransaction( mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { DCHECK(tx_data_union->is_solana_tx_data()); @@ -76,7 +75,6 @@ void SolanaTxManager::AddUnapprovedTransaction( meta.set_id(TxMeta::GenerateMetaID()); meta.set_origin( origin.value_or(url::Origin::Create(GURL("chrome://wallet")))); - meta.set_group_id(group_id); meta.set_created_time(base::Time::Now()); meta.set_status(mojom::TransactionStatus::Unapproved); meta.set_chain_id(chain_id); diff --git a/components/brave_wallet/browser/solana_tx_manager.h b/components/brave_wallet/browser/solana_tx_manager.h index 9140d49a7a4f..651d687d5432 100644 --- a/components/brave_wallet/browser/solana_tx_manager.h +++ b/components/brave_wallet/browser/solana_tx_manager.h @@ -46,7 +46,6 @@ class SolanaTxManager : public TxManager, public SolanaBlockTracker::Observer { mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback) override; void ApproveTransaction(const std::string& chain_id, const std::string& tx_meta_id, diff --git a/components/brave_wallet/browser/solana_tx_manager_unittest.cc b/components/brave_wallet/browser/solana_tx_manager_unittest.cc index ad6c9a9cd18d..5cdd521988fe 100644 --- a/components/brave_wallet/browser/solana_tx_manager_unittest.cc +++ b/components/brave_wallet/browser/solana_tx_manager_unittest.cc @@ -244,22 +244,20 @@ class SolanaTxManagerUnitTest : public testing::Test { const mojom::AccountIdPtr& from, std::string* meta_id) { AddUnapprovedTransaction(chain_id, std::move(solana_tx_data), from, - GetOrigin(), meta_id, absl::nullopt); + GetOrigin(), meta_id); } - void AddUnapprovedTransaction( - const std::string& chain_id, - mojom::SolanaTxDataPtr solana_tx_data, - const mojom::AccountIdPtr& from, - const absl::optional& origin, - std::string* meta_id, - const absl::optional& group_id = absl::nullopt) { + void AddUnapprovedTransaction(const std::string& chain_id, + mojom::SolanaTxDataPtr solana_tx_data, + const mojom::AccountIdPtr& from, + const absl::optional& origin, + std::string* meta_id) { auto tx_data_union = mojom::TxDataUnion::NewSolanaTxData(std::move(solana_tx_data)); base::RunLoop run_loop; solana_tx_manager()->AddUnapprovedTransaction( - chain_id, std::move(tx_data_union), from, origin, group_id, + chain_id, std::move(tx_data_union), from, origin, base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { ASSERT_TRUE(success); @@ -620,27 +618,6 @@ TEST_F(SolanaTxManagerUnitTest, SomeSiteOrigin) { url::Origin::Create(GURL("https://some.site.com"))); } -TEST_F(SolanaTxManagerUnitTest, AddUnapprovedTransactionWithGroupId) { - const auto& from = sol_account(); - const std::string to = "JDqrvDz8d8tFCADashbUKQDKfJZFobNy13ugN65t1wvV"; - mojom::SolanaTxDataPtr system_transfer_data = nullptr; - TestMakeSystemProgramTransferTxData(from, to, 10000000, nullptr, - mojom::SolanaProviderError::kSuccess, "", - &system_transfer_data); - ASSERT_TRUE(system_transfer_data); - - std::string meta_id; - AddUnapprovedTransaction(mojom::kSolanaMainnet, - std::move(system_transfer_data), from, absl::nullopt, - &meta_id, "mockGroupId"); - - auto tx_meta = - solana_tx_manager()->GetTxForTesting(mojom::kSolanaMainnet, meta_id); - ASSERT_TRUE(tx_meta); - EXPECT_EQ(tx_meta->chain_id(), mojom::kSolanaMainnet); - EXPECT_EQ(tx_meta->group_id(), "mockGroupId"); -} - TEST_F(SolanaTxManagerUnitTest, MakeSystemProgramTransferTxData) { const auto& from_account = sol_account(); std::string from_account_address = from_account->address; diff --git a/components/brave_wallet/browser/solana_tx_meta.cc b/components/brave_wallet/browser/solana_tx_meta.cc index f164c3822bd9..5ade7b1a5588 100644 --- a/components/brave_wallet/browser/solana_tx_meta.cc +++ b/components/brave_wallet/browser/solana_tx_meta.cc @@ -45,8 +45,8 @@ mojom::TransactionInfoPtr SolanaTxMeta::ToTransactionInfo() const { base::Milliseconds(created_time_.ToJavaTime()), base::Milliseconds(submitted_time_.ToJavaTime()), base::Milliseconds(confirmed_time_.ToJavaTime()), - origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, group_id_, - chain_id_, absl::nullopt); + origin_.has_value() ? MakeOriginInfo(*origin_) : nullptr, chain_id_, + absl::nullopt); } } // namespace brave_wallet diff --git a/components/brave_wallet/browser/solana_tx_meta_unittest.cc b/components/brave_wallet/browser/solana_tx_meta_unittest.cc index cadc456d6760..0fd7fd9945ac 100644 --- a/components/brave_wallet/browser/solana_tx_meta_unittest.cc +++ b/components/brave_wallet/browser/solana_tx_meta_unittest.cc @@ -65,7 +65,6 @@ TEST(SolanaTxMetaUnitTest, ToTransactionInfo) { "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzr" "FmBV6UjKdiSZkQUW"); meta.set_origin(url::Origin::Create(GURL("https://test.brave.com/"))); - meta.set_group_id("mockGroupId"); mojom::TransactionInfoPtr ti = meta.ToTransactionInfo(); EXPECT_EQ(ti->id, meta.id()); @@ -76,7 +75,6 @@ TEST(SolanaTxMetaUnitTest, ToTransactionInfo) { EXPECT_EQ( ti->origin_info, MakeOriginInfo(url::Origin::Create(GURL("https://test.brave.com/")))); - EXPECT_EQ(ti->group_id, meta.group_id()); EXPECT_EQ(meta.created_time().ToJavaTime(), ti->created_time.InMilliseconds()); diff --git a/components/brave_wallet/browser/solana_tx_state_manager_unittest.cc b/components/brave_wallet/browser/solana_tx_state_manager_unittest.cc index aa8c3ddcfce3..3f8b5baade95 100644 --- a/components/brave_wallet/browser/solana_tx_state_manager_unittest.cc +++ b/components/brave_wallet/browser/solana_tx_state_manager_unittest.cc @@ -10,7 +10,6 @@ #include #include "base/files/scoped_temp_dir.h" -#include "base/test/bind.h" #include "base/test/task_environment.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/solana_account_meta.h" @@ -91,7 +90,6 @@ TEST_F(SolanaTxStateManagerUnitTest, SolanaTxMetaAndValue) { "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzr" "FmBV6UjKdiSZkQUW"); meta.set_origin(url::Origin::Create(GURL("https://test.brave.com/"))); - meta.set_group_id("mockGroupId"); meta.set_chain_id(mojom::kSolanaMainnet); base::Value::Dict meta_value = meta.ToValue(); diff --git a/components/brave_wallet/browser/tx_manager.h b/components/brave_wallet/browser/tx_manager.h index 6595edf9349f..7d4d7798165a 100644 --- a/components/brave_wallet/browser/tx_manager.h +++ b/components/brave_wallet/browser/tx_manager.h @@ -52,7 +52,6 @@ class TxManager : public TxStateManager::Observer, mojom::TxDataUnionPtr tx_data_union, const mojom::AccountIdPtr& from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback) = 0; virtual void ApproveTransaction(const std::string& chain_id, const std::string& tx_meta_id, diff --git a/components/brave_wallet/browser/tx_meta.cc b/components/brave_wallet/browser/tx_meta.cc index 9e2db2e2dc5d..edb49d7febf0 100644 --- a/components/brave_wallet/browser/tx_meta.cc +++ b/components/brave_wallet/browser/tx_meta.cc @@ -19,7 +19,7 @@ bool TxMeta::operator==(const TxMeta& meta) const { created_time_ == meta.created_time_ && submitted_time_ == meta.submitted_time_ && confirmed_time_ == meta.confirmed_time_ && tx_hash_ == meta.tx_hash_ && - origin_ == meta.origin_ && group_id_ == meta.group_id_; + origin_ == meta.origin_; } base::Value::Dict TxMeta::ToValue() const { @@ -36,9 +36,6 @@ base::Value::Dict TxMeta::ToValue() const { DCHECK(!origin_->opaque()); dict.Set("origin", origin_->GetURL().spec()); } - if (group_id_.has_value()) { - dict.Set("group_id", *group_id_); - } dict.Set("chain_id", chain_id_); return dict; } diff --git a/components/brave_wallet/browser/tx_meta.h b/components/brave_wallet/browser/tx_meta.h index 5f49efa8c538..e10a379aa017 100644 --- a/components/brave_wallet/browser/tx_meta.h +++ b/components/brave_wallet/browser/tx_meta.h @@ -37,7 +37,6 @@ class TxMeta { base::Time confirmed_time() const { return confirmed_time_; } const std::string& tx_hash() const { return tx_hash_; } const absl::optional& origin() const { return origin_; } - const absl::optional& group_id() const { return group_id_; } const std::string& chain_id() const { return chain_id_; } void set_id(const std::string& id) { id_ = id; } @@ -56,9 +55,6 @@ class TxMeta { void set_origin(const absl::optional& origin) { origin_ = origin; } - void set_group_id(const absl::optional& group_id) { - group_id_ = group_id; - } void set_chain_id(const std::string& chain_id) { chain_id_ = chain_id; } protected: @@ -72,7 +68,6 @@ class TxMeta { base::Time confirmed_time_; std::string tx_hash_; absl::optional origin_; - absl::optional group_id_; std::string chain_id_; }; diff --git a/components/brave_wallet/browser/tx_service.cc b/components/brave_wallet/browser/tx_service.cc index 0811c51445ef..92ceddaa541c 100644 --- a/components/brave_wallet/browser/tx_service.cc +++ b/components/brave_wallet/browser/tx_service.cc @@ -164,7 +164,6 @@ void TxService::AddUnapprovedTransaction( mojom::TxDataUnionPtr tx_data_union, mojom::AccountIdPtr from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback callback) { if (!account_resolver_delegate_->ValidateAccountId(from)) { std::move(callback).Run( @@ -176,7 +175,7 @@ void TxService::AddUnapprovedTransaction( auto coin_type = GetCoinTypeFromTxDataUnion(*tx_data_union); GetTxManager(coin_type)->AddUnapprovedTransaction( json_rpc_service_->GetChainIdSync(coin_type, origin), - std::move(tx_data_union), from, origin, group_id, std::move(callback)); + std::move(tx_data_union), from, origin, std::move(callback)); } void TxService::ApproveTransaction(mojom::CoinType coin_type, diff --git a/components/brave_wallet/browser/tx_service.h b/components/brave_wallet/browser/tx_service.h index 9ecef9c45f48..6d519ddeb427 100644 --- a/components/brave_wallet/browser/tx_service.h +++ b/components/brave_wallet/browser/tx_service.h @@ -78,7 +78,6 @@ class TxService : public KeyedService, void AddUnapprovedTransaction(mojom::TxDataUnionPtr tx_data_union, mojom::AccountIdPtr from, const absl::optional& origin, - const absl::optional& group_id, AddUnapprovedTransactionCallback) override; void ApproveTransaction(mojom::CoinType coin_type, const std::string& chain_id, diff --git a/components/brave_wallet/browser/tx_state_manager.cc b/components/brave_wallet/browser/tx_state_manager.cc index 3f290afea73a..b19bb3f7c611 100644 --- a/components/brave_wallet/browser/tx_state_manager.cc +++ b/components/brave_wallet/browser/tx_state_manager.cc @@ -99,11 +99,6 @@ bool TxStateManager::ValueToBaseTxMeta(const base::Value::Dict& value, DCHECK(!meta->origin()->opaque()); } - const std::string* group_id = value.FindString("group_id"); - if (group_id) { - meta->set_group_id(*group_id); - } - const auto* chain_id_string = value.FindString("chain_id"); if (!chain_id_string) { return false; diff --git a/components/brave_wallet/common/brave_wallet.mojom b/components/brave_wallet/common/brave_wallet.mojom index f543ac99e1da..6040b1c081f4 100644 --- a/components/brave_wallet/common/brave_wallet.mojom +++ b/components/brave_wallet/common/brave_wallet.mojom @@ -1464,7 +1464,6 @@ struct TransactionInfo { mojo_base.mojom.TimeDelta submitted_time; mojo_base.mojom.TimeDelta confirmed_time; OriginInfo? origin_info; - string? group_id; string chain_id; // Currently only available for ETH and FIL // Represent effective recipient of the transaction @@ -1495,7 +1494,7 @@ interface TxServiceObserver { // transactions. interface TxService { // Used to add a transaction. Missing origin is expected to come from chrome://wallet. - AddUnapprovedTransaction(TxDataUnion tx_data_union, AccountId from, url.mojom.Origin? origin, string? group_id) + AddUnapprovedTransaction(TxDataUnion tx_data_union, AccountId from, url.mojom.Origin? origin) => (bool success, string tx_meta_id, string error_message); // Used to approve a transaction diff --git a/components/brave_wallet_ui/common/async/lib.ts b/components/brave_wallet_ui/common/async/lib.ts index 65087a646009..eb5dfa5dd9f2 100644 --- a/components/brave_wallet_ui/common/async/lib.ts +++ b/components/brave_wallet_ui/common/async/lib.ts @@ -304,7 +304,6 @@ export async function sendEthTransaction (payload: SendEthTransactionParams) { return await apiProxy.txService.addUnapprovedTransaction( toTxDataUnion({ ethTxData1559: txData1559 }), payload.fromAccount.accountId, - null, null ) } @@ -312,7 +311,6 @@ export async function sendEthTransaction (payload: SendEthTransactionParams) { return await apiProxy.txService.addUnapprovedTransaction( toTxDataUnion({ ethTxData: txData }), payload.fromAccount.accountId, - null, null ) } @@ -331,7 +329,6 @@ export async function sendFilTransaction(payload: SendFilTransactionParams) { return await apiProxy.txService.addUnapprovedTransaction( toTxDataUnion({ filTxData: filTxData }), payload.fromAccount.accountId, - null, null ) } @@ -346,7 +343,6 @@ export async function sendSolTransaction(payload: SendSolTransactionParams) { return await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: value.txData ?? undefined }), payload.fromAccount.accountId, - null, null ) } @@ -369,8 +365,7 @@ export async function sendSolanaSerializedTransaction( return await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: result.txData ?? undefined }), payload.accountId, - null, - payload.groupId || null + null ) } diff --git a/components/brave_wallet_ui/common/constants/mocks.ts b/components/brave_wallet_ui/common/constants/mocks.ts index 10603b67c44f..78741e9cc9e0 100644 --- a/components/brave_wallet_ui/common/constants/mocks.ts +++ b/components/brave_wallet_ui/common/constants/mocks.ts @@ -81,7 +81,6 @@ export const getMockedTransactionInfo = originSpec: 'https://brave.com', eTldPlusOne: 'brave.com' }, - groupId: undefined, effectiveRecipient: '0x8b52c24d6e2600bdb8dbb6e8da849ed38ab7e81f' } } @@ -527,7 +526,6 @@ export const mockSolDappSignAndSendTransactionRequest: SerializableTransactionIn originSpec: 'https://f40y4d.csb.app', eTldPlusOne: 'csb.app' }, - groupId: undefined, effectiveRecipient: undefined } diff --git a/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts b/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts index 6c756373c9a9..6942b62237a8 100644 --- a/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts +++ b/components/brave_wallet_ui/common/hooks/use-pending-transaction.ts @@ -25,7 +25,6 @@ import { getTransactionGasFee, isSolanaTransaction, parseTransactionWithPrices, - sortTransactionByDate, findTransactionToken, isEthereumTransaction } from '../../utils/tx-utils' @@ -467,38 +466,6 @@ export const usePendingTransactions = () => { } }, [transactionInfo]) - // List of all transactions that belong to the same group as the selected - // pending transaction. - const groupTransactions = React.useMemo( - () => - transactionInfo?.groupId - ? sortTransactionByDate( - pendingTransactions.filter( - (txn) => txn.groupId === transactionInfo.groupId - ) - ) - : [], - [transactionInfo, pendingTransactions] - ) - - const unconfirmedGroupTransactionIds = React.useMemo(() => - groupTransactions - .filter(txn => txn.txStatus !== BraveWallet.TransactionStatus.Confirmed) - .map(txn => txn.id), - [groupTransactions]) - - // Position of the selected pending transaction in the group, if exists. - const selectedPendingTransactionGroupIndex = React.useMemo(() => - groupTransactions.findIndex(txn => transactionInfo?.id === txn.id), - [groupTransactions, transactionInfo]) - - // The selected pending transaction can only be approved if: - // - it does not belong to a transaction group - // - it is the first unconfirmed transaction in the group - const canSelectedPendingTransactionBeApproved = React.useMemo(() => - unconfirmedGroupTransactionIds.findIndex(idx => transactionInfo?.id === idx) <= 0, - [transactionInfo, unconfirmedGroupTransactionIds]) - // memos const fromOrb = useAccountOrb(txAccount) const toOrb = useAddressOrb(transactionDetails?.recipient, { scale: 10 }) @@ -554,14 +521,12 @@ export const usePendingTransactions = () => { insufficientFundsError === undefined || !!insufficientFundsForGasError || !!insufficientFundsError || - !!transactionDetails?.missingGasLimitError || - !canSelectedPendingTransactionBeApproved + !!transactionDetails?.missingGasLimitError ) }, [ transactionDetails, hasFeeEstimatesError, isLoadingGasFee, - canSelectedPendingTransactionBeApproved, insufficientFundsError, insufficientFundsForGasError ]) @@ -666,8 +631,6 @@ export const usePendingTransactions = () => { solanaSendOptions: transactionInfo?.txDataUnion.solanaTxData?.sendOptions, updateUnapprovedTransactionGasFields, updateUnapprovedTransactionNonce, - groupTransactions, - selectedPendingTransactionGroupIndex, hasFeeEstimatesError, selectedPendingTransaction: transactionInfo, isLoadingGasFee, diff --git a/components/brave_wallet_ui/common/slices/api.slice.ts b/components/brave_wallet_ui/common/slices/api.slice.ts index 4e004bad8aba..fcd0aaf9bd30 100644 --- a/components/brave_wallet_ui/common/slices/api.slice.ts +++ b/components/brave_wallet_ui/common/slices/api.slice.ts @@ -1619,7 +1619,6 @@ export function createWalletApi () { ? toTxDataUnion({ ethTxData1559: txData1559 }) : toTxDataUnion({ ethTxData: txData }), payload.fromAccount.accountId, - null, null ) @@ -1675,7 +1674,6 @@ export function createWalletApi () { await txService.addUnapprovedTransaction( toTxDataUnion({ filTxData: filTxData }), payload.fromAccount.accountId, - null, null ) @@ -1738,7 +1736,6 @@ export function createWalletApi () { await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: txData ?? undefined }), payload.fromAccount.accountId, - null, null ) @@ -1790,7 +1787,6 @@ export function createWalletApi () { await txService.addUnapprovedTransaction( toTxDataUnion({ btcTxData }), payload.fromAccount.accountId, - null, null ) @@ -1973,7 +1969,6 @@ export function createWalletApi () { await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: txData }), payload.fromAccount.accountId, - null, null ) diff --git a/components/brave_wallet_ui/components/extension/confirm-transaction-panel/confirm-bitcoin-transaction-panel.tsx b/components/brave_wallet_ui/components/extension/confirm-transaction-panel/confirm-bitcoin-transaction-panel.tsx index af48c7b8dea6..f572a27dd855 100644 --- a/components/brave_wallet_ui/components/extension/confirm-transaction-panel/confirm-bitcoin-transaction-panel.tsx +++ b/components/brave_wallet_ui/components/extension/confirm-transaction-panel/confirm-bitcoin-transaction-panel.tsx @@ -5,9 +5,6 @@ import * as React from 'react' -// types -import { BraveWallet } from '../../../constants/types' - // Utils import Amount from '../../../utils/amount' import { WalletSelectors } from '../../../common/selectors' @@ -47,15 +44,7 @@ import { AccountCircleWrapper, ArrowIcon, FromToRow, - GroupBox, - GroupBoxColumn, - GroupBoxTitle, - GroupBoxText, - GroupEnumeration, - SmallLoadIcon } from './style' -import { StatusBubble } from '../../shared/style' -import { getTransactionStatusString } from '../../../utils/tx-utils' type confirmPanelTabs = 'transaction' | 'details' @@ -74,8 +63,6 @@ export const ConfirmBitcoinTransactionPanel = () => { transactionDetails, transactionsNetwork, transactionTitle, - groupTransactions, - selectedPendingTransactionGroupIndex, selectedPendingTransaction, onConfirm, onReject, @@ -164,34 +151,6 @@ export const ConfirmBitcoinTransactionPanel = () => { } - {(groupTransactions.length > 0 && - selectedPendingTransactionGroupIndex >= 0 && - selectedPendingTransaction) && - - - - Transaction group - - { - groupTransactions.map((txn, idx) => - - - [{idx + 1}/{groupTransactions.length}] - - - - - {getTransactionStatusString(txn.txStatus)} - - {[BraveWallet.TransactionStatus.Approved, BraveWallet.TransactionStatus.Submitted] - .includes(txn.txStatus) && } - - ) - } - - - } - { transactionsNetwork, transactionTitle, isSolanaDappTransaction, - groupTransactions, - selectedPendingTransactionGroupIndex, selectedPendingTransaction, onConfirm, onReject, @@ -200,34 +188,6 @@ export const ConfirmSolanaTransactionPanel = () => { } - {(groupTransactions.length > 0 && - selectedPendingTransactionGroupIndex >= 0 && - selectedPendingTransaction) && - - - - Transaction group - - { - groupTransactions.map((txn, idx) => - - - [{idx + 1}/{groupTransactions.length}] - - - - - {getTransactionStatusString(txn.txStatus)} - - {[BraveWallet.TransactionStatus.Approved, BraveWallet.TransactionStatus.Submitted] - .includes(txn.txStatus) && } - - ) - } - - - } - p.theme.color.divider01}; - box-sizing: border-box; - border-radius: 4px; - width: 255px; - min-height: 82px; - padding: 4px 14px; - overflow-y: scroll; - overflow-x: hidden; - position: relative; - margin-top: 10px; - background: ${p => p.theme.color.infoBackground}; -` - -export const GroupBoxColumn = styled.div` - display: flex; - align-items: flex-start; - justify-content: flex-start; - width: 100%; - flex-direction: column; -` - -export const GroupBoxTitle = styled.span` - font-family: Poppins; - font-size: 12px; - font-weight: 600; - line-height: 18px; - letter-spacing: 0.01em; - color: ${(p) => p.theme.color.text02}; - word-break: break-all; -` - -export const GroupBoxText = styled.div<{ dark: boolean }>` - font-family: Poppins; - font-size: 11px; - font-weight: ${(p) => p.dark ? 600 : 400}; - line-height: 18px; - letter-spacing: 0.01em; - color: ${(p) => p.dark ? p.theme.color.text02 : p.theme.color.text03}; - flex: 1; - display: flex; - align-items: center; - justify-content: flex-start; - flex-direction: row; -` - -export const GroupEnumeration = styled.code` - padding-right: 5px; -` - -export const SmallLoadIcon = styled(LoaderIcon)` - color: ${p => p.theme.color.interactive08}; - height: 16px; - width: 16px; - opacity: .4; - padding-left: 5px; -` - export const ContractButton = styled(WalletButton)` display: flex; align-items: center; diff --git a/components/brave_wallet_ui/constants/types.ts b/components/brave_wallet_ui/constants/types.ts index f39543ff202d..6d35553010fb 100644 --- a/components/brave_wallet_ui/constants/types.ts +++ b/components/brave_wallet_ui/constants/types.ts @@ -398,7 +398,6 @@ export interface SolanaSerializedTransactionParams { accountId: BraveWallet.AccountId txType: BraveWallet.TransactionType sendOptions?: BraveWallet.SolanaSendTransactionOptions - groupId?: string } export interface SendEthTransactionParams extends BaseEthTransactionParams { From 430b2af5fdeab03cc5eb0b612637b425ec997212 Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 6 Sep 2023 16:09:28 +0700 Subject: [PATCH 2/5] removed origin from AddUnapprovedTransaction mojo call --- ...llet_button_notification_source_browsertest.cc | 8 ++++---- .../browser/ethereum_provider_impl.cc | 4 ++-- .../brave_wallet/browser/solana_provider_impl.cc | 2 +- components/brave_wallet/browser/tx_service.cc | 8 ++++++++ components/brave_wallet/browser/tx_service.h | 6 +++++- components/brave_wallet/common/brave_wallet.mojom | 3 +-- components/brave_wallet_ui/common/async/lib.ts | 15 +++++---------- .../brave_wallet_ui/common/slices/api.slice.ts | 15 +++++---------- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc b/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc index 47b4b26ea2a5..5ca9b5993ee2 100644 --- a/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc +++ b/browser/ui/views/toolbar/wallet_button_notification_source_browsertest.cc @@ -193,7 +193,7 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, "" /* nonce */, "10" /* gas_premium */, "10" /* gas_fee_cap */, "100" /* gas_limit */, "" /* max_fee */, to_account, "11")); tx_service()->AddUnapprovedTransaction( - std::move(tx_data), from_account->account_id.Clone(), absl::nullopt, + std::move(tx_data), from_account->account_id.Clone(), base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { first_tx_meta_id = id; @@ -236,7 +236,7 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, std::vector(), false, absl::nullopt); tx_service()->AddUnapprovedTransaction( brave_wallet::mojom::TxDataUnion::NewEthTxData(std::move(tx_data)), - from_account->account_id.Clone(), absl::nullopt, + from_account->account_id.Clone(), base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { second_tx_meta_id = id; @@ -269,7 +269,7 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, tx_service()->AddUnapprovedTransaction( brave_wallet::mojom::TxDataUnion::NewSolanaTxData(std::move(tx_data)), - from_account->account_id.Clone(), absl::nullopt, + from_account->account_id.Clone(), base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { third_tx_meta_id = id; @@ -366,7 +366,7 @@ IN_PROC_BROWSER_TEST_F(WalletButtonNotificationSourceTest, "" /* nonce */, "10" /* gas_premium */, "10" /* gas_fee_cap */, "100" /* gas_limit */, "" /* max_fee */, to_account, "11")); tx_service()->AddUnapprovedTransaction( - std::move(tx_data), from_account->account_id.Clone(), absl::nullopt, + std::move(tx_data), from_account->account_id.Clone(), base::BindLambdaForTesting([&](bool success, const std::string& id, const std::string& err_message) { tx_meta_id = id; diff --git a/components/brave_wallet/browser/ethereum_provider_impl.cc b/components/brave_wallet/browser/ethereum_provider_impl.cc index 45d8d7800f12..c9e636ec25b4 100644 --- a/components/brave_wallet/browser/ethereum_provider_impl.cc +++ b/components/brave_wallet/browser/ethereum_provider_impl.cc @@ -301,14 +301,14 @@ void EthereumProviderImpl::OnGetNetworkAndDefaultKeyringInfo( keyring_info->account_infos, from)) { // Set chain_id to current chain_id. tx_data_1559->chain_id = chain->chain_id; - tx_service_->AddUnapprovedTransaction( + tx_service_->AddUnapprovedTransactionWithOrigin( mojom::TxDataUnion::NewEthTxData1559(std::move(tx_data_1559)), account_id.Clone(), origin, base::BindOnce(&EthereumProviderImpl::OnAddUnapprovedTransactionAdapter, weak_factory_.GetWeakPtr(), std::move(callback), std::move(id))); } else { - tx_service_->AddUnapprovedTransaction( + tx_service_->AddUnapprovedTransactionWithOrigin( mojom::TxDataUnion::NewEthTxData(std::move(tx_data_1559->base_data)), account_id.Clone(), origin, base::BindOnce(&EthereumProviderImpl::OnAddUnapprovedTransactionAdapter, diff --git a/components/brave_wallet/browser/solana_provider_impl.cc b/components/brave_wallet/browser/solana_provider_impl.cc index 1b651a9a7769..34e20a372445 100644 --- a/components/brave_wallet/browser/solana_provider_impl.cc +++ b/components/brave_wallet/browser/solana_provider_impl.cc @@ -520,7 +520,7 @@ void SolanaProviderImpl::SignAndSendTransaction( tx.set_send_options( SolanaTransaction::SendOptions::FromValue(std::move(send_options))); - tx_service_->AddUnapprovedTransaction( + tx_service_->AddUnapprovedTransactionWithOrigin( mojom::TxDataUnion::NewSolanaTxData(tx.ToSolanaTxData()), account->account_id.Clone(), delegate_->GetOrigin(), base::BindOnce(&SolanaProviderImpl::OnAddUnapprovedTransaction, diff --git a/components/brave_wallet/browser/tx_service.cc b/components/brave_wallet/browser/tx_service.cc index 92ceddaa541c..21fde182e02c 100644 --- a/components/brave_wallet/browser/tx_service.cc +++ b/components/brave_wallet/browser/tx_service.cc @@ -161,6 +161,14 @@ void TxService::BindFilTxManagerProxy( } void TxService::AddUnapprovedTransaction( + mojom::TxDataUnionPtr tx_data_union, + mojom::AccountIdPtr from, + AddUnapprovedTransactionCallback callback) { + AddUnapprovedTransactionWithOrigin(std::move(tx_data_union), std::move(from), + absl::nullopt, std::move(callback)); +} + +void TxService::AddUnapprovedTransactionWithOrigin( mojom::TxDataUnionPtr tx_data_union, mojom::AccountIdPtr from, const absl::optional& origin, diff --git a/components/brave_wallet/browser/tx_service.h b/components/brave_wallet/browser/tx_service.h index 6d519ddeb427..7880770e51b5 100644 --- a/components/brave_wallet/browser/tx_service.h +++ b/components/brave_wallet/browser/tx_service.h @@ -77,8 +77,12 @@ class TxService : public KeyedService, // mojom::TxService void AddUnapprovedTransaction(mojom::TxDataUnionPtr tx_data_union, mojom::AccountIdPtr from, - const absl::optional& origin, AddUnapprovedTransactionCallback) override; + void AddUnapprovedTransactionWithOrigin( + mojom::TxDataUnionPtr tx_data_union, + mojom::AccountIdPtr from, + const absl::optional& origin, + AddUnapprovedTransactionCallback); void ApproveTransaction(mojom::CoinType coin_type, const std::string& chain_id, const std::string& tx_meta_id, diff --git a/components/brave_wallet/common/brave_wallet.mojom b/components/brave_wallet/common/brave_wallet.mojom index 6040b1c081f4..d97025833fc9 100644 --- a/components/brave_wallet/common/brave_wallet.mojom +++ b/components/brave_wallet/common/brave_wallet.mojom @@ -1493,8 +1493,7 @@ interface TxServiceObserver { // For transaction management such as creation, broadcasting, and storing // transactions. interface TxService { - // Used to add a transaction. Missing origin is expected to come from chrome://wallet. - AddUnapprovedTransaction(TxDataUnion tx_data_union, AccountId from, url.mojom.Origin? origin) + AddUnapprovedTransaction(TxDataUnion tx_data_union, AccountId from) => (bool success, string tx_meta_id, string error_message); // Used to approve a transaction diff --git a/components/brave_wallet_ui/common/async/lib.ts b/components/brave_wallet_ui/common/async/lib.ts index eb5dfa5dd9f2..f2e08f6a1b80 100644 --- a/components/brave_wallet_ui/common/async/lib.ts +++ b/components/brave_wallet_ui/common/async/lib.ts @@ -303,15 +303,13 @@ export async function sendEthTransaction (payload: SendEthTransactionParams) { } return await apiProxy.txService.addUnapprovedTransaction( toTxDataUnion({ ethTxData1559: txData1559 }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) } return await apiProxy.txService.addUnapprovedTransaction( toTxDataUnion({ ethTxData: txData }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) } @@ -328,8 +326,7 @@ export async function sendFilTransaction(payload: SendFilTransactionParams) { } return await apiProxy.txService.addUnapprovedTransaction( toTxDataUnion({ filTxData: filTxData }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) } @@ -342,8 +339,7 @@ export async function sendSolTransaction(payload: SendSolTransactionParams) { ) return await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: value.txData ?? undefined }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) } @@ -364,8 +360,7 @@ export async function sendSolanaSerializedTransaction( return await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: result.txData ?? undefined }), - payload.accountId, - null + payload.accountId ) } diff --git a/components/brave_wallet_ui/common/slices/api.slice.ts b/components/brave_wallet_ui/common/slices/api.slice.ts index fcd0aaf9bd30..4405044c9355 100644 --- a/components/brave_wallet_ui/common/slices/api.slice.ts +++ b/components/brave_wallet_ui/common/slices/api.slice.ts @@ -1618,8 +1618,7 @@ export function createWalletApi () { isEIP1559 ? toTxDataUnion({ ethTxData1559: txData1559 }) : toTxDataUnion({ ethTxData: txData }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) if (!success && errorMessage) { @@ -1673,8 +1672,7 @@ export function createWalletApi () { const { errorMessage, success } = await txService.addUnapprovedTransaction( toTxDataUnion({ filTxData: filTxData }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) if (!success && errorMessage) { @@ -1735,8 +1733,7 @@ export function createWalletApi () { const { errorMessage, success } = await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: txData ?? undefined }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) if (!success && errorMessage) { @@ -1786,8 +1783,7 @@ export function createWalletApi () { const { errorMessage, success } = await txService.addUnapprovedTransaction( toTxDataUnion({ btcTxData }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) if (!success && errorMessage) { @@ -1968,8 +1964,7 @@ export function createWalletApi () { const { errorMessage, success } = await txService.addUnapprovedTransaction( toTxDataUnion({ solanaTxData: txData }), - payload.fromAccount.accountId, - null + payload.fromAccount.accountId ) if (!success) { From 56bf22fb0956b629fb030765795f77f1e5753c8a Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Wed, 6 Sep 2023 16:35:24 +0700 Subject: [PATCH 3/5] use synchronous calls when possible --- .../browser/ethereum_provider_impl.cc | 42 +++++-------------- .../browser/ethereum_provider_impl.h | 27 ++---------- 2 files changed, 15 insertions(+), 54 deletions(-) diff --git a/components/brave_wallet/browser/ethereum_provider_impl.cc b/components/brave_wallet/browser/ethereum_provider_impl.cc index c9e636ec25b4..e3362848f617 100644 --- a/components/brave_wallet/browser/ethereum_provider_impl.cc +++ b/components/brave_wallet/browser/ethereum_provider_impl.cc @@ -244,29 +244,17 @@ void EthereumProviderImpl::SwitchEthereumChain(const std::string& chain_id, } } -void EthereumProviderImpl::ContinueGetDefaultKeyringInfo( +void EthereumProviderImpl::SendOrSignTransactionInternal( RequestCallback callback, base::Value id, const std::string& normalized_json_request, - const url::Origin& origin, - bool sign_only, - mojom::NetworkInfoPtr chain) { - keyring_service_->GetKeyringInfo( - mojom::kDefaultKeyringId, - base::BindOnce(&EthereumProviderImpl::OnGetNetworkAndDefaultKeyringInfo, - weak_factory_.GetWeakPtr(), std::move(callback), - std::move(id), normalized_json_request, origin, - std::move(chain), sign_only)); -} + bool sign_only) { + url::Origin origin = delegate_->GetOrigin(); + mojom::NetworkInfoPtr chain = + json_rpc_service_->GetNetworkSync(mojom::CoinType::ETH, origin); + mojom::KeyringInfoPtr keyring_info = + keyring_service_->GetKeyringInfoSync(mojom::kDefaultKeyringId); -void EthereumProviderImpl::OnGetNetworkAndDefaultKeyringInfo( - RequestCallback callback, - base::Value id, - const std::string& normalized_json_request, - const url::Origin& origin, - mojom::NetworkInfoPtr chain, - bool sign_only, - mojom::KeyringInfoPtr keyring_info) { bool reject = false; if (!chain || !keyring_info) { mojom::ProviderError code = mojom::ProviderError::kInternalError; @@ -930,19 +918,11 @@ void EthereumProviderImpl::CommonRequestOrSendAsync( } SwitchEthereumChain(chain_id, std::move(callback), std::move(id)); } else if (method == kEthSendTransaction) { - json_rpc_service_->GetNetwork( - mojom::CoinType::ETH, delegate_->GetOrigin(), - base::BindOnce(&EthereumProviderImpl::ContinueGetDefaultKeyringInfo, - weak_factory_.GetWeakPtr(), std::move(callback), - std::move(id), normalized_json_request, - delegate_->GetOrigin(), false)); + SendOrSignTransactionInternal(std::move(callback), std::move(id), + std::move(normalized_json_request), false); } else if (method == kEthSignTransaction) { - json_rpc_service_->GetNetwork( - mojom::CoinType::ETH, delegate_->GetOrigin(), - base::BindOnce(&EthereumProviderImpl::ContinueGetDefaultKeyringInfo, - weak_factory_.GetWeakPtr(), std::move(callback), - std::move(id), normalized_json_request, - delegate_->GetOrigin(), true)); + SendOrSignTransactionInternal(std::move(callback), std::move(id), + std::move(normalized_json_request), true); } else if (method == kEthSendRawTransaction) { std::string signed_transaction; if (!ParseEthSendRawTransactionParams(normalized_json_request, diff --git a/components/brave_wallet/browser/ethereum_provider_impl.h b/components/brave_wallet/browser/ethereum_provider_impl.h index fc7db97071a5..fd918a8c6d69 100644 --- a/components/brave_wallet/browser/ethereum_provider_impl.h +++ b/components/brave_wallet/browser/ethereum_provider_impl.h @@ -223,34 +223,15 @@ class EthereumProviderImpl final : public mojom::EthereumProvider, void OnUpdateKnownAccounts(const std::vector& allowed_accounts, mojom::ProviderError error, const std::string& error_message); - - void ContinueGetDefaultKeyringInfo(RequestCallback callback, - base::Value id, - const std::string& normalized_json_request, - const url::Origin& origin, - bool sign_only, - mojom::NetworkInfoPtr chain); - void ContinueGetEncryptionPublicKey( - RequestCallback callback, - base::Value id, - const std::string& address, - const url::Origin& origin, - const std::vector& allowed_accounts, - mojom::ProviderError error, - const std::string& error_message); void ContinueDecryptWithSanitizedJson(RequestCallback callback, base::Value id, const mojom::AccountIdPtr& account_id, const url::Origin& origin, data_decoder::JsonSanitizer::Result); - void OnGetNetworkAndDefaultKeyringInfo( - RequestCallback callback, - base::Value id, - const std::string& normalized_json_request, - const url::Origin& origin, - mojom::NetworkInfoPtr chain, - bool sign_only, - mojom::KeyringInfoPtr keyring_info); + void SendOrSignTransactionInternal(RequestCallback callback, + base::Value id, + const std::string& normalized_json_request, + bool sign_only); // content_settings::Observer: void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, From 8bb62052c5c0675543f25e3c68a816ef65c4b6e0 Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Thu, 7 Sep 2023 14:29:31 +0700 Subject: [PATCH 4/5] proper deps between NotificationService and TxService --- .../asset_discovery_manager_unittest.cc | 1 + .../brave_wallet_service_unittest.cc | 1 + .../ethereum_provider_impl_unittest.cc | 12 +--------- .../brave_wallet/notifications/sources.gni | 1 - .../wallet_notification_helper_impl.cc | 21 ---------------- .../wallet_notification_service.cc | 6 ++++- .../wallet_notification_service.h | 9 +++---- .../wallet_notification_service_factory.cc | 3 ++- .../wallet_notification_service_unittest.cc | 4 ++-- browser/brave_wallet/tx_service_factory.cc | 24 +++++-------------- .../browser/asset_discovery_manager.cc | 1 + .../browser/bitcoin/bitcoin_tx_manager.cc | 1 + .../browser/brave_wallet_service.cc | 2 +- .../browser/eth_allowance_manager.cc | 2 +- .../browser/eth_block_tracker_unittest.cc | 1 + .../browser/ethereum_provider_impl.cc | 1 + .../browser/fil_tx_manager_unittest.cc | 1 + .../brave_wallet/browser/json_rpc_service.cc | 1 + .../brave_wallet/browser/json_rpc_service.h | 2 -- .../brave_wallet/browser/keyring_service.cc | 1 + .../browser/nft_metadata_fetcher.cc | 1 + .../browser/nft_metadata_fetcher_unittest.cc | 1 + .../browser/solana_block_tracker.cc | 1 + .../browser/solana_block_tracker_unittest.cc | 1 + .../browser/solana_tx_manager_unittest.cc | 2 +- components/brave_wallet/browser/tx_service.cc | 3 ++- 26 files changed, 37 insertions(+), 67 deletions(-) delete mode 100644 browser/brave_wallet/notifications/wallet_notification_helper_impl.cc diff --git a/browser/brave_wallet/asset_discovery_manager_unittest.cc b/browser/brave_wallet/asset_discovery_manager_unittest.cc index f3fbe923db7a..5c47e4285d71 100644 --- a/browser/brave_wallet/asset_discovery_manager_unittest.cc +++ b/browser/brave_wallet/asset_discovery_manager_unittest.cc @@ -12,6 +12,7 @@ #include "brave/browser/brave_wallet/json_rpc_service_factory.h" #include "brave/browser/brave_wallet/keyring_service_factory.h" #include "brave/browser/brave_wallet/tx_service_factory.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/brave_wallet_service_delegate.h" #include "brave/components/brave_wallet/browser/brave_wallet_service_observer_base.h" diff --git a/browser/brave_wallet/brave_wallet_service_unittest.cc b/browser/brave_wallet/brave_wallet_service_unittest.cc index a41ccf7f446d..1ce9e17ebd10 100644 --- a/browser/brave_wallet/brave_wallet_service_unittest.cc +++ b/browser/brave_wallet/brave_wallet_service_unittest.cc @@ -20,6 +20,7 @@ #include "brave/browser/brave_wallet/tx_service_factory.h" #include "brave/components/brave_wallet/browser/blockchain_list_parser.h" #include "brave/components/brave_wallet/browser/blockchain_registry.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_service_delegate.h" #include "brave/components/brave_wallet/browser/brave_wallet_service_observer_base.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" diff --git a/browser/brave_wallet/ethereum_provider_impl_unittest.cc b/browser/brave_wallet/ethereum_provider_impl_unittest.cc index 8a1b77955315..9c547269aab9 100644 --- a/browser/brave_wallet/ethereum_provider_impl_unittest.cc +++ b/browser/brave_wallet/ethereum_provider_impl_unittest.cc @@ -32,27 +32,20 @@ #include "brave/browser/brave_wallet/keyring_service_factory.h" #include "brave/browser/brave_wallet/tx_service_factory.h" #include "brave/components/brave_wallet/browser/asset_ratio_service.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" -#include "brave/components/brave_wallet/browser/eth_nonce_tracker.h" -#include "brave/components/brave_wallet/browser/eth_pending_tx_tracker.h" #include "brave/components/brave_wallet/browser/eth_tx_manager.h" -#include "brave/components/brave_wallet/browser/hd_keyring.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" #include "brave/components/brave_wallet/browser/keyring_service.h" -#include "brave/components/brave_wallet/browser/permission_utils.h" -#include "brave/components/brave_wallet/browser/pref_names.h" #include "brave/components/brave_wallet/browser/test_utils.h" #include "brave/components/brave_wallet/browser/tx_service.h" #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" #include "brave/components/brave_wallet/common/hex_utils.h" -#include "brave/components/brave_wallet/common/web3_provider_constants.h" #include "brave/components/permissions/brave_permission_manager.h" -#include "brave/components/permissions/contexts/brave_wallet_permission_context.h" #include "brave/components/version_info/version_info.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/permissions/permission_manager_factory.h" -#include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/scoped_testing_local_state.h" #include "chrome/test/base/testing_browser_process.h" @@ -61,9 +54,6 @@ #include "components/grit/brave_components_strings.h" #include "components/permissions/permission_request_manager.h" #include "components/prefs/pref_service.h" -#include "components/sync_preferences/testing_pref_service_syncable.h" -#include "components/user_prefs/user_prefs.h" -#include "content/public/browser/web_contents.h" #include "content/public/test/browser_task_environment.h" #include "content/public/test/test_web_contents_factory.h" #include "content/test/test_web_contents.h" diff --git a/browser/brave_wallet/notifications/sources.gni b/browser/brave_wallet/notifications/sources.gni index 3aa64aa8e020..81f274bc6fb1 100644 --- a/browser/brave_wallet/notifications/sources.gni +++ b/browser/brave_wallet/notifications/sources.gni @@ -9,7 +9,6 @@ brave_browser_brave_wallet_deps = brave_browser_brave_wallet_sources = [] if (!is_android) { brave_browser_brave_wallet_sources += [ - "//brave/browser/brave_wallet/notifications/wallet_notification_helper_impl.cc", "//brave/browser/brave_wallet/notifications/wallet_notification_service.cc", "//brave/browser/brave_wallet/notifications/wallet_notification_service.h", "//brave/browser/brave_wallet/notifications/wallet_notification_service_factory.cc", diff --git a/browser/brave_wallet/notifications/wallet_notification_helper_impl.cc b/browser/brave_wallet/notifications/wallet_notification_helper_impl.cc deleted file mode 100644 index 074e33ef27d2..000000000000 --- a/browser/brave_wallet/notifications/wallet_notification_helper_impl.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2022 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. */ - -#include "brave/browser/brave_wallet/wallet_notification_helper.h" - -#include "brave/browser/brave_wallet/notifications/wallet_notification_service_factory.h" -#include "brave/components/brave_wallet/browser/tx_service.h" - -namespace brave_wallet { - -void RegisterWalletNotificationService(content::BrowserContext* context, - TxService* tx_service) { - auto* notification_service = - WalletNotificationServiceFactory::GetInstance()->GetServiceForContext( - context); - tx_service->AddObserver(notification_service->GetReceiver()); -} - -} // namespace brave_wallet diff --git a/browser/brave_wallet/notifications/wallet_notification_service.cc b/browser/brave_wallet/notifications/wallet_notification_service.cc index bae793e81ef5..1a28bc5c3b80 100644 --- a/browser/brave_wallet/notifications/wallet_notification_service.cc +++ b/browser/brave_wallet/notifications/wallet_notification_service.cc @@ -9,6 +9,7 @@ #include #include "base/strings/utf_string_conversions.h" +#include "brave/components/brave_wallet/browser/tx_service.h" #include "chrome/browser/notifications/notification_display_service.h" #include "chrome/browser/notifications/notification_display_service_factory.h" #include "chrome/browser/profiles/profile.h" @@ -71,8 +72,11 @@ void PushNotification(content::BrowserContext* context, namespace brave_wallet { WalletNotificationService::WalletNotificationService( + TxService* tx_service, content::BrowserContext* context) - : context_(context) {} + : context_(context) { + tx_service->AddObserver(tx_observer_receiver_.BindNewPipeAndPassRemote()); +} WalletNotificationService::~WalletNotificationService() = default; diff --git a/browser/brave_wallet/notifications/wallet_notification_service.h b/browser/brave_wallet/notifications/wallet_notification_service.h index d92b7024a3aa..c682a55d3d40 100644 --- a/browser/brave_wallet/notifications/wallet_notification_service.h +++ b/browser/brave_wallet/notifications/wallet_notification_service.h @@ -11,7 +11,6 @@ #include "base/memory/raw_ptr.h" #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" #include "components/keyed_service/core/keyed_service.h" -#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" namespace content { @@ -19,11 +18,13 @@ class BrowserContext; } // namespace content namespace brave_wallet { +class TxService; class WalletNotificationService : public KeyedService, public mojom::TxServiceObserver { public: - explicit WalletNotificationService(content::BrowserContext* context); + WalletNotificationService(TxService* tx_service, + content::BrowserContext* context); ~WalletNotificationService() override; WalletNotificationService(const WalletNotificationService&) = delete; WalletNotificationService operator=(const WalletNotificationService&) = @@ -35,10 +36,6 @@ class WalletNotificationService : public KeyedService, void OnTransactionStatusChanged(mojom::TransactionInfoPtr tx_info) override; void OnTxServiceReset() override {} - mojo::PendingRemote GetReceiver() { - return tx_observer_receiver_.BindNewPipeAndPassRemote(); - } - private: friend class WalletNotificationServiceUnitTest; diff --git a/browser/brave_wallet/notifications/wallet_notification_service_factory.cc b/browser/brave_wallet/notifications/wallet_notification_service_factory.cc index 6d7c2fb76c3b..1b5762fcc5f9 100644 --- a/browser/brave_wallet/notifications/wallet_notification_service_factory.cc +++ b/browser/brave_wallet/notifications/wallet_notification_service_factory.cc @@ -35,7 +35,8 @@ WalletNotificationServiceFactory::~WalletNotificationServiceFactory() = default; KeyedService* WalletNotificationServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { - return new WalletNotificationService(context); + return new WalletNotificationService( + TxServiceFactory::GetServiceForContext(context), context); } // static diff --git a/browser/brave_wallet/notifications/wallet_notification_service_unittest.cc b/browser/brave_wallet/notifications/wallet_notification_service_unittest.cc index 122f6ade2312..6fc897ebbc77 100644 --- a/browser/brave_wallet/notifications/wallet_notification_service_unittest.cc +++ b/browser/brave_wallet/notifications/wallet_notification_service_unittest.cc @@ -49,8 +49,8 @@ class WalletNotificationServiceUnitTest : public testing::Test { tx_service_ = std::make_unique( json_rpc_service_.get(), nullptr, keyring_service_.get(), prefs(), temp_dir_.GetPath(), base::SequencedTaskRunner::GetCurrentDefault()); - notification_service_ = - std::make_unique(profile()); + notification_service_ = std::make_unique( + tx_service_.get(), profile()); tester_ = std::make_unique(profile()); keyring_service_->CreateWallet(kMnemonicDivideCruise, "brave", base::DoNothing()); diff --git a/browser/brave_wallet/tx_service_factory.cc b/browser/brave_wallet/tx_service_factory.cc index 37196f50c79a..cca6af0c0943 100644 --- a/browser/brave_wallet/tx_service_factory.cc +++ b/browser/brave_wallet/tx_service_factory.cc @@ -15,16 +15,11 @@ #include "brave/browser/brave_wallet/brave_wallet_context_utils.h" #include "brave/browser/brave_wallet/json_rpc_service_factory.h" #include "brave/browser/brave_wallet/keyring_service_factory.h" -#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/tx_service.h" #include "chrome/browser/profiles/incognito_helpers.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/user_prefs/user_prefs.h" -#if !BUILDFLAG(IS_ANDROID) -#include "brave/browser/brave_wallet/wallet_notification_helper.h" -#endif - namespace brave_wallet { // static @@ -148,19 +143,12 @@ TxServiceFactory::~TxServiceFactory() = default; KeyedService* TxServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { - auto* tx_service = - new TxService(JsonRpcServiceFactory::GetServiceForContext(context), - BitcoinWalletServiceFactory::GetServiceForContext(context), - KeyringServiceFactory::GetServiceForContext(context), - user_prefs::UserPrefs::Get(context), context->GetPath(), - base::SequencedTaskRunner::GetCurrentDefault()); -#if !BUILDFLAG(IS_ANDROID) - // TODO(apaymyshev): WalletNotificationServiceFactory depends on - // TxServiceFactory and should be responsible for subscribing on TxService. - // Refactor this. - RegisterWalletNotificationService(context, tx_service); -#endif - return tx_service; + return new TxService( + JsonRpcServiceFactory::GetServiceForContext(context), + BitcoinWalletServiceFactory::GetServiceForContext(context), + KeyringServiceFactory::GetServiceForContext(context), + user_prefs::UserPrefs::Get(context), context->GetPath(), + base::SequencedTaskRunner::GetCurrentDefault()); } content::BrowserContext* TxServiceFactory::GetBrowserContextToUse( diff --git a/components/brave_wallet/browser/asset_discovery_manager.cc b/components/brave_wallet/browser/asset_discovery_manager.cc index 780bc5d84ef1..0d6bdf191309 100644 --- a/components/brave_wallet/browser/asset_discovery_manager.cc +++ b/components/brave_wallet/browser/asset_discovery_manager.cc @@ -7,6 +7,7 @@ #include +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" diff --git a/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc b/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc index eee7dc127622..37e01450dd2f 100644 --- a/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc +++ b/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.cc @@ -17,6 +17,7 @@ #include "brave/components/brave_wallet/browser/bitcoin/bitcoin_transaction.h" #include "brave/components/brave_wallet/browser/bitcoin/bitcoin_tx_meta.h" #include "brave/components/brave_wallet/browser/bitcoin/bitcoin_tx_state_manager.h" +#include "components/grit/brave_components_strings.h" #include "ui/base/l10n/l10n_util.h" namespace brave_wallet { diff --git a/components/brave_wallet/browser/brave_wallet_service.cc b/components/brave_wallet/browser/brave_wallet_service.cc index 0501a79782fa..3695fb1e4941 100644 --- a/components/brave_wallet/browser/brave_wallet_service.cc +++ b/components/brave_wallet/browser/brave_wallet_service.cc @@ -14,6 +14,7 @@ #include "base/strings/string_util.h" #include "base/values.h" #include "brave/components/brave_wallet/browser/blockchain_registry.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/eth_allowance_manager.h" @@ -22,7 +23,6 @@ #include "brave/components/brave_wallet/browser/pref_names.h" #include "brave/components/brave_wallet/browser/tx_service.h" #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" -#include "brave/components/brave_wallet/common/brave_wallet_constants.h" #include "brave/components/brave_wallet/common/brave_wallet_response_helpers.h" #include "brave/components/brave_wallet/common/brave_wallet_types.h" #include "brave/components/brave_wallet/common/common_utils.h" diff --git a/components/brave_wallet/browser/eth_allowance_manager.cc b/components/brave_wallet/browser/eth_allowance_manager.cc index 9f6ef8a21dc8..8ba843c9b551 100644 --- a/components/brave_wallet/browser/eth_allowance_manager.cc +++ b/components/brave_wallet/browser/eth_allowance_manager.cc @@ -8,8 +8,8 @@ #include #include +#include "base/no_destructor.h" #include "brave/components/brave_wallet/browser/blockchain_registry.h" -#include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" #include "brave/components/brave_wallet/browser/keyring_service.h" #include "brave/components/brave_wallet/browser/pref_names.h" diff --git a/components/brave_wallet/browser/eth_block_tracker_unittest.cc b/components/brave_wallet/browser/eth_block_tracker_unittest.cc index e75c422cea15..aa5fe79e0f81 100644 --- a/components/brave_wallet/browser/eth_block_tracker_unittest.cc +++ b/components/brave_wallet/browser/eth_block_tracker_unittest.cc @@ -14,6 +14,7 @@ #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" #include "brave/components/brave_wallet/common/hex_utils.h" +#include "components/grit/brave_components_strings.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h" #include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" diff --git a/components/brave_wallet/browser/ethereum_provider_impl.cc b/components/brave_wallet/browser/ethereum_provider_impl.cc index e3362848f617..ba8795c91c19 100644 --- a/components/brave_wallet/browser/ethereum_provider_impl.cc +++ b/components/brave_wallet/browser/ethereum_provider_impl.cc @@ -17,6 +17,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "brave/components/brave_wallet/browser/account_resolver_delegate_impl.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_provider_delegate.h" #include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" diff --git a/components/brave_wallet/browser/fil_tx_manager_unittest.cc b/components/brave_wallet/browser/fil_tx_manager_unittest.cc index 6640b44b72ea..658e0a8b4c65 100644 --- a/components/brave_wallet/browser/fil_tx_manager_unittest.cc +++ b/components/brave_wallet/browser/fil_tx_manager_unittest.cc @@ -27,6 +27,7 @@ #include "brave/components/brave_wallet/browser/tx_service.h" #include "brave/components/brave_wallet/common/brave_wallet.mojom.h" #include "brave/components/brave_wallet/common/features.h" +#include "components/grit/brave_components_strings.h" #include "components/sync_preferences/testing_pref_service_syncable.h" #include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h" #include "services/network/public/cpp/resource_request.h" diff --git a/components/brave_wallet/browser/json_rpc_service.cc b/components/brave_wallet/browser/json_rpc_service.cc index facaf208d7a3..35497b8afa28 100644 --- a/components/brave_wallet/browser/json_rpc_service.cc +++ b/components/brave_wallet/browser/json_rpc_service.cc @@ -17,6 +17,7 @@ #include "base/notreached.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/ens_resolver_task.h" diff --git a/components/brave_wallet/browser/json_rpc_service.h b/components/brave_wallet/browser/json_rpc_service.h index 4358f2d66b09..9a9628a31045 100644 --- a/components/brave_wallet/browser/json_rpc_service.h +++ b/components/brave_wallet/browser/json_rpc_service.h @@ -18,9 +18,7 @@ #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" -#include "base/observer_list_threadsafe.h" #include "brave/components/api_request_helper/api_request_helper.h" -#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/ens_resolver_task.h" #include "brave/components/brave_wallet/browser/sns_resolver_task.h" #include "brave/components/brave_wallet/browser/solana_transaction.h" diff --git a/components/brave_wallet/browser/keyring_service.cc b/components/brave_wallet/browser/keyring_service.cc index c74828ef6be0..6a4c4a529eed 100644 --- a/components/brave_wallet/browser/keyring_service.cc +++ b/components/brave_wallet/browser/keyring_service.cc @@ -22,6 +22,7 @@ #include "base/value_iterators.h" #include "base/values.h" #include "brave/components/brave_wallet/browser/bitcoin/bitcoin_keyring.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/ethereum_keyring.h" diff --git a/components/brave_wallet/browser/nft_metadata_fetcher.cc b/components/brave_wallet/browser/nft_metadata_fetcher.cc index 40783197dcb6..55f9ad07915d 100644 --- a/components/brave_wallet/browser/nft_metadata_fetcher.cc +++ b/components/brave_wallet/browser/nft_metadata_fetcher.cc @@ -9,6 +9,7 @@ #include #include "base/base64.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/eth_data_builder.h" #include "brave/components/brave_wallet/browser/eth_response_parser.h" diff --git a/components/brave_wallet/browser/nft_metadata_fetcher_unittest.cc b/components/brave_wallet/browser/nft_metadata_fetcher_unittest.cc index 68544ee49878..54b87dcae503 100644 --- a/components/brave_wallet/browser/nft_metadata_fetcher_unittest.cc +++ b/components/brave_wallet/browser/nft_metadata_fetcher_unittest.cc @@ -11,6 +11,7 @@ #include "base/json/json_reader.h" #include "base/test/bind.h" #include "base/test/task_environment.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" diff --git a/components/brave_wallet/browser/solana_block_tracker.cc b/components/brave_wallet/browser/solana_block_tracker.cc index c38d4e817930..16b7a8f638f5 100644 --- a/components/brave_wallet/browser/solana_block_tracker.cc +++ b/components/brave_wallet/browser/solana_block_tracker.cc @@ -12,6 +12,7 @@ #include "base/functional/bind.h" #include "base/functional/callback_helpers.h" #include "base/logging.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" namespace brave_wallet { diff --git a/components/brave_wallet/browser/solana_block_tracker_unittest.cc b/components/brave_wallet/browser/solana_block_tracker_unittest.cc index c9e12ddfb489..1f85375602cb 100644 --- a/components/brave_wallet/browser/solana_block_tracker_unittest.cc +++ b/components/brave_wallet/browser/solana_block_tracker_unittest.cc @@ -11,6 +11,7 @@ #include "base/scoped_observation.h" #include "base/test/bind.h" #include "base/test/task_environment.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" #include "components/sync_preferences/testing_pref_service_syncable.h" diff --git a/components/brave_wallet/browser/solana_tx_manager_unittest.cc b/components/brave_wallet/browser/solana_tx_manager_unittest.cc index 5cdd521988fe..dfe91242e1d3 100644 --- a/components/brave_wallet/browser/solana_tx_manager_unittest.cc +++ b/components/brave_wallet/browser/solana_tx_manager_unittest.cc @@ -15,8 +15,8 @@ #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "base/test/values_test_util.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" -#include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" #include "brave/components/brave_wallet/browser/keyring_service.h" #include "brave/components/brave_wallet/browser/solana_block_tracker.h" diff --git a/components/brave_wallet/browser/tx_service.cc b/components/brave_wallet/browser/tx_service.cc index 21fde182e02c..932731ed3510 100644 --- a/components/brave_wallet/browser/tx_service.cc +++ b/components/brave_wallet/browser/tx_service.cc @@ -10,16 +10,17 @@ #include "base/notreached.h" #include "brave/components/brave_wallet/browser/account_resolver_delegate_impl.h" #include "brave/components/brave_wallet/browser/bitcoin/bitcoin_tx_manager.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_prefs.h" #include "brave/components/brave_wallet/browser/eth_tx_manager.h" #include "brave/components/brave_wallet/browser/fil_tx_manager.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" #include "brave/components/brave_wallet/browser/solana_tx_manager.h" #include "brave/components/brave_wallet/browser/tx_manager.h" -#include "brave/components/brave_wallet/browser/tx_state_manager.h" #include "brave/components/brave_wallet/browser/tx_storage_delegate_impl.h" #include "brave/components/brave_wallet/common/common_utils.h" #include "brave/components/brave_wallet/common/fil_address.h" +#include "components/grit/brave_components_strings.h" #include "components/value_store/value_store_factory_impl.h" #include "ui/base/l10n/l10n_util.h" #include "url/origin.h" From 39030427e451bbb7193716414f62b5d3be85a550 Mon Sep 17 00:00:00 2001 From: Anton Paymyshev Date: Thu, 14 Sep 2023 11:49:06 +0700 Subject: [PATCH 5/5] fix ci --- .../browser/android_page_appearing_browsertest.cc | 1 + components/brave_wallet/browser/asset_discovery_manager.cc | 1 + components/brave_wallet/browser/asset_ratio_service.cc | 1 + components/brave_wallet/browser/brave_wallet_constants.cc | 7 +++++-- components/brave_wallet/browser/brave_wallet_constants.h | 3 --- .../stories/mock-data/mock-transaction-info.ts | 3 --- .../brave_wallet_ui/stories/wallet-extension-panels.tsx | 7 ------- 7 files changed, 8 insertions(+), 15 deletions(-) diff --git a/components/brave_wallet/browser/android_page_appearing_browsertest.cc b/components/brave_wallet/browser/android_page_appearing_browsertest.cc index 2ca28e4d8121..18619e9c553f 100644 --- a/components/brave_wallet/browser/android_page_appearing_browsertest.cc +++ b/components/brave_wallet/browser/android_page_appearing_browsertest.cc @@ -15,6 +15,7 @@ #include "brave/components/brave_shields/browser/ad_block_service.h" #include "brave/components/brave_wallet/browser/asset_ratio_service.h" #include "brave/components/brave_wallet/browser/blockchain_registry.h" +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" #include "brave/components/brave_wallet/browser/json_rpc_service.h" diff --git a/components/brave_wallet/browser/asset_discovery_manager.cc b/components/brave_wallet/browser/asset_discovery_manager.cc index 0d6bdf191309..90da1ea9a19a 100644 --- a/components/brave_wallet/browser/asset_discovery_manager.cc +++ b/components/brave_wallet/browser/asset_discovery_manager.cc @@ -7,6 +7,7 @@ #include +#include "base/no_destructor.h" #include "brave/components/brave_wallet/browser/brave_wallet_constants.h" #include "brave/components/brave_wallet/browser/brave_wallet_service.h" #include "brave/components/brave_wallet/browser/brave_wallet_utils.h" diff --git a/components/brave_wallet/browser/asset_ratio_service.cc b/components/brave_wallet/browser/asset_ratio_service.cc index 271bec2c14f0..a4f5d42064b0 100644 --- a/components/brave_wallet/browser/asset_ratio_service.cc +++ b/components/brave_wallet/browser/asset_ratio_service.cc @@ -12,6 +12,7 @@ #include "base/base64.h" #include "base/environment.h" #include "base/json/json_writer.h" +#include "base/no_destructor.h" #include "base/strings/stringprintf.h" #include "brave/components/api_request_helper/api_request_helper.h" #include "brave/components/brave_wallet/browser/brave_wallet_constants.h" diff --git a/components/brave_wallet/browser/brave_wallet_constants.cc b/components/brave_wallet/browser/brave_wallet_constants.cc index b5eb61b24f6b..8d7ab0975ad7 100644 --- a/components/brave_wallet/browser/brave_wallet_constants.cc +++ b/components/brave_wallet/browser/brave_wallet_constants.cc @@ -3,13 +3,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at https://mozilla.org/MPL/2.0/. */ +#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" + #include #include #include "base/command_line.h" #include "base/containers/contains.h" -#include "brave/components/brave_wallet/browser/brave_wallet_constants.h" -#include "brave/components/brave_wallet/common/brave_wallet.mojom-shared.h" +#include "base/no_destructor.h" +#include "brave/components/brave_wallet/common/brave_wallet.mojom.h" +#include "brave/components/brave_wallet/common/switches.h" namespace brave_wallet { diff --git a/components/brave_wallet/browser/brave_wallet_constants.h b/components/brave_wallet/browser/brave_wallet_constants.h index 08141e375e27..b63b9ec7325a 100644 --- a/components/brave_wallet/browser/brave_wallet_constants.h +++ b/components/brave_wallet/browser/brave_wallet_constants.h @@ -9,10 +9,7 @@ #include #include -#include "base/no_destructor.h" -#include "brave/components/brave_wallet/common/brave_wallet.mojom.h" #include "brave/components/brave_wallet/common/brave_wallet_types.h" -#include "brave/components/brave_wallet/common/switches.h" #include "components/grit/brave_components_strings.h" #include "ui/base/webui/web_ui_util.h" diff --git a/components/brave_wallet_ui/stories/mock-data/mock-transaction-info.ts b/components/brave_wallet_ui/stories/mock-data/mock-transaction-info.ts index 3c3fdbdcc3e1..c59acd1fa53d 100644 --- a/components/brave_wallet_ui/stories/mock-data/mock-transaction-info.ts +++ b/components/brave_wallet_ui/stories/mock-data/mock-transaction-info.ts @@ -56,7 +56,6 @@ export const mockTransactionInfo: SerializableTransactionInfo = { submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '0x0d8775f648430679a709e98d2b0cb6250d2887ef' } @@ -104,7 +103,6 @@ export const mockSolanaTransactionInfo: SerializableTransactionInfo = { submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: undefined } @@ -114,7 +112,6 @@ export const mockFilSendTransaction: FileCoinTransactionInfo = { createdTime: { microseconds: BigInt(new Date().getUTCMilliseconds()) }, fromAddress: mockFilecoinAccount.address, fromAccountId: mockFilecoinAccount.accountId, - groupId: undefined, id: 'fil-send-tx', originInfo: undefined, submittedTime: { microseconds: BigInt(new Date().getUTCMilliseconds()) }, diff --git a/components/brave_wallet_ui/stories/wallet-extension-panels.tsx b/components/brave_wallet_ui/stories/wallet-extension-panels.tsx index ac944aada234..fe8e360cbccc 100644 --- a/components/brave_wallet_ui/stories/wallet-extension-panels.tsx +++ b/components/brave_wallet_ui/stories/wallet-extension-panels.tsx @@ -149,7 +149,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: (Date.now() * 1000) - 1000 * 60 * 5 }, confirmedTime: { microseconds: (Date.now() * 1000) - 1000 * 60 * 5 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' }, { @@ -186,7 +185,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' }, { @@ -223,7 +221,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' }, { @@ -260,7 +257,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' }, { @@ -297,7 +293,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' } ], @@ -336,7 +331,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' }, { @@ -373,7 +367,6 @@ const transactionDummyData: SerializableTransactionInfo[][] = [ submittedTime: { microseconds: 0 }, confirmedTime: { microseconds: 0 }, originInfo: mockOriginInfo, - groupId: undefined, effectiveRecipient: '' } ]