From 2e3b47e9adbc81e32ea69a7a8876c147c21f3571 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:08:13 +0200 Subject: [PATCH 01/13] refactor: move mgmt functions together Signed-off-by: David Dal Busco --- src/mission_control/src/lib.rs | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/mission_control/src/lib.rs b/src/mission_control/src/lib.rs index 1e304d2a8..5f061724f 100644 --- a/src/mission_control/src/lib.rs +++ b/src/mission_control/src/lib.rs @@ -271,25 +271,6 @@ async fn del_orbiter(orbiter_id: OrbiterId, cycles_to_deposit: u128) { .unwrap_or_else(|e| trap(&e)); } -/// Mgmt - -#[update(guard = "caller_is_user_or_admin_controller")] -async fn top_up(canister_id: Principal, amount: Tokens) { - top_up_canister(&canister_id, &amount) - .await - .unwrap_or_else(|e| trap(&e)); -} - -#[query(guard = "caller_is_user_or_admin_controller")] -fn get_user() -> UserId { - get_user_store() -} - -#[update(guard = "caller_is_user_or_admin_controller")] -fn set_metadata(metadata: Metadata) { - set_metadata_store(&metadata) -} - /// /// Controllers /// @@ -348,6 +329,23 @@ fn list_mission_control_controllers() -> Controllers { /// Mgmt /// +#[query(guard = "caller_is_user_or_admin_controller")] +fn get_user() -> UserId { + get_user_store() +} + +#[update(guard = "caller_is_user_or_admin_controller")] +fn set_metadata(metadata: Metadata) { + set_metadata_store(&metadata) +} + +#[update(guard = "caller_is_user_or_admin_controller")] +async fn top_up(canister_id: Principal, amount: Tokens) { + top_up_canister(&canister_id, &amount) + .await + .unwrap_or_else(|e| trap(&e)); +} + #[update(guard = "caller_is_user_or_admin_controller")] async fn deposit_cycles(args: DepositCyclesArgs) { deposit_cycles_shared(args) From 54781b98e991b6139dad51aa5bc25d8c0be5b8f6 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:22:02 +0200 Subject: [PATCH 02/13] chore:next version Signed-off-by: David Dal Busco --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b4ad1081..1b807d1c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@junobuild/juno", - "version": "0.0.34", + "version": "0.0.35", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@junobuild/juno", - "version": "0.0.34", + "version": "0.0.35", "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "@dfinity/agent": "^2.0.0", diff --git a/package.json b/package.json index 3b3dd655f..8e423b165 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@junobuild/juno", - "version": "0.0.34", + "version": "0.0.35", "private": true, "author": "David Dal Busco ", "license": "SEE LICENSE IN LICENSE.md", From 7959d388e182f1ff05bd3a7f3bcdbc3e67f2b7f9 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:50:38 +0200 Subject: [PATCH 03/13] refactor: extract common canister settings and cycles (#748) Signed-off-by: David Dal Busco --- src/libs/shared/src/mgmt/cmc.rs | 21 ++++++--------------- src/libs/shared/src/mgmt/ic.rs | 16 ++++------------ src/libs/shared/src/mgmt/mod.rs | 1 + src/libs/shared/src/mgmt/settings.rs | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 src/libs/shared/src/mgmt/settings.rs diff --git a/src/libs/shared/src/mgmt/cmc.rs b/src/libs/shared/src/mgmt/cmc.rs index 5b78b2d1d..9d8da3b6c 100644 --- a/src/libs/shared/src/mgmt/cmc.rs +++ b/src/libs/shared/src/mgmt/cmc.rs @@ -1,17 +1,16 @@ -use crate::constants::{ - CREATE_CANISTER_CYCLES, IC_TRANSACTION_FEE_ICP, MEMO_CANISTER_TOP_UP, WASM_MEMORY_LIMIT, -}; +use crate::constants::{IC_TRANSACTION_FEE_ICP, MEMO_CANISTER_TOP_UP}; use crate::env::CMC; use crate::ledger::icp::transfer_payment; use crate::mgmt::ic::install_code; +use crate::mgmt::settings::{create_canister_cycles, create_canister_settings}; use crate::mgmt::types::cmc::{ CreateCanister, CreateCanisterResult, Cycles, NotifyError, SubnetId, SubnetSelection, TopUpCanisterArgs, }; use crate::mgmt::types::ic::WasmArg; -use candid::{Nat, Principal}; +use candid::Principal; use ic_cdk::api::call::{call_with_payment128, CallResult}; -use ic_cdk::api::management_canister::main::{CanisterId, CanisterInstallMode, CanisterSettings}; +use ic_cdk::api::management_canister::main::{CanisterId, CanisterInstallMode}; use ic_cdk::call; use ic_ledger_types::{Subaccount, Tokens}; @@ -81,22 +80,14 @@ pub async fn cmc_create_canister_install_code( let create_canister_arg = CreateCanister { subnet_type: None, subnet_selection: Some(SubnetSelection::Subnet { subnet: *subnet_id }), - settings: Some(CanisterSettings { - controllers: Some(controllers.clone()), - compute_allocation: None, - memory_allocation: None, - freezing_threshold: None, - reserved_cycles_limit: None, - log_visibility: None, - wasm_memory_limit: Some(Nat::from(WASM_MEMORY_LIMIT)), - }), + settings: create_canister_settings(controllers), }; let result: CallResult<(CreateCanisterResult,)> = call_with_payment128( cmc, "create_canister", (create_canister_arg,), - CREATE_CANISTER_CYCLES + cycles, + create_canister_cycles(cycles), ) .await; diff --git a/src/libs/shared/src/mgmt/ic.rs b/src/libs/shared/src/mgmt/ic.rs index 4c7e2d3f0..6feed46f9 100644 --- a/src/libs/shared/src/mgmt/ic.rs +++ b/src/libs/shared/src/mgmt/ic.rs @@ -1,10 +1,10 @@ -use crate::constants::{CREATE_CANISTER_CYCLES, WASM_MEMORY_LIMIT}; +use crate::mgmt::settings::{create_canister_cycles, create_canister_settings}; use crate::mgmt::types::ic::WasmArg; use crate::types::interface::DepositCyclesArgs; use crate::types::state::{ SegmentCanisterSettings, SegmentCanisterStatus, SegmentStatus, SegmentStatusResult, }; -use candid::{Nat, Principal}; +use candid::{Principal}; use ic_cdk::api::call::CallResult; use ic_cdk::api::management_canister::main::{ canister_status as ic_canister_status, create_canister, delete_canister, @@ -31,17 +31,9 @@ pub async fn create_canister_install_code( ) -> Result { let record = create_canister( CreateCanisterArgument { - settings: Some(CanisterSettings { - controllers: Some(controllers.clone()), - compute_allocation: None, - memory_allocation: None, - freezing_threshold: None, - reserved_cycles_limit: None, - log_visibility: None, - wasm_memory_limit: Some(Nat::from(WASM_MEMORY_LIMIT)), - }), + settings: create_canister_settings(controllers), }, - CREATE_CANISTER_CYCLES + cycles, + create_canister_cycles(cycles), ) .await; diff --git a/src/libs/shared/src/mgmt/mod.rs b/src/libs/shared/src/mgmt/mod.rs index 2955fc740..b5b96509d 100644 --- a/src/libs/shared/src/mgmt/mod.rs +++ b/src/libs/shared/src/mgmt/mod.rs @@ -1,4 +1,5 @@ pub mod cmc; pub mod ic; mod impls; +mod settings; pub mod types; diff --git a/src/libs/shared/src/mgmt/settings.rs b/src/libs/shared/src/mgmt/settings.rs new file mode 100644 index 000000000..c5902b51f --- /dev/null +++ b/src/libs/shared/src/mgmt/settings.rs @@ -0,0 +1,19 @@ +use crate::constants::{CREATE_CANISTER_CYCLES, WASM_MEMORY_LIMIT}; +use candid::{Nat, Principal}; +use ic_cdk::api::management_canister::main::CanisterSettings; + +pub fn create_canister_settings(controllers: Vec) -> Option { + Some(CanisterSettings { + controllers: Some(controllers.clone()), + compute_allocation: None, + memory_allocation: None, + freezing_threshold: None, + reserved_cycles_limit: None, + log_visibility: None, + wasm_memory_limit: Some(Nat::from(WASM_MEMORY_LIMIT)), + }) +} + +pub fn create_canister_cycles(cycles: u128) -> u128 { + CREATE_CANISTER_CYCLES + cycles +} From 258ba44d2e680478a4e1c210095bafaa597e3661 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:51:43 +0200 Subject: [PATCH 04/13] chore: version for release Signed-off-by: David Dal Busco --- Cargo.lock | 33 ++++++++++++++++++++++++++------- src/libs/shared/Cargo.toml | 2 +- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f44d89a8..8abbcb02a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,7 +263,7 @@ dependencies = [ "ic-ledger-types", "ic-stable-structures", "junobuild-collections", - "junobuild-shared", + "junobuild-shared 0.0.21", "junobuild-storage", "regex", "serde", @@ -832,7 +832,7 @@ dependencies = [ "ic-cdk", "ic-cdk-macros", "ic-cdk-timers", - "junobuild-shared", + "junobuild-shared 0.0.20", "serde", ] @@ -862,7 +862,7 @@ dependencies = [ "ic-cdk-timers", "ic-stable-structures", "junobuild-collections", - "junobuild-shared", + "junobuild-shared 0.0.20", "junobuild-storage", "junobuild-utils 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand", @@ -876,6 +876,25 @@ dependencies = [ [[package]] name = "junobuild-shared" version = "0.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0877f076bb487faf40227f3265a23ff383b674f9e8c920a36c688e3e81b14dfa" +dependencies = [ + "candid", + "ciborium", + "futures", + "ic-cdk", + "ic-cdk-macros", + "ic-ledger-types", + "ic-stable-structures", + "icrc-ledger-types", + "regex", + "serde", + "time", +] + +[[package]] +name = "junobuild-shared" +version = "0.0.21" dependencies = [ "candid", "ciborium", @@ -906,7 +925,7 @@ dependencies = [ "ic-response-verification", "ic-stable-structures", "junobuild-collections", - "junobuild-shared", + "junobuild-shared 0.0.20", "regex", "serde", "serde_bytes", @@ -1013,7 +1032,7 @@ dependencies = [ "ic-cdk-macros", "ic-ledger-types", "icrc-ledger-types", - "junobuild-shared", + "junobuild-shared 0.0.21", "serde", ] @@ -1071,7 +1090,7 @@ dependencies = [ "ic-cdk", "ic-cdk-macros", "ic-cdk-timers", - "junobuild-shared", + "junobuild-shared 0.0.21", "lazy_static", "serde", ] @@ -1092,7 +1111,7 @@ dependencies = [ "ic-cdk-macros", "ic-stable-structures", "isbot", - "junobuild-shared", + "junobuild-shared 0.0.21", "lazy_static", "regex", "serde", diff --git a/src/libs/shared/Cargo.toml b/src/libs/shared/Cargo.toml index bfd4064be..a1591aa99 100644 --- a/src/libs/shared/Cargo.toml +++ b/src/libs/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "junobuild-shared" -version = "0.0.20" +version = "0.0.21" authors.workspace = true edition.workspace = true repository.workspace = true From 7465d57f081c4d2fe844ca51330944c4ce6a6c74 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:53:08 +0200 Subject: [PATCH 05/13] chore: version for release Signed-off-by: David Dal Busco --- Cargo.lock | 32 ++++++++++++++++++++++++++++++-- src/libs/storage/Cargo.toml | 4 ++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8abbcb02a..23dbaed45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -264,7 +264,7 @@ dependencies = [ "ic-stable-structures", "junobuild-collections", "junobuild-shared 0.0.21", - "junobuild-storage", + "junobuild-storage 0.0.11", "regex", "serde", "serde_cbor", @@ -863,7 +863,7 @@ dependencies = [ "ic-stable-structures", "junobuild-collections", "junobuild-shared 0.0.20", - "junobuild-storage", + "junobuild-storage 0.0.10", "junobuild-utils 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand", "regex", @@ -912,6 +912,8 @@ dependencies = [ [[package]] name = "junobuild-storage" version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3815cc6162da1d28a9d3748e414a469f493cd4df1420ca724bc66777bf7923ca" dependencies = [ "base64 0.13.1", "candid", @@ -935,6 +937,32 @@ dependencies = [ "urlencoding", ] +[[package]] +name = "junobuild-storage" +version = "0.0.11" +dependencies = [ + "base64 0.13.1", + "candid", + "globset", + "hex", + "ic-cdk", + "ic-cdk-macros", + "ic-cdk-timers", + "ic-certification", + "ic-representation-independent-hash", + "ic-response-verification", + "ic-stable-structures", + "junobuild-collections", + "junobuild-shared 0.0.21", + "regex", + "serde", + "serde_bytes", + "serde_cbor", + "sha2", + "url", + "urlencoding", +] + [[package]] name = "junobuild-utils" version = "0.0.4" diff --git a/src/libs/storage/Cargo.toml b/src/libs/storage/Cargo.toml index ec0ff9b70..71130072d 100644 --- a/src/libs/storage/Cargo.toml +++ b/src/libs/storage/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "junobuild-storage" -version = "0.0.10" +version = "0.0.11" authors.workspace = true edition.workspace = true repository.workspace = true @@ -32,5 +32,5 @@ base64 = "0.13.1" url = "2.4.0" urlencoding = "2.1.3" globset = "0.4.13" -junobuild-shared = "0.0.20" +junobuild-shared = "0.0.21" junobuild-collections = "0.0.7" From 0eb0221cdaa426dac8119208b6b0ec4136865818 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:53:38 +0200 Subject: [PATCH 06/13] chore: version for release Signed-off-by: David Dal Busco --- Cargo.lock | 22 ++++++++++++++++++---- src/libs/collections/Cargo.toml | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23dbaed45..ced2e3276 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,7 @@ dependencies = [ "ic-cdk-timers", "ic-ledger-types", "ic-stable-structures", - "junobuild-collections", + "junobuild-collections 0.0.8", "junobuild-shared 0.0.21", "junobuild-storage 0.0.11", "regex", @@ -827,6 +827,8 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "junobuild-collections" version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38ae0a739f185426a8f612fde1e3b73ee313766a58e3b63aaec80e5c5db250b7" dependencies = [ "candid", "ic-cdk", @@ -836,6 +838,18 @@ dependencies = [ "serde", ] +[[package]] +name = "junobuild-collections" +version = "0.0.8" +dependencies = [ + "candid", + "ic-cdk", + "ic-cdk-macros", + "ic-cdk-timers", + "junobuild-shared 0.0.21", + "serde", +] + [[package]] name = "junobuild-macros" version = "0.0.2" @@ -861,7 +875,7 @@ dependencies = [ "ic-cdk-macros", "ic-cdk-timers", "ic-stable-structures", - "junobuild-collections", + "junobuild-collections 0.0.7", "junobuild-shared 0.0.20", "junobuild-storage 0.0.10", "junobuild-utils 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -926,7 +940,7 @@ dependencies = [ "ic-representation-independent-hash", "ic-response-verification", "ic-stable-structures", - "junobuild-collections", + "junobuild-collections 0.0.7", "junobuild-shared 0.0.20", "regex", "serde", @@ -952,7 +966,7 @@ dependencies = [ "ic-representation-independent-hash", "ic-response-verification", "ic-stable-structures", - "junobuild-collections", + "junobuild-collections 0.0.7", "junobuild-shared 0.0.21", "regex", "serde", diff --git a/src/libs/collections/Cargo.toml b/src/libs/collections/Cargo.toml index bfa2f0bb0..6822cf176 100644 --- a/src/libs/collections/Cargo.toml +++ b/src/libs/collections/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "junobuild-collections" -version = "0.0.7" +version = "0.0.8" authors.workspace = true edition.workspace = true repository.workspace = true @@ -19,4 +19,4 @@ ic-cdk.workspace = true ic-cdk-macros.workspace = true ic-cdk-timers.workspace = true serde.workspace = true -junobuild-shared = "0.0.20" \ No newline at end of file +junobuild-shared = "0.0.21" \ No newline at end of file From 139227eff5455cbb42caf1c739649ee9d322dc33 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:55:43 +0200 Subject: [PATCH 07/13] chore: version for release Signed-off-by: David Dal Busco --- Cargo.lock | 2 +- src/libs/storage/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ced2e3276..e19ed6fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -966,7 +966,7 @@ dependencies = [ "ic-representation-independent-hash", "ic-response-verification", "ic-stable-structures", - "junobuild-collections 0.0.7", + "junobuild-collections 0.0.8", "junobuild-shared 0.0.21", "regex", "serde", diff --git a/src/libs/storage/Cargo.toml b/src/libs/storage/Cargo.toml index 71130072d..314b83392 100644 --- a/src/libs/storage/Cargo.toml +++ b/src/libs/storage/Cargo.toml @@ -33,4 +33,4 @@ url = "2.4.0" urlencoding = "2.1.3" globset = "0.4.13" junobuild-shared = "0.0.21" -junobuild-collections = "0.0.7" +junobuild-collections = "0.0.8" From b2e59fb1c528eda256a84626974a7dfbafcfffdb Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 10:57:04 +0200 Subject: [PATCH 08/13] chore: version for release Signed-off-by: David Dal Busco --- Cargo.lock | 87 ++++++----------------------------- src/libs/satellite/Cargo.toml | 8 ++-- 2 files changed, 17 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e19ed6fdc..4e20c9a93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,9 +262,9 @@ dependencies = [ "ic-cdk-timers", "ic-ledger-types", "ic-stable-structures", - "junobuild-collections 0.0.8", - "junobuild-shared 0.0.21", - "junobuild-storage 0.0.11", + "junobuild-collections", + "junobuild-shared", + "junobuild-storage", "regex", "serde", "serde_cbor", @@ -824,20 +824,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" -[[package]] -name = "junobuild-collections" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ae0a739f185426a8f612fde1e3b73ee313766a58e3b63aaec80e5c5db250b7" -dependencies = [ - "candid", - "ic-cdk", - "ic-cdk-macros", - "ic-cdk-timers", - "junobuild-shared 0.0.20", - "serde", -] - [[package]] name = "junobuild-collections" version = "0.0.8" @@ -846,7 +832,7 @@ dependencies = [ "ic-cdk", "ic-cdk-macros", "ic-cdk-timers", - "junobuild-shared 0.0.21", + "junobuild-shared", "serde", ] @@ -866,7 +852,7 @@ dependencies = [ [[package]] name = "junobuild-satellite" -version = "0.0.20-patch.3" +version = "0.0.20-patch.4" dependencies = [ "candid", "ciborium", @@ -875,9 +861,9 @@ dependencies = [ "ic-cdk-macros", "ic-cdk-timers", "ic-stable-structures", - "junobuild-collections 0.0.7", - "junobuild-shared 0.0.20", - "junobuild-storage 0.0.10", + "junobuild-collections", + "junobuild-shared", + "junobuild-storage", "junobuild-utils 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand", "regex", @@ -887,25 +873,6 @@ dependencies = [ "url", ] -[[package]] -name = "junobuild-shared" -version = "0.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0877f076bb487faf40227f3265a23ff383b674f9e8c920a36c688e3e81b14dfa" -dependencies = [ - "candid", - "ciborium", - "futures", - "ic-cdk", - "ic-cdk-macros", - "ic-ledger-types", - "ic-stable-structures", - "icrc-ledger-types", - "regex", - "serde", - "time", -] - [[package]] name = "junobuild-shared" version = "0.0.21" @@ -923,34 +890,6 @@ dependencies = [ "time", ] -[[package]] -name = "junobuild-storage" -version = "0.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3815cc6162da1d28a9d3748e414a469f493cd4df1420ca724bc66777bf7923ca" -dependencies = [ - "base64 0.13.1", - "candid", - "globset", - "hex", - "ic-cdk", - "ic-cdk-macros", - "ic-cdk-timers", - "ic-certification", - "ic-representation-independent-hash", - "ic-response-verification", - "ic-stable-structures", - "junobuild-collections 0.0.7", - "junobuild-shared 0.0.20", - "regex", - "serde", - "serde_bytes", - "serde_cbor", - "sha2", - "url", - "urlencoding", -] - [[package]] name = "junobuild-storage" version = "0.0.11" @@ -966,8 +905,8 @@ dependencies = [ "ic-representation-independent-hash", "ic-response-verification", "ic-stable-structures", - "junobuild-collections 0.0.8", - "junobuild-shared 0.0.21", + "junobuild-collections", + "junobuild-shared", "regex", "serde", "serde_bytes", @@ -1074,7 +1013,7 @@ dependencies = [ "ic-cdk-macros", "ic-ledger-types", "icrc-ledger-types", - "junobuild-shared 0.0.21", + "junobuild-shared", "serde", ] @@ -1132,7 +1071,7 @@ dependencies = [ "ic-cdk", "ic-cdk-macros", "ic-cdk-timers", - "junobuild-shared 0.0.21", + "junobuild-shared", "lazy_static", "serde", ] @@ -1153,7 +1092,7 @@ dependencies = [ "ic-cdk-macros", "ic-stable-structures", "isbot", - "junobuild-shared 0.0.21", + "junobuild-shared", "lazy_static", "regex", "serde", diff --git a/src/libs/satellite/Cargo.toml b/src/libs/satellite/Cargo.toml index ab727c841..7ed83864c 100644 --- a/src/libs/satellite/Cargo.toml +++ b/src/libs/satellite/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "junobuild-satellite" -version = "0.0.20-patch.3" +version = "0.0.20-patch.4" authors.workspace = true edition.workspace = true repository.workspace = true @@ -41,7 +41,7 @@ regex.workspace = true url = "2.4.0" getrandom = { version = "0.2", features = ["custom"] } rand = { version = "0.8.5", features = ["getrandom"]} -junobuild-shared = "0.0.20" +junobuild-shared = "0.0.21" junobuild-utils = "0.0.4" -junobuild-collections = "0.0.7" -junobuild-storage = "0.0.10" \ No newline at end of file +junobuild-collections = "0.0.8" +junobuild-storage = "0.0.11" \ No newline at end of file From b31dbe955bfdbaec9fe3cb8ade2441dd179b58f6 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 11:11:42 +0200 Subject: [PATCH 09/13] chore: missing did file Signed-off-by: David Dal Busco --- .github/workflows/release.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 93641205b..a8804b63b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -209,6 +209,12 @@ jobs: name: satellite.did path: . + - name: Download satellite_extension.did + uses: actions/download-artifact@v4 + with: + name: satellite_extension.did + path: . + - name: Download orbiter.did uses: actions/download-artifact@v4 with: From cd7fdfb91033ab0c210a748bbf43548a9921aabb Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 11:42:53 +0200 Subject: [PATCH 10/13] feat: extract attach module flow (#749) Signed-off-by: David Dal Busco --- .../src/lib/api/mission-control.api.ts | 15 +++ .../analytics/NoAnalyticsAttach.svelte | 99 +++-------------- .../components/canister/CanisterAttach.svelte | 102 ++++++++++++++++++ src/frontend/src/lib/i18n/en.json | 3 +- src/frontend/src/lib/i18n/zh-cn.json | 3 +- src/frontend/src/lib/types/i18n.d.ts | 3 +- 6 files changed, 139 insertions(+), 86 deletions(-) create mode 100644 src/frontend/src/lib/components/canister/CanisterAttach.svelte diff --git a/src/frontend/src/lib/api/mission-control.api.ts b/src/frontend/src/lib/api/mission-control.api.ts index 19f005dba..3e44b0daf 100644 --- a/src/frontend/src/lib/api/mission-control.api.ts +++ b/src/frontend/src/lib/api/mission-control.api.ts @@ -344,6 +344,21 @@ export const unsetOrbiter = async ({ return unset_orbiter(orbiterId); }; +export const setSatellite = async ({ + missionControlId, + satelliteId, + satelliteName, + identity +}: { + missionControlId: Principal; + satelliteId: Principal; + satelliteName?: string; + identity: OptionIdentity; +}): Promise => { + const { set_satellite } = await getMissionControlActor({ missionControlId, identity }); + return set_satellite(satelliteId, toNullable(satelliteName)); +}; + export const unsetSatellite = async ({ missionControlId, satelliteId, diff --git a/src/frontend/src/lib/components/analytics/NoAnalyticsAttach.svelte b/src/frontend/src/lib/components/analytics/NoAnalyticsAttach.svelte index 0028ffe5d..e75b7e438 100644 --- a/src/frontend/src/lib/components/analytics/NoAnalyticsAttach.svelte +++ b/src/frontend/src/lib/components/analytics/NoAnalyticsAttach.svelte @@ -1,96 +1,29 @@ - -
- - - - - -
-
- - + + {$i18n.analytics.attach} + {$i18n.analytics.attach_id} + diff --git a/src/frontend/src/lib/components/canister/CanisterAttach.svelte b/src/frontend/src/lib/components/canister/CanisterAttach.svelte new file mode 100644 index 000000000..6f5a0a3f8 --- /dev/null +++ b/src/frontend/src/lib/components/canister/CanisterAttach.svelte @@ -0,0 +1,102 @@ + + + +
+

