Skip to content

chore: DEFI-2304 remove deprecated ic-cdk imports in ic-icrc1-index-ng#10324

Draft
gregorydemay wants to merge 2 commits into
masterfrom
gdemay/DEFI-2304-icrc1-index-ng
Draft

chore: DEFI-2304 remove deprecated ic-cdk imports in ic-icrc1-index-ng#10324
gregorydemay wants to merge 2 commits into
masterfrom
gdemay/DEFI-2304-icrc1-index-ng

Conversation

@gregorydemay
Copy link
Copy Markdown
Contributor

@gregorydemay gregorydemay commented May 27, 2026

Summary

Closes DEFI-2304 — removing the final file-level #![allow(deprecated)] attribute introduced in #6264 across the defi-owned crates in the ic repo.

This PR handles ic-icrc1-index-ng:

  • ic_cdk::api::call::call(...)ic_cdk::call::Call::unbounded_wait(...).await?.candid::<T>()? for the icrc1_supported_standards query on the ledger.
  • ic_cdk::api::call::call_raw(...)ic_cdk::call::Call::unbounded_wait(...).with_raw_args(&req) + Response::into_bytes in the measured_call helper, keeping the existing candid::Decode!-based decoding.
  • ic_cdk::api::stable::StableReaderic_cdk::stable::StableReader.
  • ic_cdk::api::stable::stable_sizeic_cdk::stable::stable_size.
  • ic_cdk::api::canister_balance128ic_cdk::api::canister_cycle_balance.

InitArg::retrieve_blocks_from_ledger_interval_seconds is 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.

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>
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

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}) with ic_cdk::call::Call + Response::{candid, into_bytes}.
  • Switched deprecated stable memory APIs (ic_cdk::api::stable::*) to ic_cdk::stable::*.
  • Switched deprecated cycles balance API (canister_balance128) to canister_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants