seda_sdk_rs/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(missing_docs)]
3
4pub mod bytes;
5pub mod errors;
6pub mod hashmap;
7pub mod http;
8pub mod keccak256;
9pub mod log;
10pub mod process;
11pub mod promise;
12mod promise_actions;
13pub mod proxy_http_fetch;
14mod raw;
15pub mod secp256k1;
16mod tally;
17mod vm_modes;
18
19pub use http::{http_fetch, HttpFetchMethod, HttpFetchOptions, HttpFetchResponse};
20pub use keccak256::keccak256;
21pub use process::Process;
22pub use proxy_http_fetch::{generate_proxy_http_signing_message, proxy_http_fetch};
23pub use secp256k1::secp256k1_verify;
24pub use tally::*;
25
26pub use seda_sdk_macros::oracle_program;
27
28#[cfg(feature = "hide-panic-paths")]
29/// A function run before the main function, via [`ctor::ctor`], to set a sanitized panic hook.
30/// This hook takes the `std::panic::PanicInfo` and attempts to downcast the payload to a string.
31/// If unsuccessful, it defaults to printing "<panic>".
32/// It then gracefully aborts the process.
33#[ctor::ctor]
34fn init_sanitized_panic_hook() {
35    std::panic::set_hook(Box::new(|info| {
36        // print only the panic message, never the location
37        let msg = info
38            .payload()
39            .downcast_ref::<&str>()
40            .copied()
41            .or_else(|| info.payload().downcast_ref::<String>().map(|s| s.as_str()))
42            .unwrap_or("<panic>");
43        elog!("panicked: {msg}");
44        elog!("note: you can disable the `hide-panic-paths` feature to see the full panic message, including the file and line number.");
45        std::process::abort();
46    }));
47}