From 6dee57fc46fa30420510ef7d8b7100607762fe3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 30 Aug 2024 18:35:02 +0100 Subject: [PATCH] adjusting the API and fixing CI --- .../commands/src/ecash/issue_ticket_book.rs | 6 +-- .../src/ecash/bandwidth/importable.rs | 44 ++++++++++++++++--- .../cli/ecash/import_coin_index_signatures.rs | 1 - .../ip-packet-router/src/cli/ecash/mod.rs | 1 - .../ip-packet-router/src/cli/mod.rs | 5 +-- 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/common/commands/src/ecash/issue_ticket_book.rs b/common/commands/src/ecash/issue_ticket_book.rs index 22da4b04c83..e580190ca65 100644 --- a/common/commands/src/ecash/issue_ticket_book.rs +++ b/common/commands/src/ecash/issue_ticket_book.rs @@ -123,7 +123,7 @@ async fn issue_to_file(args: Args, client: SigningClient) -> anyhow::Result<()> .await? .ok_or(anyhow!("missing expiration date signatures!"))?; - exported.with_expiration_date_signatures(&AggregatedExpirationDateSignatures { + exported = exported.with_expiration_date_signatures(&AggregatedExpirationDateSignatures { epoch_id, expiration_date, signatures, @@ -135,7 +135,7 @@ async fn issue_to_file(args: Args, client: SigningClient) -> anyhow::Result<()> .get_coin_index_signatures(epoch_id) .await? .ok_or(anyhow!("missing coin index signatures!"))?; - exported.with_coin_index_signatures(&AggregatedCoinIndicesSignatures { + exported = exported.with_coin_index_signatures(&AggregatedCoinIndicesSignatures { epoch_id, signatures, }); @@ -147,7 +147,7 @@ async fn issue_to_file(args: Args, client: SigningClient) -> anyhow::Result<()> .await? .ok_or(anyhow!("missing master verification key!"))?; - exported.with_master_verification_key(&EpochVerificationKey { epoch_id, key }); + exported = exported.with_master_verification_key(&EpochVerificationKey { epoch_id, key }); } let data = exported.pack().data; diff --git a/common/credentials/src/ecash/bandwidth/importable.rs b/common/credentials/src/ecash/bandwidth/importable.rs index a1f9ac099e9..1765248faa8 100644 --- a/common/credentials/src/ecash/bandwidth/importable.rs +++ b/common/credentials/src/ecash/bandwidth/importable.rs @@ -53,28 +53,58 @@ impl From for ImportableTicketBook { impl ImportableTicketBook { pub fn with_expiration_date_signatures( - &mut self, + mut self, signatures: &AggregatedExpirationDateSignatures, - ) -> &mut Self { + ) -> Self { self.serialised_expiration_date_signatures = Some(signatures.pack()); self } pub fn with_coin_index_signatures( - &mut self, + mut self, signatures: &AggregatedCoinIndicesSignatures, - ) -> &mut Self { + ) -> Self { self.serialised_coin_index_signatures = Some(signatures.pack()); self } - pub fn with_master_verification_key(&mut self, key: &EpochVerificationKey) -> &mut Self { + pub fn with_master_verification_key(mut self, key: &EpochVerificationKey) -> Self { self.serialised_master_verification_key = Some(key.pack()); self } - pub fn finalize_export(self) -> Vec { - self.pack().data + pub fn with_maybe_expiration_date_signatures( + self, + signatures: &Option, + ) -> Self { + if let Some(sigs) = signatures { + self.with_expiration_date_signatures(sigs) + } else { + self + } + } + + pub fn with_maybe_coin_index_signatures( + self, + signatures: &Option, + ) -> Self { + if let Some(sigs) = signatures { + self.with_coin_index_signatures(sigs) + } else { + self + } + } + + pub fn with_maybe_master_verification_key(self, key: &Option) -> Self { + if let Some(sigs) = key { + self.with_master_verification_key(sigs) + } else { + self + } + } + + pub fn finalize_export(self) -> VersionSerialised { + self.pack() } pub fn try_unpack_full(&self) -> Result { diff --git a/service-providers/ip-packet-router/src/cli/ecash/import_coin_index_signatures.rs b/service-providers/ip-packet-router/src/cli/ecash/import_coin_index_signatures.rs index 9ffe5439fa6..a06f9e70b8b 100644 --- a/service-providers/ip-packet-router/src/cli/ecash/import_coin_index_signatures.rs +++ b/service-providers/ip-packet-router/src/cli/ecash/import_coin_index_signatures.rs @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 use crate::cli::CliIpPacketRouterClient; -use crate::error::ClientError; use nym_client_core::cli_helpers::client_import_coin_index_signatures::{ import_coin_index_signatures, CommonClientImportCoinIndexSignaturesArgs, }; diff --git a/service-providers/ip-packet-router/src/cli/ecash/mod.rs b/service-providers/ip-packet-router/src/cli/ecash/mod.rs index b0c7ca0ba96..500f0666c5f 100644 --- a/service-providers/ip-packet-router/src/cli/ecash/mod.rs +++ b/service-providers/ip-packet-router/src/cli/ecash/mod.rs @@ -10,7 +10,6 @@ use std::error::Error; pub(crate) mod import_coin_index_signatures; pub(crate) mod import_credential; -pub mod import_credential; pub(crate) mod import_expiration_date_signatures; pub(crate) mod import_master_verification_key; pub(crate) mod show_ticketbooks; diff --git a/service-providers/ip-packet-router/src/cli/mod.rs b/service-providers/ip-packet-router/src/cli/mod.rs index fb47e4c09fa..6a0a9ed19b2 100644 --- a/service-providers/ip-packet-router/src/cli/mod.rs +++ b/service-providers/ip-packet-router/src/cli/mod.rs @@ -1,4 +1,4 @@ -use crate::commands::ecash::Ecash; +use crate::cli::ecash::Ecash; use clap::{CommandFactory, Parser, Subcommand}; use log::error; use nym_bin_common::completions::{fig_generate, ArgShell}; @@ -77,9 +77,6 @@ pub(crate) enum Commands { /// Change the currently active gateway. Note that you must have already registered with the new gateway! SwitchGateway(switch_gateway::Args), - /// Display information associated with the imported ticketbooks, - ShowTicketbooks(show_ticketbooks::Args), - /// Sign to prove ownership of this network requester Sign(sign::Sign),