b3_utils 0.13.1

Utility functions for building on the Internet Computer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::fmt;

pub fn caller_is_controller() -> Result<(), String> {
    if ic_cdk::api::is_controller(&ic_cdk::caller()) {
        Ok(())
    } else {
        Err("Caller is not controller".to_string())
    }
}

pub fn revert<T, E: fmt::Display>(err: E) -> T {
    ic_cdk::trap(&format!("{}", err));
}