+ + + + + + +
+
+ + diff --git a/src/frontend/src/lib/i18n/en.json b/src/frontend/src/lib/i18n/en.json index ffcae2923..c75577f64 100644 --- a/src/frontend/src/lib/i18n/en.json +++ b/src/frontend/src/lib/i18n/en.json @@ -419,7 +419,8 @@ "orbiter_configuration_missing": "Satellites and configuration must be provided.", "orbiter_configuration_unexpected": "Unexpected error(s) while trying to edit your configuration.", "orbiter_configuration_listing": "Error while fetching the configuration.", - "orbiter_id_missing": "A valid Orbiter ID must be provided.", + "canister_id_missing": "A valid ID must be provided.", + "canister_attach_error": "Unexpected error(s) while trying to attach the module.", "orbiter_attach": "Unexpected error(s) while trying to attach the orbiter to your mission control.", "orbiter_unexpected_error": "Unexpected error(s) while creating the orbiter.", "transactions_next": "Error while fetching the next transactions.", diff --git a/src/frontend/src/lib/i18n/zh-cn.json b/src/frontend/src/lib/i18n/zh-cn.json index a46a39ebd..912348454 100644 --- a/src/frontend/src/lib/i18n/zh-cn.json +++ b/src/frontend/src/lib/i18n/zh-cn.json @@ -419,7 +419,8 @@ "orbiter_configuration_missing": "请提供 Satellites 和配置.", "orbiter_configuration_unexpected": "编辑配置时出现意外错误.", "orbiter_configuration_listing": "获取配置时出错.", - "orbiter_id_missing": "提供一个有效的 Orbiter ID .", + "canister_id_missing": "A valid ID must be provided.", + "canister_attach_error": "Unexpected error(s) while trying to attach the module.", "orbiter_attach": "试图关联 orbiter 到你的 mission control时候出现异常.", "orbiter_unexpected_error": "创建 orbiter 时出现异常错误.", "transactions_next": "获取下一部分事务时出错.", diff --git a/src/frontend/src/lib/types/i18n.d.ts b/src/frontend/src/lib/types/i18n.d.ts index 9495e15ac..011b1d44c 100644 --- a/src/frontend/src/lib/types/i18n.d.ts +++ b/src/frontend/src/lib/types/i18n.d.ts @@ -435,7 +435,8 @@ interface I18nErrors { orbiter_configuration_missing: string; orbiter_configuration_unexpected: string; orbiter_configuration_listing: string; - orbiter_id_missing: string; + canister_id_missing: string; + canister_attach_error: string; orbiter_attach: string; orbiter_unexpected_error: string; transactions_next: string; From 17d1cb2ba87e8366559ccbaaaaa4079723d8fb02 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 12:41:21 +0200 Subject: [PATCH 11/13] feat: attach satellite (#750) Signed-off-by: David Dal Busco --- .../MissionControlActions.svelte | 3 ++ .../MissionControlSatelliteAttach.svelte | 51 +++++++++++++++++++ src/frontend/src/lib/i18n/en.json | 4 +- src/frontend/src/lib/i18n/zh-cn.json | 4 +- .../lib/services/mission-control.services.ts | 12 +++++ .../src/lib/services/satellites.services.ts | 2 +- .../src/lib/stores/satellite.store.ts | 30 ++++++++++- src/frontend/src/lib/types/i18n.d.ts | 2 + 8 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 src/frontend/src/lib/components/mission-control/MissionControlSatelliteAttach.svelte diff --git a/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte b/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte index 4c5790f60..110c0608c 100644 --- a/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte +++ b/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte @@ -5,6 +5,7 @@ import { emit } from '$lib/utils/events.utils'; import type { CanisterIcStatus } from '$lib/types/canister'; import type { Principal } from '@dfinity/principal'; + import MissionControlSatelliteAttach from '$lib/components/mission-control/MissionControlSatelliteAttach.svelte'; export let missionControlId: Principal; @@ -42,4 +43,6 @@ + + diff --git a/src/frontend/src/lib/components/mission-control/MissionControlSatelliteAttach.svelte b/src/frontend/src/lib/components/mission-control/MissionControlSatelliteAttach.svelte new file mode 100644 index 000000000..003bad4aa --- /dev/null +++ b/src/frontend/src/lib/components/mission-control/MissionControlSatelliteAttach.svelte @@ -0,0 +1,51 @@ + + + + + + {$i18n.satellites.attach} + {$i18n.satellites.id} + diff --git a/src/frontend/src/lib/i18n/en.json b/src/frontend/src/lib/i18n/en.json index c75577f64..0533396ce 100644 --- a/src/frontend/src/lib/i18n/en.json +++ b/src/frontend/src/lib/i18n/en.json @@ -110,6 +110,7 @@ "detach_title": "Detach {0}", "detach_explanation": "Detaching this {0} will remove it from your mission control list. It will continue to function if it's active, or be forgotten if it's inactive and won't appear in the console anymore.", "detach_info": "Do you want to detach your {0}?", + "attach_success": "{0} attached.", "detach_success": "{0} detached.", "delete_success": "{0} deleted.", "transfer_cycles": "Transfer cycles", @@ -181,7 +182,8 @@ "extended_version": "Extended version", "build": "Build", "see_all_satellites": "See all satellites", - "go_launchpad": "Go to launchpad" + "go_launchpad": "Go to launchpad", + "attach": "Attach satellite" }, "mission_control": { "title": "Mission Control", diff --git a/src/frontend/src/lib/i18n/zh-cn.json b/src/frontend/src/lib/i18n/zh-cn.json index 912348454..b51fb7872 100644 --- a/src/frontend/src/lib/i18n/zh-cn.json +++ b/src/frontend/src/lib/i18n/zh-cn.json @@ -110,6 +110,7 @@ "detach_title": "Detach {0}", "detach_explanation": "解绑这个 {0} 会将它从mission control列表中删除. 如果它是激活状态,那么它将正常工作,否则就会被遗忘,也不会显示在仪表盘里面.", "detach_info": "你想解绑你的 {0}?", + "attach_success": "{0} attached.", "detach_success": "{0} 已解绑的.", "delete_success": "{0} 已删除.", "transfer_cycles": "转移 cycles", @@ -181,7 +182,8 @@ "extended_version": "扩展版本", "build": "Build", "see_all_satellites": "查看所有的 satellites", - "go_launchpad": "前往发射台" + "go_launchpad": "前往发射台", + "attach": "Attach satellite" }, "mission_control": { "title": "Mission Control", diff --git a/src/frontend/src/lib/services/mission-control.services.ts b/src/frontend/src/lib/services/mission-control.services.ts index 798f99d6d..e72e61fdd 100644 --- a/src/frontend/src/lib/services/mission-control.services.ts +++ b/src/frontend/src/lib/services/mission-control.services.ts @@ -5,6 +5,7 @@ import { missionControlVersion, setMissionControlController, setOrbiter, + setSatellite, setSatelliteMetadata, setSatellitesController, unsetOrbiter, @@ -155,6 +156,17 @@ export const setSatelliteName = async ({ ]); }; +export const attachSatellite = async (params: { + missionControlId: Principal; + satelliteId: Principal; +}) => { + const identity = get(authStore).identity; + + const satellite = await setSatellite({ ...params, identity }); + + satellitesStore.add(satellite); +}; + export const detachSatellite = async ({ canisterId, missionControlId diff --git a/src/frontend/src/lib/services/satellites.services.ts b/src/frontend/src/lib/services/satellites.services.ts index f65162fb5..e6cddbd6c 100644 --- a/src/frontend/src/lib/services/satellites.services.ts +++ b/src/frontend/src/lib/services/satellites.services.ts @@ -85,6 +85,6 @@ export const loadSatellites = async ({ detail: err }); - satellitesStore.set(null); + satellitesStore.reset(); } }; diff --git a/src/frontend/src/lib/stores/satellite.store.ts b/src/frontend/src/lib/stores/satellite.store.ts index 8ff7712c0..4c252a509 100644 --- a/src/frontend/src/lib/stores/satellite.store.ts +++ b/src/frontend/src/lib/stores/satellite.store.ts @@ -3,7 +3,35 @@ import type { Satellite } from '$declarations/mission_control/mission_control.di import { isNullish } from '@dfinity/utils'; import { derived, writable, type Readable } from 'svelte/store'; -export const satellitesStore = writable(undefined); +type SatellitesStoreData = Satellite[] | undefined | null; + +interface SatellitesStore extends Readable { + set: (satellites: Satellite[]) => void; + add: (satellite: Satellite) => void; + reset: () => void; +} + +const initSatellitesStore = (): SatellitesStore => { + const { subscribe, update, set } = writable(undefined); + + return { + subscribe, + + set(satellites) { + set(satellites); + }, + + add(satellite) { + update((state) => [...(state ?? []), satellite]); + }, + + reset: () => { + set(null); + } + }; +}; + +export const satellitesStore = initSatellitesStore(); export const satelliteStore: Readable = derived( [satellitesStore, page], diff --git a/src/frontend/src/lib/types/i18n.d.ts b/src/frontend/src/lib/types/i18n.d.ts index 011b1d44c..d66020649 100644 --- a/src/frontend/src/lib/types/i18n.d.ts +++ b/src/frontend/src/lib/types/i18n.d.ts @@ -114,6 +114,7 @@ interface I18nCanisters { detach_title: string; detach_explanation: string; detach_info: string; + attach_success: string; detach_success: string; delete_success: string; transfer_cycles: string; @@ -188,6 +189,7 @@ interface I18nSatellites { build: string; see_all_satellites: string; go_launchpad: string; + attach: string; } interface I18nMission_control { From 45995495f02334c130cb79443b4659d1506950cf Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 12:54:53 +0200 Subject: [PATCH 12/13] refactor: rename component Signed-off-by: David Dal Busco --- .../components/mission-control/MissionControlActions.svelte | 4 ++-- ...liteAttach.svelte => MissionControlAttachSatellite.svelte} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/frontend/src/lib/components/mission-control/{MissionControlSatelliteAttach.svelte => MissionControlAttachSatellite.svelte} (100%) diff --git a/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte b/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte index 110c0608c..4b0f2fb00 100644 --- a/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte +++ b/src/frontend/src/lib/components/mission-control/MissionControlActions.svelte @@ -5,7 +5,7 @@ import { emit } from '$lib/utils/events.utils'; import type { CanisterIcStatus } from '$lib/types/canister'; import type { Principal } from '@dfinity/principal'; - import MissionControlSatelliteAttach from '$lib/components/mission-control/MissionControlSatelliteAttach.svelte'; + import MissionControlAttachSatellite from '$lib/components/mission-control/MissionControlAttachSatellite.svelte'; export let missionControlId: Principal; @@ -44,5 +44,5 @@ - + diff --git a/src/frontend/src/lib/components/mission-control/MissionControlSatelliteAttach.svelte b/src/frontend/src/lib/components/mission-control/MissionControlAttachSatellite.svelte similarity index 100% rename from src/frontend/src/lib/components/mission-control/MissionControlSatelliteAttach.svelte rename to src/frontend/src/lib/components/mission-control/MissionControlAttachSatellite.svelte From 2ab92ddd4f349af866468b8937250c1a6325f596 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 20 Oct 2024 13:03:55 +0200 Subject: [PATCH 13/13] feat: move attach orbiter to mission control (#751) Signed-off-by: David Dal Busco --- .../components/analytics/NoAnalytics.svelte | 3 --- .../analytics/NoAnalyticsActions.svelte | 10 -------- .../MissionControlActions.svelte | 5 ++++ .../MissionControlAttachOrbiter.svelte} | 24 +++++++++++++++++-- .../components/orbiter/OrbiterActions.svelte | 2 ++ .../satellites/SatelliteActions.svelte | 2 ++ src/frontend/src/lib/i18n/en.json | 2 +- src/frontend/src/lib/i18n/zh-cn.json | 2 +- 8 files changed, 33 insertions(+), 17 deletions(-) delete mode 100644 src/frontend/src/lib/components/analytics/NoAnalyticsActions.svelte rename src/frontend/src/lib/components/{analytics/NoAnalyticsAttach.svelte => mission-control/MissionControlAttachOrbiter.svelte} (59%) diff --git a/src/frontend/src/lib/components/analytics/NoAnalytics.svelte b/src/frontend/src/lib/components/analytics/NoAnalytics.svelte index 7452a0110..f061cc7ab 100644 --- a/src/frontend/src/lib/components/analytics/NoAnalytics.svelte +++ b/src/frontend/src/lib/components/analytics/NoAnalytics.svelte @@ -1,12 +1,9 @@

{$i18n.analytics.empty}

- -