polysig_webassembly_bindings/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Webassembly bindings for the polysig library.
#![deny(missing_docs)]
#![forbid(unsafe_code)]

/// Threshold signature protocols.
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
pub mod protocols;

/// Single party signers.
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
pub mod signers;

/// Initialize the panic hook and logging.
#[doc(hidden)]
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn start() {
    console_error_panic_hook::set_once();

    #[cfg(feature = "tracing")]
    {
        use tracing_subscriber::fmt;
        use tracing_subscriber_wasm::MakeConsoleWriter;
        fmt()
            .with_max_level(tracing::Level::DEBUG)
            .with_writer(
                MakeConsoleWriter::default()
                    .map_trace_level_to(tracing::Level::DEBUG),
            )
            // For some reason, if we don't do this
            // in the browser, we get
            // a runtime error.
            .without_time()
            .init();

        log::info!("Webassembly tracing initialized");
    }
}