1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pub use handler::*;
pub use interface::*;
pub use mock::*;

mod handler;
mod inject;
mod interface;
mod mock;
#[cfg(target_family = "wasm")]
mod wasm;

/// async_std::test to be used for async tests when not targeting WASM.
#[cfg(not(target_family = "wasm"))]
pub use async_std::test as async_test;
pub use ic_cdk::api::call::{CallResult, RejectionCode};
pub use ic_cdk::export::candid;
pub use ic_cdk::export::Principal;
pub use ic_cdk_macros as macros;

/// A set of mock principal IDs useful for testing.
#[cfg(not(target_family = "wasm"))]
pub mod mock_principals {
    use crate::Principal;

    #[inline]
    pub fn alice() -> Principal {
        Principal::from_text("sgymv-uiaaa-aaaaa-aaaia-cai").unwrap()
    }

    #[inline]
    pub fn bob() -> Principal {
        Principal::from_text("ai7t5-aibaq-aaaaa-aaaaa-c").unwrap()
    }

    #[inline]
    pub fn john() -> Principal {
        Principal::from_text("hozae-racaq-aaaaa-aaaaa-c").unwrap()
    }

    #[inline]
    pub fn xtc() -> Principal {
        Principal::from_text("aanaa-xaaaa-aaaah-aaeiq-cai").unwrap()
    }
}

/// APIs/Methods to work with the Internet Computer.
pub mod ic;
/// The type definition of common canisters on the Internet Computer.
pub mod interfaces;

/// Return the IC context depending on the build target.
#[inline(always)]
#[deprecated(note = "get_context is deprecated use ic_kit::ic::*")]
pub fn get_context() -> &'static impl Context {
    #[cfg(not(target_family = "wasm"))]
    return inject::get_context();
    #[cfg(target_family = "wasm")]
    return wasm::IcContext::context();
}