Skip to main content

Crate xrpl_escrow_stdlib

Crate xrpl_escrow_stdlib 

Source
Expand description

§xrpl-escrow-stdlib

Smart Escrow types, entry-point context, and host-function wrappers for writing XRPL Smart Escrows in Rust.

This crate is part of the xrpl-wasm-stdlib workspace. Generic XRPL primitives (AccountID, Locator, host bindings, trace, etc.) live in xrpl_wasm_stdlib; this crate hosts only what is tied specifically to escrows: the EscrowFinish transaction wrapper, the Escrow/CurrentEscrow ledger objects, the escrow-specific field-accessor traits, and EscrowFinishContext — the control surface a Smart Escrow author interacts with. Safe, scoped access to escrow-unique host functions (e.g., update_data) is exposed as inherent methods; all unsafe FFI is contained here, so user code stays fully safe.

§Usage

use xrpl_escrow_stdlib::*;
use xrpl_wasm_stdlib::core::ledger_objects::traits::CurrentEscrowFields;

#[smart_escrow]
fn run(ctx: EscrowFinishContext) -> FinishResult {
    let destination = match ctx.escrow().get_destination() {
        Ok(d) => d,
        Err(e) => return e.code().into(),
    };
    // ... evaluate conditions ...
    FinishResult::succeed()
}

The #[smart_escrow] entry-point macro (in xrpl-macros, re-exported here) constructs the context via EscrowFinishContext::default() and passes it to your function automatically, then converts your FinishResult (or i32) into the extern "C" fn finish() -> i32 the XRPL host calls.

§Crate layout

ModuleContents
ctx::escrow_finishEscrowFinishContext struct and its host-function methods
current_txEscrowFinish transaction wrapper and the EscrowFinishFields trait
ledger_objectsEscrow/CurrentEscrow objects and their field-accessor traits

§no_std

This crate is no_std when targeting wasm32. The std crate is available for host (non-WASM) builds so unit tests run normally.

Re-exports§

pub use ctx::escrow_finish::EscrowFinishContext;
pub use ctx::finish_result::FinishResult;

Modules§

ctx
current_tx
Example
ledger_objects