diff --git a/Cargo.lock b/Cargo.lock index 36796c5ed8..3c889684bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1904,10 +1904,6 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" -dependencies = [ - "gloo-timers", - "send_wrapper", -] [[package]] name = "futures-util" @@ -2092,18 +2088,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -[[package]] -name = "gloo-timers" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d12a7f4e95cfe710f1d624fb1210b7d961a5fb05c4fd942f4feab06e61f590e" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "group" version = "0.10.0" @@ -4926,12 +4910,6 @@ dependencies = [ "pest", ] -[[package]] -name = "send_wrapper" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" - [[package]] name = "serde" version = "1.0.136" @@ -6418,8 +6396,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if 1.0.0", - "serde", - "serde_json", "wasm-bindgen-macro", ] @@ -6515,15 +6491,12 @@ dependencies = [ "ethereum-types", "futures", "futures-timer", - "getrandom 0.2.6", "headers", "hex", - "js-sys", "jsonrpc-core", "log", "parking_lot 0.11.2", "pin-project", - "rand 0.8.5", "reqwest", "rlp", "secp256k1", @@ -6535,8 +6508,6 @@ dependencies = [ "tokio-stream", "tokio-util 0.6.9", "url", - "wasm-bindgen", - "wasm-bindgen-futures", "web3-async-native-tls", ] diff --git a/clients/webassembly/Cargo.toml b/clients/webassembly/Cargo.toml index 372551a29d..fefbb94e60 100644 --- a/clients/webassembly/Cargo.toml +++ b/clients/webassembly/Cargo.toml @@ -32,7 +32,7 @@ credentials = { path = "../../common/credentials", optional = true } crypto = { path = "../../common/crypto" } nymsphinx = { path = "../../common/nymsphinx" } topology = { path = "../../common/topology" } -gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm"] } +gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm", "coconut"] } validator-client = { path = "../../common/client-libs/validator-client", default-features = false } wasm-utils = { path = "../../common/wasm-utils" } diff --git a/common/client-libs/gateway-client/Cargo.toml b/common/client-libs/gateway-client/Cargo.toml index 2cd7388139..b9334ec37c 100644 --- a/common/client-libs/gateway-client/Cargo.toml +++ b/common/client-libs/gateway-client/Cargo.toml @@ -15,8 +15,8 @@ log = "0.4" thiserror = "1.0" url = "2.2" rand = { version = "0.7.3", features = ["wasm-bindgen"] } -secp256k1 = "0.20.3" -web3 = { version = "0.17.0", default-features = false } +secp256k1 = { version = "0.20.3", optional = true } +web3 = { version = "0.17.0", default-features = false, optional = true } async-trait = { version = "0.1.51" } # internal @@ -73,5 +73,5 @@ features = ["js"] [features] coconut = ["gateway-requests/coconut", "coconut-interface", "validator-client", "credentials/coconut"] -wasm = ["web3/wasm", "web3/http", "web3/signing"] -default = ["web3/default"] +wasm = [] +default = ["web3/default", "secp256k1"] diff --git a/common/client-libs/gateway-client/src/bandwidth.rs b/common/client-libs/gateway-client/src/bandwidth.rs index 9154ab7cc4..4fe71c8a11 100644 --- a/common/client-libs/gateway-client/src/bandwidth.rs +++ b/common/client-libs/gateway-client/src/bandwidth.rs @@ -23,7 +23,7 @@ use { }, }; -#[cfg(not(feature = "coconut"))] +#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] use { credentials::token::bandwidth::TokenCredential, crypto::asymmetric::identity, @@ -45,7 +45,7 @@ use { }, }; -#[cfg(not(feature = "coconut"))] +#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] pub fn eth_contract(web3: Web3) -> Contract { Contract::from_json( web3.eth(), @@ -58,7 +58,7 @@ pub fn eth_contract(web3: Web3) -> Contract { .expect("Invalid json abi") } -#[cfg(not(feature = "coconut"))] +#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] pub fn eth_erc20_contract(web3: Web3) -> Contract { Contract::from_json( web3.eth(), @@ -76,11 +76,11 @@ pub struct BandwidthController { storage: St, #[cfg(feature = "coconut")] validator_endpoints: Vec, - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] contract: Contract, - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] erc20_contract: Contract, - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] eth_private_key: SecretKey, } @@ -96,7 +96,7 @@ where } } - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] pub fn new( storage: St, eth_endpoint: String, @@ -120,7 +120,7 @@ where }) } - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] async fn backup_keypair(&self, keypair: &identity::KeyPair) -> Result<(), GatewayClientError> { self.storage .insert_erc20_credential( @@ -132,7 +132,7 @@ where Ok(()) } - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] async fn restore_keypair(&self) -> Result { let data = self.storage.get_next_erc20_credential().await?; let public_key = identity::PublicKey::from_base58_string(data.public_key).unwrap(); @@ -141,7 +141,7 @@ where Ok(identity::KeyPair::from_keys(private_key, public_key)) } - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] async fn mark_keypair_as_spent( &self, keypair: &identity::KeyPair, @@ -180,7 +180,7 @@ where )?) } - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] pub async fn prepare_token_credential( &self, gateway_identity: identity::PublicKey, @@ -219,7 +219,7 @@ where )) } - #[cfg(not(feature = "coconut"))] + #[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] pub async fn buy_token_credential( &self, verification_key: identity::PublicKey, @@ -348,7 +348,7 @@ where } } -#[cfg(not(feature = "coconut"))] +#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))] #[cfg(test)] mod tests { use network_defaults::ETH_EVENT_NAME; diff --git a/nym-connect/Cargo.lock b/nym-connect/Cargo.lock index 1e808758c8..d6bf186f83 100644 --- a/nym-connect/Cargo.lock +++ b/nym-connect/Cargo.lock @@ -5227,6 +5227,7 @@ version = "0.1.0" dependencies = [ "nymsphinx-addressing", "ordered-buffer", + "thiserror", ] [[package]]