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

Changed devgovgigs notification to devhub for proposals. Added a chec… #101

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ impl Contract {
"This account is only allowed to change proposal status from DRAFT to REVIEW"
);

require!(
proposal_body.timeline.is_draft() || proposal_body.timeline.is_review() || proposal_body.timeline.is_cancelled() || proposal_body.supervisor.is_some(),
"You can't change the timeline of the proposal to this status without adding a supervisor"
);

require!(self.proposal_categories.contains(&proposal_body.category), "Unknown category");

let old_snapshot = proposal.snapshot.clone();
Expand Down Expand Up @@ -1030,7 +1035,7 @@ mod tests {
&receipts[0].actions[0]
{
assert_eq!(method_name, b"set");
assert_eq!(args, b"{\"data\":{\"bob.near\":{\"index\":{\"notify\":\"[{\\\"key\\\":\\\"petersalomonsen.near\\\",\\\"value\\\":{\\\"type\\\":\\\"devgovgigs/mention\\\",\\\"proposal\\\":0}},{\\\"key\\\":\\\"psalomo.near.\\\",\\\"value\\\":{\\\"type\\\":\\\"devgovgigs/mention\\\",\\\"proposal\\\":0}},{\\\"key\\\":\\\"frol.near\\\",\\\"value\\\":{\\\"type\\\":\\\"devgovgigs/mention\\\",\\\"proposal\\\":0}},{\\\"key\\\":\\\"neardevdao.near\\\",\\\"value\\\":{\\\"type\\\":\\\"devgovgigs/mention\\\",\\\"proposal\\\":0}}]\"}}}}");
assert_eq!(args, b"{\"data\":{\"bob.near\":{\"index\":{\"notify\":\"[{\\\"key\\\":\\\"petersalomonsen.near\\\",\\\"value\\\":{\\\"type\\\":\\\"devhub/mention\\\",\\\"proposal\\\":0}},{\\\"key\\\":\\\"psalomo.near.\\\",\\\"value\\\":{\\\"type\\\":\\\"devhub/mention\\\",\\\"proposal\\\":0}},{\\\"key\\\":\\\"frol.near\\\",\\\"value\\\":{\\\"type\\\":\\\"devhub/mention\\\",\\\"proposal\\\":0}},{\\\"key\\\":\\\"neardevdao.near\\\",\\\"value\\\":{\\\"type\\\":\\\"devhub/mention\\\",\\\"proposal\\\":0}}]\"}}}}");
} else {
assert!(false, "Expected a function call ...")
}
Expand Down
4 changes: 2 additions & 2 deletions src/notify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn notify_proposal_subscribers(proposal: &Proposal) {
env::current_account_id(),
accounts,
json!({
"type": "devgovgigs/mention",
"type": "devhub/mention",
"proposal": proposal.id,
}),
)
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn notify_edit_proposal(proposal_id: ProposalId, post_author: AccountId) ->
env::current_account_id(),
post_author,
json!({
"type": format!("devgovgigs/{}", "edit"),
"type": "devhub/edit",
"proposal": proposal_id,
}),
)
Expand Down
4 changes: 4 additions & 0 deletions src/proposal/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ impl TimelineStatus {
}
}

pub fn is_review(&self) -> bool {
matches!(self, TimelineStatus::Review(..))
}

pub fn is_cancelled(&self) -> bool {
matches!(self, TimelineStatus::Cancelled(..))
}
Expand Down
Loading