Skip to content

Commit 1cff69c

Browse files
dviejokfsgithub-advanced-security[bot]Copilot
authored
Smart contract development editor with AI (#15)
* Update dependencies and enhance database queries for project management - Added the `github.com/sashabaranov/go-openai` dependency to `go.mod` for integrating OpenAI functionalities. - Updated `sqlc.yaml` to include an additional SQL queries file for development queries, improving database operations. - Introduced new SQL queries in `dev-queries.sql` for managing projects, including listing, creating, and deleting projects. - Enhanced the database model in `models.go` to include new structures for conversations and tool calls, supporting additional functionalities. - Refactored the `querier.go` interface to include new methods for managing conversations and tool calls, ensuring better separation of concerns. These changes improve the overall functionality and maintainability of the application, providing better tools for project management and database interactions. Signed-off-by: David VIEJO <[email protected]> * Update project configuration and enhance API documentation - Updated `.gitignore` to include `projects-data-node1`, improving project cleanliness. - Added new dependencies `github.com/google/go-github/v45` and `github.com/google/go-querystring` to `go.mod` for enhanced API functionalities. - Updated Swagger documentation to reflect changes in API endpoints, including versioning and improved descriptions for better clarity. - Enhanced SQL queries in `dev-queries.sql` to include `network_id` in project creation, ensuring better data management. These changes improve the overall organization and usability of the application, providing clearer documentation and enhanced functionality for users. Signed-off-by: David VIEJO <[email protected]> * Migrate application components from NestJS to Go - Updated `go.mod` to include new dependencies for AI functionalities, including `github.com/anthropics/anthropic-sdk-go` and `github.com/openai/openai-go`. - Refactored the HTTP server setup to utilize a new command structure, enhancing modularity and organization. - Implemented AI client adapters for both OpenAI and Claude, ensuring compatibility with the new service layer. - Introduced a new database migration management system using embedded SQL migrations, improving database setup processes. - Enhanced project lifecycle management with new platform-specific lifecycle hooks for Fabric, improving project handling. - Removed outdated test files and refactored existing AI tests to align with the new structure. These changes significantly improve the application's architecture, maintainability, and functionality, ensuring a smooth transition from NestJS to Go while preserving existing features. Signed-off-by: David VIEJO <[email protected]> * Refactor project services and enhance lifecycle management - Updated the `ProjectsService` to include new dependencies for organization, key management, and network services, improving modularity and functionality. - Refactored the `StartProjectServer` and `StopProjectServer` methods to utilize context for better error handling and lifecycle management. - Enhanced the `FabricLifecycle` implementation to support additional parameters and improve the pre-start and post-start hooks, ensuring better integration with the project lifecycle. - Introduced new methods for managing project lifecycle hooks, allowing for more flexible handling of platform-specific operations. These changes significantly improve the application's architecture and maintainability, ensuring a smoother transition from NestJS to Go while preserving existing features. Signed-off-by: David VIEJO <[email protected]> * Fix plugins Signed-off-by: David VIEJO <[email protected]> * Update Signed-off-by: David VIEJO <[email protected]> * Enhance Fabric chaincode deployment with Docker labels and address management - Introduced `DeployChaincodeWithDockerImageWithLabels` function to support Docker labels during chaincode deployment, improving container management. - Updated `DeployWithLabels` method in `DockerChaincodeDeployer` to handle Docker labels and enhance error reporting. - Enhanced `ChaincodeService` to ensure proper chaincode address handling and validation, improving deployment reliability. - Added new database queries for managing Fabric chaincodes, including creation and retrieval by name and network, ensuring better data integrity. - Updated SQL queries to reflect changes in the database schema, enhancing overall functionality. These changes improve the deployment process for Fabric chaincodes, ensuring better management and tracking of Docker containers while maintaining existing functionalities. Signed-off-by: David VIEJO <[email protected]> * Fix security issues Signed-off-by: David VIEJO <[email protected]> * Refactor project management to use chaincode_projects - Updated database queries and models to replace references to 'projects' with 'chaincode_projects', enhancing clarity and consistency in project management. - Modified API endpoints and handlers to reflect the new naming convention, ensuring proper routing and functionality. - Enhanced Swagger documentation to accurately describe the updated endpoints and their responses. - Introduced a new ChaincodeProjectDetailPage for displaying details of chaincode projects, improving user experience. These changes improve the overall organization and usability of the application, providing clearer management of chaincode projects. Signed-off-by: David VIEJO <[email protected]> * Refactor AI chat functionality and enhance project management - Introduced new AI chat endpoints for streaming conversations with the AI assistant, improving user interaction capabilities. - Updated database queries to include endorsement policy in chaincode project creation, enhancing project management features. - Enhanced the ProjectsHandler to integrate chaincode project invocation services, ensuring better handling of project-related operations. - Improved error handling and logging in the middleware for AI chat and chaincode project endpoints, ensuring robust operation. - Updated Swagger documentation to reflect new AI chat functionalities and project management enhancements, improving API usability. These changes significantly enhance the application's functionality and maintainability, providing better tools for managing AI interactions and chaincode projects. Signed-off-by: David VIEJO <[email protected]> * Implement endorsement policy management for chaincode projects - Added API endpoint to update the endorsement policy of existing chaincode projects, enhancing project management capabilities. - Updated database queries to include endorsement policy in project retrieval and updates, ensuring data consistency. - Enhanced Swagger documentation to reflect the new endorsement policy endpoint and its parameters, improving API usability. - Introduced frontend components for managing endorsement policies, including forms and validation, ensuring a user-friendly experience. These changes significantly improve the functionality and maintainability of the application, providing better tools for managing chaincode project endorsement policies. Signed-off-by: David VIEJO <[email protected]> * Refactor CodeEditor and Playground components for improved state management - Updated the CodeEditor component to streamline the layout and enhance the responsiveness of the editor and file tree panels. - Modified the Playground component to include additional state properties for function and arguments in response handling, improving data tracking during invocations and queries. - Enhanced error handling in the Playground component to provide more detailed feedback on function calls, including function names and arguments in the response logs. - Improved UI elements in the ChaincodeProjectEditorPage to display project status with badges and loading indicators for start/stop actions, enhancing user experience. These changes enhance the functionality and usability of the editor and playground components, providing better state management and user feedback. Signed-off-by: David VIEJO <[email protected]> * Refactor App component and enhance routing structure - Updated the App component to improve layout handling by conditionally rendering the sidebar and header based on the current route. - Integrated the useLocation hook from react-router-dom to manage route-based UI changes effectively. - Enhanced the Toaster component to include custom icons for different toast states, improving user feedback during interactions. - Modified the index.tsx file to wrap the App component with BrowserRouter for proper routing functionality. - Improved the EditorContent and Playground components for better layout and responsiveness, ensuring a more user-friendly experience. These changes enhance the overall structure and usability of the application, providing a more intuitive navigation experience and improved visual feedback. Signed-off-by: David VIEJO <[email protected]> * Implement GetIdentity method and refactor gateway client handling - Added the GetIdentity method in the LocalPeer struct to retrieve the admin identity and signer based on the provided keyID, enhancing identity management. - Refactored the GetGatewayClient method to accept keyID as a parameter, ensuring proper identity retrieval for gateway connections. - Updated the NodeService and ChaincodeService to utilize the new GetGatewayClient signature, improving consistency across service calls. - Enhanced error handling in the new GetIdentity method to provide more informative error messages during identity retrieval processes. - Improved the CodeEditor and Playground components for better state management and user experience, including updates to the handling of responses and operations. These changes enhance the application's identity management capabilities and improve the overall functionality of the editor and playground components. Signed-off-by: David VIEJO <[email protected]> * Enhance error handling in invokeChaincodeCmd - Updated the invokeChaincodeCmd to improve error handling during transaction submission, providing more detailed feedback on endorsement errors. - Refactored gateway client handling to use a more descriptive variable name, enhancing code clarity. - Ensured proper closure of gateway client connections to prevent resource leaks. These changes improve the robustness of the invoke command and enhance the overall user experience by providing clearer error messages. Signed-off-by: David VIEJO <[email protected]> Signed-off-by: dviejokfs <[email protected]> * Update SQLC version and enhance message model for AI interactions - Updated SQLC version from v1.28.0 to v1.29.0 across multiple files. - Modified the `messages` table to include an `enhanced_content` field for improved AI interaction capabilities. - Updated the `InsertMessage` and `ListMessagesForConversation` queries to handle the new `enhanced_content` field. - Introduced a new `UpdateMessageEnhancedContent` query and corresponding method for updating enhanced content in messages. - Enhanced the `Message` model to include the `EnhancedContent` field, improving data handling for AI responses. These changes enhance the application's ability to manage and utilize enriched message content for AI interactions, improving overall functionality and user experience. Signed-off-by: dviejokfs <[email protected]> * Checkpoint Signed-off-by: dviejokfs <[email protected]> * Update AI chat functionality and enhance conversation management - Updated the AI chat request structure to include a new `conversationId` field, improving the ability to track and manage conversations. - Implemented a new `GetConversation` method in the ChatService to retrieve conversation details based on the conversation ID. - Modified the `ChatWithPersistence` method to utilize the new `GetConversation` method for ensuring conversation existence. - Enhanced the frontend components to support the new conversation ID handling, including updates to the ChatPanel and CodeEditor components. - Updated Swagger documentation to reflect changes in the AI chat request and response structures. These changes improve the overall functionality and user experience of the AI chat feature, enabling better conversation tracking and management. Signed-off-by: dviejokfs <[email protected]> * Refactor AI chat service and clean up frontend log handling - Removed the prompt enhancement logic from the ChatWithPersistence method in the OpenAIChatService, simplifying the chat processing flow. - Cleaned up the NodeDetailPage component by ensuring proper formatting in the EventSource configuration and removing unnecessary whitespace in the log handling logic. These changes streamline the AI chat service and improve code readability in the frontend, enhancing overall maintainability. Signed-off-by: dviejokfs <[email protected]> * Refactor tool schema management and enhance file handling capabilities - Introduced GetExtendedToolSchemas function to provide an extended set of tool schemas with enhanced file handling capabilities. - Removed the previous GetDefaultToolSchemas function to streamline the tool schema retrieval process. - Updated the OpenAIChatService to utilize the new GetExtendedToolSchemas function for improved tool handling. - Enhanced error handling and validation in tool handlers for file operations, ensuring robust functionality. - Added new tools for advanced file operations, including reading, writing, and searching files, improving overall user experience. These changes enhance the application's ability to manage file operations effectively, providing a more comprehensive set of tools for user interactions. Signed-off-by: dviejokfs <[email protected]> * Enhance API documentation and update project management features - Added new tags for Chaincode Projects in the API documentation to improve clarity on project management operations. - Updated Swagger documentation to include detailed information about the Chaincode Projects and their management operations. - Enhanced the database queries to retrieve additional project details, including network information, improving the overall project management capabilities. - Removed deprecated endpoints related to Docker deployment of Fabric chaincode, streamlining the API for better usability. These changes improve the API's documentation and functionality, providing a clearer structure for managing chaincode projects and enhancing user experience. Signed-off-by: David VIEJO <[email protected]> * Refactor tool components and enhance file operation capabilities - Introduced new tool components for file operations, including reading, writing, editing, and searching files, improving user interaction with the codebase. - Enhanced the existing tool schemas to support additional parameters for file operations, such as reading specific lines and handling file paths more effectively. - Improved the UI for displaying tool results and updates, ensuring a better user experience when interacting with file operations. - Streamlined the code structure by organizing tool components and ensuring proper separation of concerns, enhancing maintainability. These changes significantly improve the application's ability to manage file operations, providing users with a comprehensive set of tools for effective codebase interaction. Signed-off-by: David VIEJO <[email protected]> * Migrate chaincode contract initialization and enhance AI service testing - Added a new `contract.go` file to implement the `InitLedger` function for initializing assets in the chaincode, ensuring proper logging and error handling. - Introduced a comprehensive test suite in `ai_test.go` to validate the AI service's functionality with existing projects, including mock dependencies and detailed output analysis. - Updated the `ai.go` file to enhance the OpenAI chat service with improved prompts and tool handling, ensuring better interaction with the user. - Refactored tool schemas in `tools.go` to support additional parameters and improve file operation capabilities, enhancing overall user experience. These changes significantly improve the application's functionality for managing chaincode and AI interactions, providing a robust foundation for future development. Signed-off-by: dviejokfs <[email protected]> * Update dependencies and enhance AI service functionality - Added the `github.com/sahilm/fuzzy` dependency to improve string matching capabilities within the application. - Updated the `ai_test.go` file to reflect changes in project directory paths and modified test cases for better accuracy in AI service testing. - Enhanced the `ai.go` file with improved comments and structure for better readability and maintainability. - Introduced a new `search_replace.go` file to implement search and replace functionality using AI, streamlining code modifications based on diffs. These changes enhance the application's AI service capabilities and improve overall code quality and testing accuracy. Signed-off-by: David VIEJO <[email protected]> * Add execution components for various tools in CodeEditor - Introduced new `Execute` components for tools including Codebase Search, Delete File, Edit File, File Search, Grep Search, List Directory, Read File, Read File Enhanced, Reapply, Run Terminal Command, Search Replace, and Write File. - Each `Execute` component provides a visual indication of the execution process with a loading spinner and descriptive text. - Updated the `ToolEventRenderer` to handle the new execution events, ensuring proper integration with the existing tool components. These enhancements improve user feedback during tool execution, providing a more interactive experience in the CodeEditor. Signed-off-by: David VIEJO <[email protected]> * Update API documentation and implement project download functionality - Updated Swagger documentation to include a new endpoint for downloading chaincode projects as zip files, enhancing clarity on project management operations. - Introduced a `DownloadProject` method in the `ProjectsHandler` to handle zip file downloads, ensuring proper error handling and response streaming. - Added a `DownloadButton` component in the frontend for user-initiated project downloads, improving user experience. - Enhanced the `CodeEditor` component to integrate the download functionality, allowing users to easily download their projects. These changes significantly improve the API's usability and enhance the overall project management experience for users. Signed-off-by: dviejokfs <[email protected]> * Update Signed-off-by: dviejokfs <[email protected]> * Update API documentation and enhance message handling - Updated Swagger documentation to reflect new API structures, including the addition of `toolArguments` in message handling. - Introduced `ToolCallAI` structure to improve the representation of tool call results in the API. - Enhanced database queries to include `tool_arguments` in message storage and retrieval, ensuring comprehensive data handling. - Refactored the `AddMessage` method in the `ChatService` to accommodate the new `toolArguments` parameter, improving message persistence. - Updated frontend types to align with the new API structure, enhancing type safety and clarity in message handling. These changes significantly improve the API's usability and enhance the overall message management experience for users. Signed-off-by: David VIEJO <[email protected]> * Enhance edit_file tool documentation and improve message handling - Updated the edit_file tool description to include detailed formatting guidelines for SEARCH/REPLACE blocks, ensuring clarity for users. - Improved the handling of message filtering in the StreamChat method to skip tool messages from previous iterations, enhancing message processing accuracy. - Refactored argument parsing in the Playground component for cleaner code and improved readability. These changes enhance the usability of the edit_file tool and improve overall message handling in the application. Signed-off-by: David VIEJO <[email protected]> * Checkpoint Signed-off-by: David VIEJO <[email protected]> * Checkpoint claude impl + decoupling (missing streaming) Signed-off-by: David VIEJO <[email protected]> * Implement streaming support in ClaudeProvider for enhanced tool call handling - Refactored the StreamAgentStep method to utilize streaming for Claude API calls, allowing for real-time processing of tool calls and content updates. - Introduced a delta grouping mechanism and a fixed interval update system to efficiently manage tool call arguments and notify observers. - Enhanced error handling and logging for tool execution results, improving overall reliability and user feedback during interactions. These changes significantly improve the responsiveness and functionality of the AI service, providing a more interactive experience for users. Signed-off-by: David VIEJO <[email protected]> * Enhance error handling and UI improvements in plugin and deployment components - Updated error messages in the PluginDetailPage to provide more informative feedback when resuming plugins. - Modified the DeploymentModal to include MSPID information for peers, improving visibility of important data. - Adjusted the scroll area in DeploymentModal to allow for better content navigation with overflow handling. - Cleaned up unnecessary code in FabricChaincodeDefinitionDetail, enhancing readability and maintainability. These changes improve user experience and error reporting across the application components. Signed-off-by: dviejokfs <[email protected]> * Update Signed-off-by: dviejokfs <[email protected]> * Refactor tool components for improved UI and functionality - Enhanced the UI of various tool components in the CodeEditor, including File Exists, Read File, Write File, and Search Replace, to provide clearer summaries and structured layouts. - Improved error handling and output display for terminal command execution, ensuring better user feedback during operations. - Consolidated dialog elements into summary cards for a more cohesive user experience. - Updated the ToolEventRenderer to integrate new tool components, enhancing the overall functionality and responsiveness of the tool execution process. These changes significantly improve the usability and visual clarity of the tool components in the application. Signed-off-by: David VIEJO <[email protected]> * Potential fix for code scanning alert no. 19: Uncontrolled data used in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: David Viejo <[email protected]> * Fix tests Signed-off-by: dviejokfs <[email protected]> * Added import for strings package in DirsService to support string manipulation functionalities. Signed-off-by: dviejokfs <[email protected]> * Update Swagger documentation and implement key management API endpoints - Updated Swagger documentation to include new endpoints for managing keys associated with organizations, including creating, listing, renewing, and deleting keys. - Enhanced the API client with new methods for interacting with the key management endpoints. - Improved error handling and validation for key management requests. - Refactored organization handler to incorporate key management routes and logic. These changes enhance the API's functionality and provide better support for key management operations within the application. Signed-off-by: dviejokfs <[email protected]> * Update . Signed-off-by: dviejokfs <[email protected]> * Refactor AI service and enhance file handling tools - Increased the maximum agent steps from 10 to 25 for improved processing capabilities. - Updated the 'read_file' tool to simplify its description and parameters, removing unnecessary options for reading entire files. - Introduced new 'edit_file' and 'rewrite_file' tools with detailed instructions for file modifications, enhancing the functionality for file editing. - Improved error handling and logging in the ClaudeProvider for better tool call management. - Enhanced UI components for file editing and reading, ensuring better user experience and clarity in the CodeEditor. These changes collectively enhance the AI service's capabilities and improve the overall user experience in file handling operations. Signed-off-by: dviejokfs <[email protected]> * Enhance Channel Configuration Card and Add PolicyCard Component - Updated ChannelConfigCard to include new capabilities, hashing algorithm, and block data hashing structure. - Introduced PolicyCard component for displaying detailed policy information with identities and rules. - Added dialog functionality for viewing policy details within ChannelConfigCard. - Improved rendering of ACLs and organization configurations for better clarity. - Adjusted ScrollArea component to ensure proper height and overflow handling. These changes enhance the user experience by providing more detailed information and better organization of channel configurations and policies. Signed-off-by: David VIEJO <[email protected]> * Update Signed-off-by: David VIEJO <[email protected]> * Update Signed-off-by: David VIEJO <[email protected]> * Improve error handling during Docker image pull in LocalOrderer and LocalPeer - Updated the Docker image pull logic to capture and return errors from the io.Copy operation, ensuring better error reporting and handling. - This change enhances the robustness of the service layer by providing clearer feedback when image pull operations fail. Signed-off-by: David VIEJO <[email protected]> * Fix security issues Signed-off-by: David VIEJO <[email protected]> * Fix GetKey and DeleteKey Signed-off-by: David VIEJO <[email protected]> * Update pkg/scai/versionmanagement/versionmanager.go Co-authored-by: Copilot <[email protected]> Signed-off-by: David Viejo <[email protected]> * Enhance GitHub Downloader with Cache Management and Validation - Introduced cache expiration logic to validate cached files and remove expired ones, improving efficiency in repository downloads. - Added methods for clearing expired cache and retrieving cache statistics, enhancing cache management capabilities. - Updated RepoMetadata struct to include download timestamp for better tracking of cached files. - Enhanced error handling in the downloader to ensure robust operations during file management. Signed-off-by: dviejokfs <[email protected]> * Refactor LeaveChannel method to support Docker ephemeral containers - Enhanced the LeaveChannel method in LocalPeer to stop the peer before unjoining from a channel. - Implemented Docker client logic to create and manage ephemeral containers for channel removal, improving the handling of peer unjoining in Docker mode. - Updated logging to include output from the unjoin command for better debugging. - Refactored the command execution logic to handle both Docker and host execution modes. Signed-off-by: dviejokfs <[email protected]> * Implement plugin creation and update error handling with toast notifications - Added useMutation for creating plugins in NewPluginPage, enhancing user feedback on success and error scenarios. - Improved error handling in EditPluginPage to provide specific feedback based on the error type during plugin updates. - Ensured consistent user experience by displaying appropriate toast messages for both creation and update operations. Signed-off-by: dviejokfs <[email protected]> * Update API documentation and settings for external IP management - Regenerated Swagger documentation to reflect the latest API changes, including updated descriptions and new security definitions. - Enhanced the settings configuration to include a default external IP address for node endpoints, improving flexibility in node management. - Updated various API endpoints and their descriptions for clarity and consistency. - Improved error handling and validation in the service layer to ensure robust operations. Signed-off-by: David VIEJO <[email protected]> * Enhance API documentation and node configuration with mode support - Updated Swagger and YAML documentation to include a new "mode" field for nodes, improving clarity on node configurations. - Reflected changes in the generated Go documentation to ensure consistency across API references. - Modified node service and request types to incorporate mode handling, allowing for dynamic updates to node modes during operations. - Improved the NodeDetailPage to display the current mode of nodes, enhancing user visibility into node configurations. Signed-off-by: David VIEJO <[email protected]> * Implement network map API and UI components for Fabric and Besu networks - Added new API endpoints to retrieve network maps for Fabric and Besu networks, including node health status and configuration details. - Updated Swagger and YAML documentation to reflect the new endpoints and their parameters. - Introduced a new NetworkMap component in the UI to visualize the network structure, displaying nodes and their health status. - Enhanced the FabricNetworkDetails component to integrate the network map functionality, improving user experience and visibility into network configurations. Signed-off-by: David VIEJO <[email protected]> * Add API endpoint and documentation for retrieving Fabric chaincode sequence - Implemented a new GET endpoint to fetch the current sequence number for a specified chaincode in the Fabric network. - Updated Swagger and YAML documentation to include the new endpoint, parameters, and response structure. - Introduced a new response struct for the Fabric chaincode sequence, ensuring clear data representation. - Enhanced the FabricChaincodeDefinitionDetail component to utilize the new API for displaying chaincode sequence information. Signed-off-by: David VIEJO <[email protected]> * Add undeploy endpoint for chaincode definitions and update documentation - Implemented a new POST endpoint to remove the deployment for a specified chaincode definition in the Fabric network. - Updated Swagger and YAML documentation to include the new endpoint, parameters, and response structure. - Enhanced the FabricChaincodeDefinitionDetail component to support undeploying chaincode, including loading states and user feedback via toast notifications. - Refactored related service and handler methods to manage Docker container removal effectively. Signed-off-by: David VIEJO <[email protected]> * Fix tests Signed-off-by: David VIEJO <[email protected]> * Add chaincode management dialogs and timeline component - Introduced `ApproveChaincodeDialog`, `CommitChaincodeDialog`, and `InstallChaincodeDialog` components for managing chaincode actions with peer selection. - Implemented `DefinitionTimeline` component to display the lifecycle events of chaincode definitions. - Enhanced `ChaincodeDefinitionCard` to integrate the new dialogs and timeline, improving user interaction for chaincode management. - Ensured consistent loading and error handling states across the new components. Signed-off-by: David VIEJO <[email protected]> * Implement chaincode invoke and query functionality with API integration - Added new endpoints for invoking and querying chaincodes in the Fabric network, enhancing the interaction capabilities with chaincode functions. - Updated Swagger and YAML documentation to include the new endpoints, parameters, and response structures for both invoke and query operations. - Introduced a Playground component for testing chaincode functions, allowing users to input function names and arguments, and view responses. - Enhanced the FabricChaincodeDefinitionDetail component to include a link to the new Playground, improving user navigation and experience. Signed-off-by: David VIEJO <[email protected]> * Enhance chaincode metadata retrieval and Playground functionality - Added a new endpoint to retrieve metadata for specific chaincodes, improving the ability to interact with chaincode functions. - Updated the Playground component to support metadata-based interactions, allowing users to select contracts and transactions dynamically. - Introduced a new MetadataForm component for handling metadata inputs, enhancing user experience in the Playground. - Improved error handling and loading states for metadata queries, ensuring better feedback for users. Signed-off-by: David VIEJO <[email protected]> * Checkpoint Signed-off-by: David VIEJO <[email protected]> * Refactor Playground and CodeEditor components to support parameter values - Updated Playground and CodeEditor components to handle parameter values for invoke and query operations, enhancing functionality. - Introduced controlled state management for parameter values in MetadataForm and Playground, improving user experience. - Enhanced loading and error handling states across components for better feedback during operations. Signed-off-by: David VIEJO <[email protected]> * Enhance chaincode project metadata retrieval and Playground integration - Implemented a new endpoint for retrieving metadata of specific chaincode projects, improving interaction capabilities. - Updated the Playground component to utilize the new metadata endpoint, allowing users to dynamically select contracts and transactions. - Enhanced the MetadataForm component to manage metadata inputs effectively, improving user experience. - Improved loading and error handling states across components for better feedback during metadata queries. Signed-off-by: David VIEJO <[email protected]> * Update latency field naming and enhance network map component - Changed latency field from `latencyMs` to `latencyNs` across multiple files for consistency in data representation. - Updated Swagger and YAML documentation to reflect the new latency field name. - Enhanced the `NetworkMap` component to compute and display node latency in milliseconds, improving user visibility into network performance. - Added refetch interval for network map data to ensure up-to-date information. Signed-off-by: David VIEJO <[email protected]> * Update Signed-off-by: David VIEJO <[email protected]> * Update dependencies and enhance chaincode operations - Updated the `go.mod` file to replace the `fabric-admin-sdk` dependency with a newer version. - Modified the `ListChaincodes` SQL query to order by `created_at` instead of `id`, improving the retrieval of chaincode definitions. - Enhanced error handling in various chaincode operations to provide more detailed feedback on transaction submission failures. - Added new operations for managing orderer organizations and updating policies in the network configuration. Signed-off-by: David VIEJO <[email protected]> * Implement Docker info retrieval for chaincode definitions - Added a new endpoint to fetch Docker container information for specific chaincode definitions, enhancing the ability to monitor chaincode status. - Updated Swagger and YAML documentation to include the new endpoint and its parameters. - Integrated Docker info retrieval into the ChaincodeDefinitionCard component, providing real-time status updates. - Implemented loading and error handling states for Docker info fetching, improving user feedback during data retrieval. Signed-off-by: David VIEJO <[email protected]> * checkpoint Signed-off-by: David VIEJO <[email protected]> * Checkpoint Signed-off-by: David VIEJO <[email protected]> * Refactor AI service initialization and enhance conversation summarization - Updated the AI service initialization logic to include a boilerplate service, ensuring better integration and functionality. - Added a new endpoint for summarizing conversations, allowing users to create a new conversation from an existing one with a summary message. - Enhanced error handling for AI operations, providing clearer feedback on issues such as token limits. - Updated Swagger and YAML documentation to reflect the new summarization endpoint and its parameters. Signed-off-by: David VIEJO <[email protected]> * Fix security issues Signed-off-by: David VIEJO <[email protected]> * Refactor metrics handler to improve error handling and response management - Wrapped route handlers with response middleware for consistent error handling and response formatting. - Updated handler functions to return errors instead of writing directly to the response, enhancing maintainability. - Improved Docker Prometheus deployment logic to handle existing containers more effectively. - Added logic to pull an Alpine image for writing configuration files, ensuring proper setup of Prometheus. Signed-off-by: David VIEJO <[email protected]> * Refactor chaincode service and database queries for improved functionality - Updated the InvokeChaincode method to streamline transient argument handling, ensuring correct submission of chaincode functions. - Removed the AddIsInternalToMessages function and its SQL query, simplifying the database layer. - Adjusted SQL queries to change user_identity condition from empty string to zero, enhancing query accuracy. Signed-off-by: David VIEJO <[email protected]> * Refactor database queries and update server configuration - Removed TODO comment for loading registry config in the server setup. - Added a new SQL query to retrieve conversation details by ID in dev-queries.sql. - Removed duplicate conversation retrieval query from queries.sql. - Changed default node expose IP from "0.0.0.0" to "127.0.0.1" in service settings. - Cleaned up console logs in ChatPanel component for better code clarity. - Consolidated import statements in NetworkMap component for improved readability. Signed-off-by: David VIEJO <[email protected]> * Refactor DevelopChaincodeDialog and SmartContractsPage for improved project management - Removed the fetching of existing chaincode projects from DevelopChaincodeDialog to streamline the component. - Integrated project fetching directly into SmartContractsPage, enhancing data management and user experience. - Implemented loading and error handling states for chaincode projects in SmartContractsPage. - Added a new section to display chaincode projects with appropriate loading skeletons and error alerts. Signed-off-by: David VIEJO <[email protected]> * Update documentation and enhance organization creation parameters - Updated Swagger and YAML documentation to include new CA certificate properties: commonName, country, province, locality, streetAddress, and postalCode. - Modified CreateOrganizationRequest and CreateOrganizationParams to incorporate CA certificate properties. - Enhanced the CreateOrganization handler to process new CA parameters. - Introduced a new ArrayFieldInput component for handling array inputs in forms. - Updated the OrganizationForm to allow customization of CA parameters with a toggle switch and dynamic input fields. Signed-off-by: David VIEJO <[email protected]> * Update organization creation parameters and documentation - Removed the commonName field from CreateOrganizationRequest and CreateOrganizationParams to streamline CA certificate properties. - Updated Swagger and YAML documentation to reflect the removal of commonName and ensure consistency across API definitions. - Adjusted the OrganizationForm component to remove commonName input and enhance the handling of CA parameters. - Modified the organization creation logic to generate commonName dynamically based on the MspID. Signed-off-by: David VIEJO <[email protected]> * Update session encryption key handling in middleware - Changed the fallback mechanism for the SESSION_ENCRYPTION_KEY environment variable to panic if not set, enhancing error handling and ensuring that the application does not run with a default key in production. Signed-off-by: David VIEJO <[email protected]> --------- Signed-off-by: David VIEJO <[email protected]> Signed-off-by: dviejokfs <[email protected]> Signed-off-by: David Viejo <[email protected]> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Copilot <[email protected]>
1 parent cc71499 commit 1cff69c

File tree

209 files changed

+52055
-23480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+52055
-23480
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ tasks.json
3838
tasks/
3939
.roo
4040
.taskmasterconfig
41-
scripts
41+
scripts
42+
projects-data-node1

.vscode/launch.json

Lines changed: 0 additions & 68 deletions
This file was deleted.

cmd/fabric/invoke/invoke.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import (
1111
"github.com/hyperledger/fabric-admin-sdk/pkg/network"
1212
"github.com/hyperledger/fabric-gateway/pkg/client"
1313
"github.com/hyperledger/fabric-gateway/pkg/identity"
14+
"github.com/hyperledger/fabric-protos-go-apiv2/gateway"
1415
"github.com/pkg/errors"
1516
"github.com/spf13/cobra"
1617
"google.golang.org/grpc"
18+
"google.golang.org/grpc/status"
1719
)
1820

1921
type invokeChaincodeCmd struct {
@@ -112,12 +114,12 @@ func (c *invokeChaincodeCmd) run(out io.Writer) error {
112114
return err
113115
}
114116
defer conn.Close()
115-
gateway, err := client.Connect(userIdentity, client.WithSign(userPK), client.WithClientConnection(conn))
117+
gatewayClient, err := client.Connect(userIdentity, client.WithSign(userPK), client.WithClientConnection(conn))
116118
if err != nil {
117119
return err
118120
}
119-
defer gateway.Close()
120-
network := gateway.GetNetwork(c.channel)
121+
defer gatewayClient.Close()
122+
network := gatewayClient.GetNetwork(c.channel)
121123
contract := network.GetContract(c.chaincode)
122124
args := [][]byte{}
123125
for _, arg := range c.args {
@@ -134,7 +136,21 @@ func (c *invokeChaincodeCmd) run(out io.Writer) error {
134136
}
135137
submitResponse, err := endorseResponse.Submit()
136138
if err != nil {
137-
return errors.Wrapf(err, "failed to submit proposal")
139+
endorseError, ok := err.(*client.EndorseError)
140+
if ok {
141+
detailsStr := []string{}
142+
for _, detail := range status.Convert(err).Details() {
143+
switch detail := detail.(type) {
144+
case *gateway.ErrorDetail:
145+
detailsStr = append(detailsStr, fmt.Sprintf("- address: %s; mspId: %s; message: %s\n", detail.GetAddress(), detail.GetMspId(), detail.GetMessage()))
146+
147+
}
148+
}
149+
return fmt.Errorf("failed to submit transaction: %s (gRPC status: %s)",
150+
endorseError.TransactionError.Error(),
151+
strings.Join(detailsStr, "\n"))
152+
}
153+
return fmt.Errorf("failed to submit transaction: %w", err)
138154
}
139155
responseBytes, err := submitResponse.Bytes()
140156
if err != nil {

cmd/fabric/query/query.go

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import (
1111
"github.com/hyperledger/fabric-admin-sdk/pkg/network"
1212
"github.com/hyperledger/fabric-gateway/pkg/client"
1313
"github.com/hyperledger/fabric-gateway/pkg/identity"
14+
"github.com/hyperledger/fabric-protos-go-apiv2/gateway"
1415
"github.com/pkg/errors"
1516
"github.com/spf13/cobra"
1617
"google.golang.org/grpc"
18+
"google.golang.org/grpc/status"
1719
)
1820

1921
type queryChaincodeCmd struct {
@@ -109,18 +111,48 @@ func (c *queryChaincodeCmd) run(out io.Writer) error {
109111
}
110112
defer conn.Close()
111113

112-
gateway, err := client.Connect(userIdentity, client.WithSign(userPK), client.WithClientConnection(conn))
114+
gatewayFabric, err := client.Connect(userIdentity, client.WithSign(userPK), client.WithClientConnection(conn))
113115
if err != nil {
114116
return err
115117
}
116-
defer gateway.Close()
118+
defer gatewayFabric.Close()
117119

118-
network := gateway.GetNetwork(c.channel)
120+
network := gatewayFabric.GetNetwork(c.channel)
119121
contract := network.GetContract(c.chaincode)
120122

121123
result, err := contract.EvaluateTransaction(c.fcn, c.args...)
122124
if err != nil {
123-
return errors.Wrapf(err, "failed to evaluate transaction")
125+
endorseError, ok := err.(*client.EndorseError)
126+
if ok {
127+
detailsStr := []string{}
128+
for _, detail := range status.Convert(err).Details() {
129+
switch detail := detail.(type) {
130+
case *gateway.ErrorDetail:
131+
detailsStr = append(detailsStr, fmt.Sprintf("- address: %s; mspId: %s; message: %s\n", detail.GetAddress(), detail.GetMspId(), detail.GetMessage()))
132+
133+
}
134+
}
135+
return fmt.Errorf("failed to submit transaction: %s (gRPC status: %s)",
136+
endorseError.TransactionError.Error(),
137+
strings.Join(detailsStr, "\n"))
138+
}
139+
statusError := status.Convert(err)
140+
if statusError != nil {
141+
detailsStr := []string{}
142+
for _, detail := range statusError.Details() {
143+
switch detail := detail.(type) {
144+
case *gateway.ErrorDetail:
145+
detailsStr = append(detailsStr, fmt.Sprintf("- address: %s; mspId: %s; message: %s",
146+
detail.GetAddress(),
147+
detail.GetMspId(),
148+
detail.GetMessage()))
149+
}
150+
}
151+
return fmt.Errorf("failed to submit transaction: %s (gRPC status details: %s)",
152+
statusError.Message(),
153+
strings.Join(detailsStr, "\n"))
154+
}
155+
return fmt.Errorf("failed to submit transaction: %w", err)
124156
}
125157

126158
_, err = fmt.Fprint(out, string(result))

0 commit comments

Comments
 (0)