Crate tari_template_lib

Source
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

§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! and args! 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