MCPcopy Create free account
hub / github.com/dfinity/orbit / init_canister

Method init_canister

core/station/impl/src/services/system.rs:520–600  ·  view source on GitHub ↗

Initializes the canister with the given owners and settings. Must only be called within a canister init call.

(&self, input: SystemInit)

Source from the content-addressed store, hash-verified

518 ///
519 /// Must only be called within a canister init call.
520 pub async fn init_canister(&self, input: SystemInit) -> ServiceResult<()> {
521 let mut system_info = SystemInfo::default();
522
523 match &input.initial_config {
524 InitialConfig::WithAllDefaults {
525 admin_quorum,
526 operator_quorum,
527 users,
528 } => {
529 // adds the default admin group
530 init_canister_sync_handlers::add_default_groups();
531 // registers the admins of the canister
532 init_canister_sync_handlers::set_initial_users(users.clone(), &DEFAULT_GROUP_IDS)?;
533 // registers the default canister configurations such as policies and user groups.
534 init_canister_sync_handlers::init_default_permissions_and_policies(
535 *admin_quorum,
536 *operator_quorum,
537 )?;
538 // add default assets
539 init_canister_sync_handlers::add_default_assets();
540 }
541 InitialConfig::WithDefaultPolicies {
542 assets,
543 users,
544 admin_quorum,
545 operator_quorum,
546 ..
547 } => {
548 // adds the default admin group
549 init_canister_sync_handlers::add_default_groups();
550 // registers the admins of the canister
551 init_canister_sync_handlers::set_initial_users(users.clone(), &DEFAULT_GROUP_IDS)?;
552 // adds the initial assets
553 init_canister_sync_handlers::set_initial_assets(assets).await?;
554
555 // registers the default canister configurations such as policies and user groups.
556 init_canister_sync_handlers::init_default_permissions_and_policies(
557 *admin_quorum,
558 *operator_quorum,
559 )?;
560
561 // initial accounts are added in the post process work timer, since they might do inter-canister calls
562 }
563 InitialConfig::Complete {
564 users,
565 user_groups,
566 permissions,
567 request_policies,
568 named_rules,
569 assets,
570 ..
571 } => {
572 print("adding initial user groups");
573 init_canister_sync_handlers::set_initial_user_groups(user_groups).await?;
574 print("adding initial users");
575 init_canister_sync_handlers::set_initial_users(users.clone(), &[])?;
576 print("adding initial named rules");
577 init_canister_sync_handlers::set_initial_named_rules(named_rules)?;

Callers 2

initializeMethod · 0.45
canister_initFunction · 0.45

Calls 13

add_default_groupsFunction · 0.85
set_initial_usersFunction · 0.85
add_default_assetsFunction · 0.85
set_initial_assetsFunction · 0.85
printFunction · 0.85
set_initial_user_groupsFunction · 0.85
set_initial_named_rulesFunction · 0.85
set_initial_permissionsFunction · 0.85
set_nameMethod · 0.80
init_cacheMethod · 0.80

Tested by

no test coverage detected