Skip to content

Commit

Permalink
fix(wasm-dpp): lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic committed Jan 31, 2025
1 parent ccf0921 commit 1a2520e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
6 changes: 4 additions & 2 deletions packages/rs-dpp/src/document/document_factory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use crate::data_contract::document_type::DocumentTypeRef;
use crate::document::Document;
#[cfg(feature = "extended-document")]
use crate::document::ExtendedDocument;
use crate::fee::Credits;
#[cfg(feature = "state-transitions")]
use crate::state_transition::documents_batch_transition::{
document_transition::action_type::DocumentTransitionActionType, DocumentsBatchTransition,
};
use crate::util::entropy_generator::EntropyGenerator;
pub use v0::DocumentFactoryV0;
use crate::fee::Credits;

/// # Document Factory
///
Expand Down Expand Up @@ -125,7 +125,9 @@ impl DocumentFactory {
price: Option<Credits>,
) -> Result<DocumentsBatchTransition, ProtocolError> {
match self {
DocumentFactory::V0(v0) => v0.create_state_transition(documents_iter, nonce_counter, recipient, price),
DocumentFactory::V0(v0) => {
v0.create_state_transition(documents_iter, nonce_counter, recipient, price)
}
}
}

Expand Down
41 changes: 23 additions & 18 deletions packages/rs-dpp/src/document/document_factory/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ use crate::document::{
extended_document::v0::ExtendedDocumentV0,
serialization_traits::DocumentPlatformConversionMethodsV0, ExtendedDocument,
};
use crate::fee::Credits;
use crate::prelude::{BlockHeight, CoreBlockHeight, TimestampMillis};
use crate::state_transition::documents_batch_transition::document_transition::{
DocumentPurchaseTransition, DocumentTransferTransition, DocumentUpdatePriceTransition,
};
#[cfg(feature = "state-transitions")]
use crate::state_transition::documents_batch_transition::{
document_transition::{
Expand All @@ -32,8 +36,6 @@ use crate::state_transition::documents_batch_transition::{
DocumentsBatchTransition, DocumentsBatchTransitionV0,
};
use itertools::Itertools;
use crate::fee::Credits;
use crate::state_transition::documents_batch_transition::document_transition::{DocumentPurchaseTransition, DocumentTransferTransition, DocumentUpdatePriceTransition};

const PROPERTY_FEATURE_VERSION: &str = "$version";
const PROPERTY_ENTROPY: &str = "$entropy";
Expand Down Expand Up @@ -213,7 +215,7 @@ impl DocumentFactoryV0 {
>,
nonce_counter: &mut BTreeMap<(Identifier, Identifier), u64>, //IdentityID/ContractID -> nonce,
recipient: Option<Identifier>,
price: Option<Credits>
price: Option<Credits>,
) -> Result<DocumentsBatchTransition, ProtocolError> {
let platform_version = PlatformVersion::get(self.protocol_version)?;
let documents: Vec<(
Expand Down Expand Up @@ -273,17 +275,19 @@ impl DocumentFactoryV0 {
.collect(),
nonce_counter,
platform_version,
recipient
),
DocumentTransitionActionType::UpdatePrice => Self::document_update_price_transitions(
documents
.into_iter()
.map(|(document, document_type, _)| (document, document_type))
.collect(),
nonce_counter,
platform_version,
price
recipient,
),
DocumentTransitionActionType::UpdatePrice => {
Self::document_update_price_transitions(
documents
.into_iter()
.map(|(document, document_type, _)| (document, document_type))
.collect(),
nonce_counter,
platform_version,
price,
)
}
DocumentTransitionActionType::Purchase => Self::document_purchase_transitions(
documents
.into_iter()
Expand All @@ -292,14 +296,15 @@ impl DocumentFactoryV0 {
nonce_counter,
platform_version,
price,
recipient
recipient,
),
_ => {
let action_type_name: &str = action.into();

Err(ProtocolError::InvalidStateTransitionType(
action_type_name.to_string(),
))},
))
}
})
.collect::<Result<Vec<_>, ProtocolError>>()?
.into_iter()
Expand Down Expand Up @@ -588,7 +593,7 @@ impl DocumentFactoryV0 {
documents: Vec<(Document, DocumentTypeRef)>,
nonce_counter: &mut BTreeMap<(Identifier, Identifier), u64>, //IdentityID/ContractID -> nonce
platform_version: &PlatformVersion,
recipient_owner_id: Option<Identifier>
recipient_owner_id: Option<Identifier>,
) -> Result<Vec<DocumentTransition>, ProtocolError> {
documents
.into_iter()
Expand Down Expand Up @@ -635,7 +640,7 @@ impl DocumentFactoryV0 {
documents: Vec<(Document, DocumentTypeRef)>,
nonce_counter: &mut BTreeMap<(Identifier, Identifier), u64>, //IdentityID/ContractID -> nonce
platform_version: &PlatformVersion,
price: Option<Credits>
price: Option<Credits>,
) -> Result<Vec<DocumentTransition>, ProtocolError> {
documents
.into_iter()
Expand Down Expand Up @@ -680,7 +685,7 @@ impl DocumentFactoryV0 {
nonce_counter: &mut BTreeMap<(Identifier, Identifier), u64>, //IdentityID/ContractID -> nonce
platform_version: &PlatformVersion,
price: Option<Credits>,
recipient: Option<Identifier>
recipient: Option<Identifier>,
) -> Result<Vec<DocumentTransition>, ProtocolError> {
documents
.into_iter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ impl TryFrom<&str> for DocumentTransitionActionType {
}
}


impl From<DocumentTransitionActionType> for &str {
fn from(value: DocumentTransitionActionType) -> Self {
match value {
Expand All @@ -58,7 +57,9 @@ impl From<DocumentTransitionActionType> for &str {
DocumentTransitionActionType::Transfer => "Transfer",
DocumentTransitionActionType::Purchase => "Purchase",
DocumentTransitionActionType::UpdatePrice => "UpdatePrice",
DocumentTransitionActionType::IgnoreWhileBumpingRevision => "IgnoreWhileBumpingRevision"
DocumentTransitionActionType::IgnoreWhileBumpingRevision => {
"IgnoreWhileBumpingRevision"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn get_document_transitions_fixture<'a>(
DocumentFactory::new(protocol_version).expect("expected to get document factory");

document_factory
.create_state_transition(documents, nonce_counter)
.create_state_transition(documents, nonce_counter, None, None)
.expect("the transitions should be created")
.transitions()
.to_owned()
Expand Down

0 comments on commit 1a2520e

Please sign in to comment.