Skip to main content

Crate thruput_macros

Crate thruput_macros 

Source
Expand description

Generate interfacing materials from a trait or impl that has been annotated with the contract macro. This crate produces:

  • Client-stub implementations for making contract calls
  • Guest method stubs and external symbols for calling into the contract
  • Test-registration code

Macros§

export_interface_spec
Anchor a #[contract] trait’s spec for inclusion. Spec shaking drops a trait’s (candidate) interface spec unless something anchors it — normally a #[contract] impl. Use this in an interface crate’s spec-carrier main.rs so building that crate on its own emits the interface’s full spec:
hash_to_array
Compute a [u8; 32] at compile time: sha256 of the literal’s value (quotes stripped, escapes resolved). Accepts string and byte-string literals: hash_to_array!("foo") == sha256 of the 3 bytes foo and agrees with thruput_sdk::crypto::sha256(b"foo") at runtime and with sha256_static!/static_key! for the same string.
sha256_array_ident
Like sha256_ident! (sha256 of the bare identifier’s text), but expands to a [u8; 32] array instead of a SHA256Hash.
sha256_ident
Compute a SHA256Hash at compile time: sha256 of the bare identifier’s text (no quotes — sha256_ident!(foo) hashes the 3 bytes foo).
sha256_static
Compute a SHA256Hash at compile time: sha256 of the string literal’s value (quotes stripped, escapes resolved).
static_key
Compute a StorageKey at compile time: sha256 of the string literal’s value (quotes stripped, escapes resolved).

Attribute Macros§

contract
Turn a trait, impl block, or free function into contract entrypoints, generating exports, a typed client, and spec registration.
contract_exception
#[contract_exception] or #[contract_exception(version = "1.0.0", name = "...")] — full convenience macro: derives + #[repr(i32)] + impl Exn + impl ContractTypeName.
contract_type
Make a struct or enum usable as a contract argument, return value, or auth-token payload: derives XDR codecs, spec registration, auth-handle walkers, and the Mintable preimage machinery.
exn
#[exn] or #[exn(version = "1.0.0")] — emits impl Exn with a computed selector. Use this when you handle your own derives. For the full convenience macro, use #[contract_exception] instead.
storage
Mark a struct as contract storage: generates From<Keypath> so each field is bound to a storage slot derived from the struct’s keypath.

Derive Macros§

ContractTypeSpec
Derive ContractTypeSpec (plus ContractTypeRefSpec, a linker anchor, and the raw typedef link-section fragment) for a struct or enum.
Deletable
Event
Derive event encoding, signature and spec metadata.
Storage