connectFromChains method

Future<List<String>> connectFromChains(
  1. List<String> chains, {
  2. Map<String, List<String>>? nodeList,
})

Implementation

Future<List<String>> connectFromChains(List<String> chains,
    {Map<String, List<String>>? nodeList}) async {
  assert(_runner != null, 'bridge not init');
  final list =
      await Future.wait(chains.map((e) => _checkConnection(e)).toList());
  final nonNullList =
      list.where((element) => element != null).toList() as List<String>;
  chains.removeWhere((element) => nonNullList.contains(element));
  if (chains.isEmpty) {
    return nonNullList;
  }
  final res = await _runner?.evalJavascript(
      'bridge.connectFromChains(${jsonEncode(chains)}, ${nodeList == null ? 'undefined' : jsonEncode(nodeList)})');
  return List<String>.from(res) + nonNullList;
}