Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
1xstj committed Nov 24, 2023
1 parent 8fac89a commit 42b16de
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
8 changes: 6 additions & 2 deletions pallets/dkg/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ fn set_fees_works() {
#[test]
fn dkg_key_verifcation_works() {
new_test_ext().execute_with(|| {
let job_to_verify =
DKGResult { key: vec![], participants: vec![], keys_and_signatures: vec![], threshold: 2 };
let job_to_verify = DKGResult {
key: vec![],
participants: vec![],
keys_and_signatures: vec![],
threshold: 2,
};

// should fail for empty participants
assert_noop!(
Expand Down
8 changes: 3 additions & 5 deletions primitives/src/traits/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Tangle. If not, see <http://www.gnu.org/licenses/>.

use crate::jobs::{JobId, JobKey, JobSubmission, ValidatorOffence, JobResult};
use crate::jobs::{JobId, JobKey, JobResult, JobSubmission, ValidatorOffence};
use frame_support::dispatch::Vec;
use sp_arithmetic::traits::{BaseArithmetic, Unsigned};
use sp_runtime::DispatchResult;
Expand Down Expand Up @@ -48,9 +48,7 @@ pub trait MPCHandler<AccountId, BlockNumber, Balance> {
/// # Errors
///
/// Returns a `DispatchResult` indicating success or an error if verification fails.
fn verify(
data : JobResult
) -> DispatchResult;
fn verify(data: JobResult) -> DispatchResult;

// Verify a validator report
///
Expand All @@ -65,7 +63,7 @@ pub trait MPCHandler<AccountId, BlockNumber, Balance> {
fn verify_validator_report(
validator: AccountId,
offence: ValidatorOffence,
signatures: Vec<Vec<u8>>
signatures: Vec<Vec<u8>>,
) -> DispatchResult;

/// Validate the authority key associated with a specific validator.
Expand Down
10 changes: 6 additions & 4 deletions primitives/src/traits/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Tangle. If not, see <http://www.gnu.org/licenses/>.

use crate::jobs::{JobKey, ValidatorOffence};
use crate::{
jobs::{JobKey, ValidatorOffence},
roles::RoleTypeMetadata,
};
use sp_runtime::DispatchResult;
use crate::roles::RoleTypeMetadata;

/// A trait that handles roles associated with job types.
pub trait RolesHandler<AccountId> {
Expand Down Expand Up @@ -54,7 +56,7 @@ pub trait RolesHandler<AccountId> {
///
/// # Returns
///
/// Returns an `Option<RoleTypeMetadata>` containing metadata information for the specified validator,
/// or `None` if no metadata is found.
/// Returns an `Option<RoleTypeMetadata>` containing metadata information for the specified
/// validator, or `None` if no metadata is found.
fn get_validator_metadata(address: AccountId, job_key: JobKey) -> Option<RoleTypeMetadata>;
}
14 changes: 6 additions & 8 deletions primitives/src/types/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
//
// You should have received a copy of the GNU General Public License
// along with Tangle. If not, see <http://www.gnu.org/licenses/>.
use crate::roles::RoleType;
use frame_support::{dispatch::Vec, pallet_prelude::*, RuntimeDebug};
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use sp_core::ecdsa;
use crate::roles::RoleType;

pub type JobId = u32;

Expand Down Expand Up @@ -275,13 +275,12 @@ pub enum JobResult {

pub type KeysAndSignatures = Vec<(Vec<u8>, Vec<u8>)>;


#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, Clone)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct DKGResult {
/// Submitted key
pub key: Vec<u8>,

/// List of participants' public keys
pub participants: Vec<ecdsa::Public>,

Expand All @@ -302,7 +301,7 @@ pub struct DKGSignatureResult {
pub signature: Vec<u8>,

/// The expected key for the signature
pub signing_key : Vec<u8>
pub signing_key: Vec<u8>,
}

#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, Clone)]
Expand All @@ -315,16 +314,15 @@ pub struct ZkSaasPhaseOneResult {
pub participants: Vec<Vec<u8>>,

/// The data to verify
pub data: Vec<u8>
pub data: Vec<u8>,
}


#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo, Clone)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub struct ZkSaasPhaseTwoResult {
/// The data to verify
pub data: Vec<u8>,

/// The expected key for the signature
pub signing_key : Vec<u8>
}
pub signing_key: Vec<u8>,
}

0 comments on commit 42b16de

Please sign in to comment.