getApprovedChains method

List<String>? getApprovedChains({
  1. String? namespace,
})

Implementation

List<String>? getApprovedChains({String? namespace}) {
  if (sessionService.noSession) {
    return null;
  }
  // Coinbase only support EIP155 but since we can not know which chains are actually approved...
  // Magic only support EIP155 and Solana but since we can not know which chains are actually approved...

  final allEIP155 = ReownAppKitModalNetworks.getAllSupportedNetworks(
    namespace: NetworkUtils.eip155,
  ).map((e) => '${NetworkUtils.eip155}:${e.chainId}').toList();

  if (sessionService.isCoinbase) {
    return [...allEIP155];
  }

  final allSolana = ReownAppKitModalNetworks.getAllSupportedNetworks(
    namespace: NetworkUtils.solana,
  ).map((e) => '${NetworkUtils.solana}:${e.chainId}').toList();

  if (sessionService.isMagic) {
    return [...allEIP155, ...allSolana];
  }

  final accounts = getAccounts(namespace: namespace) ?? [];
  return NamespaceUtils.getChainsFromAccounts(accounts);
}