8 releases
new 0.1.6 | Jun 12, 2024 |
---|---|
0.1.5 | May 28, 2024 |
0.1.5-rc1 | Jun 12, 2024 |
#632 in #sdk
258 downloads per month
63KB
1.5K
SLoC
Zephyr Rust SDK
Implementation of the Zephyr SDK for Rust. The Zephyr SDK lets you build Zephyr programs for the Mercury Cloud Execution environment.
Examples can be found at the zephyr-examples repository.
For any bugs or feature requests, please open an issue in this repository.
lib.rs
:
Zephyr Rust SDK
The zephyr rust sdk aids developers in writing programs for the Zephyr Virtual Machine.
Hello Ledger Example
use rs_zephyr_sdk::{bincode, log, stellar_xdr::next::{Limits, WriteXdr}, Condition, DatabaseDerive, DatabaseInteract, EnvClient, ZephyrVal};
#[derive(DatabaseDerive, Clone)]
#[with_name("curr_seq")]
struct Sequence {
pub current: u32,
}
#[no_mangle]
pub extern "C" fn on_close() {
let env = EnvClient::new();
let reader = env.reader();
let sequence = Sequence {
current: reader.ledger_sequence()
};
if let Some(last) = Sequence::read_to_rows(&env).iter().find(|x| x.current == sequence.current - 1) {
sequence.update(&env, &[Condition::ColumnEqualTo("current".into(), bincode::serialize(&ZephyrVal::U32(last.current)).unwrap())]);
} else {
sequence.put(&env)
}
}
Dependencies
~17MB
~328K SLoC