isValidChains static method
This function will throw an error if
- the nsOrChainId parameter is a chainId, and the chains param exists
- The list of chains contains an invalid chainId
Implementation
static bool isValidChains({
  required String nsOrChainId,
  List<String>? chains,
  required String context,
}) {
  // If the key is a valid chain Id, then the chains should be empty
  final bool isChainId = NamespaceUtils.isValidChainId(nsOrChainId);
  if (isChainId) {
    if (chains != null && chains.isNotEmpty) {
      throw Errors.getSdkError(
        Errors.UNSUPPORTED_CHAINS,
        context: '$context, namespace is a chainId, but chains is not empty',
      ).toSignError();
    }
  } else {
    for (String c in chains!) {
      if (!NamespaceUtils.isValidChainId(c)) {
        throw Errors.getSdkError(
          Errors.UNSUPPORTED_CHAINS,
          context: '$context, chain $c should conform to "CAIP-2" format',
        ).toSignError();
      }
    }
  }
  return true;
}