Skip to content

Commit

Permalink
chore(wasm-dpp): fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic committed Jan 31, 2025
1 parent 1207597 commit 3443b3f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
10 changes: 5 additions & 5 deletions packages/wasm-dpp/src/document/document_facade.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::rc::Rc;
use wasm_bindgen::{prelude::*, JsValue};
use dpp::fee::Credits;
use dpp::identifier::Identifier;
use crate::document::factory::DocumentFactoryWASM;
use crate::{DataContractWasm, ExtendedDocumentWasm};
use dpp::fee::Credits;
use dpp::identifier::Identifier;
use std::rc::Rc;
use wasm_bindgen::{prelude::*, JsValue};

use crate::document::state_transition::document_batch_transition::DocumentsBatchTransitionWasm;
use crate::identifier::IdentifierWrapper;
Expand Down Expand Up @@ -99,7 +99,7 @@ impl DocumentFacadeWasm {
documents: &JsValue,
nonce_counter_value: &js_sys::Object, //IdentityID/ContractID -> nonce,
recipient: Option<IdentifierWrapper>,
price: Option<Credits>
price: Option<Credits>,
) -> Result<DocumentsBatchTransitionWasm, JsValue> {
self.factory
.create_state_transition(documents, nonce_counter_value, recipient, price)
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm-dpp/src/document/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn from_document_to_js_error(e: DocumentError) -> JsValue {
DocumentError::InvalidActionError(action) => InvalidActionError::new(action.into()).into(),
DocumentError::TryingToDeleteIndelibleDocument { document } => {
TryingToDeleteImmutableDocumentError::new((*document).into()).into()
},
}
DocumentError::TryingToTransferNonTransferableDocument { document } => {
TryingToTransferNonTransferableDocumentError::new((*document).into()).into()
}
Expand Down
4 changes: 3 additions & 1 deletion packages/wasm-dpp/src/document/extended_document.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use dpp::document::{DocumentV0Getters, DocumentV0Setters, ExtendedDocument, EXTENDED_DOCUMENT_IDENTIFIER_FIELDS};
use dpp::document::{
DocumentV0Getters, DocumentV0Setters, ExtendedDocument, EXTENDED_DOCUMENT_IDENTIFIER_FIELDS,
};
use serde_json::Value as JsonValue;

use dpp::platform_value::{Bytes32, Value};
Expand Down
29 changes: 19 additions & 10 deletions packages/wasm-dpp/src/document/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ use dpp::document::Document;

use dpp::prelude::ExtendedDocument;

use dpp::identifier::Identifier;
use dpp::state_transition::documents_batch_transition::document_transition::action_type::DocumentTransitionActionType;
use dpp::version::PlatformVersion;
use std::convert::TryFrom;
use dpp::fee::Credits;
use crate::document_batch_transition::DocumentsBatchTransitionWasm;
use crate::entropy_generator::ExternalEntropyGenerator;
use crate::identifier::IdentifierWrapper;
use crate::{
identifier::identifier_from_js_value,
utils::{IntoWasm, ToSerdeJSONExt, WithJsError},
DataContractWasm, ExtendedDocumentWasm,
};
use crate::identifier::IdentifierWrapper;
use dpp::fee::Credits;
use dpp::identifier::Identifier;
use dpp::state_transition::documents_batch_transition::document_transition::action_type::DocumentTransitionActionType;
use dpp::version::PlatformVersion;
use std::convert::TryFrom;

#[wasm_bindgen(js_name=DocumentTransitions)]
#[derive(Debug, Default)]
Expand Down Expand Up @@ -111,7 +111,7 @@ impl DocumentFactoryWASM {
documents: &JsValue,
nonce_counter_value: &js_sys::Object, //IdentityID/ContractID -> nonce
recipient: Option<IdentifierWrapper>,
price: Option<Credits>
price: Option<Credits>,
) -> Result<DocumentsBatchTransitionWasm, JsValue> {
let mut nonce_counter = BTreeMap::new();
let mut contract_ids_to_check = HashSet::<&Identifier>::new();
Expand Down Expand Up @@ -179,7 +179,12 @@ impl DocumentFactoryWASM {

let batch_transition = self
.0
.create_state_transition(documents, &mut nonce_counter, recipient.map(|e| { Identifier::from(e)}), price)
.create_state_transition(
documents,
&mut nonce_counter,
recipient.map(|e| Identifier::from(e)),
price,
)
.with_js_error()?;

Ok(batch_transition.into())
Expand Down Expand Up @@ -282,14 +287,18 @@ fn extract_documents_by_action(
let documents_replace = extract_documents_of_action(documents, "replace").with_js_error()?;
let documents_delete = extract_documents_of_action(documents, "delete").with_js_error()?;
let documents_transfer = extract_documents_of_action(documents, "transfer").with_js_error()?;
let documents_update_price = extract_documents_of_action(documents, "updatePrice").with_js_error()?;
let documents_update_price =
extract_documents_of_action(documents, "updatePrice").with_js_error()?;
let documents_purchase = extract_documents_of_action(documents, "purchase").with_js_error()?;

documents_by_action.insert(DocumentTransitionActionType::Create, documents_create);
documents_by_action.insert(DocumentTransitionActionType::Replace, documents_replace);
documents_by_action.insert(DocumentTransitionActionType::Delete, documents_delete);
documents_by_action.insert(DocumentTransitionActionType::Transfer, documents_transfer);
documents_by_action.insert(DocumentTransitionActionType::UpdatePrice, documents_update_price);
documents_by_action.insert(
DocumentTransitionActionType::UpdatePrice,
documents_update_price,
);
documents_by_action.insert(DocumentTransitionActionType::Purchase, documents_purchase);

Ok(documents_by_action)
Expand Down

0 comments on commit 3443b3f

Please sign in to comment.