Skip to content

refactor: extract duplicate contract client init to _make_contract_client helper#433

Merged
anderdc merged 6 commits intoentrius:testfrom
dataCenter430:refactor/extract-make-contract-client
Apr 15, 2026
Merged

refactor: extract duplicate contract client init to _make_contract_client helper#433
anderdc merged 6 commits intoentrius:testfrom
dataCenter430:refactor/extract-make-contract-client

Conversation

@dataCenter430
Copy link
Copy Markdown
Contributor

The same 3-line block — bt.Wallet, bt.Subtensor, IssueCompetitionContractClient(...) — was copy-pasted identically across 6 admin commands and 2 vote commands (8 sites in total). Extracting it as _make_contract_client() in helpers.py gives a single source of truth.

The lazy imports (bittensor, IssueCompetitionContractClient) are preserved inside the helper, so ImportError still propagates to the existing except ImportError handlers in each caller unchanged.

  • Pyright clean
  • Ruff lint and format clean

@dataCenter430
Copy link
Copy Markdown
Contributor Author

Hi, @anderdc
admin.py has 6 commands and vote.py has 2 commands that all start with the same 8-line block — create a wallet, a subtensor, and an IssueCompetitionContractClient.
This PR extracts that block into _make_contract_client() in issue_commands/helpers.py and replaces all 8 call sites with a single line.
Really hope your review with this.

Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean mechanical refactor. All 8 call sites updated, lazy imports correctly preserved, and the two sites in mutations.py that look similar were reasonably excluded (extra steps that don't fit the helper signature).

LGTM

@anderdc anderdc merged commit fd91051 into entrius:test Apr 15, 2026
4 checks passed
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.

2 participants