Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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-dapi-client/src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<T: TransportRequest> DumpData<T> {
// Return request type (T) name without module prefix
fn request_type() -> String {
let req_type = std::any::type_name::<T>();
req_type.split(':').last().unwrap_or(req_type).to_string()
req_type.rsplit(':').next().unwrap_or(req_type).to_string()
}
/// Generate unique filename for this dump.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ pub enum DistributionFunction {
/// - `step_count`: The number of periods between each step.
/// - `decrease_per_interval_numerator` and `decrease_per_interval_denominator`: Define the reduction factor per step.
/// - `start_decreasing_offset`: Optional start period offset (e.g., start block or time). If not provided, the contract creation start is used.
/// If this is provided before this number we give out the distribution start amount every interval.
/// If this is provided before this number we give out the distribution start amount every interval.
/// - `max_interval_count`: The maximum amount of intervals there can be. Can be up to 1024.
/// !!!Very important!!! -> This will default to 128 is default if not set.
/// This means that after 128 cycles we will be distributing trailing_distribution_interval_amount per interval.
/// !!!Very important!!! -> This will default to 128 is default if not set.
/// This means that after 128 cycles we will be distributing trailing_distribution_interval_amount per interval.
/// - `distribution_start_amount`: The initial token emission.
/// - `trailing_distribution_interval_amount`: The token emission after all decreasing intervals.
/// - `min_value`: Optional minimum emission value.
Expand Down Expand Up @@ -524,6 +524,7 @@ pub enum DistributionFunction {
/// f(x) = 10000 * ln(5000 / x)
/// ```
/// - Values: a = 10000 n = 5000 m = 1 o = 0 b = 0 d = 0
/// ```text
/// y
/// ↑
/// 10000 |*
Expand All @@ -538,6 +539,7 @@ pub enum DistributionFunction {
/// 1000 | *
/// 0 +-------------------*----------→ x
/// 0 2000 4000 6000 8000
/// ```
///
/// - The emission **starts high** and **gradually decreases**, ensuring early adopters receive
/// more tokens while later participants still get rewards.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ impl DocumentTypeV0 {
// TODO: Split into multiple functions
#[allow(unused_variables)]
#[allow(clippy::too_many_arguments)]
#[allow(clippy::ptr_arg)]
#[allow(clippy::unnecessary_operation)]
pub(super) fn try_from_schema(
data_contract_id: Identifier,
name: &str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ impl DocumentTypeV1 {
// TODO: Split into multiple functions
#[allow(unused_variables)]
#[allow(clippy::too_many_arguments)]
#[allow(clippy::ptr_arg)]
#[allow(clippy::unnecessary_operation)]
pub(super) fn try_from_schema(
data_contract_id: Identifier,
name: &str,
Expand Down
14 changes: 7 additions & 7 deletions packages/rs-dpp/src/data_contract/document_type/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ pub trait DocumentTypeV0Methods: DocumentTypeV0Getters + DocumentTypeV0MethodsVe
/// - `id`: An identifier for the document. Unique within the context of the document's type.
/// - `owner_id`: The identifier of the entity that will own this document.
/// - `block_height`: The block height at which this document is considered to have been created.
/// While this value is recorded in the document, it is ignored when the document is broadcasted
/// to the network. This is because the actual block height at the time of broadcast may differ.
/// This parameter is included to fulfill schema requirements that specify a block height; you may
/// use the current block height, a placeholder value of 0, or any other value as necessary.
/// While this value is recorded in the document, it is ignored when the document is broadcasted
/// to the network. This is because the actual block height at the time of broadcast may differ.
/// This parameter is included to fulfill schema requirements that specify a block height; you may
/// use the current block height, a placeholder value of 0, or any other value as necessary.
/// - `core_block_height`: Similar to `block_height`, this represents the core network's block height
/// at the document's creation time. It is handled the same way as `block_height` regarding broadcast
/// and schema requirements.
/// at the document's creation time. It is handled the same way as `block_height` regarding broadcast
/// and schema requirements.
/// - `properties`: A collection of properties for the document, structured as a `BTreeMap<String, Value>`.
/// These must be pre-validated to match the document's schema definitions.
/// These must be pre-validated to match the document's schema definitions.
/// - `platform_version`: A reference to the current version of the platform for which the document is created.
///
/// # Returns:
Expand Down
1 change: 1 addition & 0 deletions packages/rs-dpp/src/data_contract/document_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub enum DocumentTypeMutRef<'a> {
V1(&'a mut DocumentTypeV1),
}

#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq, From)]
pub enum DocumentType {
V0(DocumentTypeV0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl DocumentPropertyType {
let min_size = self.min_size()?;
let max_size = self.max_size()?;
if platform_version.protocol_version > 8 {
Some(((min_size as u32 + max_size as u32 + 1) / 2) as u16)
Some(((min_size as u32 + max_size as u32).div_ceil(2)) as u16)
} else {
Some(min_size.wrapping_add(max_size).wrapping_add(1) / 2)
}
Expand Down Expand Up @@ -342,7 +342,9 @@ impl DocumentPropertyType {
return Ok(None);
};
if platform_version.protocol_version > 8 {
Ok(Some(((min_size as u32 + max_size as u32 + 1) / 2) as u16))
Ok(Some(
((min_size as u32 + max_size as u32).div_ceil(2)) as u16,
))
} else {
Ok(Some(min_size.wrapping_add(max_size).wrapping_add(1) / 2))
}
Expand Down
10 changes: 4 additions & 6 deletions packages/rs-dpp/src/data_contract/extra/drive_api_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ mod test {
&[("$ownerId", "asc"), ("$updatedAt", "asc")],
),
],
..Default::default()
},
ExpectedDocumentsData {
document_name: "contactInfo",
Expand All @@ -49,7 +48,6 @@ mod test {
("index1", true, &[("$ownerId", "asc")]),
("index2", false, &[("$ownerId", "asc"), ("lastName", "asc")]),
],
..Default::default()
},
ExpectedDocumentsData {
document_name: "contactRequest",
Expand Down Expand Up @@ -150,25 +148,25 @@ mod test {
assert!(!contract.config().readonly()); // the contract shouldn't be readonly
assert!(!contract.config.documents_keep_history_contract_default());
assert_eq!(contract.document_types.len(), 3);
assert!(contract.document_types.get("profile").is_some());
assert!(contract.document_types.contains_key("profile"));
assert!(contract
.document_types
.get("profile")
.unwrap()
.documents_mutable());
assert!(contract.document_types.get("contactInfo").is_some());
assert!(contract.document_types.contains_key("contactInfo"));
assert!(contract
.document_types
.get("contactInfo")
.unwrap()
.documents_mutable());
assert!(contract.document_types.get("contactRequest").is_some());
assert!(contract.document_types.contains_key("contactRequest"));
assert!(!contract
.document_types
.get("contactRequest")
.unwrap()
.documents_mutable());
assert!(contract.document_types.get("non_existent_key").is_none());
assert!(!contract.document_types.contains_key("non_existent_key"));

let contact_info_indices = &contract
.document_types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ use crate::consensus::basic::{
use crate::consensus::state::identity::master_public_key_update_error::MasterPublicKeyUpdateError;
use crate::data_contract::errors::DataContractError;

#[allow(clippy::large_enum_variant)]
#[derive(
Error, Debug, PlatformSerialize, PlatformDeserialize, Encode, Decode, PartialEq, Clone,
)]
Expand Down
1 change: 1 addition & 0 deletions packages/rs-dpp/src/errors/consensus/consensus_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::errors::consensus::basic::BasicError;
)]
#[platform_serialize(limit = 2000)]
#[error(transparent)]
#[allow(clippy::large_enum_variant)]
pub enum ConsensusError {
/*
Expand Down
1 change: 1 addition & 0 deletions packages/rs-dpp/src/errors/protocol_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use crate::version::FeatureVersion;
use platform_value::{Error as ValueError, Value};
use platform_version::error::PlatformVersionError;

#[allow(clippy::large_enum_variant)]
#[derive(Error, Debug)]
pub enum ProtocolError {
#[error("Identifier Error: {0}")]
Expand Down
5 changes: 1 addition & 4 deletions packages/rs-dpp/src/fee/fee_result/refunds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ impl FeeRefunds {
) -> Option<Credits> {
let credits_per_epoch = self.get(identity_id.as_bytes())?;

let credits = credits_per_epoch
.iter()
.map(|(_epoch_index, credits)| credits)
.sum();
let credits = credits_per_epoch.values().sum();

Some(credits)
}
Expand Down
32 changes: 16 additions & 16 deletions packages/rs-dpp/src/identity/identity_public_key/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ impl IdentityPublicKey {
/// * `id`: The `KeyID` for the generated key.
/// * `rng`: A mutable reference to a random number generator of type `StdRng`.
/// * `used_key_matrix`: An optional tuple that contains the count of keys that have already been used
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// * `platform_version`: The platform version which determines the structure of the identity key.
///
/// # Returns
///
/// * `Result<Self, ProtocolError>`: If successful, returns an instance of `Self`.
/// In case of an error, it returns a `ProtocolError`.
/// In case of an error, it returns a `ProtocolError`.
///
/// # Errors
///
Expand Down Expand Up @@ -121,13 +121,13 @@ impl IdentityPublicKey {
/// * `id`: The `KeyID` for the generated key.
/// * `seed`: A seed that will create a random number generator `StdRng`.
/// * `used_key_matrix`: An optional tuple that contains the count of keys that have already been used
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// * `platform_version`: The platform version which determines the structure of the identity key.
///
/// # Returns
///
/// * `Result<(Self, Vec<u8>), ProtocolError>`: If successful, returns an instance of `Self` and the private key as `Vec<u8>`.
/// In case of an error, it returns a `ProtocolError`.
/// In case of an error, it returns a `ProtocolError`.
///
/// # Errors
///
Expand Down Expand Up @@ -158,13 +158,13 @@ impl IdentityPublicKey {
/// * `id`: The `KeyID` for the generated key.
/// * `rng`: A mutable reference to a random number generator of type `StdRng`.
/// * `used_key_matrix`: An optional tuple that contains the count of keys that have already been used
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// * `platform_version`: The platform version which determines the structure of the identity key.
///
/// # Returns
///
/// * `Result<(Self, Vec<u8>), ProtocolError>`: If successful, returns an instance of `Self` and the private key as `Vec<u8>`.
/// In case of an error, it returns a `ProtocolError`.
/// In case of an error, it returns a `ProtocolError`.
///
/// # Errors
///
Expand Down Expand Up @@ -205,13 +205,13 @@ impl IdentityPublicKey {
/// * `id`: The `KeyID` for the generated key.
/// * `rng`: A mutable reference to a random number generator of type `StdRng`.
/// * `used_key_matrix`: An optional tuple that contains the count of keys that have already been used
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// * `platform_version`: The platform version which determines the structure of the identity key.
///
/// # Returns
///
/// * `Result<Self, ProtocolError>`: If successful, returns an instance of `Self`.
/// In case of an error, it returns a `ProtocolError`.
/// In case of an error, it returns a `ProtocolError`.
///
/// # Errors
///
Expand Down Expand Up @@ -251,13 +251,13 @@ impl IdentityPublicKey {
/// * `id`: The `KeyID` for the generated key.
/// * `rng`: A mutable reference to a random number generator of type `StdRng`.
/// * `used_key_matrix`: An optional tuple that contains the count of keys that have already been used
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// and a mutable reference to a matrix (or vector) that tracks which keys have been used.
/// * `platform_version`: The platform version which determines the structure of the identity key.
///
/// # Returns
///
/// * `Result<Self, ProtocolError>`: If successful, returns an instance of `Self`.
/// In case of an error, it returns a `ProtocolError`.
/// In case of an error, it returns a `ProtocolError`.
///
/// # Errors
///
Expand Down Expand Up @@ -311,7 +311,7 @@ impl IdentityPublicKey {
/// # Returns
///
/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
/// and the second element is the corresponding private key.
/// and the second element is the corresponding private key.
///
pub fn random_ecdsa_master_authentication_key_with_rng(
id: KeyID,
Expand Down Expand Up @@ -377,7 +377,7 @@ impl IdentityPublicKey {
/// # Returns
///
/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
/// and the second element is the corresponding private key.
/// and the second element is the corresponding private key.
///
pub fn random_ecdsa_master_authentication_key(
id: KeyID,
Expand All @@ -404,7 +404,7 @@ impl IdentityPublicKey {
/// # Returns
///
/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
/// and the second element is the corresponding private key.
/// and the second element is the corresponding private key.
///
pub fn random_ecdsa_critical_level_authentication_key(
id: KeyID,
Expand Down Expand Up @@ -435,7 +435,7 @@ impl IdentityPublicKey {
/// # Returns
///
/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
/// and the second element is the corresponding private key.
/// and the second element is the corresponding private key.
///
pub fn random_ecdsa_critical_level_authentication_key_with_rng(
id: KeyID,
Expand Down Expand Up @@ -622,7 +622,7 @@ impl IdentityPublicKey {
/// # Returns
///
/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
/// and the second element is the corresponding private key.
/// and the second element is the corresponding private key.
///
pub fn random_ecdsa_high_level_authentication_key(
id: KeyID,
Expand All @@ -649,7 +649,7 @@ impl IdentityPublicKey {
/// # Returns
///
/// * `(Self, Vec<u8>)`: A tuple where the first element is an instance of the `IdentityPublicKey` struct,
/// and the second element is the corresponding private key.
/// and the second element is the corresponding private key.
///
pub fn random_ecdsa_high_level_authentication_key_with_rng(
id: KeyID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ impl AssetLockProof {
match proof_type_res {
Ok(proof_type_int) => {
let proof_type = AssetLockProofType::try_from(proof_type_int);
match proof_type {
Ok(pt) => Some(pt),
Err(_) => None,
}
proof_type.ok()
}
Err(_) => None,
}
Expand Down
1 change: 1 addition & 0 deletions packages/rs-dpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![forbid(unsafe_code)]
//#![deny(missing_docs)]
#![allow(dead_code)]
#![allow(clippy::result_large_err)]

extern crate core;

Expand Down
8 changes: 4 additions & 4 deletions packages/rs-dpp/src/state_transition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ pub struct StateTransitionSigningOptions {
impl StateTransition {
pub fn deserialize_from_bytes_in_version(
bytes: &[u8],
platform_version: &PlatformVersion,
_platform_version: &PlatformVersion,
) -> Result<Self, ProtocolError> {
let state_transition = StateTransition::deserialize_from_bytes(bytes)?;
#[cfg(all(feature = "state-transitions", feature = "validation"))]
Expand All @@ -304,16 +304,16 @@ impl StateTransition {

// Tests are done with very high protocol ranges, while we could put this behind a feature,
// that would probably be overkill.
if active_version_range.contains(&platform_version.protocol_version)
|| platform_version.protocol_version > 268435456
if active_version_range.contains(&_platform_version.protocol_version)
|| _platform_version.protocol_version > 268435456
{
Ok(state_transition)
} else {
Err(ProtocolError::StateTransitionError(
StateTransitionIsNotActiveError {
state_transition_type: state_transition.name(),
active_version_range,
current_protocol_version: platform_version.protocol_version,
current_protocol_version: _platform_version.protocol_version,
},
))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait DataContractCreateTransitionMethodsV0 {
/// * `signer` - A reference to an object implementing the `Signer` trait.
/// * `platform_version` - The current platform version that should be used.
/// * `feature_version` - You can set the feature version to a different version than the default for the current
/// protocol version.
/// protocol version.
///
/// # Returns
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ impl IdentityCreateTransitionV0 {

let public_keys = identity
.public_keys()
.iter()
.map(|(_, public_key)| public_key.into())
.values()
.map(|public_key| public_key.into())
.collect::<Vec<IdentityPublicKeyInCreation>>();
identity_create_transition.set_public_keys(public_keys);

Expand Down
Loading
Loading