ic_kit/
lib.rs

1pub use handler::*;
2pub use interface::*;
3pub use mock::*;
4pub use setup::*;
5
6mod handler;
7mod inject;
8mod interface;
9mod mock;
10mod setup;
11#[cfg(target_family = "wasm")]
12mod wasm;
13
14/// A set of mock principal IDs useful for testing.
15#[cfg(not(target_family = "wasm"))]
16#[deprecated(since = "0.4.7", note = "mock_principals is deprecated.")]
17pub mod mock_principals {
18    use crate::Principal;
19
20    #[inline]
21    pub fn alice() -> Principal {
22        Principal::from_text("sgymv-uiaaa-aaaaa-aaaia-cai").unwrap()
23    }
24
25    #[inline]
26    pub fn bob() -> Principal {
27        Principal::from_text("ai7t5-aibaq-aaaaa-aaaaa-c").unwrap()
28    }
29
30    #[inline]
31    pub fn john() -> Principal {
32        Principal::from_text("hozae-racaq-aaaaa-aaaaa-c").unwrap()
33    }
34
35    #[inline]
36    pub fn xtc() -> Principal {
37        Principal::from_text("aanaa-xaaaa-aaaah-aaeiq-cai").unwrap()
38    }
39}
40
41/// Return the IC context depending on the build target.
42#[inline(always)]
43#[deprecated(note = "get_context is deprecated use ic_kit::ic::*")]
44pub fn get_context() -> &'static impl Context {
45    #[cfg(not(target_family = "wasm"))]
46    return inject::get_context();
47    #[cfg(target_family = "wasm")]
48    return wasm::IcContext::context();
49}
50
51/// APIs/Methods to work with the Internet Computer.
52pub mod ic;
53/// The type definition of common canisters on the Internet Computer.
54pub mod interfaces;
55/// The APIs for StableReader/StableWriter.
56pub mod stable;
57/// Internal storage abstraction for singletons.
58pub mod storage;
59
60/// async_std::test to be used for async tests when not targeting WASM.
61#[cfg(not(target_family = "wasm"))]
62pub use async_std::test as async_test;
63pub use ic_cdk::api::call::{CallResult, RejectionCode};
64pub use ic_cdk::export::candid;
65pub use ic_cdk::export::Principal;
66pub use ic_kit_macros as macros;
67
68/// ic_cdk APIs to be used with ic-kit-macros only, please don't use this directly
69/// we may decide to change it anytime and break compatability.
70pub mod ic_call_api_v0_ {
71    pub use ic_cdk::api::call::arg_data;
72    pub use ic_cdk::api::call::reject;
73    pub use ic_cdk::api::call::reply;
74}