diff --git a/components/brave_wallet/browser/json_rpc_service.cc b/components/brave_wallet/browser/json_rpc_service.cc index cc6588ef8add..42a7abce21b3 100644 --- a/components/brave_wallet/browser/json_rpc_service.cc +++ b/components/brave_wallet/browser/json_rpc_service.cc @@ -297,7 +297,21 @@ void JsonRpcService::UpdateIsEip1559(const std::string& chain_id, if (error != mojom::ProviderError::kSuccess) return; + // Disable EIP-1559 on selected networks, by overwriting is_eip1559 to + // false. + // + // This list needs to be updated until we have a generic EIP-1559 gas + // oracle. See: https://github.com/brave/brave-browser/issues/20469. + if (chain_id == "0x13881" || // Polygon Mumbai Testnet + chain_id == "0x89" || // Polygon Mainnet + chain_id == "0xa86a" || // Avalanche Mainnet + chain_id == "0xa869" // Avalanche Fuji Testnet + ) { + is_eip1559 = false; + } + bool changed = false; + if (chain_id == brave_wallet::mojom::kLocalhostChainId) { changed = prefs_->GetBoolean(kSupportEip1559OnLocalhostChain) != is_eip1559; prefs_->SetBoolean(kSupportEip1559OnLocalhostChain, is_eip1559); diff --git a/components/brave_wallet/browser/json_rpc_service_unittest.cc b/components/brave_wallet/browser/json_rpc_service_unittest.cc index 397a63a9ee30..f464f30479bd 100644 --- a/components/brave_wallet/browser/json_rpc_service_unittest.cc +++ b/components/brave_wallet/browser/json_rpc_service_unittest.cc @@ -1386,6 +1386,41 @@ TEST_F(JsonRpcServiceUnitTest, UpdateIsEip1559CustomChain) { EXPECT_FALSE(GetIsEip1559FromPrefs(chain2.chain_id)); } +TEST_F(JsonRpcServiceUnitTest, UpdateIsEip1559DisablePolygon) { + std::vector values; + + // Define EthereumChain for Polygon network with is_eip1559 set to true. + brave_wallet::mojom::EthereumChain polygon( + "0x89", "Polygon Mainnet", {"https://url.com"}, {"https://url.com"}, + {"https://url.com"}, "Polygon Matic", "MATIC", 18, true); + auto polygon_ptr = polygon.Clone(); + values.push_back(brave_wallet::EthereumChainToValue(polygon_ptr)); + + UpdateCustomNetworks(prefs(), &values); + + // Expected is_eip1559 should always be false for Polygon. + TestJsonRpcServiceObserver observer(polygon.chain_id, false); + json_rpc_service_->AddObserver(observer.GetReceiver()); + + // Switching to Polygon should update is_eip1559 to false, even if it + // was previously set to true. + EXPECT_TRUE(GetIsEip1559FromPrefs(polygon.chain_id)); + SetIsEip1559Interceptor(true); + SetNetwork(polygon.chain_id); + EXPECT_TRUE(observer.chain_changed_called()); + EXPECT_TRUE(observer.is_eip1559_changed_called()); + EXPECT_FALSE(GetIsEip1559FromPrefs(polygon.chain_id)); + + // Switching to Polygon again should not call observer methods for change + // in is_eip1559. + observer.Reset(polygon.chain_id, false); + SetIsEip1559Interceptor(true); + SetNetwork(polygon.chain_id); + EXPECT_TRUE(observer.chain_changed_called()); + EXPECT_FALSE(observer.is_eip1559_changed_called()); + EXPECT_FALSE(GetIsEip1559FromPrefs(polygon.chain_id)); +} + TEST_F(JsonRpcServiceUnitTest, GetEthAddrInvalidDomain) { const std::vector invalid_domains = {"", ".eth", "-brave.eth", "brave-.eth", "b.eth"};