Small Rust utilities for NEAR smart contracts plus a derive macro crate.
Note
In the future, this should be part of near-plugins.
omni-utils: helpers likeNearExpectandPromiseOrPromiseIndexOrValue, plus a re-export ofErrorDisplay.omni-utils-derive: proc-macro derive for formatting enum errors (expects the enum to implementAsRef<str>).
use omni_utils::{ErrorDisplay, near_expect::NearExpect, promise::PromiseOrPromiseIndexOrValue};
#[derive(ErrorDisplay, strum::AsRefStr)]
enum MyError {
BadInput(String),
}
fn handler(opt: Option<u64>) {
let value = opt.near_expect("ERR_MISSING");
PromiseOrPromiseIndexOrValue::Value(value).as_return();
}