MCPcopy Create free account
hub / github.com/dfinity/ic-repl / str_to_principal

Function str_to_principal

src/utils.rs:149–160  ·  view source on GitHub ↗
(id: &str, helper: &MyHelper)

Source from the content-addressed store, hash-verified

147}
148
149pub fn str_to_principal(id: &str, helper: &MyHelper) -> Result<Principal> {
150 let try_id = Principal::from_text(id);
151 Ok(match try_id {
152 Ok(id) => id,
153 Err(_) => match helper.env.0.get(id) {
154 Some(IDLValue::Principal(id)) => *id,
155 Some(IDLValue::Service(id)) => *id,
156 Some(IDLValue::Func(id, _)) => *id,
157 _ => return Err(anyhow!("{} is not a canister id", id)),
158 },
159 })
160}
161
162pub fn get_effective_canister_id(
163 canister_id: Principal,

Callers 3

evalMethod · 0.85
get_infoMethod · 0.85
partial_parseFunction · 0.85

Calls 2

from_textFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected