fix: missing eth case

This commit is contained in:
julian 2023-05-30 10:38:47 -06:00
parent 243994ff45
commit 774bfe517e
4 changed files with 39 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
@ -150,6 +151,14 @@ class _NodeDetailsViewState extends ConsumerState<NodeDetailsView> {
}
break;
case Coin.ethereum:
try {
testPassed = await testEthNodeConnection(node!.host);
} catch (_) {
testPassed = false;
}
break;
}
if (testPassed) {

View file

@ -0,0 +1,12 @@
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart' as web3;
Future<bool> testEthNodeConnection(String host) async {
web3.Web3Client client = web3.Web3Client(host, Client());
try {
await client.getBlockNumber();
return true;
} catch (_) {
return false;
}
}

View file

@ -17,6 +17,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
@ -172,6 +173,14 @@ class _NodeCardState extends ConsumerState<NodeCard> {
}
break;
case Coin.ethereum:
try {
testPassed = await testEthNodeConnection(node.host);
} catch (_) {
testPassed = false;
}
break;
}
if (testPassed) {

View file

@ -17,6 +17,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
@ -155,6 +156,14 @@ class NodeOptionsSheet extends ConsumerWidget {
}
break;
case Coin.ethereum:
try {
testPassed = await testEthNodeConnection(node.host);
} catch (_) {
testPassed = false;
}
break;
}
if (testPassed) {