Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fixes after halborn second round #199

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dao/src/bid_escrow/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ impl Job {
revert(Error::OnlyWorkerCanSubmitProof);
}

if self.finish_time() + self.grace_period() < request.block_time {
revert(Error::JobProofSubmittedAfterGracePeriod);
if self.finish_time() < request.block_time {
revert(Error::JobProofSubmittedAfterFinishTime);
}

self.job_proof = Some(request.proof);
Expand Down
2 changes: 1 addition & 1 deletion dao/src/utils/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ execution_error! {
BidAlreadyPicked => 4038,
BidCanceled => 4039,
BidRejected => 4040,
JobProofSubmittedAfterGracePeriod => 4041,
JobProofSubmittedAfterFinishTime => 4041,

// Reputation Token Errors.
CannotStakeTwice => 4500,
Expand Down
15 changes: 1 addition & 14 deletions dao/src/voting_contracts/simple_voter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl SimpleVoterContract {
) -> Option<Ballot>;
pub fn get_voter(&self, voting_id: VotingId, voting_type: VotingType, at: u32) -> Option<Address>;
pub fn cancel_finished_voting(&mut self, voting_id: VotingId);
pub fn finish_voting(&mut self, voting_id: VotingId, voting_type: VotingType) -> VotingSummary;
}

to self.access_control {
Expand Down Expand Up @@ -98,20 +99,6 @@ impl SimpleVoterContract {
SimpleVotingCreated::new(document_hash, info).emit();
}

pub fn finish_voting(&mut self, voting_id: VotingId, voting_type: VotingType) -> VotingSummary {
let voting_summary = self.voting_engine.finish_voting(voting_id, voting_type);

if let VotingType::Formal = voting_summary.voting_type() {
self.simple_votings.set(
&voting_id,
self.simple_votings
.get(&voting_id)
.unwrap_or_revert_with(Error::VariableValueNotSet),
);
}
voting_summary
}

pub fn get_document_hash(&self, voting_id: VotingId) -> Option<DocumentHash> {
self.simple_votings.get(&voting_id)
}
Expand Down
2 changes: 1 addition & 1 deletion dao/tests/steps/bid_escrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ fn bid_pick_failed(w: &mut DaoWorld, job_poster: Account, worker: Account) {
fn submit_outdated_job_proof(w: &mut DaoWorld, worker: Account, job_id: JobId) {
let worker = w.get_address(&worker);
test_env::set_caller(worker);
test_env::assert_exception(Error::JobProofSubmittedAfterGracePeriod, || {
test_env::assert_exception(Error::JobProofSubmittedAfterFinishTime, || {
w.bid_escrow
.submit_job_proof(job_id, DocumentHash::from("Job Proof"));
});
Expand Down
30 changes: 15 additions & 15 deletions resources/simple_voter_contract_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@
],
"return_ty": "Unit"
},
{
"name": "finish_voting",
"is_mutable": true,
"args": [
{
"name": "voting_id",
"ty": "U32"
},
{
"name": "voting_type",
"ty": "U32"
}
],
"return_ty": "Any"
},
{
"name": "get_document_hash",
"is_mutable": false,
Expand Down Expand Up @@ -178,6 +163,21 @@
],
"return_ty": "Unit"
},
{
"name": "finish_voting",
"is_mutable": true,
"args": [
{
"name": "voting_id",
"ty": "U32"
},
{
"name": "voting_type",
"ty": "U32"
}
],
"return_ty": "Any"
},
{
"name": "propose_new_owner",
"is_mutable": true,
Expand Down
Loading