canic_cdk/env/sns.rs
1//! Preconfigured SNS deployments and helpers for looking up their canisters.
2
3use candid::Principal;
4use std::{collections::HashMap, sync::OnceLock};
5
6// -----------------------------------------------------------------------------
7// Parsing
8// -----------------------------------------------------------------------------
9
10fn parse_principal(sns: SnsType, role: &'static str, text: &'static str) -> Principal {
11 Principal::from_text(text)
12 .unwrap_or_else(|_| panic!("Invalid SNS {sns:?} {role} principal: {text}"))
13}
14
15// -----------------------------------------------------------------------------
16// Types
17// -----------------------------------------------------------------------------
18
19///
20/// SnsCanisters
21///
22
23#[derive(Clone, Debug)]
24pub struct SnsCanisters {
25 pub root: Principal,
26 pub governance: Principal,
27 pub index: Principal,
28 pub ledger: Principal,
29}
30
31///
32/// SnsRole
33///
34
35#[derive(Clone, Copy, Debug)]
36pub enum SnsRole {
37 Root,
38 Governance,
39 Index,
40 Ledger,
41}
42
43include!("sns.inc.rs");