diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13c309b6..bb2a9b48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,10 +82,10 @@ jobs: locked: true - name: Code Coverage - Generate - run: cargo tarpaulin + run: cargo tarpaulin --out xml - name: Code Coverage - Upload to CodeCov.io uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV }} - fail_ci_if_error: true \ No newline at end of file + fail_ci_if_error: true diff --git a/.tarpaulin.toml b/.tarpaulin.toml new file mode 100644 index 00000000..d3dc8ad1 --- /dev/null +++ b/.tarpaulin.toml @@ -0,0 +1,9 @@ +[all] +exclude-files = ["src/existing_types_in_sargon.rs"] +verbose = false +force-clean = true +timeout = "2m" +locked = true +all-features = true +jobs = 1 +out = ["html"] diff --git a/README.md b/README.md index 8d0cd5cf..ad56a611 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -[![Average](https://codecov.io/gh/sajjon/one-does-not-simply-sign/graph/badge.svg?token=8QPKIUSAQD)](https://codecov.io/github/sajjon/one-does-not-simply-sign) \ No newline at end of file +[![codecov](https://codecov.io/github/Sajjon/one-does-not-simply-sign/branch/main/graph/badge.svg?token=PTFupnAjyZ)](https://codecov.io/github/Sajjon/one-does-not-simply-sign) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..1781a03a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,19 @@ +codecov: + notify: + wait_for_ci: true + max_report_age: off + require_ci_to_pass: true +comment: + behavior: default + layout: "reach, diff, flags, files" + show_carryforward_flags: false +coverage: + precision: 1 + range: 80...98 # red -> yellow (the inside range) -> green + status: + patch: + default: + target: auto + threshold: 80% + base: auto + only_pulls: true diff --git a/src/types/sargon.rs b/src/existing_types_in_sargon.rs similarity index 82% rename from src/types/sargon.rs rename to src/existing_types_in_sargon.rs index 6fd13210..f45b9de3 100644 --- a/src/types/sargon.rs +++ b/src/existing_types_in_sargon.rs @@ -137,21 +137,6 @@ impl FactorInstance { } } -#[derive(Clone, PartialEq, Eq, std::hash::Hash, derive_more::Debug)] -#[debug("{:?}: {:?}", owner, factor_instance)] -pub struct OwnedFactorInstance { - pub factor_instance: FactorInstance, - pub owner: AccountAddressOrIdentityAddress, -} -impl OwnedFactorInstance { - pub fn new(factor_instance: FactorInstance, owner: AccountAddressOrIdentityAddress) -> Self { - Self { - factor_instance, - owner, - } - } -} - #[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)] pub struct Hash { id: Uuid, @@ -245,19 +230,6 @@ impl Entity { } } -impl From<&Entity> for OwnedMatrixOfFactorInstances { - fn from(value: &Entity) -> Self { - let matrix = match value.security_state.clone() { - EntitySecurityState::Securified(matrix) => matrix.clone(), - EntitySecurityState::Unsecured(instance) => MatrixOfFactorInstances::from(instance), - }; - OwnedMatrixOfFactorInstances { - address_of_owner: value.address.clone(), - matrix, - } - } -} - #[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)] pub struct MatrixOfFactorInstances { pub threshold_factors: Vec, @@ -308,23 +280,6 @@ impl From for MatrixOfFactorInstances { } } -#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)] -pub struct OwnedMatrixOfFactorInstances { - pub address_of_owner: AccountAddressOrIdentityAddress, - pub matrix: MatrixOfFactorInstances, -} -impl OwnedMatrixOfFactorInstances { - pub fn new( - address_of_owner: AccountAddressOrIdentityAddress, - matrix: MatrixOfFactorInstances, - ) -> Self { - Self { - address_of_owner, - matrix, - } - } -} - #[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)] pub struct IntentHash { hash: Hash, @@ -377,20 +332,3 @@ pub enum CommonError { #[error("Failed")] Failure, } - -#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)] -pub struct InvalidTransactionIfSkipped { - pub intent_hash: IntentHash, - pub entities_which_would_fail_auth: Vec, -} -impl InvalidTransactionIfSkipped { - pub fn new( - intent_hash: IntentHash, - entities_which_would_fail_auth: Vec, - ) -> Self { - Self { - intent_hash, - entities_which_would_fail_auth, - } - } -} diff --git a/src/lib.rs b/src/lib.rs index 19a77a91..84ab302c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,9 +2,11 @@ //! SingleSigningDrivers other than the fact that BatchSigningDerivers can sign //! many transactions with many derivations paths at once? +mod existing_types_in_sargon; mod types; pub mod prelude { + pub use crate::existing_types_in_sargon::*; pub use crate::types::*; pub use async_trait::async_trait; @@ -359,7 +361,7 @@ mod tests { let signature = &context.sign().await.unwrap().all_signatures()[0]; assert_eq!( - &signature.owned_factor_instance.factor_instance, + signature.owned_factor_instance.factor_instance(), account .security_state .all_factor_instances() @@ -495,7 +497,7 @@ mod tests { assert_eq!( signature .owned_factor_instance - .factor_instance + .factor_instance() .factor_source_id, FactorSourceID::fs4() ); @@ -518,7 +520,7 @@ mod tests { assert_eq!( signature .owned_factor_instance - .factor_instance + .factor_instance() .factor_source_id .kind, FactorSourceKind::Device diff --git a/src/types/drivers/batch_tx_batch_key_signing_request.rs b/src/types/drivers/batch_tx_batch_key_signing_request.rs index 054e20ae..18b1b0ca 100644 --- a/src/types/drivers/batch_tx_batch_key_signing_request.rs +++ b/src/types/drivers/batch_tx_batch_key_signing_request.rs @@ -25,7 +25,7 @@ impl BatchKeySigningRequest { ) -> Self { assert!(owned_factor_instances .iter() - .all(|f| f.factor_instance.factor_source_id == factor_source_id)); + .all(|f| f.by_factor_source(factor_source_id))); Self { intent_hash, factor_source_id, diff --git a/src/types/hd_signature.rs b/src/types/hd_signature.rs new file mode 100644 index 00000000..20719271 --- /dev/null +++ b/src/types/hd_signature.rs @@ -0,0 +1,21 @@ +use crate::prelude::*; + +/// A signature of `intent_hash` by `entity` using `factor_source_id` and `derivation_path`, with `public_key` used for verification. +#[derive(Clone, PartialEq, Eq, Hash, derive_more::Debug)] +#[debug("HDSignature {{ instance: {:?} }}", owned_factor_instance)] +pub struct HDSignature { + /// Hash which was signed. + pub intent_hash: IntentHash, + + /// The ECDSA/EdDSA signature produced by the private key of the + /// `owned_hd_factor_instance.public_key`, + /// derived by the FactorSource identified by + /// `owned_hd_factor_instance.factor_source_id` and which + /// was derived at `owned_hd_factor_instance.derivation_path`. + pub signature: Signature, + + /// The account or identity address of the entity which signed the hash, + /// with expected public key and with derivation path to derive PrivateKey + /// with. + pub owned_factor_instance: OwnedFactorInstance, +} diff --git a/src/types/invalid_transaction_if_skipped.rs b/src/types/invalid_transaction_if_skipped.rs new file mode 100644 index 00000000..c9cba95e --- /dev/null +++ b/src/types/invalid_transaction_if_skipped.rs @@ -0,0 +1,18 @@ +use crate::prelude::*; + +#[derive(Clone, Debug, PartialEq, Eq, std::hash::Hash)] +pub struct InvalidTransactionIfSkipped { + pub intent_hash: IntentHash, + pub entities_which_would_fail_auth: Vec, +} +impl InvalidTransactionIfSkipped { + pub fn new( + intent_hash: IntentHash, + entities_which_would_fail_auth: Vec, + ) -> Self { + Self { + intent_hash, + entities_which_would_fail_auth, + } + } +} diff --git a/src/types/mod.rs b/src/types/mod.rs index 8ca80ee8..494c2998 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -1,7 +1,11 @@ mod drivers; +mod hd_signature; +mod invalid_transaction_if_skipped; mod new_types; +mod owned; +mod owned_factor_instance; +mod owned_matrix_of_factor_instances; mod petitions; -mod sargon; mod signatures_building_coordinator; mod signatures_outcome; mod signing_driver; @@ -9,9 +13,13 @@ mod signing_drivers_context; mod simulated_user; pub use drivers::*; +pub use hd_signature::*; +pub use invalid_transaction_if_skipped::*; pub use new_types::*; +pub use owned::*; +pub use owned_factor_instance::*; +pub use owned_matrix_of_factor_instances::*; pub use petitions::*; -pub use sargon::*; pub use signatures_building_coordinator::*; pub use signatures_outcome::*; pub use signing_driver::*; diff --git a/src/types/new_types.rs b/src/types/new_types.rs index 12c2507a..fe906610 100644 --- a/src/types/new_types.rs +++ b/src/types/new_types.rs @@ -1,25 +1,5 @@ use crate::prelude::*; -/// A signature of `intent_hash` by `entity` using `factor_source_id` and `derivation_path`, with `public_key` used for verification. -#[derive(Clone, PartialEq, Eq, Hash, derive_more::Debug)] -#[debug("HDSignature {{ instance: {:?} }}", owned_factor_instance)] -pub struct HDSignature { - /// Hash which was signed. - pub intent_hash: IntentHash, - - /// The ECDSA/EdDSA signature produced by the private key of the - /// `owned_hd_factor_instance.public_key`, - /// derived by the FactorSource identified by - /// `owned_hd_factor_instance.factor_source_id` and which - /// was derived at `owned_hd_factor_instance.derivation_path`. - pub signature: Signature, - - /// The account or identity address of the entity which signed the hash, - /// with expected public key and with derivation path to derive PrivateKey - /// with. - pub owned_factor_instance: OwnedFactorInstance, -} - impl HDSignature { pub fn new( intent_hash: IntentHash, diff --git a/src/types/owned.rs b/src/types/owned.rs new file mode 100644 index 00000000..5aec94a1 --- /dev/null +++ b/src/types/owned.rs @@ -0,0 +1,14 @@ +use crate::prelude::*; + +#[derive(Clone, PartialEq, Eq, std::hash::Hash, derive_more::Debug)] +#[debug("{:?}: {:?}", owner, value)] +pub struct Owned { + pub owner: AccountAddressOrIdentityAddress, + pub value: T, +} + +impl Owned { + pub fn new(owner: AccountAddressOrIdentityAddress, value: T) -> Self { + Self { owner, value } + } +} diff --git a/src/types/owned_factor_instance.rs b/src/types/owned_factor_instance.rs new file mode 100644 index 00000000..79050541 --- /dev/null +++ b/src/types/owned_factor_instance.rs @@ -0,0 +1,21 @@ +use std::borrow::Borrow; + +use crate::prelude::*; + +pub type OwnedFactorInstance = Owned; + +impl OwnedFactorInstance { + pub fn owned_factor_instance( + owner: AccountAddressOrIdentityAddress, + factor_instance: FactorInstance, + ) -> Self { + Self::new(owner, factor_instance) + } + pub fn factor_instance(&self) -> &FactorInstance { + &self.value + } + pub fn by_factor_source(&self, factor_source_id: impl Borrow) -> bool { + let factor_source_id = factor_source_id.borrow(); + self.factor_instance().factor_source_id() == *factor_source_id + } +} diff --git a/src/types/owned_matrix_of_factor_instances.rs b/src/types/owned_matrix_of_factor_instances.rs new file mode 100644 index 00000000..46e1c68d --- /dev/null +++ b/src/types/owned_matrix_of_factor_instances.rs @@ -0,0 +1,22 @@ +use crate::prelude::*; + +pub type OwnedMatrixOfFactorInstances = Owned; + +impl OwnedMatrixOfFactorInstances { + pub fn owned_matrix( + owner: AccountAddressOrIdentityAddress, + matrix: MatrixOfFactorInstances, + ) -> Self { + Self::new(owner, matrix) + } +} + +impl From<&Entity> for OwnedMatrixOfFactorInstances { + fn from(value: &Entity) -> Self { + let matrix = match value.security_state.clone() { + EntitySecurityState::Securified(matrix) => matrix.clone(), + EntitySecurityState::Unsecured(instance) => MatrixOfFactorInstances::from(instance), + }; + OwnedMatrixOfFactorInstances::owned_matrix(value.address.clone(), matrix) + } +} diff --git a/src/types/petitions.rs b/src/types/petitions.rs index 51896e78..f44c07a2 100644 --- a/src/types/petitions.rs +++ b/src/types/petitions.rs @@ -91,7 +91,7 @@ impl PetitionOfTransactionByEntity { .unwrap_or_default(); o.union(&t) - .map(|f| OwnedFactorInstance::new(f.clone(), self.entity.clone())) + .map(|f| OwnedFactorInstance::owned_factor_instance(self.entity.clone(), f.clone())) .collect::>() } @@ -207,7 +207,7 @@ impl PetitionOfTransactionByEntity { /// `Ok(true)` means "continue", `Ok(false)` means "stop, we are done". `Err(_)` means "stop, we have failed". pub(super) fn continue_if_necessary(&self) -> Result { - let status = match self.status() { + match self.status() { PetitionForFactorListStatus::InProgress => Ok(true), PetitionForFactorListStatus::Finished(PetitionForFactorListStatusFinished::Fail) => { Err(CommonError::Failure) @@ -215,9 +215,7 @@ impl PetitionOfTransactionByEntity { PetitionForFactorListStatus::Finished(PetitionForFactorListStatusFinished::Success) => { Ok(false) } - }; - println!("đŸšĻ status: {:?}", &status); - status + } } } @@ -254,11 +252,7 @@ impl PetitionOfTransactionByEntity { ) -> PetitionForFactorListStatus { let simulation = self.clone(); simulation.did_skip(factor_source_id, true); - - print!("🕹ī¸ if skipping, simulated status: ",); - let simulated_status = simulation.status(); - println!("{:?}", simulated_status); - simulated_status + simulation.status() } pub fn did_skip(&self, factor_source_id: &FactorSourceID, simulated: bool) { @@ -290,26 +284,16 @@ impl PetitionOfTransactionByEntity { match (maybe_threshold, maybe_override) { (None, None) => panic!("Programmer error! Should have at least one factors list."), - (Some(threshold), None) => { - println!("đŸĻ€ ONLY threshold status: {:?}", threshold); - threshold - } - (None, Some(r#override)) => { - println!("đŸĻ€ ONLY override status: {:?}", r#override); - r#override - } - (Some(threshold), Some(r#override)) => { - println!("đŸĻ€ threshold status: {:?}", threshold); - println!("đŸĻ€ override status: {:?}", r#override); - match (threshold, r#override) { - (InProgress, InProgress) => PetitionForFactorListStatus::InProgress, - (Finished(Fail), InProgress) => PetitionForFactorListStatus::InProgress, - (InProgress, Finished(Fail)) => PetitionForFactorListStatus::InProgress, - (Finished(Fail), Finished(Fail)) => PetitionForFactorListStatus::Finished(Fail), - (Finished(Success), _) => PetitionForFactorListStatus::Finished(Success), - (_, Finished(Success)) => PetitionForFactorListStatus::Finished(Success), - } - } + (Some(threshold), None) => threshold, + (None, Some(r#override)) => r#override, + (Some(threshold), Some(r#override)) => match (threshold, r#override) { + (InProgress, InProgress) => PetitionForFactorListStatus::InProgress, + (Finished(Fail), InProgress) => PetitionForFactorListStatus::InProgress, + (InProgress, Finished(Fail)) => PetitionForFactorListStatus::InProgress, + (Finished(Fail), Finished(Fail)) => PetitionForFactorListStatus::Finished(Fail), + (Finished(Success), _) => PetitionForFactorListStatus::Finished(Success), + (_, Finished(Success)) => PetitionForFactorListStatus::Finished(Success), + }, } } } @@ -352,6 +336,7 @@ impl PetitionWithFactors { pub fn new_unsecurified(factor: FactorInstance) -> Self { Self::new_threshold(vec![factor], 1).unwrap() // define as 1/1 threshold factor, which is a good definition. } + pub fn new_override(factors: Vec) -> Option { if factors.is_empty() { return None; @@ -361,6 +346,7 @@ impl PetitionWithFactors { PetitionWithFactorsInput::new_override(IndexSet::from_iter(factors)), )) } + pub fn new_not_used() -> Self { Self { petition_kind: Petition::Override, // does not matter.. @@ -377,11 +363,11 @@ impl PetitionWithFactors { self.state.borrow_mut().did_skip(factor_instance, simulated); } - pub fn has_instance_with_id(&self, factor_instance: &OwnedFactorInstance) -> bool { + pub fn has_instance_with_id(&self, owned_factor_instance: &OwnedFactorInstance) -> bool { self.input .factors .iter() - .any(|f| f == &factor_instance.factor_instance) + .any(|f| f == owned_factor_instance.factor_instance()) } pub fn add_signature(&self, signature: &HDSignature) { @@ -444,7 +430,9 @@ impl FactorSourceReferencing for FactorInstance { impl FactorSourceReferencing for HDSignature { fn factor_source_id(&self) -> FactorSourceID { - self.owned_factor_instance.factor_instance.factor_source_id + self.owned_factor_instance + .factor_instance() + .factor_source_id } } @@ -500,14 +488,12 @@ impl PetitionWithFactorsState { pub(crate) fn did_skip(&self, factor_instance: &FactorInstance, simulated: bool) { if !simulated { - println!("🙅đŸģ‍♀ī¸ did_skip: {:?}", factor_instance); self.assert_not_referencing_factor_source(factor_instance.factor_source_id); } self.skipped.borrow_mut().insert(factor_instance); } pub(crate) fn add_signature(&self, signature: &HDSignature) { - println!("🖊ī¸ add_signature: {:?}", signature); self.assert_not_referencing_factor_source(signature.factor_source_id()); self.signed.borrow_mut().insert(signature) } @@ -532,10 +518,6 @@ impl PetitionWithFactorsState { .borrow() .references_factor_source_by_id(factor_source_id) { - println!( - "🐍 Found factor_source_id: {:?} in signed list", - factor_source_id - ); return true; } @@ -544,10 +526,6 @@ impl PetitionWithFactorsState { .borrow() .references_factor_source_by_id(factor_source_id) { - println!( - "🐍 Found factor_source_id: {:?} in skipped list", - factor_source_id - ); return true; } @@ -599,28 +577,13 @@ impl PetitionWithFactorsInput { } fn factors_left_to_prompt(&self, snapshot: PetitionWithFactorsStateSnapshot) -> i8 { - let left = self.factors_count() - snapshot.prompted_count(); - println!( - "🐙 factors_count: {}, prompted_count: {}, left: {}", - self.factors_count(), - snapshot.prompted_count(), - left - ); - left + self.factors_count() - snapshot.prompted_count() } fn is_failure_with(&self, snapshot: PetitionWithFactorsStateSnapshot) -> bool { let signed_or_pending = self.factors_left_to_prompt(snapshot.clone()) + snapshot.signed_count(); - let is_failure = signed_or_pending < self.required; - println!( - "đŸŗ factors_left_to_prompt: {}, required: {}, signed_or_pending: {} => is_failure: {} (factors_left_to_prompt < required)", - self.factors_left_to_prompt(snapshot), - self.required, - signed_or_pending, - is_failure - ); - is_failure + signed_or_pending < self.required } } @@ -644,12 +607,6 @@ impl PetitionWithFactors { } fn is_finished_successfully(&self) -> bool { - println!( - "đŸ¯ PetitionWithFactors kind: {:?}, input: {:?}, state_snapshot: {:?}", - self.petition_kind, - self.input, - self.state_snapshot() - ); self.input.is_fulfilled_by(self.state_snapshot()) } @@ -801,14 +758,12 @@ impl Petitions { } fn skip_factor_source_with_id(&self, skipped_factor_source_id: &FactorSourceID) { - println!("đŸšĢ Skipping factor source: {:?}", skipped_factor_source_id); let binding = self.txid_to_petition.borrow(); let txids = self.factor_to_txid.get(skipped_factor_source_id).unwrap(); txids.into_iter().for_each(|txid| { let petition = binding.get(txid).unwrap(); petition.skipped_factor_source(skipped_factor_source_id) }); - println!("đŸšĢ Skipped factor source: {:?}", skipped_factor_source_id); } pub(crate) fn process_single_response( @@ -846,21 +801,6 @@ impl Petitions { } } } - - // pub(super) fn process_outcome( - // &self, - // outcome: SignWithFactorSourceOrSourcesOutcome, - // factor_sources: IndexSet, - // ) { - // for factor_source in factor_sources { - // let txids = self.factor_to_txid.get(&factor_source.id).unwrap(); - // for txid in txids { - // let binding = self.txid_to_petition.borrow(); - // let petition = binding.get(txid).unwrap(); - // petition.process_outcome(&outcome, &factor_source); - // } - // } - // } } /// Essentially a wrapper around `Iterator`. @@ -915,18 +855,16 @@ impl PetitionOfTransaction { ) -> IndexSet { self._all_factor_instances() .into_iter() - .filter(|f| f.factor_instance.factor_source_id == *factor_source_id) + .filter(|f| f.factor_instance().factor_source_id == *factor_source_id) .collect() } pub fn add_signature(&self, signature: HDSignature) { - println!("❓ Adding signature: {:?}", signature); let for_entities = self.for_entities.borrow_mut(); let for_entity = for_entities .get(&signature.owned_factor_instance.owner) .unwrap(); for_entity.add_signature(signature.clone()); - println!("⁉ī¸ Added signature? {:?}", signature); } pub fn skipped_factor_source(&self, factor_source_id: &FactorSourceID) { @@ -943,7 +881,7 @@ impl PetitionOfTransaction { let owned_factors = self .all_factor_instances_of_source(factor_source_id) .into_iter() - .filter(|fi| fi.factor_instance.factor_source_id() == *factor_source_id) + .filter(|fi| fi.by_factor_source(factor_source_id)) .collect::>(); owned_factors diff --git a/src/types/signatures_building_coordinator.rs b/src/types/signatures_building_coordinator.rs index b4dbd023..11f30888 100644 --- a/src/types/signatures_building_coordinator.rs +++ b/src/types/signatures_building_coordinator.rs @@ -79,12 +79,6 @@ impl SignaturesBuildingCoordinator { add(primary_role_matrix.override_factors.clone()); add(primary_role_matrix.threshold_factors.clone()); - - // let builder = SignaturesBuilderLevel2::new_securified( - // address.clone(), - // primary_role_matrix, - // ); - // builders_level_2.insert(address.clone(), builder); let petition = PetitionOfTransactionByEntity::new_securified( transaction_index.clone(), address.clone(), @@ -96,15 +90,6 @@ impl SignaturesBuildingCoordinator { let factor_instance = uec; let factor_source_id = factor_instance.factor_source_id; use_factor_in_tx(&factor_source_id, &transaction.intent_hash); - - // let builder = - // SignaturesBuilderLevel2::new_unsecurified( - // address.clone(), - // factor_instance, - // ); - // builders_level_2 - // .insert(address.clone(), builder); - let petition = PetitionOfTransactionByEntity::new_unsecurified( transaction_index.clone(), address.clone(), @@ -114,14 +99,6 @@ impl SignaturesBuildingCoordinator { } } } - // builders_level_0.insert( - // transaction.intent_hash.clone(), - // SignaturesBuilderLevel1::new( - // transaction.intent_hash.clone(), - // builders_level_2, - // ), - // ); - let petition_of_tx = PetitionOfTransaction::new(transaction.intent_hash.clone(), petitions_for_entities); @@ -178,11 +155,9 @@ impl SignaturesBuildingCoordinator { async fn do_sign(&self) -> Result<()> { let factors_of_kind = self.factors_of_kind.clone(); for (kind, factor_sources) in factors_of_kind.into_iter() { - println!("✍đŸģ sign with factor sources: {:?}", factor_sources); self.sign_with_factor_sources(factor_sources, kind).await?; let should_continue = self.continue_if_necessary()?; if !should_continue { - println!("🌈 finished early"); return Ok(()); // finished early, we have fulfilled signing requirements of all transactions } } @@ -233,7 +208,6 @@ impl SignaturesBuildingCoordinator { &self, response: SignWithFactorSourceOrSourcesOutcome, ) -> bool { - println!("đŸ”Ĩ process_single_response: {:?}", response); { let petitions = self.petitions.borrow_mut(); petitions.process_single_response(response); @@ -244,7 +218,6 @@ impl SignaturesBuildingCoordinator { &self, response: SignWithFactorSourceOrSourcesOutcome, ) { - println!("đŸ”Ĩ process_batch_response: {:?}", response); let petitions = self.petitions.borrow_mut(); petitions.process_batch_response(response) } @@ -253,7 +226,6 @@ impl SignaturesBuildingCoordinator { impl SignaturesBuildingCoordinator { pub async fn sign(self) -> Result { self.do_sign().await?; - println!("🤷‍♂ī¸ finished signing?"); let outcome = self.petitions.into_inner().outcome(); Ok(outcome) } diff --git a/src/types/signing_driver.rs b/src/types/signing_driver.rs index e946ac55..0008c269 100644 --- a/src/types/signing_driver.rs +++ b/src/types/signing_driver.rs @@ -24,10 +24,8 @@ impl SigningDriver { factor_sources: IndexSet, signatures_building_coordinator: &SignaturesBuildingCoordinator, ) { - let factor_source_count = factor_sources.len(); match self { Self::ParallelBatch(driver) => { - println!("🚀 Signing with Parallel Batch driver..."); let per_factor_source = factor_sources .clone() .into_iter() @@ -50,12 +48,7 @@ impl SigningDriver { signatures_building_coordinator.process_batch_response(response); } Self::SerialBatch(driver) => { - println!("🚗 Signing with Serial Batch driver... #{} factor sources, signing with one factor source at a time", factor_source_count); for factor_source in factor_sources { - println!( - "🚗 Signing with Serial Batch driver, signing with factor source: {:?}", - factor_source.id - ); let batch_signing_request = signatures_building_coordinator .input_for_parallel_batch_driver(&factor_source.id); @@ -68,24 +61,14 @@ impl SigningDriver { ); let response = driver.sign(request).await; - - println!( - "☑ī¸ Got 1 response (of #{}) from Serial Batch driver: {:?}", - factor_source_count, &response - ); signatures_building_coordinator.process_batch_response(response); } } Self::SerialSingle(driver) => { - println!("🐌 Signing with Serial Single driver...#{} factor sources, signing with one factor source at a time, many times, one time for each factor instance", factor_source_count); for factor_source in factor_sources { let invalid_transactions_if_skipped = signatures_building_coordinator .invalid_transactions_if_skipped(&factor_source.id); - println!( - "🐌 Signing with Serial Single, signing with factor source: {:?}", - factor_source.id - ); let requests_per_transaction = signatures_building_coordinator .inputs_for_serial_single_driver(&factor_source.id); for (_, requests_for_transaction) in requests_per_transaction { @@ -94,15 +77,11 @@ impl SigningDriver { partial_request, invalid_transactions_if_skipped.clone(), ); - println!( - "🐌 Signing with Serial Single, signing with instance: {:?}", - &request.input.owned_factor_instance - ); + let response = driver.sign(request).await; let should_continue_with_factor_source = signatures_building_coordinator.process_single_response(response); if !should_continue_with_factor_source { - println!("⁉ī¸ Breaking, should continue with next factor source...."); break; } }