diff --git a/pallets/disputes/src/lib.rs b/pallets/disputes/src/lib.rs index 9f257358..115c75d1 100644 --- a/pallets/disputes/src/lib.rs +++ b/pallets/disputes/src/lib.rs @@ -27,6 +27,8 @@ use frame_support::pallet_prelude::*; type DisputeKey: AtLeast32BitUnsigned + FullEncode + FullCodec + MaxEncodedLen + TypeInfo; type MaxReasonLength: Get; type MaxJurySize: Get; + type DisputeHooks: traits::DisputeHooks; + type TimeLimit: Get<::BlockNumber>; } #[pallet::storage] @@ -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, } @@ -96,16 +99,15 @@ use frame_support::pallet_prelude::*; impl DisputeRaiser> for Pallet { type DisputeKey = T::DisputeKey; + fn raise_dispute( + dispute_key: Self::DisputeKey, raised_by: AccountIdOf, fund_account: AccountIdOf, reason: Vec, project_id: u32, jury: Vec>, ) -> Result<(), DispatchError> { - - //incrementing the dispute_key - let dispute_key = DisputeKey::::get().saturating_add(1); // creating the struct with the passed information and initializing vote as 0 initially let dispute:Dispute = Dispute{ raised_by, @@ -118,6 +120,8 @@ use frame_support::pallet_prelude::*; jury, }; + ensure!(!Disputes::::contains_key(dispute_key), Error::::DisputeAlreadyExists); + //storing the raised dispute inside the disputes storage Disputes::::insert(dispute_key, dispute); diff --git a/pallets/disputes/src/traits.rs b/pallets/disputes/src/traits.rs index 68152cfc..7199e4cf 100644 --- a/pallets/disputes/src/traits.rs +++ b/pallets/disputes/src/traits.rs @@ -1,21 +1,25 @@ use sp_runtime::{DispatchError, traits::AtLeast32BitUnsigned}; pub trait DisputeRaiser { - 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, + fund_account: AccountIdOf, reason: Vec, project_id: u32, - jury: Vec, + jury: Vec>, ) -> Result<(), DispatchError>; } -pub trait JurySelector{ - fn select_jury()-> Result<(), DispatchError>; -} \ No newline at end of file +pub trait DisputeHooks { + // Outcome + // handle the completed dispute + fn on_dispute_complete() -> (); +} +