tari_template_lib/
lib.rs

1//  Copyright 2022. The Tari Project
2//
3//  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4//  following conditions are met:
5//
6//  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7//  disclaimer.
8//
9//  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10//  following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12//  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13//  products derived from this software without specific prior written permission.
14//
15//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16//  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17//  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18//  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19//  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20//  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21//  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23//! This crate provides ergonomic abstractions that allow WASM templates to interact with the Tari Ootle engine.
24//! Most if not all Ootle templates written in rust should depend on this crate.
25//!
26//! In most cases, you will only require the `prelude` which can be included with:
27//! ```
28//! use tari_template_lib::prelude::*;
29//! ```
30//!
31//! Typically, a template author will use structs exported from the [models] module, the
32//! [ResourceBuilder](resource::ResourceBuilder) and the [ComponentBuilder](component::ComponentBuilder). This crate
33//! re-exports low-level ABI functions in `tari_template_abi` and the `tari_template_macros` proc macro.
34//!
35//! ## Template Examples
36//!
37//! - <https://github.com/tari-project/wasm-template>
38//! - <https://github.com/tari-project/wasm-examples>
39//! - <https://github.com/tari-project/tari-ootle/tree/development/crates/engine/tests/templates>
40//!
41//! ## no_std
42//!
43//! no_std can be enabled using the `no_std` feature flag.
44
45pub mod auth;
46
47#[macro_use]
48pub mod args;
49pub mod models;
50
51pub mod component;
52mod consensus;
53pub use consensus::Consensus;
54
55pub mod caller_context;
56mod context;
57pub use context::{get_context, init_context, AbiContext};
58
59pub mod rand;
60pub mod resource;
61
62pub mod events;
63
64pub mod template;
65
66pub use tari_template_lib_types as types;
67
68// ---------------------------------------- WASM target exports ------------------------------------------------
69
70pub mod template_dependencies;
71
72mod engine;
73pub use engine::engine;
74
75pub mod panic_hook;
76pub mod prelude;
77#[cfg(all(feature = "macro", target_arch = "wasm32"))]
78pub use prelude::template;
79// Re-export for macro
80pub use tari_bor::to_value;
81
82pub mod constants;
83
84#[macro_use]
85mod newtype_serde_macros;
86#[macro_use]
87pub mod macros;