isValidNamespaceChains function

ErrorObject? isValidNamespaceChains(
  1. ProposalRequiredNamespaces namespaces,
  2. String method
)

Implementation

ErrorObject? isValidNamespaceChains(
  ProposalRequiredNamespaces namespaces,
  String method,
) {
  ErrorObject? error;
  namespaces.entries.forEach((entry) {
    final key = entry.key;
    final namespace = entry.value;
    if (error != null) return;
    final validChainsError =
        isValidChains(key, namespace.chains, '$method requiredNamespace');
    final validExtensionError = isValidExtension(namespace, method);
    if (validChainsError != null) {
      error = validChainsError;
    } else if (validExtensionError != null) {
      error = validExtensionError;
    } else if (namespace.extension != null) {
      namespace.extension!.forEach((extension) {
        if (error != null) return;
        final validChainsError =
            isValidChains(key, extension.chains, '$method extension');
        if (validChainsError != null) {
          error = validChainsError;
        }
      });
    }
  });

  return error;
}