Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rs-drive-abci/tests/strategy_tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ pub(crate) fn create_chain_for_strategy(
strategy: NetworkStrategy,
config: PlatformConfig,
rng: StdRng,
) -> ChainExecutionOutcome {
) -> ChainExecutionOutcome<'_> {
let abci_application = FullAbciApplication::new(platform);

let seed = strategy
Expand Down
6 changes: 5 additions & 1 deletion packages/rs-drive/src/drive/document/paths.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use crate::drive::{constants, RootTree};
#[cfg(feature = "server")]
use crate::util::type_constants::DEFAULT_HASH_SIZE_U8;
#[cfg(feature = "server")]
use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters;
#[cfg(feature = "server")]
use dpp::data_contract::document_type::methods::DocumentTypeBasicMethods;
#[cfg(feature = "server")]
use dpp::data_contract::document_type::DocumentTypeRef;
#[cfg(feature = "server")]
use grovedb::batch::key_info::KeyInfo;
Expand Down Expand Up @@ -36,7 +40,7 @@ pub(crate) fn contract_document_type_path_vec(
]
}

#[cfg(any(feature = "server", feature = "verify"))]
#[cfg(feature = "server")]
/// Returns the path to the primary keys of a contract document type.
pub(crate) fn contract_documents_primary_key_path<'a>(
contract_id: &'a [u8],
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-drive/src/drive/identity/key/fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ use {
},
query::{Query, QueryItem},
},
dpp::{
identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0,
identity::{KeyID, Purpose, SecurityLevel},
},
dpp::identity::{KeyID, Purpose, SecurityLevel},
grovedb::{PathQuery, SizedQuery},
integer_encoding::VarInt,
std::{collections::BTreeMap, ops::RangeFull},
};

#[cfg(feature = "server")]
use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0;

