chore: DEFI-2304 remove deprecated ic-cdk imports in ic-icrc1-index-ng#10324
Draft
gregorydemay wants to merge 2 commits into
Draft
chore: DEFI-2304 remove deprecated ic-cdk imports in ic-icrc1-index-ng#10324gregorydemay wants to merge 2 commits into
gregorydemay wants to merge 2 commits into
Conversation
Migrate the ICRC-1 index-ng canister off `ic_cdk::api::call::{call, call_raw}`,
`ic_cdk::api::stable::{StableReader, stable_size}` and
`ic_cdk::api::canister_balance128` (all deprecated in #6264), and drop the
file-level `#![allow(deprecated)]`. The two outgoing calls are rewritten on top
of the `ic_cdk::call::Call::unbounded_wait(...)` builder: the
`icrc1_supported_standards` query uses `.candid::<Vec<StandardRecord>>()` for
the response, and `measured_call` uses `.with_raw_args(&req)` +
`Response::into_bytes` to keep the existing `candid::Decode!`-based decoding.
`InitArg::retrieve_blocks_from_ledger_interval_seconds` (itself separately
deprecated) keeps a narrowly scoped `#[allow(deprecated)]` on the two
destructuring patterns where it is still observed; this is out of scope for
DEFI-2304.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the last file-level #![allow(deprecated)] in ic-icrc1-index-ng by migrating remaining deprecated ic-cdk APIs to their non-deprecated equivalents (per DEFI-2304), keeping narrowly-scoped #[allow(deprecated)] only where InitArg::retrieve_blocks_from_ledger_interval_seconds is still used.
Changes:
- Replaced deprecated cross-canister call APIs (
ic_cdk::api::call::{call, call_raw}) withic_cdk::call::Call+Response::{candid, into_bytes}. - Switched deprecated stable memory APIs (
ic_cdk::api::stable::*) toic_cdk::stable::*. - Switched deprecated cycles balance API (
canister_balance128) tocanister_cycle_balance.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .map_err(|err| format!("failed to candid encode the input {i:?}: {err}"))?; | ||
| let res = ic_cdk::api::call::call_raw(id, method, &req, 0) | ||
| let res = Call::unbounded_wait(id, method) | ||
| .with_raw_args(&req) |
| log!( | ||
| P0, | ||
| "[get_supported_standards_from_ledger]: failed to call get_supported_standards_from_ledger on ledger {}. Error code: {:?} message: {}", | ||
| "[get_supported_standards_from_ledger]: failed to call get_supported_standards_from_ledger on ledger {}: {}", |
Per Copilot review on #10324: - Switch the `measured_call` helper from `with_raw_args(&req)` to `take_raw_args(req)`. `req` is already an owned `Vec<u8>`, and other Rust canisters in this repo use the `take_raw_args` flavour, so this keeps the pattern consistent and avoids the borrow. - Update the `get_supported_standards_from_ledger` error log to name the actual ledger method that was called (`icrc1_supported_standards`) rather than the local function name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes DEFI-2304 — removing the final file-level
#![allow(deprecated)]attribute introduced in #6264 across the defi-owned crates in theicrepo.This PR handles
ic-icrc1-index-ng:ic_cdk::api::call::call(...)→ic_cdk::call::Call::unbounded_wait(...).await?.candid::<T>()?for theicrc1_supported_standardsquery on the ledger.ic_cdk::api::call::call_raw(...)→ic_cdk::call::Call::unbounded_wait(...).with_raw_args(&req)+Response::into_bytesin themeasured_callhelper, keeping the existingcandid::Decode!-based decoding.ic_cdk::api::stable::StableReader→ic_cdk::stable::StableReader.ic_cdk::api::stable::stable_size→ic_cdk::stable::stable_size.ic_cdk::api::canister_balance128→ic_cdk::api::canister_cycle_balance.InitArg::retrieve_blocks_from_ledger_interval_secondsis itself separately deprecated (tracked by a different ticket); its two destructuring patterns keep a narrowly scoped#[allow(deprecated)]so this PR stays focused on the DEFI-2304 surface.No behavior change.