Skip to content

Commit 203b4d6

Browse files
Changing ending of the dispute
- dispute ends when judge issues a verdict - majority of votes starts from 70% - changed indexing of dispute rounds - deposit distribution is done when judge issues a verdict
1 parent ef0f671 commit 203b4d6

File tree

10 files changed

+93
-244
lines changed

10 files changed

+93
-244
lines changed

cli/lib/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ use liminal_ark_relations::{
2121

2222
pub mod helpers;
2323

24+
pub const MAJORITY_OF_VOTES: f32 = 0.70; // 70%
25+
2426
pub struct PublicVote {
2527
pub id: AccountId,
2628
pub pub_key: Vec<u8>,
@@ -102,21 +104,21 @@ pub fn prepare_counting_inputs(
102104
}
103105
}
104106

105-
let votes_minimum: u8 = (0.75 * votes.len() as f32).ceil() as u8;
107+
let votes_minimum: u8 = (MAJORITY_OF_VOTES * votes.len() as f32).ceil() as u8;
106108
let votes_maximum: u8 = votes.len() as u8 - votes_minimum;
107109
let verdict = if sum_votes >= votes_minimum {
108110
jurors_banned = jurors_banned
109111
.iter()
110112
.enumerate()
111-
.filter(|&(index, _)| decoded_votes[index] != 0)
113+
.filter(|&(index, _)| decoded_votes[index] == 0)
112114
.map(|(_, &ref value)| value.clone())
113115
.collect();
114116
VerdictRelation::Positive
115117
} else if sum_votes <= votes_maximum {
116118
jurors_banned = jurors_banned
117119
.iter()
118120
.enumerate()
119-
.filter(|&(index, _)| decoded_votes[index] == 0)
121+
.filter(|&(index, _)| decoded_votes[index] == 1)
120122
.map(|(_, &ref value)| value.clone())
121123
.collect();
122124
VerdictRelation::Negative

cli/src/bright_disputes.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -366,19 +366,4 @@ impl BrightDisputes {
366366

367367
Ok(())
368368
}
369-
370-
/// Calls 'distribute_deposit' of the contract.
371-
pub async fn distribute_deposit(
372-
&self,
373-
connection: &SignedConnection,
374-
dispute_id: u32,
375-
) -> Result<()> {
376-
let ink_contract: Instance = (&self.contract).into();
377-
378-
connection
379-
.exec(ink_contract.distribute_deposit(dispute_id))
380-
.await?;
381-
382-
Ok(())
383-
}
384369
}

cli/src/bright_disputes_ink.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use scale::Encode as _;
44

55
#[allow(dead_code)]
66
pub const CODE_HASH: [u8; 32] = [
7-
134, 34, 57, 191, 103, 29, 44, 56, 12, 231, 88, 242, 64, 144, 53, 34, 131, 56, 170, 238, 192,
8-
142, 229, 240, 82, 204, 67, 181, 250, 239, 22, 82,
7+
172, 163, 202, 102, 55, 35, 203, 88, 236, 195, 156, 213, 90, 245, 231, 194, 112, 179, 169, 197,
8+
90, 183, 142, 26, 36, 52, 220, 49, 44, 93, 167, 79,
99
];
1010

1111
#[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
@@ -225,7 +225,7 @@ impl Instance {
225225
ink_wrapper_types::ReadCall::new(self.account_id, data)
226226
}
227227

228-
/// Get single dispute by id
228+
/// Remove single dispute by id
229229
#[allow(dead_code, clippy::too_many_arguments)]
230230
pub fn remove_dispute(&self, dispute_id: u32) -> ink_wrapper_types::ExecCall {
231231
let data = {
@@ -405,17 +405,6 @@ impl Instance {
405405
ink_wrapper_types::ExecCall::new(self.account_id, data)
406406
}
407407

408-
/// Judge can confirm his participation in dispute
409-
#[allow(dead_code, clippy::too_many_arguments)]
410-
pub fn distribute_deposit(&self, dispute_id: u32) -> ink_wrapper_types::ExecCall {
411-
let data = {
412-
let mut data = vec![117, 233, 246, 239];
413-
dispute_id.encode_to(&mut data);
414-
data
415-
};
416-
ink_wrapper_types::ExecCall::new(self.account_id, data)
417-
}
418-
419408
/// Register a verification key.
420409
#[allow(dead_code, clippy::too_many_arguments)]
421410
pub fn register_vk(&self, relation: Relation, vk: Vec<u8>) -> ink_wrapper_types::ExecCall {

cli/src/config.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,4 @@ pub enum ContractCmd {
9999
caller_account: String,
100100
dispute_id: u32,
101101
},
102-
/// Distribute dispute deposit
103-
DistributeDeposit {
104-
caller_account: String,
105-
dispute_id: u32,
106-
},
107102
}

cli/src/main.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
Command, Config,
2727
ContractCmd::{
2828
ConfirmDefendant, ConfirmJudgeParticipation, ConfirmJurorParticipation, CountTheVotes,
29-
CreateDispute, DistributeDeposit, GetDispute, GetDisputeFull, ProcessDisputeRound,
29+
CreateDispute, GetDispute, GetDisputeFull, ProcessDisputeRound,
3030
RegisterAsAnActiveJuror, UnregisterAsAnActiveJuror, UpdateDefendantDescription,
3131
UpdateOwnerDescription, Vote,
3232
},
@@ -284,18 +284,6 @@ async fn handle_contract_command(
284284
dispute_state
285285
);
286286
}
287-
DistributeDeposit {
288-
caller_account,
289-
dispute_id,
290-
} => {
291-
let account = keypair_from_string(&caller_account);
292-
let signed_connection = SignedConnection::from_connection(connection, account.clone());
293-
294-
bright_dispute
295-
.distribute_deposit(&signed_connection, dispute_id)
296-
.await?;
297-
info!("Deposit distributed successfully!");
298-
}
299287
}
300288
Ok(())
301289
}

0 commit comments

Comments
 (0)