-
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.
- Loading branch information
Showing
40 changed files
with
1,747 additions
and
471 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
19 changes: 19 additions & 0 deletions
19
scripts/canisters/local_deploy/upgrade_subnet_orchestrator.sh
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,19 @@ | ||
# !/bin/bash | ||
|
||
|
||
dfx build user_index | ||
|
||
# Specify the path to your Wasm.gz file | ||
wasm=".dfx/local/canisters/user_index/user_index.wasm.gz" | ||
|
||
|
||
|
||
# Use xxd to convert the file content to a hexadecimal string | ||
char=$(hexdump -ve '1/1 "%.2x"' "$wasm") | ||
|
||
# Escape special characters in the hexadecimal string | ||
char_escaped=$(printf "%s" "$char" | sed 's/../\\&/g') | ||
|
||
# Create a shell script with the escaped hexadecimal string | ||
printf "(record {version = \"v2.2.0\"; canister = variant {SubnetOrchestratorWasm}; wasm_blob = blob \"%s\"})" "$char_escaped" > argument | ||
dfx canister call platform_orchestrator upgrade_canisters_in_network --argument-file argument |
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
59 changes: 59 additions & 0 deletions
59
src/canister/individual_user_template/src/api/cdao/delete_all_sns_creator_token.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,59 @@ | ||
use ic_cdk::api::management_canister::main::{deposit_cycles, CanisterIdRecord}; | ||
use ic_cdk_macros::update; | ||
use shared_utils::{ | ||
canister_specific::individual_user_template::types::{ | ||
cdao::DeployedCdaoCanisters, session::SessionType, | ||
}, | ||
common::utils::permissions::is_caller_controller, | ||
}; | ||
|
||
use crate::CANISTER_DATA; | ||
|
||
use super::{ | ||
request_cycles_from_subnet_orchestrator, | ||
utils::uninstall_code_and_return_empty_canisters_to_subnet_backup_pool, SubnetOrchestrator, | ||
}; | ||
|
||
#[update(guard = "is_caller_controller")] | ||
pub fn delete_all_creator_token() { | ||
let session_type_opt = CANISTER_DATA.with_borrow(|canister_data| canister_data.session_type); | ||
|
||
if let Some(session_type) = session_type_opt { | ||
if matches!(session_type, SessionType::RegisteredSession) { | ||
return; | ||
} | ||
} | ||
|
||
let deployed_canisters = | ||
CANISTER_DATA.with_borrow(|canister_data| canister_data.cdao_canisters.clone()); | ||
|
||
deployed_canisters | ||
.iter() | ||
.for_each(|deployed_cdao_canisters| { | ||
delete_sns_creator_token(deployed_cdao_canisters); | ||
}); | ||
|
||
CANISTER_DATA.with_borrow_mut(|canister_data| { | ||
canister_data.cdao_canisters = vec![]; | ||
}) | ||
} | ||
|
||
pub fn delete_sns_creator_token(deployed_canisters: &DeployedCdaoCanisters) { | ||
let canister_ids = deployed_canisters.get_canister_ids(); | ||
|
||
const UNINSTALL_RECHARGE_AMOUNT: u128 = 300_000_000_000; | ||
|
||
ic_cdk::spawn(async move { | ||
let _ = request_cycles_from_subnet_orchestrator(5 * UNINSTALL_RECHARGE_AMOUNT).await; | ||
for canister_id in canister_ids.iter() { | ||
let _ = deposit_cycles( | ||
CanisterIdRecord { | ||
canister_id: *canister_id, | ||
}, | ||
UNINSTALL_RECHARGE_AMOUNT, | ||
) | ||
.await; | ||
} | ||
uninstall_code_and_return_empty_canisters_to_subnet_backup_pool(canister_ids).await; | ||
}); | ||
} |
Oops, something went wrong.