Expand description
This crate provides ergonomic abstractions that allow WASM templates to interact with the Tari Ootle engine. Most if not all Ootle templates written in rust should depend on this crate.
In most cases, you will only require the prelude
which can be included with:
use tari_template_lib::prelude::*;
Typically, a template author will use structs exported from the models module, the
ResourceBuilder and the ComponentBuilder. This crate
re-exports low-level ABI functions in tari_template_abi
and the tari_template_macros
proc macro.
§Template Examples
- https://github.com/tari-project/wasm-template
- https://github.com/tari-project/wasm-examples
- https://github.com/tari-project/tari-ootle/tree/development/crates/engine/tests/templates
§no_std
no_std can be enabled using the no_std
feature flag.
Re-exports§
pub use tari_template_lib_types as types;
Modules§
- args
- Definitions and utilities related to instruction arguments
- auth
- Access control rules for template-related data like component methods and resources
- caller_
context - Context definitions related to the caller of an instruction
- component
- Utilities for building and managing components inside templates
- constants
- A collection of convenient constant values
- events
- A wrapper for engine calls related to events
- macros
- Rust macros that can be used inside templates
- models
- The collection of all struct definitions that represent data in the Tari network (e.g., resources, components, proofs, etc.)
- panic_
hook - Hook that implements common behavior when a panic happens during template execution
- prelude
- The prelude contains all the commonly used types and functions that are used. To use it, add the import
use tari_template_lib::prelude::*;
- rand
- Utilities to get random values inside templates
- resource
- Utilities for building and managing resources inside templates
- template
- Utilities related to templates
- template_
dependencies - Public types that are available to internal template code.
Macros§
- __
args_ inner - Low-level macro for building instruction arguments, used by both
arg!
andargs!
macros. Not intended for general usage. - __
build_ vec - __
build_ vec_ inner - __
expr_ counter - Low-level macro used for counting characters in the encoding of arguments. Not intended for general usage
- __
require_ rule - __
restricted_ access_ rule - __
rule_ requirement - call_
arg - Utility macro for building a single instruction argument
- call_
args - Utility macro for building multiple instruction arguments
- debug
- Macro for writing debug messages from inside templates
- error
- Macro for emitting error log messages from inside templates
- info
- Macro for emitting log messages from inside templates
- invoke_
args - Low-level macro used for encoding the arguments of engine calls. Not intended for general usage
- log
- Macro for emitting log messages from inside templates
- newtype_
struct_ serde_ impl - Low-level macro used for generating serde serializers/deserializers for newtype structs. Not intended for general usage
- rule
- A macro to build access rules for components and resources.
- warn
- Macro for emitting warn log messages from inside templates
Structs§
- AbiContext
- TODO: YAGNI currently
- Consensus
- The Consensus module provides access to data about the current state of the
chain. Currently, it only exposes the epoch via
current_epoch
.
Functions§
- engine
- Returns the corresponding
TariEngine
of the current template execution - get_
context - Returns a template’s current call context
- init_
context - Sets up a template’s current call context
- to_
value - Encodes any Rust type using CBOR