Skip to content

Commit

Permalink
refactor(nns): Change Root interface crate to use ic-cdk (#3306)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-dfinity authored Jan 6, 2025
1 parent a47dde8 commit ea0222c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions rs/nns/handlers/root/interface/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ DEPENDENCIES = [
# Keep sorted.
"//rs/nervous_system/clients",
"//rs/nns/constants",
"//rs/rust_canisters/dfn_candid",
"//rs/rust_canisters/dfn_core",
"//rs/types/base_types",
"@crate_index//:candid",
"@crate_index//:ic-cdk",
Expand Down
2 changes: 0 additions & 2 deletions rs/nns/handlers/root/interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ edition = "2021"
[dependencies]
async-trait = { workspace = true }
candid = { workspace = true }
dfn_candid = { path = "../../../../rust_canisters/dfn_candid" }
dfn_core = { path = "../../../../rust_canisters/dfn_core" }
ic-base-types = { path = "../../../../types/base_types" }
ic-cdk = { workspace = true }
ic-nervous-system-clients = { path = "../../../../nervous_system/clients" }
Expand Down
17 changes: 9 additions & 8 deletions rs/nns/handlers/root/interface/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::{
ChangeCanisterControllersResponse, ChangeCanisterControllersResult,
};
use async_trait::async_trait;
use dfn_candid::candid_one;
use dfn_core::call;
use ic_base_types::PrincipalId;
use ic_cdk::call;
use ic_nervous_system_clients::{
canister_id_record::CanisterIdRecord,
canister_status::{
Expand Down Expand Up @@ -44,25 +43,27 @@ impl NnsRootCanisterClient for NnsRootCanisterClientImpl {
change_canister_controllers_request: ChangeCanisterControllersRequest,
) -> Result<ChangeCanisterControllersResponse, (Option<i32>, String)> {
call(
ROOT_CANISTER_ID,
ROOT_CANISTER_ID.get().0,
"change_canister_controllers",
candid_one,
change_canister_controllers_request,
(change_canister_controllers_request,),
)
.await
.map(|(response,): (ChangeCanisterControllersResponse,)| response)
.map_err(|(code, message)| (Some(code as i32), message))
}

async fn canister_status(
&self,
canister_id_record: CanisterIdRecord,
) -> Result<CanisterStatusResult, (Option<i32>, String)> {
call(
ROOT_CANISTER_ID,
ROOT_CANISTER_ID.get().0,
"canister_status",
candid_one,
canister_id_record,
(canister_id_record,),
)
.await
.map(|(response,): (CanisterStatusResult,)| response)
.map_err(|(code, message)| (Some(code as i32), message))
}
}

Expand Down

0 comments on commit ea0222c

Please sign in to comment.