Skip to content

Conversation

hmoragrega
Copy link
Contributor

@hmoragrega hmoragrega commented Oct 13, 2025

This PR removes an unused dependency between chain and exchange client, it prevents circular dependencies in the clients too.

Summary by CodeRabbit

  • Refactor

    • Decoupled market assistant initialization from a specific exchange client, improving flexibility and forward compatibility.
    • No changes to user-facing behavior or performance.
  • Tests

    • Simplified test setup by removing external client mocks, improving reliability and maintainability.

Copy link

coderabbitai bot commented Oct 13, 2025

Walkthrough

Public constructors in client/chain/markets_assistant.go changed their exchange client parameter type from exchange.ExchangeClient to any, with deprecation comments added. Tests were updated to remove mock exchange usage and pass nil for the exchange client. No internal token initialization logic was modified.

Changes

Cohort / File(s) Summary
Constructors API change
client/chain/markets_assistant.go
Updated signatures: constructors now accept any instead of exchange.ExchangeClient; added deprecation notes about exchangeClient removal. No internal behavior changes to token initialization from chain denoms/markets (standard and human-readable variants).
Tests adjusted for API
client/chain/markets_assistant_test.go
Removed mock exchange client setup; updated calls to constructors to pass nil for the exchange client argument; retained existing test logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant MA as NewMarketsAssistantWithAllTokens
  participant CC as ChainClient / ChainClientV2

  Caller->>MA: Call with (exchangeClient: any|nil, chainClient)
  note over MA: exchangeClient parameter accepted but not required
  MA->>CC: Fetch denoms/markets
  CC-->>MA: Chain tokens/markets data
  MA-->>Caller: MarketsAssistant instance
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nudge my paws through change so slight,
Swapped a type—now “any” feels right.
Tests hop lightly, mocks set free,
Nil in place, as it should be.
In burrows of code where tokens spin,
A rabbit grins—less fuss, same win. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly reflects the primary change of the pull request by stating the removal of the unused exchange client dependency, aligning with the PR’s objective to prevent circular dependencies without introducing unnecessary noise or vagueness.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch f/clean-market-assistant

Comment @coderabbitai help to get the list of available commands and usage tips.

@hmoragrega hmoragrega force-pushed the f/clean-market-assistant branch from 5b762eb to 9a43255 Compare October 13, 2025 11:46
@hmoragrega hmoragrega requested a review from aarmoa October 13, 2025 11:47
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
client/chain/markets_assistant.go (2)

58-60: Use standard Go deprecation format and improve migration guidance.

The deprecation comment uses a non-standard format. Per Go conventions, use // Deprecated: (capital D, followed by colon). Additionally, consider clarifying what callers should pass (e.g., "pass nil") and when the parameter will be removed.

Apply this diff:

-// NewMarketsAssistantWithAllTokens initializes a MarketsAssistant by first fetching all token metadata from the chain's bank module
-// @deprecated removed exchangeClient
-func NewMarketsAssistantWithAllTokens(ctx context.Context, exchangeClient any, chainClient ChainClient) (MarketsAssistant, error) {
+// NewMarketsAssistantWithAllTokens initializes a MarketsAssistant by first fetching all token metadata from the chain's bank module
+//
+// Deprecated: The exchangeClient parameter is unused and will be removed in a future version. Pass nil for this parameter.
+func NewMarketsAssistantWithAllTokens(ctx context.Context, exchangeClient any, chainClient ChainClient) (MarketsAssistant, error) {

68-70: Use standard Go deprecation format and improve migration guidance.

The deprecation comment uses a non-standard format. Per Go conventions, use // Deprecated: (capital D, followed by colon). Additionally, consider clarifying what callers should pass (e.g., "pass nil") and when the parameter will be removed.

Apply this diff:

-// NewHumanReadableMarketsAssistantWithAllTokens initializes a MarketsAssistant by first fetching all token metadata from the chain's bank module
-// @deprecated removed exchangeClient
-func NewHumanReadableMarketsAssistantWithAllTokens(ctx context.Context, exchangeClient any, chainClient ChainClientV2) (MarketsAssistant, error) {
+// NewHumanReadableMarketsAssistantWithAllTokens initializes a MarketsAssistant by first fetching all token metadata from the chain's bank module
+//
+// Deprecated: The exchangeClient parameter is unused and will be removed in a future version. Pass nil for this parameter.
+func NewHumanReadableMarketsAssistantWithAllTokens(ctx context.Context, exchangeClient any, chainClient ChainClientV2) (MarketsAssistant, error) {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca4abcb and 9a43255.

📒 Files selected for processing (2)
  • client/chain/markets_assistant.go (1 hunks)
  • client/chain/markets_assistant_test.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
client/chain/markets_assistant_test.go (1)
client/chain/markets_assistant.go (2)
  • NewMarketsAssistantWithAllTokens (60-66)
  • NewHumanReadableMarketsAssistantWithAllTokens (70-76)
client/chain/markets_assistant.go (2)
client/chain/chain.go (1)
  • ChainClient (74-332)
client/chain/chain_v2.go (1)
  • ChainClientV2 (54-310)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: run-tests
  • GitHub Check: lint
🔇 Additional comments (2)
client/chain/markets_assistant_test.go (2)

193-193: LGTM!

Correctly passes nil for the now-unused exchange client parameter, aligning with the updated constructor signature.


377-377: LGTM!

Correctly passes nil for the now-unused exchange client parameter, consistent with the signature change.

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.

1 participant