Remove kBraveWalletFilecoinFeature, kBraveWalletSolanaFeature, kCreateDefaultSolanaAccount feature flags

This commit is contained in:
Jocelyn Liu
2023-11-10 08:18:12 -08:00
parent 53d66c3ef5
commit f93340aa57
36 changed files with 111 additions and 462 deletions
@@ -13,8 +13,6 @@ public abstract class BraveFeatureList {
public static final String USE_DEV_UPDATER_URL = "UseDevUpdaterUrl";
public static final String FORCE_WEB_CONTENTS_DARK_MODE = "WebContentsForceDark";
public static final String ENABLE_FORCE_DARK = "enable-force-dark";
public static final String BRAVE_WALLET_SOLANA = "BraveWalletSolana";
public static final String BRAVE_WALLET_FILECOIN = "BraveWalletFilecoin";
public static final String BRAVE_SEARCH_OMNIBOX_BANNER = "BraveSearchOmniboxBanner";
public static final String BRAVE_BACKGROUND_VIDEO_PLAYBACK = "BraveBackgroundVideoPlayback";
public static final String BRAVE_BACKGROUND_VIDEO_PLAYBACK_INTERNAL =
@@ -11,7 +11,6 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import org.chromium.base.BraveFeatureList;
import org.chromium.brave_wallet.mojom.AccountInfo;
import org.chromium.brave_wallet.mojom.AssetRatioService;
import org.chromium.brave_wallet.mojom.BlockchainRegistry;
@@ -31,7 +30,6 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.crypto_wallet.adapters.WalletCoinAdapter;
import org.chromium.chrome.browser.crypto_wallet.model.CryptoAccountTypeInfo;
import org.chromium.chrome.browser.crypto_wallet.util.PendingTxHelper;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.mojo.bindings.Callbacks.Callback1;
import java.util.ArrayList;
@@ -181,18 +179,20 @@ public class CryptoModel {
mContext.getString(R.string.brave_wallet_create_account_ethereum_description),
mContext.getString(R.string.wallet_eth_name), CoinType.ETH, R.drawable.eth));
if (isSolanaEnabled()) {
cryptoAccountTypeInfos.add(new CryptoAccountTypeInfo(
mContext.getString(R.string.brave_wallet_create_account_solana_description),
mContext.getString(R.string.wallet_sol_name), CoinType.SOL,
R.drawable.ic_sol_asset_icon));
}
if (isFilecoinEnabled()) {
cryptoAccountTypeInfos.add(new CryptoAccountTypeInfo(
mContext.getString(R.string.brave_wallet_create_account_filecoin_description),
mContext.getString(R.string.wallet_fil_name), CoinType.FIL,
R.drawable.ic_fil_asset_icon));
}
cryptoAccountTypeInfos.add(
new CryptoAccountTypeInfo(
mContext.getString(R.string.brave_wallet_create_account_solana_description),
mContext.getString(R.string.wallet_sol_name),
CoinType.SOL,
R.drawable.ic_sol_asset_icon));
cryptoAccountTypeInfos.add(
new CryptoAccountTypeInfo(
mContext.getString(
R.string.brave_wallet_create_account_filecoin_description),
mContext.getString(R.string.wallet_fil_name),
CoinType.FIL,
R.drawable.ic_fil_asset_icon));
return cryptoAccountTypeInfos;
}
@@ -227,14 +227,6 @@ public class CryptoModel {
mBraveWalletService, mJsonRpcService, mBlockchainRegistry, mSharedData, type);
}
public boolean isSolanaEnabled() {
return ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_WALLET_SOLANA);
}
public boolean isFilecoinEnabled() {
return ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_WALLET_FILECOIN);
}
public void updateCoinType() {
updateCoinType(null, null);
}
-16
View File
@@ -218,22 +218,6 @@
FEATURE_VALUE_TYPE( \
brave_wallet::features::kNativeBraveWalletFeature), \
}, \
{ \
"brave-wallet-filecoin", \
"Enable Brave Wallet Filecoin support", \
"Filecoin support for native Brave Wallet", \
kOsDesktop | kOsAndroid, \
FEATURE_VALUE_TYPE( \
brave_wallet::features::kBraveWalletFilecoinFeature), \
}, \
{ \
"brave-wallet-solana", \
"Enable Brave Wallet Solana support", \
"Solana support for native Brave Wallet", \
kOsDesktop | kOsAndroid, \
FEATURE_VALUE_TYPE( \
brave_wallet::features::kBraveWalletSolanaFeature), \
}, \
{ \
"brave-wallet-bitcoin", \
"Enable Brave Wallet Bitcoin support", \
@@ -13,7 +13,6 @@
#include "brave/components/brave_wallet/browser/keyring_service.h"
#include "brave/components/brave_wallet/browser/pref_names.h"
#include "brave/components/brave_wallet/common/brave_wallet.mojom.h"
#include "brave/components/brave_wallet/common/features.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -53,16 +52,6 @@ class BraveWalletP3AUnitTest : public testing::Test {
};
TEST_F(BraveWalletP3AUnitTest, KeyringCreated) {
base::test::ScopedFeatureList feature_list;
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(
brave_wallet::features::kBraveWalletSolanaFeature, parameters);
feature_list.InitWithFeaturesAndParameters(enabled_features, {});
histogram_tester_->ExpectBucketCount(kKeyringCreatedHistogramName, 0, 1);
keyring_service_->CreateWallet("testing123", base::DoNothing());
WaitForResponse();
+22 -143
View File
@@ -1121,11 +1121,6 @@ TEST_F(KeyringServiceUnitTest, ValidatePassword) {
}
TEST_F(KeyringServiceUnitTest, LockAndUnlock) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({features::kBraveWalletFilecoinFeature,
features::kBraveWalletSolanaFeature},
{});
{
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
// No encryptor but there is no keyring created so they should be unlocked.
@@ -1235,9 +1230,6 @@ TEST_F(KeyringServiceUnitTest, BackupComplete) {
}
TEST_F(KeyringServiceUnitTest, AccountMetasForKeyring) {
base::test::ScopedFeatureList feature_list{
features::kBraveWalletFilecoinFeature};
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(RestoreWallet(&service, kMnemonicDivideCruise, "brave", false));
@@ -1310,9 +1302,6 @@ TEST_F(KeyringServiceUnitTest, AccountMetasForKeyring) {
}
TEST_F(KeyringServiceUnitTest, MigrateDerivedAccountIndex) {
base::test::ScopedFeatureList feature_list{
features::kBraveWalletFilecoinFeature};
{
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(RestoreWallet(&service, kMnemonicDivideCruise, "brave", false));
@@ -1440,16 +1429,6 @@ TEST_F(KeyringServiceUnitTest, MigrateDerivedAccountIndex) {
}
TEST_F(KeyringServiceUnitTest, CreateAndRestoreWallet) {
base::test::ScopedFeatureList feature_list;
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(features::kBraveWalletSolanaFeature,
parameters);
feature_list.InitWithFeaturesAndParameters(enabled_features, {});
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
NiceMock<TestKeyringServiceObserver> observer(service);
@@ -1463,10 +1442,13 @@ TEST_F(KeyringServiceUnitTest, CreateAndRestoreWallet) {
std::vector<mojom::AccountInfoPtr> account_infos =
service.GetAccountInfosForKeyring(mojom::kDefaultKeyringId);
std::vector<mojom::AccountInfoPtr> solana_account_infos =
service.GetAccountInfosForKeyring(mojom::kSolanaKeyringId);
EXPECT_EQ(account_infos.size(), 1u);
EXPECT_EQ(account_infos[0], service.GetSelectedWalletAccount());
EXPECT_EQ(account_infos[0], service.GetSelectedEthereumDappAccount());
EXPECT_FALSE(service.GetSelectedSolanaDappAccount());
EXPECT_EQ(solana_account_infos.size(), 1u);
EXPECT_EQ(solana_account_infos[0], service.GetSelectedWalletAccount());
EXPECT_EQ(solana_account_infos[0], service.GetSelectedSolanaDappAccount());
EXPECT_FALSE(account_infos[0]->address.empty());
const std::string address0 = account_infos[0]->address;
@@ -1482,7 +1464,6 @@ TEST_F(KeyringServiceUnitTest, CreateAndRestoreWallet) {
std::vector<mojom::AccountInfoPtr> account_infos =
service.GetAccountInfosForKeyring(mojom::kDefaultKeyringId);
EXPECT_EQ(account_infos.size(), 1u);
EXPECT_EQ(account_infos[0], service.GetSelectedWalletAccount());
EXPECT_EQ(account_infos[0], service.GetSelectedEthereumDappAccount());
EXPECT_EQ(account_infos[0]->address, address0);
EXPECT_EQ(account_infos[0]->name, "Account 1");
@@ -1504,8 +1485,9 @@ TEST_F(KeyringServiceUnitTest, CreateAndRestoreWallet) {
{
std::vector<mojom::AccountInfoPtr> account_infos =
service.GetAccountInfosForKeyring(mojom::kSolanaKeyringId);
EXPECT_EQ(account_infos.size(), 0u);
EXPECT_FALSE(service.GetSelectedSolanaDappAccount());
EXPECT_EQ(account_infos.size(), 1u);
EXPECT_EQ(account_infos[0], service.GetSelectedWalletAccount());
EXPECT_EQ(account_infos[0], service.GetSelectedSolanaDappAccount());
}
});
observer.WaitAndVerify();
@@ -1824,16 +1806,6 @@ TEST_F(KeyringServiceUnitTest, ImportedAccountFromJson) {
}
TEST_F(KeyringServiceUnitTest, EncodePrivateKeyForExport) {
base::test::ScopedFeatureList feature_list;
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(features::kBraveWalletSolanaFeature,
parameters);
feature_list.InitWithFeaturesAndParameters(enabled_features, {});
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(RestoreWallet(&service, kMnemonicDivideCruise, "brave", false));
@@ -1877,13 +1849,6 @@ TEST_F(KeyringServiceUnitTest, EncodePrivateKeyForExport) {
mojom::AccountKind::kDerived, "0x123")));
// Other keyrings
// account not added yet
EXPECT_FALSE(EncodePrivateKeyForExport(
&service, MakeAccountId(mojom::CoinType::SOL, mojom::kSolanaKeyringId,
mojom::AccountKind::kDerived,
"BrG44HdsEhzapvs8bEqzvkq4egwevS3fRE6ze2ENo6S8")));
ASSERT_TRUE(AddAccount(&service, mojom::CoinType::SOL,
mojom::kSolanaKeyringId, "Account 1"));
// Wrong password.
EXPECT_FALSE(EncodePrivateKeyForExport(
&service,
@@ -2107,9 +2072,6 @@ TEST_F(KeyringServiceUnitTest, RestoreLegacyBraveWallet) {
}
TEST_F(KeyringServiceUnitTest, HardwareAccounts) {
base::test::ScopedFeatureList feature_list{
features::kBraveWalletFilecoinFeature};
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
SetNetwork(mojom::kFilecoinMainnet, mojom::CoinType::FIL);
@@ -2457,16 +2419,6 @@ TEST_F(KeyringServiceUnitTest, NotifyUserInteraction) {
}
TEST_F(KeyringServiceUnitTest, SelectAddedAccount) {
base::test::ScopedFeatureList feature_list;
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(features::kBraveWalletSolanaFeature,
parameters);
feature_list.InitWithFeaturesAndParameters(enabled_features, {});
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(CreateWallet(&service, "brave"));
@@ -2589,11 +2541,6 @@ TEST_F(KeyringServiceUnitTest, SelectHardwareAccount) {
}
TEST_F(KeyringServiceUnitTest, SetSelectedAccount) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({features::kBraveWalletFilecoinFeature,
features::kBraveWalletSolanaFeature},
{});
const mojom::AccountInfoPtr empty_account;
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
@@ -3176,9 +3123,6 @@ TEST_F(KeyringServiceUnitTest, AddFilecoinAccounts) {
service.Reset();
}
base::test::ScopedFeatureList feature_list{
features::kBraveWalletFilecoinFeature};
ASSERT_TRUE(CreateWallet(&service, "brave"));
ASSERT_TRUE(ImportAccount(
@@ -3223,9 +3167,6 @@ TEST_F(KeyringServiceUnitTest, AddFilecoinAccounts) {
}
TEST_F(KeyringServiceUnitTest, ImportFilecoinAccounts) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(features::kBraveWalletFilecoinFeature);
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(CreateWallet(&service, "brave"));
@@ -3382,33 +3323,8 @@ TEST_F(KeyringServiceUnitTest, ImportFilecoinAccounts) {
}
TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) {
base::test::ScopedFeatureList feature_list;
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(features::kBraveWalletSolanaFeature,
parameters);
feature_list.InitWithFeaturesAndParameters(enabled_features, {});
{
// Create default wallet with disabled filecoin feature.
// Solana feature is enabled on desktop and disabled on Android.
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(CreateWallet(&service, "brave"));
EXPECT_NE(service.encryptors_.at(mojom::kDefaultKeyringId), nullptr);
EXPECT_NE(service.encryptors_.at(mojom::kSolanaKeyringId), nullptr);
EXPECT_NE(service.encryptors_.at(mojom::kFilecoinKeyringId), nullptr);
service.Reset();
}
{
// Create wallet with enabled filecoin & solana
base::test::ScopedFeatureList local_feature_list;
local_feature_list.InitWithFeatures({features::kBraveWalletFilecoinFeature,
features::kBraveWalletSolanaFeature},
{});
// Create wallet
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(CreateWallet(&service, "brave"));
EXPECT_NE(service.encryptors_.at(mojom::kDefaultKeyringId), nullptr);
@@ -3417,17 +3333,13 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) {
service.Reset();
}
{
// Create wallet and enable filecoin & solana before unlock
// Create wallet and unlock
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
ASSERT_TRUE(CreateWallet(&service, "brave"));
EXPECT_NE(service.encryptors_.at(mojom::kDefaultKeyringId), nullptr);
EXPECT_NE(service.encryptors_.at(mojom::kSolanaKeyringId), nullptr);
EXPECT_NE(service.encryptors_.at(mojom::kFilecoinKeyringId), nullptr);
service.Lock();
base::test::ScopedFeatureList local_feature_list;
local_feature_list.InitWithFeatures({features::kBraveWalletFilecoinFeature,
features::kBraveWalletSolanaFeature},
{});
ASSERT_TRUE(Unlock(&service, "brave"));
EXPECT_NE(service.encryptors_.at(mojom::kDefaultKeyringId), nullptr);
@@ -3436,7 +3348,7 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) {
service.Reset();
}
{
// Create default wallet and enable filecoin solana before restore
// Create default wallet and restore
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
absl::optional<std::string> mnemonic_to_be_restored =
CreateWallet(&service, "brave");
@@ -3449,19 +3361,6 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) {
EXPECT_NE(service.encryptors_.at(mojom::kSolanaKeyringId), nullptr);
EXPECT_NE(service.encryptors_.at(mojom::kFilecoinKeyringId), nullptr);
base::test::ScopedFeatureList local_feature_list;
base::FieldTrialParams local_parameters;
local_parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> local_enabled_features;
local_enabled_features.emplace_back(features::kBraveWalletSolanaFeature,
local_parameters);
local_enabled_features.emplace_back(features::kBraveWalletFilecoinFeature,
base::FieldTrialParams());
local_feature_list.InitWithFeaturesAndParameters(local_enabled_features,
{});
service.Reset();
NiceMock<TestKeyringServiceObserver> observer(service);
@@ -3478,23 +3377,11 @@ TEST_F(KeyringServiceUnitTest, PreCreateEncryptors) {
}
TEST_F(KeyringServiceUnitTest, SolanaKeyring) {
base::test::ScopedFeatureList feature_list;
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(features::kBraveWalletSolanaFeature,
parameters);
feature_list.InitWithFeaturesAndParameters(enabled_features, {});
{
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
NiceMock<TestKeyringServiceObserver> observer(service);
ASSERT_TRUE(CreateWallet(&service, "brave"));
ASSERT_TRUE(AddAccount(&service, mojom::CoinType::SOL,
mojom::kSolanaKeyringId, "Account 1"));
ASSERT_TRUE(AddAccount(&service, mojom::CoinType::SOL,
mojom::kSolanaKeyringId, "Account 2"));
@@ -3503,7 +3390,7 @@ TEST_F(KeyringServiceUnitTest, SolanaKeyring) {
auto account_infos = GetAccountUtils(&service).AllSolAccounts();
EXPECT_EQ(account_infos.size(), 2u);
EXPECT_EQ(account_infos[0]->name, "Account 1");
EXPECT_EQ(account_infos[0]->name, "Solana Account 1");
EXPECT_EQ(account_infos[0]->account_id->kind, mojom::AccountKind::kDerived);
EXPECT_EQ(account_infos[1]->name, "Account 2");
EXPECT_EQ(account_infos[1]->account_id->kind, mojom::AccountKind::kDerived);
@@ -3518,12 +3405,9 @@ TEST_F(KeyringServiceUnitTest, SolanaKeyring) {
ASSERT_TRUE(RestoreWallet(&service, kMnemonicDivideCruise, "brave", false));
observer.WaitAndVerify();
ASSERT_TRUE(AddAccount(&service, mojom::CoinType::SOL,
mojom::kSolanaKeyringId, "Account 1"));
auto account_infos = GetAccountUtils(&service).AllSolAccounts();
EXPECT_EQ(account_infos.size(), 1u);
EXPECT_EQ(account_infos[0]->name, "Account 1");
EXPECT_EQ(account_infos[0]->name, "Solana Account 1");
EXPECT_EQ(account_infos[0]->address,
"BrG44HdsEhzapvs8bEqzvkq4egwevS3fRE6ze2ENo6S8");
EXPECT_EQ(account_infos[0]->account_id->kind, mojom::AccountKind::kDerived);
@@ -3579,22 +3463,22 @@ TEST_F(KeyringServiceUnitTest, SolanaKeyring) {
RemoveAccount(&service, imported_account->account_id, kPasswordBrave));
auto account_infos = GetAccountUtils(&service).AllSolAccounts();
ASSERT_EQ(account_infos.size(), 1u);
EXPECT_EQ(account_infos[0]->name, "Imported Account 1");
EXPECT_EQ(account_infos[0]->address,
ASSERT_EQ(account_infos.size(), 2u);
EXPECT_EQ(account_infos[1]->name, "Imported Account 1");
EXPECT_EQ(account_infos[1]->address,
"C5ukMV73nk32h52MjxtnZXTrrr7rupD9CTDDRnYYDRYQ");
EXPECT_EQ(account_infos[0]->account_id->kind,
EXPECT_EQ(account_infos[1]->account_id->kind,
mojom::AccountKind::kImported);
service.Lock();
EXPECT_TRUE(Unlock(&service, "brave"));
// imported accounts persist after lock & unlock
account_infos = GetAccountUtils(&service).AllSolAccounts();
ASSERT_EQ(account_infos.size(), 1u);
EXPECT_EQ(account_infos[0]->name, "Imported Account 1");
EXPECT_EQ(account_infos[0]->address,
ASSERT_EQ(account_infos.size(), 2u);
EXPECT_EQ(account_infos[1]->name, "Imported Account 1");
EXPECT_EQ(account_infos[1]->address,
"C5ukMV73nk32h52MjxtnZXTrrr7rupD9CTDDRnYYDRYQ");
EXPECT_EQ(account_infos[0]->account_id->kind,
EXPECT_EQ(account_infos[1]->account_id->kind,
mojom::AccountKind::kImported);
service.Reset();
@@ -4092,11 +3976,7 @@ TEST_F(KeyringServiceAccountDiscoveryUnitTest, RestoreWalletTwice) {
class KeyringServiceEncryptionKeysMigrationUnitTest
: public KeyringServiceUnitTest {
public:
KeyringServiceEncryptionKeysMigrationUnitTest() {
feature_list_.InitWithFeatures({features::kBraveWalletFilecoinFeature,
features::kBraveWalletSolanaFeature},
{});
}
KeyringServiceEncryptionKeysMigrationUnitTest() {}
void SetupKeyring() {
KeyringService service(json_rpc_service(), GetPrefs(), GetLocalState());
@@ -4229,7 +4109,6 @@ class KeyringServiceEncryptionKeysMigrationUnitTest
private:
std::string saved_mnemonic_;
base::test::ScopedFeatureList feature_list_;
};
TEST_F(KeyringServiceEncryptionKeysMigrationUnitTest, NoMigration) {
@@ -4,13 +4,11 @@
* You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/values_test_util.h"
#include "brave/browser/brave_wallet/asset_ratio_service_factory.h"
#include "brave/browser/brave_wallet/brave_wallet_service_factory.h"
@@ -29,7 +27,6 @@
#include "brave/components/brave_wallet/common/brave_wallet_constants.h"
#include "brave/components/brave_wallet/common/common_utils.h"
#include "brave/components/brave_wallet/common/encoding_utils.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/brave_wallet/common/solana_utils.h"
#include "brave/components/brave_wallet/renderer/resource_helper.h"
#include "brave/components/constants/brave_paths.h"
@@ -334,13 +331,6 @@ class SolanaProviderTest : public InProcessBrowserTest {
SolanaProviderTest()
: https_server_for_files_(net::EmbeddedTestServer::TYPE_HTTPS),
https_server_for_rpc_(net::EmbeddedTestServer::TYPE_HTTPS) {
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(
brave_wallet::features::kBraveWalletSolanaFeature, parameters);
feature_list_.InitWithFeaturesAndParameters(enabled_features, {});
}
~SolanaProviderTest() override = default;
@@ -719,7 +709,6 @@ class SolanaProviderTest : public InProcessBrowserTest {
private:
TestTxServiceObserver observer_;
base::test::ScopedFeatureList feature_list_;
net::test_server::EmbeddedTestServer https_server_for_files_;
net::test_server::EmbeddedTestServer https_server_for_rpc_;
raw_ptr<TxService> tx_service_ = nullptr;
@@ -8,11 +8,9 @@
#include "base/containers/cxx20_erase_vector.h"
#include "brave/components/brave_wallet/browser/solana_provider_impl.h"
#include "base/feature_list.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "brave/browser/brave_wallet/brave_wallet_provider_delegate_impl.h"
#include "brave/browser/brave_wallet/brave_wallet_provider_delegate_impl_helper.h"
#include "brave/browser/brave_wallet/brave_wallet_service_delegate_impl.h"
@@ -30,7 +28,6 @@
#include "brave/components/brave_wallet/browser/tx_service.h"
#include "brave/components/brave_wallet/common/brave_wallet_constants.h"
#include "brave/components/brave_wallet/common/encoding_utils.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/brave_wallet/common/solana_utils.h"
#include "brave/components/permissions/brave_permission_manager.h"
#include "brave/components/permissions/contexts/brave_wallet_permission_context.h"
@@ -97,8 +94,6 @@ class SolanaProviderImplUnitTest : public testing::Test {
: shared_url_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_)) {
feature_list_.InitAndEnableFeature(
brave_wallet::features::kBraveWalletSolanaFeature);
}
~SolanaProviderImplUnitTest() override = default;
@@ -488,7 +483,6 @@ class SolanaProviderImplUnitTest : public testing::Test {
content::BrowserTaskEnvironment browser_task_environment_;
content::TestWebContentsFactory factory_;
TestingProfile profile_;
base::test::ScopedFeatureList feature_list_;
data_decoder::test::InProcessDataDecoder in_process_data_decoder_;
network::TestURLLoaderFactory url_loader_factory_;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory_;
@@ -10,7 +10,6 @@
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "brave/browser/brave_content_browser_client.h"
#include "brave/browser/brave_wallet/keyring_service_factory.h"
#include "brave/browser/profiles/brave_renderer_updater.h"
@@ -532,8 +531,6 @@ class SolanaProviderRendererTest : public InProcessBrowserTest {
public:
SolanaProviderRendererTest()
: https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {
feature_list_.InitWithFeatures(
{brave_wallet::features::kBraveWalletSolanaFeature}, {});
brave::RegisterPathProvider();
base::FilePath test_data_dir;
base::PathService::Get(brave::DIR_TEST_DATA, &test_data_dir);
@@ -597,27 +594,12 @@ class SolanaProviderRendererTest : public InProcessBrowserTest {
protected:
net::EmbeddedTestServer https_server_;
TestBraveContentBrowserClient test_content_browser_client_;
base::test::ScopedFeatureList feature_list_;
private:
content::ContentMockCertVerifier mock_cert_verifier_;
net::test_server::EmbeddedTestServerHandle test_server_handle_;
};
class SolanaProviderDisabledTest : public SolanaProviderRendererTest {
public:
SolanaProviderDisabledTest() {
feature_list_.Reset();
feature_list_.InitAndDisableFeature(
brave_wallet::features::kBraveWalletSolanaFeature);
}
};
IN_PROC_BROWSER_TEST_F(SolanaProviderDisabledTest, SolanaObject) {
auto result = EvalJs(web_contents(browser()), CheckSolanaProviderScript);
EXPECT_EQ(base::Value(false), result.value);
}
IN_PROC_BROWSER_TEST_F(SolanaProviderRendererTest, Incognito) {
Browser* private_browser = CreateIncognitoBrowser(nullptr);
GURL url = embedded_test_server()->GetURL("/empty.html");
@@ -35,9 +35,8 @@ void WalletHandler::GetWalletInfo(GetWalletInfoCallback callback) {
std::move(callback).Run(mojom::WalletInfo::New(
keyring_service_->IsWalletCreatedSync(), keyring_service_->IsLockedSync(),
keyring_service_->IsWalletBackedUpSync(), IsFilecoinEnabled(),
IsSolanaEnabled(), IsBitcoinEnabled(), IsZCashEnabled(),
IsNftPinningEnabled(), IsAnkrBalancesEnabled()));
keyring_service_->IsWalletBackedUpSync(), IsBitcoinEnabled(),
IsZCashEnabled(), IsNftPinningEnabled(), IsAnkrBalancesEnabled()));
}
} // namespace brave_wallet
@@ -35,8 +35,6 @@
&brave_search_conversion::features::kOmniboxBanner, \
&brave_vpn::features::kBraveVPNLinkSubscriptionAndroidUI, \
&brave_wallet::features::kNativeBraveWalletFeature, \
&brave_wallet::features::kBraveWalletSolanaFeature, \
&brave_wallet::features::kBraveWalletFilecoinFeature, \
&playlist::features::kPlaylist, \
&preferences::features::kBraveBackgroundVideoPlayback, \
&request_otr::features::kBraveRequestOTRTab, \
@@ -60,17 +60,14 @@ void AccountDiscoveryManager::StartDiscovery() {
AddDiscoveryAccount(std::make_unique<DiscoveryContext>(
mojom::CoinType::ETH, mojom::KeyringId::kDefault, mojom::kMainnetChainId,
derived_count[mojom::KeyringId::kDefault], kDiscoveryAttempts));
if (IsFilecoinEnabled()) {
AddDiscoveryAccount(std::make_unique<DiscoveryContext>(
mojom::CoinType::FIL, mojom::KeyringId::kFilecoin,
mojom::kFilecoinMainnet, derived_count[mojom::KeyringId::kFilecoin],
kDiscoveryAttempts));
}
if (IsSolanaEnabled()) {
AddDiscoveryAccount(std::make_unique<DiscoveryContext>(
mojom::CoinType::SOL, mojom::KeyringId::kSolana, mojom::kSolanaMainnet,
derived_count[mojom::KeyringId::kSolana], kDiscoveryAttempts));
}
AddDiscoveryAccount(std::make_unique<DiscoveryContext>(
mojom::CoinType::FIL, mojom::KeyringId::kFilecoin,
mojom::kFilecoinMainnet, derived_count[mojom::KeyringId::kFilecoin],
kDiscoveryAttempts));
AddDiscoveryAccount(std::make_unique<DiscoveryContext>(
mojom::CoinType::SOL, mojom::KeyringId::kSolana, mojom::kSolanaMainnet,
derived_count[mojom::KeyringId::kSolana], kDiscoveryAttempts));
if (IsBitcoinEnabled()) {
CHECK(bitcoin_wallet_service_);
@@ -23,7 +23,6 @@
#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/test_utils.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/constants/webui_url_constants.h"
#include "brave/components/cosmetic_filters/browser/cosmetic_filters_resources.h"
#include "chrome/browser/chrome_content_browser_client.h"
@@ -200,9 +199,6 @@ class AndroidPageAppearingBrowserTest : public PlatformBrowserTest {
AndroidPageAppearingBrowserTest() {
factory_ = std::make_unique<TestWebUIControllerFactory>(kWalletPageHost);
content::WebUIControllerFactory::RegisterFactory(factory_.get());
scoped_feature_list_.InitWithFeatures(
{}, {features::kBraveWalletFilecoinFeature,
features::kBraveWalletSolanaFeature});
}
void SetUpOnMainThread() override {
@@ -390,7 +386,6 @@ class AndroidPageAppearingBrowserTest : public PlatformBrowserTest {
absl::optional<std::string> file_digest_;
std::unique_ptr<TestWebUIControllerFactory> factory_;
base::test::ScopedFeatureList scoped_feature_list_;
raw_ptr<brave_wallet::AssetRatioService> asset_ratio_service_;
raw_ptr<brave_wallet::KeyringService> keyring_service_;
raw_ptr<brave_wallet::JsonRpcService> json_rpc_service_;
@@ -16,7 +16,6 @@
#include "base/functional/callback_helpers.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#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/blockchain_registry.h"
@@ -38,7 +37,6 @@
#include "brave/components/brave_wallet/browser/tx_storage_delegate.h"
#include "brave/components/brave_wallet/browser/tx_storage_delegate_impl.h"
#include "brave/components/brave_wallet/common/brave_wallet.mojom.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/brave_wallet/common/hex_utils.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/value_store/value_store_frontend.h"
@@ -193,14 +191,6 @@ class EthTxManagerUnitTest : public testing::Test {
&url_loader_factory_)) {}
void SetUp() override {
base::FieldTrialParams parameters;
parameters[features::kCreateDefaultSolanaAccount.name] = "false";
std::vector<base::test::FeatureRefAndParams> enabled_features;
enabled_features.emplace_back(
brave_wallet::features::kBraveWalletSolanaFeature, parameters);
feature_list_.InitWithFeaturesAndParameters(enabled_features, {});
url_loader_factory_.SetInterceptor(base::BindLambdaForTesting(
[&](const network::ResourceRequest& request) {
url_loader_factory_.ClearResponses();
@@ -469,7 +459,6 @@ class EthTxManagerUnitTest : public testing::Test {
}
protected:
base::test::ScopedFeatureList feature_list_;
base::test::TaskEnvironment task_environment_;
base::ScopedTempDir temp_dir_;
sync_preferences::TestingPrefServiceSyncable profile_prefs_;
@@ -14,7 +14,6 @@
#include "base/json/json_writer.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "brave/components/brave_wallet/browser/brave_wallet_prefs.h"
#include "brave/components/brave_wallet/browser/brave_wallet_utils.h"
@@ -26,7 +25,6 @@
#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/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"
@@ -74,9 +72,6 @@ class FilTxManagerUnitTest : public testing::Test {
&url_loader_factory_)) {}
void SetUp() override {
feature_list_.InitAndEnableFeature(
brave_wallet::features::kBraveWalletFilecoinFeature);
brave_wallet::RegisterLocalStatePrefs(local_state_.registry());
brave_wallet::RegisterProfilePrefs(prefs_.registry());
brave_wallet::RegisterProfilePrefsForMigration(prefs_.registry());
@@ -235,7 +230,6 @@ class FilTxManagerUnitTest : public testing::Test {
}
protected:
base::test::ScopedFeatureList feature_list_;
base::test::TaskEnvironment task_environment_;
base::ScopedTempDir temp_dir_;
sync_preferences::TestingPrefServiceSyncable prefs_;
@@ -1033,19 +1033,6 @@ void KeyringService::GetMnemonicForDefaultKeyring(
std::move(callback).Run(GetMnemonicForKeyringImpl(mojom::kDefaultKeyringId));
}
void KeyringService::MaybeCreateDefaultSolanaAccount() {
if (!ShouldCreateDefaultSolanaAccount()) {
return;
}
auto account = AddAccountForKeyring(mojom::kSolanaKeyringId,
"Solana " + GetAccountName(1));
if (account) {
SetSelectedAccountInternal(*account);
NotifyAccountsAdded(*account);
}
}
void KeyringService::IsWalletCreated(IsWalletCreatedCallback callback) {
std::move(callback).Run(IsWalletCreatedSync());
}
@@ -1082,14 +1069,13 @@ void KeyringService::CreateWallet(const std::string& mnemonic,
}
}
if (IsFilecoinEnabled()) {
CreateKeyring(mojom::kFilecoinKeyringId, mnemonic, password);
CreateKeyring(mojom::kFilecoinTestnetKeyringId, mnemonic, password);
}
if (IsSolanaEnabled()) {
CreateKeyring(mojom::kSolanaKeyringId, mnemonic, password);
MaybeCreateDefaultSolanaAccount();
CreateKeyring(mojom::kFilecoinKeyringId, mnemonic, password);
CreateKeyring(mojom::kFilecoinTestnetKeyringId, mnemonic, password);
CreateKeyring(mojom::kSolanaKeyringId, mnemonic, password);
if (auto account = AddAccountForKeyring(mojom::kSolanaKeyringId,
"Solana " + GetAccountName(1))) {
SetSelectedAccountInternal(*account);
NotifyAccountsAdded(*account);
}
if (IsBitcoinEnabled()) {
@@ -1150,19 +1136,20 @@ bool KeyringService::RestoreWalletSync(const std::string& mnemonic,
}
}
if (IsFilecoinEnabled()) {
// Restore mainnet filecoin acc
RestoreKeyring(mojom::kFilecoinKeyringId, mnemonic, password, false);
// Restore testnet filecoin acc
RestoreKeyring(mojom::kFilecoinTestnetKeyringId, mnemonic, password, false);
}
// Restore mainnet filecoin acc
RestoreKeyring(mojom::kFilecoinKeyringId, mnemonic, password, false);
// Restore testnet filecoin acc
RestoreKeyring(mojom::kFilecoinTestnetKeyringId, mnemonic, password, false);
if (IsSolanaEnabled()) {
auto* solana_keyring =
RestoreKeyring(mojom::kSolanaKeyringId, mnemonic, password, false);
if (solana_keyring && !GetDerivedAccountsNumberForKeyring(
profile_prefs_, mojom::kSolanaKeyringId)) {
MaybeCreateDefaultSolanaAccount();
auto* solana_keyring =
RestoreKeyring(mojom::kSolanaKeyringId, mnemonic, password, false);
if (solana_keyring && !GetDerivedAccountsNumberForKeyring(
profile_prefs_, mojom::kSolanaKeyringId)) {
auto account = AddAccountForKeyring(mojom::kSolanaKeyringId,
"Solana " + GetAccountName(1));
if (account) {
SetSelectedAccountInternal(*account);
NotifyAccountsAdded(*account);
}
}
@@ -1220,14 +1207,6 @@ mojom::AccountInfoPtr KeyringService::AddAccountSync(
mojom::CoinType coin,
mojom::KeyringId keyring_id,
const std::string& account_name) {
if (IsFilecoinKeyringId(keyring_id) && !IsFilecoinEnabled()) {
return nullptr;
}
if (keyring_id == mojom::kSolanaKeyringId && !IsSolanaEnabled()) {
return nullptr;
}
if (IsBitcoinKeyring(keyring_id) && !IsBitcoinEnabled()) {
return nullptr;
}
@@ -1923,29 +1902,25 @@ void KeyringService::Unlock(const std::string& password,
return;
}
if (IsFilecoinEnabled()) {
if (!ResumeKeyring(mojom::kFilecoinKeyringId, password)) {
VLOG(1) << __func__ << " Unable to unlock filecoin keyring";
encryptors_.erase(mojom::kFilecoinKeyringId);
std::move(callback).Run(false);
return;
}
if (!ResumeKeyring(mojom::kFilecoinTestnetKeyringId, password)) {
VLOG(1) << __func__ << " Unable to unlock filecoin testnet keyring";
encryptors_.erase(mojom::kFilecoinTestnetKeyringId);
std::move(callback).Run(false);
return;
}
if (!ResumeKeyring(mojom::kFilecoinKeyringId, password)) {
VLOG(1) << __func__ << " Unable to unlock filecoin keyring";
encryptors_.erase(mojom::kFilecoinKeyringId);
std::move(callback).Run(false);
return;
}
if (IsSolanaEnabled()) {
if (!ResumeKeyring(mojom::kSolanaKeyringId, password)) {
VLOG(1) << __func__ << " Unable to unlock Solana keyring";
encryptors_.erase(mojom::kSolanaKeyringId);
std::move(callback).Run(false);
return;
}
if (!ResumeKeyring(mojom::kFilecoinTestnetKeyringId, password)) {
VLOG(1) << __func__ << " Unable to unlock filecoin testnet keyring";
encryptors_.erase(mojom::kFilecoinTestnetKeyringId);
std::move(callback).Run(false);
return;
}
if (!ResumeKeyring(mojom::kSolanaKeyringId, password)) {
VLOG(1) << __func__ << " Unable to unlock Solana keyring";
encryptors_.erase(mojom::kSolanaKeyringId);
std::move(callback).Run(false);
return;
}
if (IsBitcoinEnabled()) {
@@ -11,7 +11,6 @@
#include "base/base64.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#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_prefs.h"
@@ -24,7 +23,6 @@
#include "brave/components/brave_wallet/common/brave_wallet_constants.h"
#include "brave/components/brave_wallet/common/brave_wallet_types.h"
#include "brave/components/brave_wallet/common/encoding_utils.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/brave_wallet/common/solana_utils.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
@@ -101,9 +99,6 @@ class SolanaTransactionUnitTest : public testing::Test {
};
TEST_F(SolanaTransactionUnitTest, GetSignedTransaction) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
brave_wallet::features::kBraveWalletSolanaFeature);
ASSERT_TRUE(
RestoreWallet(keyring_service(), kMnemonicDivideCruise, "brave", false));
@@ -13,7 +13,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
#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/blockchain_registry.h"
@@ -33,7 +32,6 @@
#include "brave/components/brave_wallet/common/brave_wallet_constants.h"
#include "brave/components/brave_wallet/common/brave_wallet_types.h"
#include "brave/components/brave_wallet/common/encoding_utils.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/brave_wallet/common/solana_utils.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
@@ -67,10 +65,6 @@ class SolanaTxManagerUnitTest : public testing::Test {
last_valid_block_height2_ = 3290;
last_valid_block_height3_ = 3490;
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
brave_wallet::features::kBraveWalletSolanaFeature);
SetInterceptor(latest_blockhash1_, last_valid_block_height1_, tx_hash1_, "",
false, last_valid_block_height1_);
brave_wallet::RegisterProfilePrefs(prefs_.registry());
@@ -712,8 +712,6 @@ struct WalletInfo {
bool is_wallet_created;
bool is_wallet_locked;
bool is_wallet_backed_up;
bool is_filecoin_enabled;
bool is_solana_enabled;
bool is_bitcoin_enabled;
bool is_z_cash_enabled;
bool is_nft_pinning_feature_enabled;
+3 -19
View File
@@ -34,22 +34,10 @@ bool IsNativeWalletEnabled() {
return base::FeatureList::IsEnabled(features::kNativeBraveWalletFeature);
}
bool IsFilecoinEnabled() {
return base::FeatureList::IsEnabled(features::kBraveWalletFilecoinFeature);
}
bool IsSolanaEnabled() {
return base::FeatureList::IsEnabled(features::kBraveWalletSolanaFeature);
}
bool IsNftPinningEnabled() {
return base::FeatureList::IsEnabled(features::kBraveWalletNftPinningFeature);
}
bool ShouldCreateDefaultSolanaAccount() {
return IsSolanaEnabled() && features::kCreateDefaultSolanaAccount.Get();
}
bool IsBitcoinEnabled() {
return base::FeatureList::IsEnabled(features::kBraveWalletBitcoinFeature);
}
@@ -159,13 +147,9 @@ GURL GetActiveEndpointUrl(const mojom::NetworkInfo& chain) {
std::vector<mojom::KeyringId> GetSupportedKeyrings() {
std::vector<mojom::KeyringId> ids = {mojom::KeyringId::kDefault};
if (IsFilecoinEnabled()) {
ids.push_back(mojom::KeyringId::kFilecoin);
ids.push_back(mojom::KeyringId::kFilecoinTestnet);
}
if (IsSolanaEnabled()) {
ids.push_back(mojom::KeyringId::kSolana);
}
ids.push_back(mojom::KeyringId::kFilecoin);
ids.push_back(mojom::KeyringId::kFilecoinTestnet);
ids.push_back(mojom::KeyringId::kSolana);
if (IsBitcoinEnabled()) {
ids.push_back(mojom::KeyringId::kBitcoin84);
ids.push_back(mojom::KeyringId::kBitcoin84Testnet);
@@ -22,10 +22,7 @@ constexpr mojom::CoinType kAllCoins[] = {
bool IsZCashKeyring(mojom::KeyringId keyring_id);
bool IsNativeWalletEnabled();
bool IsFilecoinEnabled();
bool IsSolanaEnabled();
bool IsNftPinningEnabled();
bool ShouldCreateDefaultSolanaAccount();
bool IsBitcoinEnabled();
bool IsZCashEnabled();
bool IsAnkrBalancesEnabled();
@@ -105,8 +105,6 @@ TEST(CommonUtils, GetActiveEndpointUrl) {
TEST(CommonUtils, GetSupportedKeyrings) {
base::test::ScopedFeatureList disabled_feature_list;
const std::vector<base::test::FeatureRef> coin_features = {
features::kBraveWalletSolanaFeature,
features::kBraveWalletFilecoinFeature,
features::kBraveWalletBitcoinFeature};
disabled_feature_list.InitWithFeatures({}, coin_features);
@@ -127,14 +125,10 @@ TEST(CommonUtils, GetSupportedKeyrings) {
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kDefault);
if (IsFilecoinEnabled()) {
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kFilecoin);
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kFilecoinTestnet);
}
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kFilecoin);
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kFilecoinTestnet);
if (IsSolanaEnabled()) {
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kSolana);
}
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kSolana);
if (IsBitcoinEnabled()) {
EXPECT_EQ(keyrings[last_pos++], mojom::KeyringId::kBitcoin84);
@@ -14,16 +14,6 @@ namespace features {
BASE_FEATURE(kNativeBraveWalletFeature,
"NativeBraveWallet",
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kBraveWalletFilecoinFeature,
"BraveWalletFilecoin",
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kBraveWalletSolanaFeature,
"BraveWalletSolana",
base::FEATURE_ENABLED_BY_DEFAULT);
const base::FeatureParam<bool> kCreateDefaultSolanaAccount{
&kBraveWalletSolanaFeature, "create_default_solana_account", true};
BASE_FEATURE(kBraveWalletNftPinningFeature,
"BraveWalletNftPinning",
@@ -13,10 +13,7 @@ namespace brave_wallet {
namespace features {
BASE_DECLARE_FEATURE(kNativeBraveWalletFeature);
BASE_DECLARE_FEATURE(kBraveWalletFilecoinFeature);
BASE_DECLARE_FEATURE(kBraveWalletSolanaFeature);
BASE_DECLARE_FEATURE(kBraveWalletNftPinningFeature);
extern const base::FeatureParam<bool> kCreateDefaultSolanaAccount;
BASE_DECLARE_FEATURE(kBraveWalletBitcoinFeature);
extern const base::FeatureParam<int> kBitcoinRpcThrottle;
extern const base::FeatureParam<bool> kBitcoinTestnetDiscovery;
@@ -818,8 +818,6 @@ export class MockedWalletApiProxy {
}> => {
return {
walletInfo: {
isSolanaEnabled: true,
isFilecoinEnabled: true,
isBitcoinEnabled: true,
isZCashEnabled: true,
isWalletBackedUp: true,
@@ -127,8 +127,6 @@ export class BaseQueryCache {
// network type flags
const {
isFilecoinEnabled,
isSolanaEnabled,
isBitcoinEnabled,
isZCashEnabled
} = await this.getWalletInfo()
@@ -137,8 +135,8 @@ export class BaseQueryCache {
const filteredSupportedCoinTypes = SupportedCoinTypes.filter((coin) => {
// FIL and SOL networks, unless enabled by brave://flags
return (
(coin === BraveWallet.CoinType.FIL && isFilecoinEnabled) ||
(coin === BraveWallet.CoinType.SOL && isSolanaEnabled) ||
coin === BraveWallet.CoinType.FIL ||
coin === BraveWallet.CoinType.SOL ||
(coin === BraveWallet.CoinType.BTC && isBitcoinEnabled) ||
(coin === BraveWallet.CoinType.ZEC && isZCashEnabled) ||
coin === BraveWallet.CoinType.ETH
@@ -20,8 +20,6 @@ export const defaultFiatCurrency = ({ wallet }: State) =>
export const hasIncorrectPassword = ({ wallet }: State) =>
wallet.hasIncorrectPassword
export const hasInitialized = ({ wallet }: State) => wallet.hasInitialized
export const isFilecoinEnabled = ({ wallet }: State) => wallet.isFilecoinEnabled
export const isSolanaEnabled = ({ wallet }: State) => wallet.isSolanaEnabled
export const isBitcoinEnabled = ({ wallet }: State) => wallet.isBitcoinEnabled
export const isZCashEnabled = ({ wallet }: State) => wallet.isZCashEnabled
export const isLoadingCoinMarketData = ({ wallet }: State) =>
@@ -49,8 +49,6 @@ import { createAction, createSlice, PayloadAction } from '@reduxjs/toolkit'
const defaultState: WalletState = {
hasInitialized: false,
isFilecoinEnabled: false,
isSolanaEnabled: false,
isBitcoinEnabled: false,
isZCashEnabled: false,
isWalletCreated: false,
@@ -267,8 +265,6 @@ export const createWalletSlice = (initialState: WalletState = defaultState) => {
) {
state.hasInitialized = true
state.isWalletCreated = payload.walletInfo.isWalletCreated
state.isFilecoinEnabled = payload.walletInfo.isFilecoinEnabled
state.isSolanaEnabled = payload.walletInfo.isSolanaEnabled
state.isBitcoinEnabled = payload.walletInfo.isBitcoinEnabled
state.isZCashEnabled = payload.walletInfo.isZCashEnabled
state.isWalletLocked = payload.walletInfo.isWalletLocked
@@ -32,12 +32,6 @@ import { SelectAccountType } from './select-account-type/select-account-type'
// style
import { StyledWrapper } from './style'
// hooks
import { WalletSelectors } from '../../../../common/selectors'
// selectors
import { useSafeWalletSelector } from '../../../../common/hooks/use-safe-selector'
interface Params {
accountTypeName: string
}
@@ -53,20 +47,14 @@ export const AddHardwareAccountModal = ({ onSelectAccountType }: Props) => {
// redux
const dispatch = useDispatch()
const isFilecoinEnabled = useSafeWalletSelector(
WalletSelectors.isFilecoinEnabled
)
const isSolanaEnabled = useSafeWalletSelector(WalletSelectors.isSolanaEnabled)
// memos
const createAccountOptions = React.useMemo(() => {
return CreateAccountOptions({
isFilecoinEnabled,
isSolanaEnabled,
isBitcoinEnabled: false, // No bitcoin hardware accounts by now.
isZCashEnabled: false // No zcash hardware accounts by now.
})
}, [isFilecoinEnabled, isSolanaEnabled])
}, [])
const selectedAccountType: CreateAccountOptionsType | undefined =
React.useMemo(() => {
@@ -83,10 +83,6 @@ export const ImportAccountModal = () => {
const { accountTypeName } = useParams<Params>()
// redux
const isFilecoinEnabled = useSafeWalletSelector(
WalletSelectors.isFilecoinEnabled
)
const isSolanaEnabled = useSafeWalletSelector(WalletSelectors.isSolanaEnabled)
const hasImportError = useSafeWalletSelector(
WalletSelectors.importAccountError
)
@@ -94,12 +90,10 @@ export const ImportAccountModal = () => {
// memos
const createAccountOptions = React.useMemo(() => {
return CreateAccountOptions({
isFilecoinEnabled,
isSolanaEnabled,
isBitcoinEnabled: false, // No bitcoin imported accounts by now.
isZCashEnabled: false // No zcash imported accounts by now.
})
}, [isFilecoinEnabled, isSolanaEnabled])
}, [])
const selectedAccountType = React.useMemo(() => {
return createAccountOptions.find((option) => {
@@ -66,10 +66,6 @@ export const CreateAccountModal = () => {
// redux
const dispatch = useDispatch()
const isFilecoinEnabled = useSafeWalletSelector(
WalletSelectors.isFilecoinEnabled
)
const isSolanaEnabled = useSafeWalletSelector(WalletSelectors.isSolanaEnabled)
const isBitcoinEnabled = useSafeWalletSelector(
WalletSelectors.isBitcoinEnabled
)
@@ -96,12 +92,10 @@ export const CreateAccountModal = () => {
// memos
const createAccountOptions = React.useMemo(() => {
return CreateAccountOptions({
isFilecoinEnabled,
isSolanaEnabled,
isBitcoinEnabled,
isZCashEnabled
})
}, [isFilecoinEnabled, isSolanaEnabled, isBitcoinEnabled, isZCashEnabled])
}, [isBitcoinEnabled, isZCashEnabled])
const selectedAccountType = React.useMemo(() => {
return createAccountOptions.find((option) => {
@@ -202,8 +202,6 @@ export interface UIState {
export interface WalletState {
hasInitialized: boolean
isFilecoinEnabled: boolean
isSolanaEnabled: boolean
isBitcoinEnabled: boolean
isZCashEnabled: boolean
isWalletCreated: boolean
@@ -7,8 +7,6 @@ import { getLocale } from '../../common/locale'
import { getNetworkLogo } from './asset-options'
export const CreateAccountOptions = (options: {
isFilecoinEnabled: boolean
isSolanaEnabled: boolean
isBitcoinEnabled: boolean
isZCashEnabled: boolean
}): CreateAccountOptionsType[] => {
@@ -20,22 +18,20 @@ export const CreateAccountOptions = (options: {
icon: getNetworkLogo(BraveWallet.MAINNET_CHAIN_ID, 'ETH')
}
]
if (options.isSolanaEnabled) {
accounts.push({
description: getLocale('braveWalletCreateAccountSolanaDescription'),
name: 'Solana',
coin: BraveWallet.CoinType.SOL,
icon: getNetworkLogo(BraveWallet.SOLANA_MAINNET, 'SOL')
})
}
if (options.isFilecoinEnabled) {
accounts.push({
description: getLocale('braveWalletCreateAccountFilecoinDescription'),
name: 'Filecoin',
coin: BraveWallet.CoinType.FIL,
icon: getNetworkLogo(BraveWallet.FILECOIN_MAINNET, 'FIL')
})
}
accounts.push({
description: getLocale('braveWalletCreateAccountSolanaDescription'),
name: 'Solana',
coin: BraveWallet.CoinType.SOL,
icon: getNetworkLogo(BraveWallet.SOLANA_MAINNET, 'SOL')
})
accounts.push({
description: getLocale('braveWalletCreateAccountFilecoinDescription'),
name: 'Filecoin',
coin: BraveWallet.CoinType.FIL,
icon: getNetworkLogo(BraveWallet.FILECOIN_MAINNET, 'FIL')
})
if (options.isBitcoinEnabled) {
accounts.push({
description: getLocale('braveWalletCreateAccountBitcoinDescription'),
@@ -89,9 +89,7 @@ export const mockWalletState: WalletState = {
gasEstimates: undefined,
hasIncorrectPassword: false,
hasInitialized: true,
isFilecoinEnabled: false,
isMetaMaskInstalled: false,
isSolanaEnabled: false,
isBitcoinEnabled: false,
isZCashEnabled: false,
isAnkrBalancesFeatureEnabled: false,
@@ -22,8 +22,6 @@ export const _DesktopWalletConcept = () => {
walletStateOverride={{
hasIncorrectPassword: false,
isWalletCreated: true,
isSolanaEnabled: true,
isFilecoinEnabled: true
}}
pageStateOverride={{
hasInitialized: true
@@ -46,8 +44,6 @@ export const _WalletOnboardingConcept = () => {
<WalletPageStory
walletStateOverride={{
hasIncorrectPassword: false,
isSolanaEnabled: true,
isFilecoinEnabled: true,
isWalletBackedUp: false,
isWalletCreated: false
}}
@@ -60,19 +60,15 @@ export function handleEndpointError(
export async function getEnabledCoinTypes(api: WalletApiProxy) {
const {
isFilecoinEnabled,
isSolanaEnabled,
isBitcoinEnabled,
isZCashEnabled
} = (await api.walletHandler.getWalletInfo()).walletInfo
// Get All Networks
return SupportedCoinTypes.filter((coin) => {
// MULTICHAIN: While we are still in development for FIL and SOL,
// we will not use their networks unless enabled by brave://flags
return (
(coin === BraveWallet.CoinType.FIL && isFilecoinEnabled) ||
(coin === BraveWallet.CoinType.SOL && isSolanaEnabled) ||
coin === BraveWallet.CoinType.FIL ||
coin === BraveWallet.CoinType.SOL ||
(coin === BraveWallet.CoinType.BTC && isBitcoinEnabled) ||
(coin === BraveWallet.CoinType.ZEC && isZCashEnabled) ||
coin === BraveWallet.CoinType.ETH
@@ -8,8 +8,6 @@
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "brave/components/brave_wallet/common/features.h"
#include "brave/components/brave_wallet/renderer/v8_helper.h"
#include "build/buildflag.h"
#include "content/public/common/isolated_world_ids.h"
@@ -106,9 +104,7 @@ void BraveWalletRenderFrameObserver::DidClearWindowObject() {
render_frame());
}
if (base::FeatureList::IsEnabled(
brave_wallet::features::kBraveWalletSolanaFeature) &&
web_frame->GetDocument().IsDOMFeaturePolicyEnabled(context, "solana") &&
if (web_frame->GetDocument().IsDOMFeaturePolicyEnabled(context, "solana") &&
dynamic_params.brave_use_native_solana_wallet) {
JSSolanaProvider::Install(
dynamic_params.allow_overwrite_window_solana_provider, render_frame());