Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Aug 4, 2024
1 parent 276e75f commit c16685e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 30 deletions.
4 changes: 2 additions & 2 deletions packages/rs-dpp/src/core_subsidy/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,4 +23,4 @@ impl NetworkCoreSubsidy for Network {
_ => 210240,
}
}
}
}
2 changes: 1 addition & 1 deletion packages/rs-drive-abci/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ impl<C> Platform<C> {

#[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;
Expand Down Expand Up @@ -252,7 +252,7 @@ mod tests {
else {
panic!("expected proof")
};

let network = Network::Testnet;

let core_subsidy_halving_interval = network.core_subsidy_halving_interval();
Expand Down
20 changes: 15 additions & 5 deletions packages/rs-drive-proof-verifier/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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.
///
Expand Down Expand Up @@ -193,8 +193,13 @@ pub trait FromProof<Req> {
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))
}

Expand Down Expand Up @@ -228,8 +233,13 @@ pub trait FromProof<Req> {
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))
}
}
Expand Down
18 changes: 12 additions & 6 deletions packages/rs-sdk/src/mock/sdk.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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,
)?
}
};

Expand Down
13 changes: 8 additions & 5 deletions packages/rs-sdk/src/platform/document_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
};
Expand Down Expand Up @@ -173,8 +173,11 @@ impl FromProof<DocumentQuery> for Document {

let (documents, metadata, proof): (Option<Documents>, ResponseMetadata, Proof) =
<Documents as FromProof<Self::Request>>::maybe_from_proof_with_metadata(
request, response,
network, platform_version, provider,
request,
response,
network,
platform_version,
provider,
)?;

match documents {
Expand Down
26 changes: 17 additions & 9 deletions packages/rs-sdk/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -548,7 +556,7 @@ pub struct SdkBuilder {
/// If `None`, a mock client will be created.
addresses: Option<AddressList>,
settings: RequestSettings,

network: Network,

core_ip: String,
Expand Down

0 comments on commit c16685e

Please sign in to comment.