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