From e157aed258fe0c938294ab2c081cac091572992b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Tue, 16 Apr 2024 11:55:26 +0200 Subject: [PATCH 1/2] Optimize wasm for explorer --- Cargo.toml | 9 ++++ bindings/core/Cargo.toml | 3 +- bindings/core/src/error.rs | 2 + bindings/core/src/lib.rs | 15 ++++-- bindings/core/src/method/mod.rs | 5 +- bindings/core/src/method/wallet.rs | 13 +++-- .../core/src/method_handler/call_method.rs | 19 ++++--- bindings/core/src/method_handler/mod.rs | 7 +-- bindings/core/src/response.rs | 18 +++++-- bindings/nodejs/Cargo.toml | 1 + bindings/python/Cargo.toml | 2 + bindings/wasm/Cargo.toml | 12 +++-- bindings/wasm/package.json | 5 +- bindings/wasm/src/client.rs | 1 + bindings/wasm/src/secret_manager.rs | 1 + bindings/wasm/src/wallet.rs | 50 ++++++++++++++++++- sdk/src/client/node_api/core/routes.rs | 8 +-- sdk/src/types/api/core.rs | 1 + sdk/src/wallet/core/mod.rs | 1 + 19 files changed, 138 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 99647d0d92..8f021e7ece 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,12 @@ codegen-units = 1 inherits = "release" lto = true strip = "symbols" +incremental = false + +[profile.wasm] +codegen-units = 1 +inherits = "release" +lto = true +strip = "symbols" +opt-level = "z" +incremental = false diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index fe4984c2f2..015b7bc175 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -10,7 +10,7 @@ publish = false [dependencies] iota-sdk = { path = "../../sdk", default-features = false, features = [ - "wallet", + "client", "protocol_parameters_samples", "tls", ] } @@ -51,3 +51,4 @@ rocksdb = ["iota-sdk/rocksdb"] storage = ["iota-sdk/storage"] stronghold = ["iota-sdk/stronghold"] private_key_secret_manager = ["iota-sdk/private_key_secret_manager"] +wallet = ["iota-sdk/wallet"] diff --git a/bindings/core/src/error.rs b/bindings/core/src/error.rs index 128b6d4454..cd636940fb 100644 --- a/bindings/core/src/error.rs +++ b/bindings/core/src/error.rs @@ -34,6 +34,7 @@ pub enum Error { /// Client errors. #[error("{0}")] Client(#[from] iota_sdk::client::ClientError), + #[cfg(feature = "wallet")] /// Wallet errors. #[error("{0}")] Wallet(#[from] iota_sdk::wallet::WalletError), @@ -80,6 +81,7 @@ impl Serialize for Error { error: match &self { // Only Client and wallet have a proper serde impl Self::Client(e) => serde_json::to_value(e).map_err(serde::ser::Error::custom)?, + #[cfg(feature = "wallet")] Self::Wallet(e) => serde_json::to_value(e).map_err(serde::ser::Error::custom)?, _ => serde_json::Value::String(self.to_string()), }, diff --git a/bindings/core/src/lib.rs b/bindings/core/src/lib.rs index 2c36cb9403..720b6bd0ab 100644 --- a/bindings/core/src/lib.rs +++ b/bindings/core/src/lib.rs @@ -11,16 +11,21 @@ mod response; use std::fmt::{Formatter, Result as FmtResult}; +#[cfg(feature = "wallet")] use crypto::keys::bip44::Bip44; +#[cfg(feature = "wallet")] use derivative::Derivative; use fern_logger::{logger_init, LoggerConfig, LoggerOutputConfigBuilder}; pub use iota_sdk; +use iota_sdk::client::secret::SecretManagerDto; +#[cfg(feature = "wallet")] use iota_sdk::{ - client::secret::{SecretManager, SecretManagerDto}, + client::secret::SecretManager, types::block::address::Bech32Address, utils::serde::bip44::option_bip44, wallet::{ClientOptions, Wallet, WalletError}, }; +#[cfg(feature = "wallet")] use serde::Deserialize; #[cfg(feature = "mqtt")] @@ -29,10 +34,12 @@ pub use self::method_handler::listen_mqtt; pub use self::method_handler::CallMethod; pub use self::{ error::Error, - method::{ClientMethod, SecretManagerMethod, UtilsMethod, WalletMethod}, - method_handler::{call_client_method, call_secret_manager_method, call_utils_method, call_wallet_method}, + method::{ClientMethod, SecretManagerMethod, UtilsMethod}, + method_handler::{call_client_method, call_secret_manager_method, call_utils_method}, response::Response, }; +#[cfg(feature = "wallet")] +pub use self::{method::WalletMethod, method_handler::call_wallet_method}; pub fn init_logger(config: String) -> std::result::Result<(), fern_logger::Error> { let output_config: LoggerOutputConfigBuilder = serde_json::from_str(&config).expect("invalid logger config"); @@ -40,6 +47,7 @@ pub fn init_logger(config: String) -> std::result::Result<(), fern_logger::Error logger_init(config) } +#[cfg(feature = "wallet")] #[derive(Derivative, Deserialize, Default)] #[derivative(Debug)] #[serde(rename_all = "camelCase")] @@ -54,6 +62,7 @@ pub struct WalletOptions { pub storage_path: Option, } +#[cfg(feature = "wallet")] impl WalletOptions { pub fn with_address(mut self, address: impl Into>) -> Self { self.address = address.into(); diff --git a/bindings/core/src/method/mod.rs b/bindings/core/src/method/mod.rs index 6e47c80767..44079ef369 100644 --- a/bindings/core/src/method/mod.rs +++ b/bindings/core/src/method/mod.rs @@ -4,6 +4,9 @@ mod client; mod secret_manager; mod utils; +#[cfg(feature = "wallet")] mod wallet; -pub use self::{client::ClientMethod, secret_manager::SecretManagerMethod, utils::UtilsMethod, wallet::WalletMethod}; +#[cfg(feature = "wallet")] +pub use self::wallet::WalletMethod; +pub use self::{client::ClientMethod, secret_manager::SecretManagerMethod, utils::UtilsMethod}; diff --git a/bindings/core/src/method/wallet.rs b/bindings/core/src/method/wallet.rs index 1522beb9a8..3c3782a782 100644 --- a/bindings/core/src/method/wallet.rs +++ b/bindings/core/src/method/wallet.rs @@ -6,22 +6,25 @@ use std::path::PathBuf; use crypto::keys::bip44::Bip44; use derivative::Derivative; -use iota_sdk::client::api::options::TransactionOptions; -#[cfg(feature = "events")] -use iota_sdk::wallet::events::types::{WalletEvent, WalletEventType}; // #[cfg(feature = "participation")] // use iota_sdk::{ // client::node_manager::node::Node, // types::api::plugins::participation::types::{ParticipationEventId, ParticipationEventType}, // wallet::types::participation::ParticipationEventRegistrationOptions, // }; +#[cfg(feature = "stronghold")] +use iota_sdk::types::block::address::Hrp; +#[cfg(feature = "events")] +use iota_sdk::wallet::events::types::{WalletEvent, WalletEventType}; use iota_sdk::{ client::{ - api::{transaction_builder::Burn, PreparedTransactionDataDto, SignedTransactionDataDto}, + api::{ + options::TransactionOptions, transaction_builder::Burn, PreparedTransactionDataDto, + SignedTransactionDataDto, + }, node_manager::node::NodeAuth, }, types::block::{ - address::Hrp, output::{AccountId, DelegationId, Output, OutputId, TokenId}, payload::signed_transaction::TransactionId, }, diff --git a/bindings/core/src/method_handler/call_method.rs b/bindings/core/src/method_handler/call_method.rs index f16e460692..07314bf196 100644 --- a/bindings/core/src/method_handler/call_method.rs +++ b/bindings/core/src/method_handler/call_method.rs @@ -4,19 +4,20 @@ use std::pin::Pin; use futures::Future; -use iota_sdk::{ - client::{ - secret::{DowncastSecretManager, SecretManage}, - Client, - }, - wallet::Wallet, +use iota_sdk::client::{ + secret::{DowncastSecretManager, SecretManage}, + Client, }; +#[cfg(feature = "wallet")] +use iota_sdk::wallet::Wallet; +#[cfg(feature = "wallet")] +use crate::{method::WalletMethod, method_handler::wallet::call_wallet_method_internal}; use crate::{ - method::{ClientMethod, SecretManagerMethod, WalletMethod}, + method::{ClientMethod, SecretManagerMethod}, method_handler::{ client::call_client_method_internal, secret_manager::call_secret_manager_method_internal, - utils::call_utils_method_internal, wallet::call_wallet_method_internal, + utils::call_utils_method_internal, }, panic::{convert_async_panics, convert_panics}, response::Response, @@ -38,6 +39,7 @@ impl CallMethod for Client { } } +#[cfg(feature = "wallet")] impl CallMethod for Wallet { type Method = WalletMethod; @@ -57,6 +59,7 @@ pub async fn call_client_method(client: &Client, method: ClientMethod) -> Respon response } +#[cfg(feature = "wallet")] /// Call a wallet method. pub async fn call_wallet_method(wallet: &Wallet, method: WalletMethod) -> Response { log::debug!("Wallet method: {method:?}"); diff --git a/bindings/core/src/method_handler/mod.rs b/bindings/core/src/method_handler/mod.rs index 5b39e211fa..756ac6856f 100644 --- a/bindings/core/src/method_handler/mod.rs +++ b/bindings/core/src/method_handler/mod.rs @@ -5,10 +5,11 @@ mod call_method; mod client; mod secret_manager; mod utils; +#[cfg(feature = "wallet")] mod wallet; -pub use call_method::{ - call_client_method, call_secret_manager_method, call_utils_method, call_wallet_method, CallMethod, -}; +#[cfg(feature = "wallet")] +pub use call_method::call_wallet_method; +pub use call_method::{call_client_method, call_secret_manager_method, call_utils_method, CallMethod}; #[cfg(feature = "mqtt")] pub use client::listen_mqtt; diff --git a/bindings/core/src/response.rs b/bindings/core/src/response.rs index 9523642b78..271a7f83de 100644 --- a/bindings/core/src/response.rs +++ b/bindings/core/src/response.rs @@ -7,6 +7,11 @@ use std::collections::HashSet; use derivative::Derivative; #[cfg(feature = "ledger_nano")] use iota_sdk::client::secret::LedgerNanoStatus; +#[cfg(feature = "wallet")] +use iota_sdk::wallet::{ + types::{Balance, OutputData, TransactionWithMetadataDto}, + PreparedCreateDelegationTransaction, PreparedCreateNativeTokenTransaction, +}; use iota_sdk::{ client::{ api::{PreparedTransactionData, SignedTransactionDataDto}, @@ -36,10 +41,6 @@ use iota_sdk::{ }, }, utils::serde::string, - wallet::{ - types::{Balance, OutputData, TransactionWithMetadataDto}, - PreparedCreateDelegationTransaction, PreparedCreateNativeTokenTransaction, - }, }; use serde::Serialize; #[cfg(feature = "participation")] @@ -287,6 +288,7 @@ pub enum Response { Panic(String), // wallet responses + #[cfg(feature = "wallet")] /// Response for: /// - [`GetAddress`](crate::method::WalletMethod::GetAddress) Address(Bech32Address), @@ -302,9 +304,11 @@ pub enum Response { /// Response for: /// - [`ClaimableOutputs`](crate::method::WalletMethod::ClaimableOutputs) OutputIds(Vec), + #[cfg(feature = "wallet")] /// Response for: /// - [`GetOutput`](crate::method::WalletMethod::GetOutput) OutputData(Option>), + #[cfg(feature = "wallet")] /// Response for: /// - [`Outputs`](crate::method::WalletMethod::Outputs), /// - [`UnspentOutputs`](crate::method::WalletMethod::UnspentOutputs) @@ -328,16 +332,20 @@ pub enum Response { /// - [`PrepareVote`](crate::method::WalletMethod::PrepareVote) /// - [`PrepareImplicitAccountTransition`](crate::method::WalletMethod::PrepareImplicitAccountTransition) PreparedTransaction(PreparedTransactionData), + #[cfg(feature = "wallet")] /// Response for: /// - [`PrepareCreateNativeToken`](crate::method::WalletMethod::PrepareCreateNativeToken), PreparedCreateNativeTokenTransaction(PreparedCreateNativeTokenTransaction), + #[cfg(feature = "wallet")] /// Response for: /// - [`PrepareCreateDelegation`](crate::method::WalletMethod::PrepareCreateDelegation), PreparedCreateDelegationTransaction(PreparedCreateDelegationTransaction), + #[cfg(feature = "wallet")] /// Response for: /// - [`GetIncomingTransaction`](crate::method::WalletMethod::GetIncomingTransaction) /// - [`GetTransaction`](crate::method::WalletMethod::GetTransaction), Transaction(Option>), + #[cfg(feature = "wallet")] /// Response for: /// - [`IncomingTransactions`](crate::method::WalletMethod::IncomingTransactions) /// - [`PendingTransactions`](crate::method::WalletMethod::PendingTransactions), @@ -346,10 +354,12 @@ pub enum Response { /// Response for: /// - [`SignTransaction`](crate::method::WalletMethod::SignTransaction) SignedTransactionData(SignedTransactionDataDto), + #[cfg(feature = "wallet")] /// Response for: /// - [`GetBalance`](crate::method::WalletMethod::GetBalance), /// - [`Sync`](crate::method::WalletMethod::Sync) Balance(Balance), + #[cfg(feature = "wallet")] /// Response for: /// - [`SignAndSubmitTransaction`](crate::method::WalletMethod::SignAndSubmitTransaction) /// - [`SubmitAndStoreTransaction`](crate::method::WalletMethod::SubmitAndStoreTransaction) diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml index 4b57e82836..37d729e00f 100644 --- a/bindings/nodejs/Cargo.toml +++ b/bindings/nodejs/Cargo.toml @@ -28,6 +28,7 @@ iota-sdk-bindings-core = { path = "../core", default-features = false, features "rocksdb", "mqtt", "private_key_secret_manager", + "wallet", ] } log = { version = "0.4.21", default-features = false } napi = { version = "2.16.1", default-features = false, features = ["async"] } diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index 268afeb726..dc991413a0 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -25,6 +25,8 @@ iota-sdk-bindings-core = { path = "../core", default-features = false, features "storage", "stronghold", "mqtt", + "private_key_secret_manager", + "wallet", ] } futures = { version = "0.3.30", default-features = false } diff --git a/bindings/wasm/Cargo.toml b/bindings/wasm/Cargo.toml index f48965fc0c..1aae6589c3 100644 --- a/bindings/wasm/Cargo.toml +++ b/bindings/wasm/Cargo.toml @@ -17,11 +17,7 @@ crate-type = ["cdylib"] doc = false [dependencies] -iota-sdk-bindings-core = { path = "../core", default-features = false, features = [ - "events", - "storage", - "private_key_secret_manager", -] } +iota-sdk-bindings-core = { path = "../core", default-features = false } console_error_panic_hook = { version = "0.1.7", default-features = false } js-sys = { version = "0.3.69", default-features = false, features = [] } @@ -41,3 +37,9 @@ getrandom = { version = "0.2.12", default-features = false, features = ["js"] } instant = { version = "0.1.12", default-features = false, features = [ "wasm-bindgen", ] } + +[features] +default = ["private_key_secret_manager", "wallet"] + +private_key_secret_manager = [ "iota-sdk-bindings-core/private_key_secret_manager" ] +wallet = [ "iota-sdk-bindings-core/events", "iota-sdk-bindings-core/storage", "iota-sdk-bindings-core/wallet" ] diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 696f67687a..503f7a7d88 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -24,6 +24,9 @@ "build:web": "node ./build_scripts/copyNodejsDefs.js && yarn run build:src && yarn run bundle:web && wasm-opt -O web/wasm/iota_sdk_wasm_bg.wasm -o web/wasm/iota_sdk_wasm_bg.wasm", "bundle:nodejs": "wasm-bindgen ../../target/wasm32-unknown-unknown/production/iota_sdk_wasm.wasm --typescript --weak-refs --target nodejs --out-dir node/wasm && node ./build_scripts/node && tsc --project tsconfig.node.json --outDir node/lib", "bundle:web": "wasm-bindgen ../../target/wasm32-unknown-unknown/production/iota_sdk_wasm.wasm --typescript --weak-refs --target web --out-dir web/wasm && node ./build_scripts/web && tsc --project tsconfig.web.json --outDir web/lib", + "build:src-client-only": "cargo build --lib --profile=wasm --target wasm32-unknown-unknown --no-default-features", + "build:web-client-only": "node ./build_scripts/copyNodejsDefs.js && yarn run build:src-client-only && yarn run bundle:web-client-only && wasm-opt -Oz web/wasm/iota_sdk_wasm_bg.wasm -o web/wasm/iota_sdk_wasm_bg.wasm", + "bundle:web-client-only": "wasm-bindgen ../../target/wasm32-unknown-unknown/wasm/iota_sdk_wasm.wasm --typescript --weak-refs --target web --out-dir web/wasm && node ./build_scripts/web && tsc --project tsconfig.web.json --outDir web/lib", "copy-nodejs-defs": "node ./build_scripts/copyNodejsDefs.js", "lint": "eslint --ignore-path .eslintignore --ext .js,.ts .", "format": "prettier --ignore-path .eslintignore -w \"{,*/**/}*.{ts,js,json}\"", @@ -73,4 +76,4 @@ "optionalDependencies": { "fsevents": "^2.3.2" } -} +} \ No newline at end of file diff --git a/bindings/wasm/src/client.rs b/bindings/wasm/src/client.rs index 8d5c7f02bd..ce9c2bee7c 100644 --- a/bindings/wasm/src/client.rs +++ b/bindings/wasm/src/client.rs @@ -17,6 +17,7 @@ use crate::{build_js_error, destroyed_err, map_err, ArrayString}; #[wasm_bindgen(js_name = ClientMethodHandler)] pub struct ClientMethodHandler(Arc>>); +#[cfg(feature = "wallet")] impl ClientMethodHandler { pub(crate) fn new(client: Client) -> Self { Self(Arc::new(RwLock::new(Some(client)))) diff --git a/bindings/wasm/src/secret_manager.rs b/bindings/wasm/src/secret_manager.rs index 894625fe38..d9919fb45c 100644 --- a/bindings/wasm/src/secret_manager.rs +++ b/bindings/wasm/src/secret_manager.rs @@ -17,6 +17,7 @@ use crate::{build_js_error, map_err}; #[wasm_bindgen(js_name = SecretManagerMethodHandler)] pub struct SecretManagerMethodHandler(Arc>); +#[cfg(feature = "wallet")] impl SecretManagerMethodHandler { pub(crate) fn new(secret_manager: Arc>) -> Self { Self(secret_manager) diff --git a/bindings/wasm/src/wallet.rs b/bindings/wasm/src/wallet.rs index b23b1ef609..49b75efafa 100644 --- a/bindings/wasm/src/wallet.rs +++ b/bindings/wasm/src/wallet.rs @@ -1,8 +1,10 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "wallet")] use std::sync::Arc; +#[cfg(feature = "wallet")] use iota_sdk_bindings_core::{ call_wallet_method as rust_call_wallet_method, iota_sdk::wallet::{ @@ -11,18 +13,30 @@ use iota_sdk_bindings_core::{ }, Response, WalletOptions, }; +#[cfg(feature = "wallet")] use tokio::sync::{ mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}, RwLock, }; -use wasm_bindgen::{prelude::wasm_bindgen, JsError, JsValue}; +#[cfg(feature = "wallet")] +use wasm_bindgen::JsError; +use wasm_bindgen::{prelude::wasm_bindgen, JsValue}; +#[cfg(feature = "wallet")] use crate::{client::ClientMethodHandler, destroyed_err, map_err, secret_manager::SecretManagerMethodHandler}; +#[cfg(feature = "wallet")] /// The Wallet method handler. #[wasm_bindgen(js_name = WalletMethodHandler)] pub struct WalletMethodHandler(Arc>>); +#[cfg(not(feature = "wallet"))] +#[wasm_bindgen(js_name = createWallet)] +#[allow(non_snake_case)] +pub fn create_wallet(_options: String) -> Result { + Err(JsValue::from(js_sys::Error::new("wallet feature not enabled"))) +} +#[cfg(feature = "wallet")] /// Creates a method handler with the given options. #[wasm_bindgen(js_name = createWallet)] #[allow(non_snake_case)] @@ -33,12 +47,24 @@ pub async fn create_wallet(options: String) -> Result Result<(), JsValue> { + Err(JsValue::from(js_sys::Error::new("wallet feature not enabled"))) +} +#[cfg(feature = "wallet")] #[wasm_bindgen(js_name = destroyWallet)] pub async fn destroy_wallet(method_handler: &WalletMethodHandler) -> Result<(), JsError> { method_handler.0.write().await.take(); Ok(()) } +#[cfg(not(feature = "wallet"))] +#[wasm_bindgen(js_name = getClient)] +pub async fn get_client(_method_handler: &js_sys::Object) -> Result<(), JsValue> { + Err(JsValue::from(js_sys::Error::new("wallet feature not enabled"))) +} +#[cfg(feature = "wallet")] #[wasm_bindgen(js_name = getClient)] pub async fn get_client(method_handler: &WalletMethodHandler) -> Result { if let Some(wallet) = &*method_handler.0.read().await { @@ -49,6 +75,12 @@ pub async fn get_client(method_handler: &WalletMethodHandler) -> Result Result<(), JsValue> { + Err(JsValue::from(js_sys::Error::new("wallet feature not enabled"))) +} +#[cfg(feature = "wallet")] #[wasm_bindgen(js_name = getSecretManager)] pub async fn get_secret_manager(method_handler: &WalletMethodHandler) -> Result { if let Some(wallet) = &*method_handler.0.read().await { @@ -59,6 +91,12 @@ pub async fn get_secret_manager(method_handler: &WalletMethodHandler) -> Result< } } +#[cfg(not(feature = "wallet"))] +#[wasm_bindgen(js_name = callWalletMethod)] +pub async fn call_wallet_method(_method_handler: &js_sys::Object, _method: String) -> Result { + Err(JsValue::from(js_sys::Error::new("wallet feature not enabled"))) +} +#[cfg(feature = "wallet")] /// Handles a method, returns the response as a JSON-encoded string. /// /// Returns an error if the response itself is an error or panic. @@ -78,6 +116,16 @@ pub async fn call_wallet_method(method_handler: &WalletMethodHandler, method: St } } +#[cfg(not(feature = "wallet"))] +#[wasm_bindgen(js_name = listenWallet)] +pub async fn listen_wallet( + _vec: js_sys::Array, + _callback: js_sys::Function, + _method_handler: &js_sys::Object, +) -> Result { + Err(JsValue::from(js_sys::Error::new("wallet feature not enabled"))) +} +#[cfg(feature = "wallet")] /// It takes a list of event types, registers a callback function, and then listens for events of those /// types /// diff --git a/sdk/src/client/node_api/core/routes.rs b/sdk/src/client/node_api/core/routes.rs index 98e1798ad0..f96b54b5f2 100644 --- a/sdk/src/client/node_api/core/routes.rs +++ b/sdk/src/client/node_api/core/routes.rs @@ -7,6 +7,8 @@ use packable::PackableExt; use serde::{Deserialize, Serialize}; use url::Url; +#[cfg(not(target_family = "wasm"))] +use crate::types::api::core::PermanodeInfoResponse; use crate::{ client::{ constants::{DEFAULT_API_TIMEOUT, DEFAULT_USER_AGENT}, @@ -18,9 +20,8 @@ use crate::{ api::core::{ BlockMetadataResponse, BlockWithMetadataResponse, CommitteeResponse, CongestionResponse, InfoResponse, IssuanceBlockHeaderResponse, ManaRewardsResponse, NetworkMetricsResponse, OutputResponse, - OutputWithMetadataResponse, PermanodeInfoResponse, RoutesResponse, SubmitBlockResponse, - TransactionMetadataResponse, UtxoChangesFullResponse, UtxoChangesResponse, ValidatorResponse, - ValidatorsResponse, + OutputWithMetadataResponse, RoutesResponse, SubmitBlockResponse, TransactionMetadataResponse, + UtxoChangesFullResponse, UtxoChangesResponse, ValidatorResponse, ValidatorsResponse, }, block::{ address::ToBech32Ext, @@ -456,6 +457,7 @@ impl Client { Ok(resp) } + #[cfg(not(target_family = "wasm"))] /// GET /api/core/v3/info endpoint pub(crate) async fn get_permanode_info(mut node: Node) -> Result { log::debug!("get_permanode_info"); diff --git a/sdk/src/types/api/core.rs b/sdk/src/types/api/core.rs index b47b39b75e..e8c950d59d 100644 --- a/sdk/src/types/api/core.rs +++ b/sdk/src/types/api/core.rs @@ -77,6 +77,7 @@ pub(crate) struct PermanodeInfoResponse { pub base_token: BaseTokenResponse, } +#[cfg(not(target_family = "wasm"))] impl PermanodeInfoResponse { pub(crate) fn protocol_parameters_by_version(&self, protocol_version: u8) -> Option<&ProtocolParametersResponse> { self.protocol_parameters.by_version(protocol_version) diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index 29657d4f99..d5f820b2b6 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -421,6 +421,7 @@ impl Wallet { *self.bip_path.read().await } + #[cfg(feature = "stronghold")] pub(crate) async fn bip_path_mut(&self) -> tokio::sync::RwLockWriteGuard<'_, Option> { self.bip_path.write().await } From 24c47e174ac06c216c387f3327ff4d33cf855691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Tue, 16 Apr 2024 12:14:33 +0200 Subject: [PATCH 2/2] Format --- bindings/wasm/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 503f7a7d88..d52c934a2b 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -76,4 +76,4 @@ "optionalDependencies": { "fsevents": "^2.3.2" } -} \ No newline at end of file +}