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;
49#[macro_use]
50pub mod models;
51
52pub mod component;
53mod consensus;
54pub use consensus::Consensus;
55
56pub mod caller_context;
57mod context;
58pub use context::{get_context, init_context, AbiContext};
59
60pub mod rand;
61pub mod resource;
62
63pub mod events;
64
65pub mod template;
66
67pub use tari_template_lib_types as types;
68
69// ---------------------------------------- WASM target exports ------------------------------------------------
70
71pub mod template_dependencies;
72
73mod engine;
74pub use engine::engine;
75
76pub mod panic_hook;
77pub mod prelude;
78#[cfg(all(feature = "macro", target_arch = "wasm32"))]
79pub use prelude::template;
80// Re-export for macro
81pub use tari_bor::to_value;
82
83pub mod constants;
84
85#[macro_use]
86mod newtype_serde_macros;
87#[macro_use]
88pub mod macros;