getAvailableChains method
Will get the list of available chains to add
Implementation
@override
List<String>? getAvailableChains() {
// if there's no session or if supportsAddChain method then every chain can be used
if (_currentSession == null) {
// meaning all chains in the list are available
return null;
}
// Valid only for EVM chains
final hasSwitchMethod = _currentSession!.hasSwitchMethod();
if (!hasSwitchMethod) {
return getApprovedChains();
}
final isMagic = _currentSession!.sessionService.isMagic;
final isCoinbase = _currentSession!.sessionService.isCoinbase;
final isPhantom = _currentSession!.sessionService.isPhantom;
if (isMagic || isCoinbase || isPhantom) {
return getApprovedChains();
}
List<String> availableChains = [];
final namespaces = ReownAppKitModalNetworks.getAllSupportedNamespaces();
for (var namespace in namespaces) {
final chains = ReownAppKitModalNetworks.getAllSupportedNetworks(
namespace: namespace,
).map((e) => e.chainId).toList();
availableChains.addAll(chains);
}
if (availableChains.isEmpty) {
return getApprovedChains();
}
return availableChains;
}