From 23fb9992d3ef6dfa6df6ad9e2f52d5aa50d62c14 Mon Sep 17 00:00:00 2001 From: ravibazz Date: Wed, 13 Nov 2024 17:27:01 +0530 Subject: [PATCH 1/3] update limit for number of creator dao tokens per user --- .../src/api/cdao/mod.rs | 27 ++++++++++--------- .../individual_user_template/consts.rs | 1 - .../individual_user_template/mod.rs | 1 - src/lib/shared_utils/src/constant.rs | 2 ++ 4 files changed, 17 insertions(+), 14 deletions(-) delete mode 100644 src/lib/shared_utils/src/canister_specific/individual_user_template/consts.rs diff --git a/src/canister/individual_user_template/src/api/cdao/mod.rs b/src/canister/individual_user_template/src/api/cdao/mod.rs index d5df18a2..7371c80a 100644 --- a/src/canister/individual_user_template/src/api/cdao/mod.rs +++ b/src/canister/individual_user_template/src/api/cdao/mod.rs @@ -28,19 +28,17 @@ use ic_nns_governance::pb::v1::{ SettleNeuronsFundParticipationRequest, SettleNeuronsFundParticipationResponse, }; use shared_utils::{ - canister_specific::individual_user_template::{ - consts::CDAO_TOKEN_LIMIT, - types::{ - cdao::{AirdropInfo, DeployedCdaoCanisters}, - error::CdaoDeployError, - session::SessionType, - }, + canister_specific::individual_user_template::types::{ + cdao::{AirdropInfo, DeployedCdaoCanisters}, + error::CdaoDeployError, + session::SessionType, }, common::types::known_principal::KnownPrincipalType, constant::{ - NNS_LEDGER_CANISTER_ID, SNS_TOKEN_ARCHIVE_MODULE_HASH, SNS_TOKEN_GOVERNANCE_MODULE_HASH, - SNS_TOKEN_INDEX_MODULE_HASH, SNS_TOKEN_LEDGER_MODULE_HASH, SNS_TOKEN_ROOT_MODULE_HASH, - SNS_TOKEN_SWAP_MODULE_HASH, USER_SNS_CANISTER_INITIAL_CYCLES, + MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN, NNS_LEDGER_CANISTER_ID, SNS_TOKEN_ARCHIVE_MODULE_HASH, + SNS_TOKEN_GOVERNANCE_MODULE_HASH, SNS_TOKEN_INDEX_MODULE_HASH, + SNS_TOKEN_LEDGER_MODULE_HASH, SNS_TOKEN_ROOT_MODULE_HASH, SNS_TOKEN_SWAP_MODULE_HASH, + USER_SNS_CANISTER_INITIAL_CYCLES, }, }; @@ -113,11 +111,16 @@ async fn deploy_cdao_sns( let (registered, limit_hit) = CANISTER_DATA.with(|cdata| { let cdata = cdata.borrow(); let registered = matches!(cdata.session_type, Some(SessionType::RegisteredSession)); - (registered, cdata.cdao_canisters.len() == CDAO_TOKEN_LIMIT) + ( + registered, + cdata.cdao_canisters.len() == MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN, + ) }); if limit_hit { - return Err(CdaoDeployError::TokenLimit(CDAO_TOKEN_LIMIT)); + return Err(CdaoDeployError::TokenLimit( + MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN, + )); } // Alloting 0.5T more to the user canister to be on safer side while deploying canisters diff --git a/src/lib/shared_utils/src/canister_specific/individual_user_template/consts.rs b/src/lib/shared_utils/src/canister_specific/individual_user_template/consts.rs deleted file mode 100644 index 0ef910ef..00000000 --- a/src/lib/shared_utils/src/canister_specific/individual_user_template/consts.rs +++ /dev/null @@ -1 +0,0 @@ -pub const CDAO_TOKEN_LIMIT: usize = 5; \ No newline at end of file diff --git a/src/lib/shared_utils/src/canister_specific/individual_user_template/mod.rs b/src/lib/shared_utils/src/canister_specific/individual_user_template/mod.rs index 08b2ec37..cd408564 100644 --- a/src/lib/shared_utils/src/canister_specific/individual_user_template/mod.rs +++ b/src/lib/shared_utils/src/canister_specific/individual_user_template/mod.rs @@ -1,2 +1 @@ pub mod types; -pub mod consts; \ No newline at end of file diff --git a/src/lib/shared_utils/src/constant.rs b/src/lib/shared_utils/src/constant.rs index a70874be..e7fb6f25 100644 --- a/src/lib/shared_utils/src/constant.rs +++ b/src/lib/shared_utils/src/constant.rs @@ -43,6 +43,8 @@ pub const RESERVED_NUMBER_OF_INSTRUCTIONS_FOR_INSTALL_CODE: u128 = 200_000_000_0 pub const THRESHOLD_NUMBER_OF_DAYS_TO_KEEP_CANISTER_RUNNING: u128 = 1; pub const MAX_NUMBER_OF_DAYS_TO_KEEP_CANISTER_RUNNING: u128 = 7; +pub const MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN: usize = 2; + pub const SNS_TOKEN_GOVERNANCE_MODULE_HASH: &'static str = "bc91fd7bc4d6c01ea814b12510a1ff8f4f74fcac9ab16248ad4af7cb98d9c69d"; pub const SNS_TOKEN_LEDGER_MODULE_HASH: &'static str = From 2a328a533087e23e5ba07e84d7ac86d69fb0b8b4 Mon Sep 17 00:00:00 2001 From: ravibazz Date: Thu, 14 Nov 2024 20:25:10 +0530 Subject: [PATCH 2/3] fix conditional check --- src/canister/individual_user_template/src/api/cdao/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/canister/individual_user_template/src/api/cdao/mod.rs b/src/canister/individual_user_template/src/api/cdao/mod.rs index 7371c80a..85c49810 100644 --- a/src/canister/individual_user_template/src/api/cdao/mod.rs +++ b/src/canister/individual_user_template/src/api/cdao/mod.rs @@ -113,7 +113,7 @@ async fn deploy_cdao_sns( let registered = matches!(cdata.session_type, Some(SessionType::RegisteredSession)); ( registered, - cdata.cdao_canisters.len() == MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN, + cdata.cdao_canisters.len() >= MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN, ) }); From baccfb15493120aa1ada169867e0bb43efa05fdf Mon Sep 17 00:00:00 2001 From: ravibazz Date: Thu, 14 Nov 2024 20:48:28 +0530 Subject: [PATCH 3/3] added test to verify the max limit of creator dao tokens --- .../tests/creator_dao/main.rs | 154 +---------- .../test_number_of_creator_tokens.rs | 258 ++++++++++++++++++ .../tests/creator_dao/utils.rs | 160 +++++++++++ 3 files changed, 422 insertions(+), 150 deletions(-) create mode 100644 src/lib/integration_tests/tests/creator_dao/test_number_of_creator_tokens.rs create mode 100644 src/lib/integration_tests/tests/creator_dao/utils.rs diff --git a/src/lib/integration_tests/tests/creator_dao/main.rs b/src/lib/integration_tests/tests/creator_dao/main.rs index ad68ab65..79d5af0d 100644 --- a/src/lib/integration_tests/tests/creator_dao/main.rs +++ b/src/lib/integration_tests/tests/creator_dao/main.rs @@ -1,4 +1,6 @@ +pub mod test_number_of_creator_tokens; pub mod types; +pub mod utils; use ic_ledger_types::Memo; use ic_sns_governance::pb::v1::governance::Version; @@ -24,6 +26,7 @@ use shared_utils::constant::{ use std::time::{Duration, UNIX_EPOCH}; use std::{collections::HashMap, fmt::Debug, str::FromStr, time::SystemTime, vec}; use test_utils::setup::test_constants::get_mock_user_bob_principal_id; +use utils::setup_sns_w_canister_for_creator_dao; use candid::{encode_args, CandidType, Decode, Encode, Nat, Principal}; use ic_base_types::PrincipalId; @@ -186,158 +189,9 @@ fn creator_dao_tests() { .unwrap(); let alice_initial_cycle_balance = pocket_ic.cycle_balance(alice_canister_id); - - let sns_wasm_w_canister_wasm = include_bytes!("../../../../../wasms/sns-wasm-canister.wasm"); let sns_wasm_w_canister_id = Principal::from_text(SNS_WASM_W_PRINCIPAL_ID).unwrap(); - let _ = pocket_ic.create_canister_with_id( - Some(super_admin), - None, - Principal::from_text(SNS_WASM_W_PRINCIPAL_ID).unwrap(), - ); - - let sns_wasm_canister_init_payload = SnsWasmCanisterInitPayload { - sns_subnet_ids: vec![], - access_controls_enabled: false, - allowed_principals: vec![], - }; - - pocket_ic.install_canister( - sns_wasm_w_canister_id, - sns_wasm_w_canister_wasm.to_vec(), - Encode!(&sns_wasm_canister_init_payload).unwrap(), - Some(super_admin), - ); - - let res = pocket_ic - .update_call( - sns_wasm_w_canister_id, - super_admin, - "add_wasm", - candid::encode_one(add_wasm( - include_bytes!("../../../../../wasms/root.wasm.gz"), - 1, - )) - .unwrap(), - ) - .map(|res| { - let response: AddWasmResultRecord = match res { - WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), - _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), - }; - response - }) - .unwrap(); - ic_cdk::println!("๐Ÿงช Result: {:?}", res); - - let res = pocket_ic - .update_call( - sns_wasm_w_canister_id, - super_admin, - "add_wasm", - candid::encode_one(add_wasm( - include_bytes!("../../../../../wasms/governance.wasm.gz"), - 2, - )) - .unwrap(), - ) - .map(|res| { - let response: AddWasmResultRecord = match res { - WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), - _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), - }; - response - }) - .unwrap(); - ic_cdk::println!("๐Ÿงช Result: {:?}", res); - - let res = pocket_ic - .update_call( - sns_wasm_w_canister_id, - super_admin, - "add_wasm", - candid::encode_one(add_wasm( - include_bytes!("../../../../../wasms/ledger.wasm.gz"), - 3, - )) - .unwrap(), - ) - .map(|res| { - let response: AddWasmResultRecord = match res { - WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), - _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), - }; - response - }) - .unwrap(); - ic_cdk::println!("๐Ÿงช Result: {:?}", res); - - let res = pocket_ic - .update_call( - sns_wasm_w_canister_id, - super_admin, - "add_wasm", - candid::encode_one(add_wasm( - include_bytes!("../../../../../wasms/swap.wasm.gz"), - 4, - )) - .unwrap(), - ) - .map(|res| { - let response: AddWasmResultRecord = match res { - WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), - _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), - }; - response - }) - .unwrap(); - ic_cdk::println!("๐Ÿงช Result: {:?}", res); - - let res = pocket_ic - .update_call( - sns_wasm_w_canister_id, - super_admin, - "add_wasm", - candid::encode_one(add_wasm( - include_bytes!("../../../../../wasms/archive.wasm.gz"), - 5, - )) - .unwrap(), - ) - .map(|res| { - let response: AddWasmResultRecord = match res { - WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), - _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), - }; - response - }) - .unwrap(); - ic_cdk::println!("๐Ÿงช Result: {:?}", res); - - let res = pocket_ic - .update_call( - sns_wasm_w_canister_id, - super_admin, - "add_wasm", - candid::encode_one(add_wasm( - include_bytes!("../../../../../wasms/index.wasm.gz"), - 6, - )) - .unwrap(), - ) - .map(|res| { - let response: AddWasmResultRecord = match res { - WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), - _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), - }; - response - }) - .unwrap(); - ic_cdk::println!("๐Ÿงช Result: {:?}", res); - - for _ in 0..50 { - pocket_ic.tick(); - } + setup_sns_w_canister_for_creator_dao(&pocket_ic, super_admin); let res = pocket_ic .update_call( diff --git a/src/lib/integration_tests/tests/creator_dao/test_number_of_creator_tokens.rs b/src/lib/integration_tests/tests/creator_dao/test_number_of_creator_tokens.rs new file mode 100644 index 00000000..1f182875 --- /dev/null +++ b/src/lib/integration_tests/tests/creator_dao/test_number_of_creator_tokens.rs @@ -0,0 +1,258 @@ +use std::{ + collections::HashMap, + str::FromStr, + time::{SystemTime, UNIX_EPOCH}, +}; + +use candid::{Decode, Principal}; +use ic_base_types::PrincipalId; +use ic_sns_init::pb::v1::{ + sns_init_payload::InitialTokenDistribution, AirdropDistribution, DeveloperDistribution, + FractionalDeveloperVotingPower, NeuronDistribution, SnsInitPayload, SwapDistribution, + TreasuryDistribution, +}; +use ic_sns_swap::pb::v1::NeuronBasketConstructionParameters; +use pocket_ic::WasmResult; +use shared_utils::{ + canister_specific::individual_user_template::types::{ + cdao::DeployedCdaoCanisters, error::CdaoDeployError, + }, + common::types::known_principal::KnownPrincipalType, + constant::{MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN, SNS_WASM_W_PRINCIPAL_ID}, +}; +use test_utils::setup::{ + env::pocket_ic_env::get_new_pocket_ic_env, + test_constants::{ + get_global_super_admin_principal_id, get_mock_user_alice_principal_id, + get_mock_user_charlie_principal_id, + }, +}; + +use crate::utils::setup_sns_w_canister_for_creator_dao; + +#[test] +pub fn test_number_of_creator_tokens() { + let (pocket_ic, known_principal) = get_new_pocket_ic_env(); + let platform_canister_id = known_principal + .get(&KnownPrincipalType::CanisterIdPlatformOrchestrator) + .cloned() + .unwrap(); + + let super_admin = get_global_super_admin_principal_id(); + + let application_subnets = pocket_ic.topology().get_app_subnets(); + + let charlie_global_admin = get_mock_user_charlie_principal_id(); + + pocket_ic + .update_call( + platform_canister_id, + super_admin, + "add_principal_as_global_admin", + candid::encode_one(charlie_global_admin).unwrap(), + ) + .unwrap(); + + pocket_ic + .update_call( + platform_canister_id, + super_admin, + "update_global_known_principal", + candid::encode_args(( + KnownPrincipalType::CanisterIdSnsWasm, + Principal::from_text(SNS_WASM_W_PRINCIPAL_ID).unwrap(), + )) + .unwrap(), + ) + .unwrap(); + + let subnet_orchestrator_canister_id: Principal = pocket_ic + .update_call( + platform_canister_id, + charlie_global_admin, + "provision_subnet_orchestrator_canister", + candid::encode_one(application_subnets[1]).unwrap(), + ) + .map(|res| { + let canister_id_result: Result = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("Canister call failed"), + }; + canister_id_result.unwrap() + }) + .unwrap(); + + for i in 0..50 { + pocket_ic.tick(); + } + + let alice_principal = get_mock_user_alice_principal_id(); + let alice_canister_id: Principal = pocket_ic + .update_call( + subnet_orchestrator_canister_id, + alice_principal, + "get_requester_principals_canister_id_create_if_not_exists", + candid::encode_one(()).unwrap(), + ) + .map(|reply_payload| { + let response: Result = match reply_payload { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap() + .unwrap(); + + let alice_initial_cycle_balance = pocket_ic.cycle_balance(alice_canister_id); + + let sns_wasm_w_canister_id = Principal::from_text(SNS_WASM_W_PRINCIPAL_ID).unwrap(); + + setup_sns_w_canister_for_creator_dao(&pocket_ic, super_admin); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + Principal::anonymous(), + "get_latest_sns_version_pretty".into(), + candid::encode_one(()).unwrap(), + ) + .map(|res| { + let response: HashMap = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + + ic_cdk::println!("๐Ÿงช HASHMAP {:?}", res); + assert_eq!(res.len(), 6); + let start = SystemTime::now(); + + let tx_fee = 1u64; + + let sns_init_args = SnsInitPayload { + confirmation_text: Some("GET RICH QUICK".to_string()), + transaction_fee_e8s: Some(tx_fee), + token_name: Some("Simulation Governance".to_string()), + token_symbol: Some("SIMG".to_string()), + proposal_reject_cost_e8s: Some(1u64), + neuron_minimum_stake_e8s: Some(2u64), + fallback_controller_principal_ids: vec![super_admin.to_string().clone()], + logo: Some("data:image/png;base64,iVBORw0".to_string()), + url: Some("https://google.com".to_string()), + name: Some("Simulation Gov".to_string()), + description: Some("Simulation gov desc".to_string()), + neuron_minimum_dissolve_delay_to_vote_seconds: Some(1), + initial_reward_rate_basis_points: Some(30u64), + final_reward_rate_basis_points: Some(20u64), + reward_rate_transition_duration_seconds: Some(1u64), + max_dissolve_delay_seconds: Some(5u64), + max_neuron_age_seconds_for_age_bonus: Some(1u64), + max_dissolve_delay_bonus_percentage: Some(10u64), + max_age_bonus_percentage: Some(10u64), + initial_voting_period_seconds: Some(86401u64), + wait_for_quiet_deadline_increase_seconds: Some(1u64), + restricted_countries: None, + dapp_canisters: None, + min_participants: Some(1), + min_icp_e8s: None, + max_icp_e8s: None, + min_direct_participation_icp_e8s: Some(15u64), + min_participant_icp_e8s: Some(2000u64), + max_direct_participation_icp_e8s: Some(100_000_000u64), + max_participant_icp_e8s: Some(100_000_000u64), + swap_start_timestamp_seconds: Some(start.duration_since(UNIX_EPOCH).unwrap().as_secs()), + swap_due_timestamp_seconds: Some(start.duration_since(UNIX_EPOCH).unwrap().as_secs() + 300), // year 3000 - hopefully we'll all be gone by then, + neuron_basket_construction_parameters: Some(NeuronBasketConstructionParameters { + count: 2, + dissolve_delay_interval_seconds: 2, + }), + nns_proposal_id: Some(1), + neurons_fund_participation: Some(false), + token_logo: Some("data:image/png;base64,iVBORw0".to_string()), + neurons_fund_participation_constraints: None, + initial_token_distribution: Some(InitialTokenDistribution::FractionalDeveloperVotingPower( + FractionalDeveloperVotingPower { + airdrop_distribution: Some(AirdropDistribution { + airdrop_neurons: vec![], + }), + developer_distribution: Some(DeveloperDistribution { + developer_neurons: vec![ + NeuronDistribution { + controller: Some( + PrincipalId::from_str(&alice_principal.to_string()).unwrap(), + ), + stake_e8s: 60_000_000_000, + memo: 0, + dissolve_delay_seconds: 0, + vesting_period_seconds: None, + }, + NeuronDistribution { + controller: Some( + PrincipalId::from_str(&alice_principal.to_string()).unwrap(), + ), + stake_e8s: 100_000, + memo: 1, + dissolve_delay_seconds: 2, + vesting_period_seconds: None, + }, + ], + }), + treasury_distribution: Some(TreasuryDistribution { + total_e8s: 10_000_000, + }), + swap_distribution: Some(SwapDistribution { + total_e8s: 65_000_000_000, + initial_swap_amount_e8s: 5_000_000, + }), + }, + )), + }; + + for _ in 0..MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN { + let creator_dao_deployed_cans_result = pocket_ic + .update_call( + alice_canister_id, + alice_principal, + "deploy_cdao_sns", + candid::encode_args((sns_init_args.clone(), 300 as u64)).unwrap(), + ) + .map(|res| { + let response: Result = match res { + WasmResult::Reply(payload) => { + ic_cdk::println!("๐Ÿงช Call made"); + Decode!(&payload, Result).unwrap() + } + _ => panic!("\n๐Ÿ›‘ deploy cdao failed with {:?}", res), + }; + response + }) + .unwrap(); + + assert!(creator_dao_deployed_cans_result.is_ok()); + } + let creator_dao_deployed_cans_result = pocket_ic + .update_call( + alice_canister_id, + alice_principal, + "deploy_cdao_sns", + candid::encode_args((sns_init_args, 300 as u64)).unwrap(), + ) + .map(|res| { + let response: Result = match res { + WasmResult::Reply(payload) => { + ic_cdk::println!("๐Ÿงช Call made"); + Decode!(&payload, Result).unwrap() + } + _ => panic!("\n๐Ÿ›‘ deploy cdao failed with {:?}", res), + }; + response + }) + .unwrap(); + + assert!(creator_dao_deployed_cans_result.is_err()); + assert!(matches!( + creator_dao_deployed_cans_result, Err(e) if e == CdaoDeployError::TokenLimit(MAX_LIMIT_FOR_CREATOR_DAO_SNS_TOKEN))) +} diff --git a/src/lib/integration_tests/tests/creator_dao/utils.rs b/src/lib/integration_tests/tests/creator_dao/utils.rs new file mode 100644 index 00000000..b3eb0a6f --- /dev/null +++ b/src/lib/integration_tests/tests/creator_dao/utils.rs @@ -0,0 +1,160 @@ +use candid::{Encode, Principal}; +use ic_sns_wasm::init::SnsWasmCanisterInitPayload; +use pocket_ic::{PocketIc, WasmResult}; +use shared_utils::constant::SNS_WASM_W_PRINCIPAL_ID; + +use crate::{add_wasm, AddWasmResultRecord}; + +pub fn setup_sns_w_canister_for_creator_dao(pocket_ic: &PocketIc, super_admin: Principal) { + let sns_wasm_w_canister_wasm = include_bytes!("../../../../../wasms/sns-wasm-canister.wasm"); + let sns_wasm_w_canister_id = Principal::from_text(SNS_WASM_W_PRINCIPAL_ID).unwrap(); + + let _ = pocket_ic.create_canister_with_id( + Some(super_admin), + None, + Principal::from_text(SNS_WASM_W_PRINCIPAL_ID).unwrap(), + ); + + let sns_wasm_canister_init_payload = SnsWasmCanisterInitPayload { + sns_subnet_ids: vec![], + access_controls_enabled: false, + allowed_principals: vec![], + }; + + pocket_ic.install_canister( + sns_wasm_w_canister_id, + sns_wasm_w_canister_wasm.to_vec(), + Encode!(&sns_wasm_canister_init_payload).unwrap(), + Some(super_admin), + ); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + super_admin, + "add_wasm", + candid::encode_one(add_wasm( + include_bytes!("../../../../../wasms/root.wasm.gz"), + 1, + )) + .unwrap(), + ) + .map(|res| { + let response: AddWasmResultRecord = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + ic_cdk::println!("๐Ÿงช Result: {:?}", res); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + super_admin, + "add_wasm", + candid::encode_one(add_wasm( + include_bytes!("../../../../../wasms/governance.wasm.gz"), + 2, + )) + .unwrap(), + ) + .map(|res| { + let response: AddWasmResultRecord = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + ic_cdk::println!("๐Ÿงช Result: {:?}", res); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + super_admin, + "add_wasm", + candid::encode_one(add_wasm( + include_bytes!("../../../../../wasms/ledger.wasm.gz"), + 3, + )) + .unwrap(), + ) + .map(|res| { + let response: AddWasmResultRecord = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + ic_cdk::println!("๐Ÿงช Result: {:?}", res); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + super_admin, + "add_wasm", + candid::encode_one(add_wasm( + include_bytes!("../../../../../wasms/swap.wasm.gz"), + 4, + )) + .unwrap(), + ) + .map(|res| { + let response: AddWasmResultRecord = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + ic_cdk::println!("๐Ÿงช Result: {:?}", res); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + super_admin, + "add_wasm", + candid::encode_one(add_wasm( + include_bytes!("../../../../../wasms/archive.wasm.gz"), + 5, + )) + .unwrap(), + ) + .map(|res| { + let response: AddWasmResultRecord = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + ic_cdk::println!("๐Ÿงช Result: {:?}", res); + + let res = pocket_ic + .update_call( + sns_wasm_w_canister_id, + super_admin, + "add_wasm", + candid::encode_one(add_wasm( + include_bytes!("../../../../../wasms/index.wasm.gz"), + 6, + )) + .unwrap(), + ) + .map(|res| { + let response: AddWasmResultRecord = match res { + WasmResult::Reply(payload) => candid::decode_one(&payload).unwrap(), + _ => panic!("\n๐Ÿ›‘ get requester principals canister id failed\n"), + }; + response + }) + .unwrap(); + ic_cdk::println!("๐Ÿงช Result: {:?}", res); + + for _ in 0..50 { + pocket_ic.tick(); + } +}