#[cfg(feature = "server")]
use {
crate::error::{drive::DriveError, fee::FeeError, identity::IdentityError, Error},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ mod tests {
let doc_value: serde_json::Value =
serde_json::from_str(doc_json).expect("Failed to parse withdrawal document JSON");

// Extract required fields
let status = doc_value["status"]
.as_u64()
.expect("status should be a number") as u8;
// // Extract required fields
// let status = doc_value["status"]
// .as_u64()
// .expect("status should be a number") as u8;

let mut properties: Value = doc_value.clone().into();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ use dpp::prelude::DataContract;
use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll;
#[cfg(feature = "server")]
use grovedb::TransactionArg;
#[cfg(feature = "server")]
use platform_version::version::PlatformVersion;
#[cfg(any(feature = "server", feature = "verify"))]
#[cfg(feature = "server")]
use std::sync::Arc;

/// A trait for resolving information related to a contested document resource vote poll.
Expand Down
9 changes: 4 additions & 5 deletions packages/rs-drive/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ use {
document_type::{DocumentTypeRef, Index, IndexProperty},
DataContract,
},
document::{
document_methods::DocumentMethodsV0,
serialization_traits::DocumentPlatformConversionMethodsV0, Document, DocumentV0Getters,
},
document::{document_methods::DocumentMethodsV0, Document, DocumentV0Getters},
platform_value::{btreemap_extensions::BTreeValueRemoveFromMapHelper, Value},
version::PlatformVersion,
ProtocolError,
Expand All @@ -41,9 +38,11 @@ use {
std::{collections::BTreeMap, ops::BitXor},
};

#[cfg(feature = "verify")]
#[cfg(all(feature = "server", feature = "verify"))]
use crate::verify::RootHash;

#[cfg(feature = "server")]
use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0;
#[cfg(feature = "server")]
pub use grovedb::{
query_result_type::{QueryResultElements, QueryResultType},
Expand Down
12 changes: 7 additions & 5 deletions packages/rs-drive/src/query/vote_poll_vote_state_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ use dpp::data_contract::DataContract;
use dpp::identifier::Identifier;
#[cfg(feature = "server")]
use dpp::serialization::PlatformDeserializable;
#[cfg(feature = "server")]
use dpp::voting::contender_structs::ContenderWithSerializedDocumentV0;
use dpp::voting::contender_structs::{
ContenderWithSerializedDocument, ContenderWithSerializedDocumentV0,
FinalizedContenderWithSerializedDocument,
};
use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::{
ContestedDocumentVotePollStoredInfo, ContestedDocumentVotePollStoredInfoV0Getters,
ContenderWithSerializedDocument, FinalizedContenderWithSerializedDocument,
};
#[cfg(feature = "server")]
use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfo;
#[cfg(feature = "server")]
use dpp::voting::vote_info_storage::contested_document_vote_poll_stored_info::ContestedDocumentVotePollStoredInfoV0Getters;
use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo;
use dpp::voting::vote_polls::contested_document_resource_vote_poll::ContestedDocumentResourceVotePoll;
#[cfg(feature = "server")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> {
}

/// Operations to construct a path query.
#[allow(dead_code)]
pub(crate) fn construct_path_query(
&self,
platform_version: &PlatformVersion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use crate::drive::votes::paths::vote_end_date_queries_tree_path_vec;
#[cfg(feature = "server")]
use crate::drive::Drive;
#[cfg(feature = "server")]
use crate::error::drive::DriveError;
#[cfg(feature = "server")]
use crate::error::Error;
#[cfg(feature = "server")]
use crate::fees::op::LowLevelDriveOperation;
#[cfg(feature = "server")]
use crate::query::GroveError;
use crate::query::Query;
use crate::util::common::encode::{decode_u64, encode_u64};
#[cfg(feature = "server")]
use crate::util::common::encode::decode_u64;
use crate::util::common::encode::encode_u64;
use bincode::{Decode, Encode};
#[cfg(feature = "server")]
use dpp::block::block_info::BlockInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ use crate::fees::op::LowLevelDriveOperation;
#[cfg(feature = "server")]
use dpp::block::block_info::BlockInfo;
use dpp::data_contract::accessors::v0::DataContractV0Getters;
#[cfg(feature = "server")]
use dpp::data_contract::document_type::DocumentTypeRef;
use dpp::data_contract::DataContract;
use dpp::identifier::Identifier;
#[cfg(feature = "server")]
use dpp::ProtocolError;
#[cfg(feature = "server")]
use grovedb::TransactionArg;
Expand All @@ -26,6 +28,7 @@ use std::sync::Arc;
/// might be needed, providing a unified interface to access their data.
#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug)]
#[cfg(feature = "server")]
pub enum DataContractInfo<'a> {
/// A unique identifier for a data contract. This variant is typically used
/// when only the identity of the data contract is required without needing
Expand All @@ -47,6 +50,7 @@ pub enum DataContractInfo<'a> {
OwnedDataContract(DataContract),
}

#[cfg(feature = "server")]
impl<'a> DataContractInfo<'a> {
#[cfg(feature = "server")]
/// Resolve the data contract info into an object that contains the data contract
Expand Down Expand Up @@ -208,7 +212,9 @@ impl AsRef<DataContract> for DataContractResolvedInfo<'_> {
}

/// Enumerates methods for identifying or referencing document types, accommodating various application needs.
#[allow(clippy::enum_variant_names)]
#[derive(Clone, Debug)]
#[cfg(feature = "server")]
pub enum DocumentTypeInfo<'a> {
/// Contains the document type name as an owned `String`, suitable for dynamic or mutable scenarios.
DocumentTypeName(String),
Expand All @@ -220,6 +226,7 @@ pub enum DocumentTypeInfo<'a> {
DocumentTypeRef(DocumentTypeRef<'a>),
}

#[cfg(feature = "server")]
impl<'a> DocumentTypeInfo<'a> {
/// Resolve the data contract info into an object that contains the data contract
pub fn resolve(self, contract: &'a DataContract) -> Result<DocumentTypeRef<'a>, ProtocolError> {
Expand Down
4 changes: 4 additions & 0 deletions packages/rs-drive/src/util/type_constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![allow(dead_code)]
// Common numeric type-size constants used across Drive.
// Many are referenced conditionally; allow dead_code at file scope.

/// Default hash size
pub const DEFAULT_HASH_SIZE_USIZE: usize = 32;
/// Default hash 160 size as u8
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-sdk-ffi/src/callback_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ unsafe extern "C" fn bridge_get_platform_activation_height(
return CallbackResult {
success: false,
error_code: -1,
error_message: "Invalid handle or output pointer\0".as_ptr() as *const i8,
error_message: c"Invalid handle or output pointer".as_ptr(),
};
}

Expand All @@ -80,7 +80,7 @@ unsafe extern "C" fn bridge_get_platform_activation_height(
CallbackResult {
success: false,
error_code: result,
error_message: "Failed to get platform activation height\0".as_ptr() as *const i8,
error_message: c"Failed to get platform activation height".as_ptr(),
}
}
}
Expand All @@ -104,7 +104,7 @@ unsafe extern "C" fn bridge_get_quorum_public_key(
return CallbackResult {
success: false,
error_code: -1,
error_message: "Invalid handle or pointer parameters\0".as_ptr() as *const i8,
error_message: c"Invalid handle or pointer parameters".as_ptr(),
};
}

Expand Down Expand Up @@ -139,7 +139,7 @@ unsafe extern "C" fn bridge_get_quorum_public_key(
CallbackResult {
success: false,
error_code: result,
error_message: "Failed to get quorum public key\0".as_ptr() as *const i8,
error_message: c"Failed to get quorum public key".as_ptr(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-sdk-ffi/src/contested_resource/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Contested resource modules
pub mod queries;
mod queries;

// Re-export all public functions
pub use queries::*;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ use std::ffi::{c_char, c_void, CStr, CString};
/// * Error message if operation fails
///
/// # Safety
/// This function is unsafe because it handles raw pointers from C
/// - `sdk_handle` must be a valid, non-null pointer to an initialized `SDKHandle`.
/// - `identity_id` must be a valid, non-null pointer to a NUL-terminated C string that remains valid during the call.
/// - `limit`, `offset`, and `order_ascending` are passed by value; no references are retained.
/// - On success, the returned `DashSDKResult` may contain a heap-allocated C string; the caller must free
/// it using the SDK's free routine. The result can also contain no data (null pointer).
/// - All pointers provided to this function must be readable and valid.
#[no_mangle]
pub unsafe extern "C" fn dash_sdk_contested_resource_get_identity_votes(
sdk_handle: *const SDKHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ use std::ffi::{c_char, c_void, CStr, CString};
/// * Error message if operation fails
///
/// # Safety
/// This function is unsafe because it handles raw pointers from C
/// - `sdk_handle` must be a valid, non-null pointer to an initialized `SDKHandle`.
/// - All C string pointers (`contract_id`, `document_type_name`, `index_name`,
/// `start_index_values_json`, `end_index_values_json`) must be either null (when documented as optional)
/// or valid pointers to NUL-terminated strings that remain valid for the duration of the call.
/// - The function reads the `count` and `order_ascending` by value and does not retain references.
/// - On success, the returned `DashSDKResult` may contain a heap-allocated C string; the caller must
/// free it using the SDK-provided free routine. The result can also contain no data (null pointer).
/// - All pointers passed in must point to readable memory; behavior is undefined if they are dangling.
#[no_mangle]
pub unsafe extern "C" fn dash_sdk_contested_resource_get_resources(
sdk_handle: *const SDKHandle,
Expand Down Expand Up @@ -81,6 +88,7 @@ pub unsafe extern "C" fn dash_sdk_contested_resource_get_resources(
}
}

#[allow(clippy::too_many_arguments)]
fn get_contested_resources(
sdk_handle: *const SDKHandle,
contract_id: *const c_char,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ use std::ffi::{c_char, c_void, CStr, CString};
/// * Error message if operation fails
///
/// # Safety
/// This function is unsafe because it handles raw pointers from C
/// - `sdk_handle` must be a valid, non-null pointer to an initialized `SDKHandle`.
/// - All C string pointers (`contract_id`, `document_type_name`, `index_name`, `index_values_json`)
/// must be valid, non-null pointers to NUL-terminated strings that remain valid for the duration of the call.
/// - `result_type` and `allow_include_locked_and_abstaining_vote_tally` are passed by value.
/// - The returned result may contain a heap-allocated C string which must be freed by the caller using
/// the SDK's free routine. It may also contain no data (null pointer) on success.
/// - All pointers must point to readable memory; passing invalid or dangling pointers results in undefined behavior.
#[no_mangle]
pub unsafe extern "C" fn dash_sdk_contested_resource_get_vote_state(
sdk_handle: *const SDKHandle,
Expand Down Expand Up @@ -84,6 +90,7 @@ pub unsafe extern "C" fn dash_sdk_contested_resource_get_vote_state(
}
}

#[allow(clippy::too_many_arguments)]
fn get_contested_resource_vote_state(
sdk_handle: *const SDKHandle,
contract_id: *const c_char,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ use std::ffi::{c_char, c_void, CStr, CString};
/// * Error message if operation fails
///
/// # Safety
/// This function is unsafe because it handles raw pointers from C
/// - `sdk_handle` must be a valid, non-null pointer to an initialized `SDKHandle`.
/// - All C string pointers (`contract_id`, `document_type_name`, `index_name`, `index_values_json`, `contestant_id`)
/// must be valid, non-null pointers to NUL-terminated strings that remain valid for the duration of the call.
/// - The function reads `count` and `order_ascending` by value and does not retain references.
/// - On success, the returned `DashSDKResult` may contain a heap-allocated C string; the caller must
/// free it using the SDK-provided free routine. The result can also contain no data (null pointer).
/// - All pointers must reference readable memory; passing invalid pointers leads to undefined behavior.
#[no_mangle]
pub unsafe extern "C" fn dash_sdk_contested_resource_get_voters_for_identity(
sdk_handle: *const SDKHandle,
Expand Down Expand Up @@ -82,6 +88,7 @@ pub unsafe extern "C" fn dash_sdk_contested_resource_get_voters_for_identity(
}
}

#[allow(clippy::too_many_arguments)]
fn get_contested_resource_voters_for_identity(
sdk_handle: *const SDKHandle,
contract_id: *const c_char,
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-sdk-ffi/src/context_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl CallbackContextProvider {

/// Create from global callbacks if available
pub fn from_global() -> Option<Self> {
get_global_callbacks().map(|callbacks| Self::new(callbacks))
get_global_callbacks().map(Self::new)
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/rs-sdk-ffi/src/context_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//! This module provides FFI bindings for configuring context providers,
//! allowing the Platform SDK to connect to Core SDK for proof verification.

use std::ffi::c_char;
use std::sync::Arc;

use drive_proof_verifier::ContextProvider;
Expand Down
4 changes: 3 additions & 1 deletion packages/rs-sdk-ffi/src/context_provider_stubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
//! These are temporary stubs for testing compilation.
//! In production, these symbols would be provided by linking against the Core SDK library.

use super::context_provider::CoreSDKHandle;
#[cfg(all(test, feature = "ffi_core_stubs", not(feature = "dash_spv")))]
use std::ffi::c_char;

// Local test-only definitions for stubs
#[cfg(all(test, feature = "ffi_core_stubs", not(feature = "dash_spv")))]
#[repr(C)]
pub struct FFIResult {
pub error_code: i32,
pub error_message: *const c_char,
}

#[cfg(all(test, feature = "ffi_core_stubs", not(feature = "dash_spv")))]
type FFIDashSpvClient = std::ffi::c_void;

// Only compile stubs for tests when explicitly enabled AND dash-spv FFI is not linked.
Expand Down
Loading
Loading