fixing more build issues

This commit is contained in:
Jędrzej Stuczyński
2024-05-10 10:45:44 +01:00
parent b8ab187db0
commit 89fb4ef03f
6 changed files with 72 additions and 40 deletions
+23
View File
@@ -0,0 +1,23 @@
build: build-go-opt build-rust build-package-json
check-fmt: check-fmt-go check-fmt-rust
build-go:
$(MAKE) -C go-mix-conn build-go
build-go-opt:
$(MAKE) -C go-mix-conn build-go-opt
build-rust:
wasm-pack build --scope nymproject --target web --out-dir ../../dist/wasm/mix-fetch
wasm-opt -Oz -o ../../dist/wasm/mix-fetch/mix_fetch_wasm_bg.wasm ../../dist/wasm/mix-fetch/mix_fetch_wasm_bg.wasm
build-package-json:
node build.mjs
check-fmt-go:
$(MAKE) -C go-mix-conn check-fmt
check-fmt-rust:
cargo fmt --check
cargo clippy --target wasm32-unknown-unknown -- -Dwarnings
+1 -1
View File
@@ -38,7 +38,7 @@ nym-http-api-client = { path = "../../common/http-api-client" }
wasm-utils = { path = "../../common/wasm/utils" }
[dev-dependencies]
anyhow = { workspac = true }
anyhow = { workspace = true }
tokio = { workspace = true, features = ["full"] }
+30 -29
View File
@@ -197,32 +197,33 @@ pub struct SerialisedNymIssuedBandwidthVoucher {
pub bs58_encoded_data: String,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::vpn_api_client::client::{new_client, NymVpnApiClient};
#[tokio::test]
async fn end_to_end() -> anyhow::Result<()> {
let client = new_client("http://0.0.0.0:8080", "foomp")?;
let opts = client.get_prehashed_public_attributes().await?;
let issuance = NymIssuanceBandwidthVoucher::prepare_new(opts, None)?;
let shares = client
.get_bandwidth_voucher_blinded_shares(issuance.blind_sign_request.clone())
.await?;
let keys = client.get_partial_verification_keys().await?;
let master_key = client.get_master_verification_key().await?;
let voucher = issuance.unblind_shares(shares, keys)?;
println!(
"valid: {}",
voucher.ensure_is_valid(master_key.bs58_encoded_key, None)
);
let serialised = voucher.serialise();
println!("final: {serialised:#?}");
Ok(())
}
}
// #[cfg(test)]
// mod tests {
// use super::*;
// use crate::vpn_api_client::client::{new_client, NymVpnApiClient};
//
// #[ignore]
// #[tokio::test]
// async fn end_to_end() -> anyhow::Result<()> {
// let client = new_client("http://0.0.0.0:8080", "foomp")?;
// let opts = client.get_prehashed_public_attributes().await?;
// let issuance = NymIssuanceBandwidthVoucher::prepare_new(opts, None)?;
//
// let shares = client
// .get_bandwidth_voucher_blinded_shares(issuance.blind_sign_request.clone())
// .await?;
// let keys = client.get_partial_verification_keys().await?;
// let master_key = client.get_master_verification_key().await?;
//
// let voucher = issuance.unblind_shares(shares, keys)?;
//
// println!(
// "valid: {}",
// voucher.ensure_is_valid(master_key.bs58_encoded_key, None)
// );
// let serialised = voucher.serialise();
// println!("final: {serialised:#?}");
//
// Ok(())
// }
// }
+7 -6
View File
@@ -1,6 +1,7 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::vpn_api_client::NymVpnApiClientError;
use thiserror::Error;
use wasm_utils::wasm_error;
@@ -11,12 +12,12 @@ pub enum ZkNymError {
#[from]
source: nym_coconut::CoconutError,
},
//
// #[error("failed to contact the vpn api")]
// HttpClientFailure {
// #[from]
// source: NymVpnApiClientError,
// },
#[error("failed to contact the vpn api")]
HttpClientFailure {
#[from]
source: NymVpnApiClientError,
},
#[error("the provided shares and issuers are not from the same epoch! {shares} and {issuers}")]
InconsistentEpochId { shares: u64, issuers: u64 },
+6 -4
View File
@@ -1,25 +1,26 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use super::NymVpnApiClientError;
use crate::error::ZkNymError;
use crate::vpn_api_client::types::{
AttributesResponse, BandwidthVoucherRequest, BandwidthVoucherResponse, ErrorResponse,
AttributesResponse, BandwidthVoucherRequest, BandwidthVoucherResponse,
MasterVerificationKeyResponse, PartialVerificationKeysResponse,
};
use async_trait::async_trait;
use nym_coconut::BlindSignRequest;
pub use nym_http_api_client::Client;
use nym_http_api_client::{parse_response, HttpClientError, PathSegments, NO_PARAMS};
use nym_http_api_client::{parse_response, PathSegments, NO_PARAMS};
use reqwest::IntoUrl;
use serde::de::DeserializeOwned;
pub type NymVpnApiClientError = HttpClientError<ErrorResponse>;
#[allow(dead_code)]
pub struct VpnApiClient {
inner: Client,
bearer_token: String,
}
#[allow(dead_code)]
pub fn new_client(
base_url: impl IntoUrl,
bearer_token: impl Into<String>,
@@ -33,6 +34,7 @@ pub fn new_client(
}
// TODO: do it properly by implementing auth headers on `ApiClient` trait
#[allow(dead_code)]
#[async_trait(?Send)]
pub trait NymVpnApiClient {
async fn simple_get<T>(&self, path: PathSegments<'_>) -> Result<T, NymVpnApiClientError>
+5
View File
@@ -1,7 +1,12 @@
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use crate::vpn_api_client::types::ErrorResponse;
use nym_http_api_client::HttpClientError;
#[cfg(test)]
pub(crate) mod client;
pub mod types;
pub type NymVpnApiClientError = HttpClientError<ErrorResponse>;