Skip to content

Near-One/omni-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

omni-utils

Small Rust utilities for NEAR smart contracts plus a derive macro crate.

Note

In the future, this should be part of near-plugins.

Contents

  • omni-utils: helpers like NearExpect and PromiseOrPromiseIndexOrValue, plus a re-export of ErrorDisplay.
  • omni-utils-derive: proc-macro derive for formatting enum errors (expects the enum to implement AsRef<str>).

Quick usage

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();
}

About

Utilities used in omni-bridge related projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages