Skip to content

feat: Extract shared ExchangeRateCanisterClient into ic-nervous-system-clients#9846

Open
jasonz-dfinity wants to merge 7 commits intomasterfrom
jason/NNS1-4319-extract-exchange-rate-client
Open

feat: Extract shared ExchangeRateCanisterClient into ic-nervous-system-clients#9846
jasonz-dfinity wants to merge 7 commits intomasterfrom
jason/NNS1-4319-extract-exchange-rate-client

Conversation

@jasonz-dfinity
Copy link
Copy Markdown
Contributor

@jasonz-dfinity jasonz-dfinity commented Apr 13, 2026

Why

CMC and the upcoming Governance timer task (next PR) both need XRC-calling logic. This extracts the shared code to avoid duplication.

https://dfinity.atlassian.net/browse/NNS1-4319

What

Moved exchange-rate-canister calling logic from CMC into a new shared module in ic-nervous-system-clients:

  • New exchange_rate_canister_client.rs with ExchangeRateCanisterClient trait, RealExchangeRateCanisterClient, error types, validation helpers, and shared constants
  • The trait adds timestamp: Option so callers can request historical rates; CMC always passes None
  • CMC exchange_rate_canister.rs is updated to use the shared types; its local duplicates are removed

This is a pure refactor -- no behavior change to CMC.

PR Chain

Testing

Existing CMC tests cover the refactor.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors Exchange Rate Canister (XRC) calling logic out of the Cycles Minting Canister (CMC) into the shared ic-nervous-system-clients crate so multiple NNS components can reuse a single implementation.

Changes:

  • Added exchange_rate_canister_client module to ic-nervous-system-clients (trait + real client + shared constants + validation/conversion helpers).
  • Updated CMC to use the shared XRC client/trait and removed local duplicate XRC-calling code.
  • Wired new dependencies in Cargo/Bazel manifests (and lockfile) for the new shared module.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rs/nns/cmc/src/main.rs Switches RealExchangeRateCanisterClient import to the shared clients crate.
rs/nns/cmc/src/exchange_rate_canister.rs Replaces local XRC trait/impl/validation with shared ExchangeRateCanisterClient + validate_exchange_rate; updates mocks accordingly.
rs/nns/cmc/Cargo.toml Adds dependency on ic-nervous-system-clients.
rs/nns/cmc/BUILD.bazel Adds Bazel dependency on //rs/nervous_system/clients.
rs/nervous_system/clients/src/lib.rs Exposes the new exchange_rate_canister_client module.
rs/nervous_system/clients/src/exchange_rate_canister_client.rs Introduces shared XRC client, errors, validation, and permyriad conversion helper.
rs/nervous_system/clients/Cargo.toml Adds ic-cdk + ic-xrc-types dependencies for the new client implementation.
rs/nervous_system/clients/BUILD.bazel Adds Bazel deps for ic-cdk and ic-xrc-types.
Cargo.lock Records new crate dependency edges.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs Outdated
Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs Outdated
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-4319-extract-exchange-rate-client branch from bda03a8 to 7491aee Compare April 15, 2026 19:23
@jasonz-dfinity jasonz-dfinity marked this pull request as ready for review April 15, 2026 21:31
@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner April 15, 2026 21:31
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):

  1. Update unreleased_changelog.md (if there are behavior changes, even if they are
    non-breaking).

  2. Are there BREAKING changes?

  3. Is a data migration needed?

  4. Security review?

How to Satisfy This Automatic Review

  1. Go to the bottom of the pull request page.

  2. Look for where it says this bot is requesting changes.

  3. Click the three dots to the right.

  4. Select "Dismiss review".

  5. In the text entry box, respond to each of the numbered items in the previous
    section, declare one of the following:

  • Done.

  • $REASON_WHY_NO_NEED. E.g. for unreleased_changelog.md, "No
    canister behavior changes.", or for item 2, "Existing APIs
    behave as before.".

Brief Guide to "Externally Visible" Changes

"Externally visible behavior change" is very often due to some NEW canister API.

Changes to EXISTING APIs are more likely to be "breaking".

If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.

If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.

Reference(s)

For a more comprehensive checklist, see here.

GOVERNANCE_CHECKLIST_REMINDER_DEDUP

Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs Outdated
Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs
@jasonz-dfinity jasonz-dfinity dismissed github-actions[bot]’s stale review April 27, 2026 23:36
  1. unreleased_changelog.md: not updated, and not required — this PR is a pure code-move refactor (extracting the XRC client out of CMC into ic-nervous-system-clients) with no observable behavior change from CMC's perspective.
  2. BREAKING changes: none — the move is internal; CMC still calls the same logic.
  3. Data migration: none — no persisted canister state changes.
  4. Security review: not needed — existing logic moves between crates without modification.
@jasonz-dfinity jasonz-dfinity requested a review from Copilot April 27, 2026 23:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs
Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs
Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs
Comment thread rs/nervous_system/clients/src/exchange_rate_canister_client.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants