Пример #1
0
        private (ErrorType?ErrorType, string ErrorMessage) Validate(JsonRpcRequest rpcRequest)
        {
            if (rpcRequest == null)
            {
                return(ErrorType.InvalidRequest, "Invalid request");
            }

            var methodName = rpcRequest.Method;

            if (string.IsNullOrWhiteSpace(methodName))
            {
                return(ErrorType.InvalidRequest, "Method is required");
            }

            methodName = methodName.Trim().ToLower();

            var result = _rpcModuleProvider.Check(methodName);

            if (result == ModuleResolution.Unknown)
            {
                return(ErrorType.MethodNotFound, $"Method {methodName} is not supported");
            }

            if (result == ModuleResolution.Disabled)
            {
                return(ErrorType.InvalidRequest, $"{methodName} found but the containing module is disabled");
            }

            return(null, null);
        }