getChainIdsFromNamespace static method

List<String> getChainIdsFromNamespace({
  1. required String nsOrChainId,
  2. required Namespace namespace,
})

Gets all unique namespaces from the provided list of accounts This function assumes that all accounts are valid Gets the chains from the namespace. If the namespace is a chain, then it returns the chain. Otherwise it gets the chains from the accounts in the namespace.

Implementation

// static List<String> getNamespacesFromAccounts(List<String> accounts) {
//   Set<String> namespaces = {};
//   accounts.forEach((account) {
//     chains.add(
//       getChainFromAccount(
//         account,
//       ),
//     );
//   });

//   return chains.toList();
// }

/// Gets the chains from the namespace.
/// If the namespace is a chain, then it returns the chain.
/// Otherwise it gets the chains from the accounts in the namespace.
static List<String> getChainIdsFromNamespace({
  required String nsOrChainId,
  required Namespace namespace,
}) {
  if (isValidChainId(nsOrChainId)) {
    return [nsOrChainId];
  }

  return getChainsFromAccounts(namespace.accounts);
}