solana_program/wasm/
mod.rs

1//! solana-program Javascript interface
2#![cfg(target_arch = "wasm32")]
3#[deprecated(since = "2.2.0", note = "Use solana_instruction::wasm instead.")]
4pub use solana_instruction::wasm as instructions;
5use wasm_bindgen::prelude::*;
6// This module is intentionally left empty. The wasm system instruction impl can be
7// found in the `solana-system-interface` crate.
8pub mod system_instruction {}
9
10/// Initialize Javascript logging and panic handler
11#[wasm_bindgen]
12pub fn solana_program_init() {
13    use std::sync::Once;
14    static INIT: Once = Once::new();
15
16    INIT.call_once(|| {
17        std::panic::set_hook(Box::new(console_error_panic_hook::hook));
18        console_log::init_with_level(log::Level::Info).unwrap();
19    });
20}
21
22pub fn display_to_jsvalue<T: std::fmt::Display>(display: T) -> JsValue {
23    display.to_string().into()
24}