From c16685e4f8936b3f7bbd8f66461fd99f943ac3fd Mon Sep 17 00:00:00 2001 From: Quantum Explorer Date: Sun, 4 Aug 2024 07:49:48 +0700 Subject: [PATCH] fmt --- packages/rs-dpp/src/core_subsidy/mod.rs | 4 +-- packages/rs-drive-abci/src/config.rs | 2 +- .../total_credits_in_platform/v0/mod.rs | 4 +-- packages/rs-drive-proof-verifier/src/proof.rs | 20 ++++++++++---- packages/rs-sdk/src/mock/sdk.rs | 18 ++++++++----- .../rs-sdk/src/platform/document_query.rs | 13 ++++++---- packages/rs-sdk/src/sdk.rs | 26 ++++++++++++------- 7 files changed, 57 insertions(+), 30 deletions(-) diff --git a/packages/rs-dpp/src/core_subsidy/mod.rs b/packages/rs-dpp/src/core_subsidy/mod.rs index 0db38969cb8..ad8a56fc840 100644 --- a/packages/rs-dpp/src/core_subsidy/mod.rs +++ b/packages/rs-dpp/src/core_subsidy/mod.rs @@ -1,7 +1,7 @@ pub mod epoch_core_reward_credits_for_distribution; -use dashcore::Network; use crate::fee::Credits; +use dashcore::Network; /// ORIGINAL CORE BLOCK DISTRIBUTION /// STARTS AT 5 Dash @@ -23,4 +23,4 @@ impl NetworkCoreSubsidy for Network { _ => 210240, } } -} \ No newline at end of file +} diff --git a/packages/rs-drive-abci/src/config.rs b/packages/rs-drive-abci/src/config.rs index 5bf823529cc..56600a83c80 100644 --- a/packages/rs-drive-abci/src/config.rs +++ b/packages/rs-drive-abci/src/config.rs @@ -32,11 +32,11 @@ use std::path::PathBuf; use crate::logging::LogConfigs; use crate::{abci::config::AbciConfig, error::Error}; +use dpp::dashcore::Network; use dpp::util::deserializer::ProtocolVersion; use dpp::version::INITIAL_PROTOCOL_VERSION; use drive::config::DriveConfig; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use dpp::dashcore::Network; /// Configuration for Dash Core RPC client used in consensus logic #[derive(Clone, Debug, Serialize, Deserialize, Default)] diff --git a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs index 7932abe9c51..8bd8ee61224 100644 --- a/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs +++ b/packages/rs-drive-abci/src/query/system/total_credits_in_platform/v0/mod.rs @@ -130,10 +130,10 @@ impl Platform { #[cfg(test)] mod tests { - use dashcore_rpc::dashcore::Network; use super::*; use crate::query::tests::setup_platform; use crate::test::helpers::fast_forward_to_block::fast_forward_to_block; + use dashcore_rpc::dashcore::Network; use dpp::block::epoch::EpochIndex; use dpp::prelude::CoreBlockHeight; use drive::drive::Drive; @@ -252,7 +252,7 @@ mod tests { else { panic!("expected proof") }; - + let network = Network::Testnet; let core_subsidy_halving_interval = network.core_subsidy_halving_interval(); diff --git a/packages/rs-drive-proof-verifier/src/proof.rs b/packages/rs-drive-proof-verifier/src/proof.rs index d484b94cf55..2f071e5adf0 100644 --- a/packages/rs-drive-proof-verifier/src/proof.rs +++ b/packages/rs-drive-proof-verifier/src/proof.rs @@ -27,6 +27,7 @@ use dapi_grpc::platform::{ use dpp::block::block_info::BlockInfo; use dpp::block::epoch::{EpochIndex, MAX_EPOCH}; use dpp::block::extended_epoch_info::ExtendedEpochInfo; +use dpp::core_subsidy::NetworkCoreSubsidy; use dpp::dashcore::hashes::Hash; use dpp::dashcore::{Network, ProTxHash}; use dpp::document::{Document, DocumentV0Getters}; @@ -52,7 +53,6 @@ use drive::query::{DriveDocumentQuery, VotePollsByEndDateDriveQuery}; use std::array::TryFromSliceError; use std::collections::BTreeMap; use std::num::TryFromIntError; -use dpp::core_subsidy::NetworkCoreSubsidy; /// Parse and verify the received proof and retrieve the requested object, if any. /// @@ -193,8 +193,13 @@ pub trait FromProof { where Self: Sized + 'a, { - let (main_item, response_metadata, _) = - Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider)?; + let (main_item, response_metadata, _) = Self::maybe_from_proof_with_metadata( + request, + response, + network, + platform_version, + provider, + )?; Ok((main_item.ok_or(Error::NotFound)?, response_metadata)) } @@ -228,8 +233,13 @@ pub trait FromProof { where Self: Sized + 'a, { - let (main_item, response_metadata, proof) = - Self::maybe_from_proof_with_metadata(request, response, network, platform_version, provider)?; + let (main_item, response_metadata, proof) = Self::maybe_from_proof_with_metadata( + request, + response, + network, + platform_version, + provider, + )?; Ok((main_item.ok_or(Error::NotFound)?, response_metadata, proof)) } } diff --git a/packages/rs-sdk/src/mock/sdk.rs b/packages/rs-sdk/src/mock/sdk.rs index f282822e9cf..6b658abf1ca 100644 --- a/packages/rs-sdk/src/mock/sdk.rs +++ b/packages/rs-sdk/src/mock/sdk.rs @@ -1,11 +1,16 @@ //! Mocking mechanisms for Dash Platform SDK. //! //! See [MockDashPlatformSdk] for more details. +use crate::{ + platform::{types::identity::IdentityRequest, DocumentQuery, Fetch, FetchMany, Query}, + Error, +}; use dapi_grpc::platform::v0::{Proof, ResponseMetadata}; use dapi_grpc::{ mock::Mockable, platform::v0::{self as proto}, }; +use dpp::dashcore::Network; use dpp::version::PlatformVersion; use drive_proof_verifier::{error::ContextProviderError, FromProof, MockContextProvider}; use rs_dapi_client::mock::MockError; @@ -16,11 +21,6 @@ use rs_dapi_client::{ }; use std::{collections::BTreeMap, path::PathBuf, sync::Arc}; use tokio::sync::Mutex; -use dpp::dashcore::Network; -use crate::{ - platform::{types::identity::IdentityRequest, DocumentQuery, Fetch, FetchMany, Query}, - Error, -}; use super::MockResponse; @@ -397,7 +397,13 @@ impl MockDashPlatformSdk { .ok_or(ContextProviderError::InvalidQuorum( "expectation not found and quorum info provider not initialized with sdk.mock().quorum_info_dir()".to_string() ))?; - O::maybe_from_proof_with_metadata(request, response, Network::Regtest, version, provider)? + O::maybe_from_proof_with_metadata( + request, + response, + Network::Regtest, + version, + provider, + )? } }; diff --git a/packages/rs-sdk/src/platform/document_query.rs b/packages/rs-sdk/src/platform/document_query.rs index fade673466f..9c61f943760 100644 --- a/packages/rs-sdk/src/platform/document_query.rs +++ b/packages/rs-sdk/src/platform/document_query.rs @@ -10,6 +10,8 @@ use dapi_grpc::platform::v0::{ get_documents_request::{get_documents_request_v0::Start, GetDocumentsRequestV0}, GetDocumentsRequest, Proof, ResponseMetadata, }; +use dpp::dashcore::Network; +use dpp::version::PlatformVersion; use dpp::{ data_contract::{ accessors::v0::DataContractV0Getters, document_type::accessors::DocumentTypeV0Getters, @@ -19,10 +21,8 @@ use dpp::{ prelude::{DataContract, Identifier}, ProtocolError, }; -use dpp::dashcore::Network; -use dpp::version::PlatformVersion; use drive::query::{DriveDocumentQuery, InternalClauses, OrderClause, WhereClause, WhereOperator}; -use drive_proof_verifier::{types::Documents, FromProof, ContextProvider}; +use drive_proof_verifier::{types::Documents, ContextProvider, FromProof}; use rs_dapi_client::transport::{ AppliedRequestSettings, BoxFuture, TransportClient, TransportRequest, }; @@ -173,8 +173,11 @@ impl FromProof for Document { let (documents, metadata, proof): (Option, ResponseMetadata, Proof) = >::maybe_from_proof_with_metadata( - request, response, - network, platform_version, provider, + request, + response, + network, + platform_version, + provider, )?; match documents { diff --git a/packages/rs-sdk/src/sdk.rs b/packages/rs-sdk/src/sdk.rs index e224953cc2a..79f53edb36f 100644 --- a/packages/rs-sdk/src/sdk.rs +++ b/packages/rs-sdk/src/sdk.rs @@ -11,6 +11,7 @@ use dapi_grpc::mock::Mockable; use dapi_grpc::platform::v0::{Proof, ResponseMetadata}; use dpp::bincode; use dpp::bincode::error::DecodeError; +use dpp::dashcore::Network; use dpp::identity::identity_nonce::IDENTITY_NONCE_VALUE_FILTER; use dpp::prelude::IdentityNonce; use dpp::version::{PlatformVersion, PlatformVersionCurrentVersion}; @@ -39,7 +40,6 @@ use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(feature = "mocks")] use tokio::sync::{Mutex, MutexGuard}; use tokio_util::sync::{CancellationToken, WaitForCancellationFuture}; -use dpp::dashcore::Network; /// How many data contracts fit in the cache. pub const DEFAULT_CONTRACT_CACHE_SIZE: usize = 100; @@ -208,10 +208,14 @@ impl Sdk { .ok_or(drive_proof_verifier::Error::ContextProviderNotSet)?; match self.inner { - SdkInstance::Dapi { .. } => { - O::maybe_from_proof_with_metadata(request, response, self.network, self.version(), &provider) - .map(|(a, b, _)| (a, b)) - } + SdkInstance::Dapi { .. } => O::maybe_from_proof_with_metadata( + request, + response, + self.network, + self.version(), + &provider, + ) + .map(|(a, b, _)| (a, b)), #[cfg(feature = "mocks")] SdkInstance::Mock { ref mock, .. } => { let guard = mock.lock().await; @@ -244,9 +248,13 @@ impl Sdk { .ok_or(drive_proof_verifier::Error::ContextProviderNotSet)?; match self.inner { - SdkInstance::Dapi { .. } => { - O::maybe_from_proof_with_metadata(request, response, self.network, self.version(), &provider) - } + SdkInstance::Dapi { .. } => O::maybe_from_proof_with_metadata( + request, + response, + self.network, + self.version(), + &provider, + ), #[cfg(feature = "mocks")] SdkInstance::Mock { ref mock, .. } => { let guard = mock.lock().await; @@ -548,7 +556,7 @@ pub struct SdkBuilder { /// If `None`, a mock client will be created. addresses: Option, settings: RequestSettings, - + network: Network, core_ip: String,