feat: Extract shared ExchangeRateCanisterClient into ic-nervous-system-clients#9846
feat: Extract shared ExchangeRateCanisterClient into ic-nervous-system-clients#9846jasonz-dfinity wants to merge 7 commits intomasterfrom
Conversation
There was a problem hiding this comment.
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_clientmodule toic-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.
bda03a8 to
7491aee
Compare
There was a problem hiding this comment.
This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):
-
Update
unreleased_changelog.md(if there are behavior changes, even if they are
non-breaking). -
Are there BREAKING changes?
-
Is a data migration needed?
-
Security review?
How to Satisfy This Automatic Review
-
Go to the bottom of the pull request page.
-
Look for where it says this bot is requesting changes.
-
Click the three dots to the right.
-
Select "Dismiss review".
-
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
unreleased_changelog.md: not updated, and not required — this PR is a pure code-move refactor (extracting the XRC client out of CMC intoic-nervous-system-clients) with no observable behavior change from CMC's perspective.- BREAKING changes: none — the move is internal; CMC still calls the same logic.
- Data migration: none — no persisted canister state changes.
- Security review: not needed — existing logic moves between crates without modification.
There was a problem hiding this comment.
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.
…ract-exchange-rate-client
There was a problem hiding this comment.
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.
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:
This is a pure refactor -- no behavior change to CMC.
PR Chain
Testing
Existing CMC tests cover the refactor.