Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
f-gate committed Aug 17, 2023
1 parent 9bc3410 commit 723bb34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 7 additions & 3 deletions pallets/disputes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use frame_support::pallet_prelude::*;
type DisputeKey: AtLeast32BitUnsigned + FullEncode + FullCodec + MaxEncodedLen + TypeInfo;
type MaxReasonLength: Get<u32>;
type MaxJurySize: Get<u32>;
type DisputeHooks: traits::DisputeHooks;
type TimeLimit: Get<<Self as frame_system::Config>::BlockNumber>;
}

#[pallet::storage]
Expand All @@ -50,6 +52,7 @@ use frame_support::pallet_prelude::*;
StorageOverflow,
//This error is thrown whenever the dispute key passed doesn't correspond to any dispute
DisputeDoesNotExist,
DisputeAlreadyExists,
}


Expand Down Expand Up @@ -96,16 +99,15 @@ use frame_support::pallet_prelude::*;

impl<T: Config> DisputeRaiser<AccountIdOf<T>> for Pallet<T> {
type DisputeKey = T::DisputeKey;

fn raise_dispute(
dispute_key: Self::DisputeKey,
raised_by: AccountIdOf<T>,
fund_account: AccountIdOf<T>,
reason: Vec<u8>,
project_id: u32,
jury: Vec<AccountIdOf<T>>,
) -> Result<(), DispatchError> {

//incrementing the dispute_key
let dispute_key = DisputeKey::<T>::get().saturating_add(1);
// creating the struct with the passed information and initializing vote as 0 initially
let dispute:Dispute<T> = Dispute{
raised_by,
Expand All @@ -118,6 +120,8 @@ use frame_support::pallet_prelude::*;
jury,
};

ensure!(!Disputes::<T>::contains_key(dispute_key), Error::<T>::DisputeAlreadyExists);

//storing the raised dispute inside the disputes storage
Disputes::<T>::insert(dispute_key, dispute);

Expand Down
18 changes: 11 additions & 7 deletions pallets/disputes/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
use sp_runtime::{DispatchError, traits::AtLeast32BitUnsigned};

pub trait DisputeRaiser<AccountId> {
type DisputeKey: AtLeast32BitUnsigned;
type DisputeKey: AtLeast32BitUnsigned + FullEncode + FullCodec + MaxEncodedLen + TypeInfo;

// Strip this to be the minumim the dispute pallet needs to know.
// where is the money,
// Who is the jury,
// Bind the string to a constant amount (500)
fn raise_dispute(
raised_by: AccountId,
fund_account: AccountId,
dispute_key: Self::DisputeKey,
raised_by: AccountIdOf<T>,
fund_account: AccountIdOf<T>,
reason: Vec<u8>,
project_id: u32,
jury: Vec<AccountId>,
jury: Vec<AccountIdOf<T>>,
) -> Result<(), DispatchError>;
}

pub trait JurySelector{
fn select_jury()-> Result<(), DispatchError>;
}
pub trait DisputeHooks<DisputeKey> {
// Outcome
// handle the completed dispute
fn on_dispute_complete() -> ();
}

0 comments on commit 723bb34

Please sign in to comment.