1#![cfg(target_arch = "wasm32")]
3
4use {
5 log::Level,
6 wasm_bindgen::prelude::{wasm_bindgen, JsValue},
7};
8
9pub mod address;
10pub mod hash;
11pub mod instruction;
12pub mod keypair;
13pub mod message;
14pub mod transaction;
15
16#[wasm_bindgen]
18pub fn atlas_program_init() {
19 use std::sync::Once;
20 static INIT: Once = Once::new();
21
22 INIT.call_once(|| {
23 std::panic::set_hook(Box::new(console_error_panic_hook::hook));
24 console_log::init_with_level(Level::Info).unwrap();
25 });
26}
27
28pub fn display_to_jsvalue<T: std::fmt::Display>(display: T) -> JsValue {
29 display.to_string().into()
30}
31
32mod conversion {
35 macro_rules! impl_inner_conversion {
36 ($Wrapper:ty, $Inner:ty) => {
37 impl From<$Inner> for $Wrapper {
38 fn from(inner: $Inner) -> Self {
39 Self { inner }
40 }
41 }
42 impl std::ops::Deref for $Wrapper {
43 type Target = $Inner;
44 fn deref(&self) -> &Self::Target {
45 &self.inner
46 }
47 }
48 };
49 }
50 pub(crate) use impl_inner_conversion;
51}