Skip to content

Add fair node exit command for removing nodes from fair manager contracts#897

Closed
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-896
Closed

Add fair node exit command for removing nodes from fair manager contracts#897
Copilot wants to merge 2 commits intodevelopfrom
copilot/fix-896

Conversation

Copy link

Copilot AI commented Aug 1, 2025

This PR implements the fair node exit --yes command to remove nodes from fair manager smart contracts as requested in issue #896.

Implementation

The new command follows the established CLI patterns and integrates seamlessly with the existing node-cli infrastructure:

skale fair node exit --yes

Key Features

  • API Integration: Sends POST request to /api/v1/fair/node/exit endpoint
  • Safety First: Requires --yes confirmation flag to prevent accidental execution
  • Consistent Error Handling: Uses the same error handling patterns as existing commands like set-domain-name
  • Proper Validation: Includes @check_inited decorator to ensure node is properly initialized
  • Stream Output: Uses @streamed_cmd decorator for consistent output handling

Architecture

The implementation follows the established three-layer pattern:

  1. CLI Layer (node_cli/cli/fair.py): Command hierarchy fairnodeexit
  2. Core Logic (node_cli/core/fair.py): API call handling using post_request helper
  3. Route Configuration (node_cli/configs/routes.py): Added fair/node/exit to API routes

Response Handling

The command provides clear feedback:

  • Success: Node successfully removed from fair manager contracts
  • Failure: Exits with CLIExitCodes.BAD_API_RESPONSE and displays error message

Testing

Comprehensive test coverage includes:

  • Success scenario with mocked API response
  • Failure scenario with error handling validation
  • Tests follow existing patterns using run_command_mock helper

The implementation maintains the codebase's style guidelines with no comments and clean, readable code that matches existing command patterns.

Fixes #896.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: dmytrotkk <15244591+dmytrotkk@users.noreply.github.com>
@dmytrotkk
Copy link
Collaborator

@copilot do not add a new blueprint, fair is the base name of the executable - just place a command in the node_cli/cli/fair_node.py, then follow the structure of other commands.

Copilot AI changed the title [WIP] Add remove fair node command Add fair node exit command for removing nodes from fair manager contracts Aug 1, 2025
Copilot AI requested a review from dmytrotkk August 1, 2025 12:57
@dmytrotkk dmytrotkk closed this Aug 1, 2025
Copy link
Author

Copilot AI commented Aug 1, 2025

@copilot do not add a new blueprint, fair is the base name of the executable - just place a command in the node_cli/cli/fair_node.py, then follow the structure of other commands.

Refactored the command structure as requested. Removed the complex blueprint hierarchy and moved the command to fair_node.py following the pattern of other commands. The command is now fair node-exit instead of the nested structure. Changes implemented in commit 1be0182.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add remove fair node command

2 participants