Skip to content
13 changes: 12 additions & 1 deletion .github/workflows/rs-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
description: The package name to run tests for
type: string
required: true
clippy-fail:
description: Fail clippy checks if any warnings detected
type: boolean
required: false

jobs:
lint:
Expand All @@ -26,10 +30,17 @@ jobs:
- name: Enable Rust cache
uses: Swatinem/rust-cache@v2

- name: Clippy args
uses: actions/github-script@v6
id: clippy-args
with:
result-encoding: string
script: "return core.getInput('clippy-fail') ? '--all-features -- -Dwarnings' : '--all-features';"

- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
args: ${{ steps.clippy-args.output.result }}

formatting:
name: Formatting
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rs-dpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jobs:
uses: ./.github/workflows/rs-checks.yml
with:
package: "dpp"
clippy-fail: true
1 change: 1 addition & 0 deletions .github/workflows/wasm-dpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
uses: ./.github/workflows/rs-checks.yml
with:
package: 'wasm-dpp'
clippy-fail: true

wasm-errors:
name: WASM compilation
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-dpp/src/data_contract/data_contract_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl DataContractFactory {
data_contract: DataContract,
) -> Result<DataContractCreateTransition, ProtocolError> {
//todo: is this right for entropy?
let entropy = data_contract.entropy.clone();
let entropy = data_contract.entropy;
Ok(DataContractCreateTransition {
protocol_version: self.protocol_version,
transition_type: StateTransitionType::DataContractCreate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ where
let identity = context
.state_repository
.fetch_identity(
&to_user_id.into(),
&to_user_id,
Some(context.state_transition_execution_context),
)
.await?;
Expand Down
8 changes: 4 additions & 4 deletions packages/rs-dpp/src/document/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ pub struct Document {

impl Document {
/// Return a value given the path to its key for a document type.
pub fn get_raw_for_document_type<'a>(
&'a self,
pub fn get_raw_for_document_type(
&self,
key_path: &str,
document_type: &DocumentType,
owner_id: Option<[u8; 32]>,
Expand Down Expand Up @@ -130,8 +130,8 @@ impl Document {
}

/// Return a value given the path to its key and the document type for a contract.
pub fn get_raw_for_contract<'a>(
&'a self,
pub fn get_raw_for_contract(
&self,
key: &str,
document_type_name: &str,
contract: &DataContract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn apply_documents_batch_transition(
) -> Result<(), ProtocolError> {
let replace_transitions: Vec<_> = state_transition
.get_transitions_slice()
.into_iter()
.iter()
.filter(|dt| dt.base().action == Action::Replace)
.collect();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl From<&DocumentCreateTransition> for DocumentCreateTransitionAction {
} = value;
DocumentCreateTransitionAction {
base: base.into(),
created_at: created_at.clone(),
updated_at: updated_at.clone(),
created_at: *created_at,
updated_at: *updated_at,
data: data.clone().unwrap_or_default(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl DocumentReplaceTransitionAction {
base: base.into(),
revision: *revision,
created_at: originally_created_at,
updated_at: updated_at.clone(),
updated_at: *updated_at,
data: data.clone().unwrap_or_default(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where
let data_triggers: Vec<DataTrigger> = data_triggers_list.into_iter().collect();

for dt in document_transitions {
let document_transition = dt.as_ref();
let document_transition = dt;
let document_type = &document_transition.base().document_type_name;
let transition_action = document_transition.base().action;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ where

// 1. Prepare fetchDocuments queries from indexed properties
for t in document_transitions {
let transition = t.as_ref();
let transition = t;
let document_schema =
data_contract.get_document_schema(&transition.base().document_type_name)?;
let document_indices = document_schema.get_indices::<Vec<_>>()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ where
&self,
data: &IdentityCreateTransition,
) -> Result<ValidationResult<Self::ResultItem>, ProtocolError> {
validate_identity_create_transition_state(&self.state_repository, data)
.await
.map_err(|err| err.into())
validate_identity_create_transition_state(&self.state_repository, data).await
}
}

Expand Down Expand Up @@ -65,7 +63,7 @@ pub async fn validate_identity_create_transition_state(
.map_err(|e| {
NonConsensusError::StateRepositoryFetchError(format!(
"state repository fetch identity balance error: {}",
e.to_string()
e
))
})?;

Expand All @@ -86,9 +84,7 @@ pub async fn validate_identity_create_transition_state(
)
.await
.map_err(Into::<NonConsensusError>::into)?;
return Ok(
IdentityCreateTransitionAction::from_borrowed(state_transition, tx_out.value).into(),
);
Ok(IdentityCreateTransitionAction::from_borrowed(state_transition, tx_out.value).into())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ where
.map_err(|e| {
NonConsensusError::StateRepositoryFetchError(format!(
"state repository fetch identity for credit withdrawal verification error: {}",
e.to_string()
e
))
})?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ where
) -> Result<ValidationResult<IdentityTopUpTransitionAction>, ProtocolError> {
validate_identity_topup_transition_state(&self.state_repository, data)
.await
.map(|result| result.into())
.map_err(|err| err.into())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl From<&IdentityUpdateTransition> for IdentityUpdateTransitionAction {
.map(|key| key.clone().to_identity_public_key())
.collect(),
disable_public_keys: disable_public_keys.clone(),
public_keys_disabled_at: public_keys_disabled_at.clone(),
public_keys_disabled_at: *public_keys_disabled_at,
identity_id: *identity_id,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ where
.map_err(|e| {
NonConsensusError::StateRepositoryFetchError(format!(
"state repository fetch identity for identity update validation error: {}",
e.to_string()
e
))
})?;

Expand Down Expand Up @@ -115,7 +115,7 @@ where
.map_err(|e| {
NonConsensusError::StateRepositoryFetchError(format!(
"state repository fetch latest platform block time error: {}",
e.to_string()
e
))
})?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pub struct PublicKeysValidatorMock {
called_with: Mutex<Vec<Value>>,
}

impl Default for PublicKeysValidatorMock {
fn default() -> Self {
Self::new()
}
}

impl PublicKeysValidatorMock {
pub fn new() -> Self {
Self {
Expand Down
163 changes: 0 additions & 163 deletions packages/wasm-dpp/src/data_contract_factory/data_contract_factory.rs

This file was deleted.

Loading