-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor uprading creator dao canisters and skip if upgrades if deplo…
…yed versio is already present
- Loading branch information
1 parent
e5bda38
commit cf64d19
Showing
15 changed files
with
924 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
23 changes: 0 additions & 23 deletions
23
...management/notify_all_individual_canisters_to_upgrade_creator_dao_governance_canisters.rs
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
...rc/api/canister_management/upgrade_all_creator_dao_governance_canisters_in_the_network.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use ic_cdk_macros::update; | ||
use shared_utils::common::{types::wasm, utils::task::run_task_concurrently}; | ||
|
||
use crate::{guard::is_caller::is_caller_global_admin_or_controller, CANISTER_DATA}; | ||
|
||
#[update(guard = "is_caller_global_admin_or_controller")] | ||
pub fn upgrade_all_creator_dao_governance_canisters_in_the_network(wasm_module: Vec<u8>) { | ||
let subnet_orchestrators = CANISTER_DATA | ||
.with_borrow(|canister_data| canister_data.all_subnet_orchestrator_canisters_list.clone()); | ||
|
||
let upgrade_governance_canister_tasks = | ||
subnet_orchestrators | ||
.into_iter() | ||
.map(move |subnet_orchestrator| { | ||
let wasm = wasm_module.clone(); | ||
async move { | ||
ic_cdk::call::<_, ()>( | ||
subnet_orchestrator, | ||
"upgrade_all_creator_dao_governance_canisters_in_the_network", | ||
(wasm,), | ||
) | ||
.await | ||
.map_err(|e| e.1) | ||
} | ||
}); | ||
|
||
ic_cdk::spawn(run_task_concurrently( | ||
upgrade_governance_canister_tasks, | ||
10, | ||
|result| { | ||
if let Err(e) = result { | ||
ic_cdk::println!("Error upgrading governance canister in the subnet. {}", e); | ||
} | ||
}, | ||
|| false, | ||
)); | ||
} |
This file contains 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
This file contains 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
25 changes: 0 additions & 25 deletions
25
...management/notify_all_individual_canisters_to_upgrade_creator_dao_governance_canisters.rs
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...rc/api/canister_management/upgrade_all_creator_dao_governance_canisters_in_the_network.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use candid::Principal; | ||
use ic_cdk_macros::update; | ||
use shared_utils::common::utils::{ | ||
permissions::is_caller_controller_or_global_admin, task::run_task_concurrently, | ||
}; | ||
|
||
use crate::CANISTER_DATA; | ||
|
||
#[update(guard = "is_caller_controller_or_global_admin")] | ||
pub fn upgrade_all_creator_dao_governance_canisters_in_the_network(wasm_module: Vec<u8>) { | ||
let individual_canisters: Vec<Principal> = CANISTER_DATA.with_borrow(|canister_data| { | ||
canister_data | ||
.user_principal_id_to_canister_id_map | ||
.values() | ||
.cloned() | ||
.collect() | ||
}); | ||
|
||
let upgrade_governance_canister_tasks = | ||
individual_canisters.into_iter().map(move |canister_id| { | ||
let wasm = wasm_module.clone(); | ||
async move { | ||
ic_cdk::call::<_, (Result<(), String>,)>( | ||
canister_id, | ||
"upgrade_creator_dao_governance_canisters", | ||
(wasm,), | ||
) | ||
.await | ||
.map_err(|e| format!("Error: {:?}", e))? | ||
.0 | ||
} | ||
}); | ||
|
||
ic_cdk::spawn(run_task_concurrently( | ||
upgrade_governance_canister_tasks, | ||
10, | ||
|result| { | ||
if let Err(e) = result { | ||
ic_cdk::println!("Error upgrading governance canister. Error: {}", e); | ||
} | ||
}, | ||
|| false, | ||
)); | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.