This commit is contained in:
Sosthene 2025-08-18 10:56:09 +02:00
parent d909905917
commit 7421e53d97
5 changed files with 24 additions and 17 deletions

View File

@ -6,25 +6,26 @@ edition = "2021"
[lib] [lib]
crate-type = ["cdylib", "rlib"] crate-type = ["cdylib", "rlib"]
[features]
default = ["sp_client/blindbit-native"]
wasm = ["dep:js-sys", "dep:serde-wasm-bindgen", "sp_client/blindbit-wasm"]
[dependencies] [dependencies]
aes-gcm = "0.10.3" aes-gcm = "0.10.3"
anyhow = "1.0" anyhow = "1.0"
js-sys = "0.3.69"
env_logger = "0.9" env_logger = "0.9"
log = "0.4.6" log = "0.4.6"
rand = "0.8.5" rand = "0.8.5"
serde = { version = "1.0.193", features = ["derive"] } serde = { version = "1.0.193", features = ["derive"] }
serde_json = { version = "1.0.108" } serde_json = { version = "1.0.108" }
serde-wasm-bindgen = "0.6.5"
# sp_client = { path = "../sp-client", features = ["blindbit-backend"] }
sp_client = { git = "https://github.com/cygnet3/sp-client.git", branch = "wasm_compatibility" ,features = ["blindbit-backend"]}
tsify = { git = "https://github.com/Sosthene00/tsify", branch = "next" }
wasm-bindgen = "0.2.91"
rs_merkle = "1.4.2" rs_merkle = "1.4.2"
zstd = "0.13.3" zstd = "0.13.3"
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] } getrandom = { version = "0.2", features = ["js"] }
tsify = { git = "https://github.com/Sosthene00/tsify", branch = "next" }
wasm-bindgen = "0.2.91"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] # WASM-specific dependencies (optional)
getrandom = { version = "0.2" } js-sys = { version = "0.3.69", optional = true }
serde-wasm-bindgen = { version = "0.6.5", optional = true }
sp_client = { path = "../sp-client", default-features = false }

View File

@ -15,8 +15,9 @@ use sp_client::{
use crate::{pcd::Member, silentpayments::SpWallet}; use crate::{pcd::Member, silentpayments::SpWallet};
#[derive(Debug, Serialize, Deserialize, Clone, Default, Tsify)] #[derive(Debug, Serialize, Deserialize, Clone, Default)]
#[tsify(into_wasm_abi, from_wasm_abi)] #[cfg_attr(feature = "wasm", derive(Tsify))]
#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
pub struct Device { pub struct Device {
sp_wallet: SpWallet, sp_wallet: SpWallet,
pairing_process_commitment: Option<OutPoint>, pairing_process_commitment: Option<OutPoint>,

View File

@ -4,17 +4,21 @@ use std::sync::{Mutex, MutexGuard};
pub use aes_gcm; pub use aes_gcm;
pub use env_logger; pub use env_logger;
pub use js_sys;
pub use log; pub use log;
pub use rand; pub use rand;
pub use serde; pub use serde;
pub use serde_json; pub use serde_json;
pub use serde_wasm_bindgen;
pub use sp_client; pub use sp_client;
pub use tsify; pub use tsify;
pub use wasm_bindgen; pub use wasm_bindgen;
pub use zstd; pub use zstd;
// WASM-specific re-exports only when wasm feature is enabled
#[cfg(feature = "wasm")]
pub use js_sys;
#[cfg(feature = "wasm")]
pub use serde_wasm_bindgen;
pub mod crypto; pub mod crypto;
pub mod device; pub mod device;
pub mod error; pub mod error;

View File

@ -222,8 +222,9 @@ impl Member {
} }
} }
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Tsify)] #[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
#[tsify(into_wasm_abi, from_wasm_abi)] #[cfg_attr(feature = "wasm", derive(Tsify))]
#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
pub struct Pcd(BTreeMap<String, Vec<u8>>); pub struct Pcd(BTreeMap<String, Vec<u8>>);
impl IntoIterator for Pcd { impl IntoIterator for Pcd {

View File

@ -1,6 +1,6 @@
use crate::{pcd::Member, process::Process}; use crate::{pcd::Member, process::Process};
use serde::de::Error; use serde::de::Error;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use serde::{Deserialize, Deserializer, Serialize, Serializer};
use sp_client::bitcoin::hex::{DisplayHex, FromHex}; use sp_client::bitcoin::hex::{DisplayHex, FromHex};
use sp_client::bitcoin::OutPoint; use sp_client::bitcoin::OutPoint;
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};