Skip to content

Commit

Permalink
Fix deadline timestamp on NNS proposals (#5136)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jan 5, 2024
1 parent eed2cab commit 4d848f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/proposals_bot/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Fixed

- Fix deadline timestamp on NNS proposals ([#5136](https://github.com/open-chat-labs/open-chat/pull/5136))

## [[2.0.998](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.998-proposals_bot)] - 2024-01-05

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ impl NervousSystem {
status: Some(proposal.status()),
reward_status: Some(proposal.reward_status()),
latest_tally: Some(proposal.tally()),
deadline: None,
deadline: Some(proposal.deadline()),
};
self.upsert_proposal_update(update);
} else if let Some((previous, message_id)) = self.active_proposals.get_mut(&proposal_id) {
Expand All @@ -400,7 +400,6 @@ impl NervousSystem {
latest_tally: (latest_tally != previous.tally()).then_some(latest_tally),
deadline: (deadline != previous.deadline()).then_some(deadline),
};

self.upsert_proposal_update(update);
} else {
self.proposals_to_be_pushed.queue.insert(proposal_id, proposal);
Expand Down Expand Up @@ -436,6 +435,9 @@ impl NervousSystem {
if let Some(t) = update.latest_tally {
current.latest_tally = Some(t);
}
if let Some(d) = update.deadline {
current.deadline = Some(d);
}
}
Vacant(e) => {
e.insert(update);
Expand Down
5 changes: 4 additions & 1 deletion backend/external_canisters/nns_governance/api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,10 @@ impl TryFrom<ProposalInfo> for types::NnsProposal {
.try_into()
.map_err(|r| format!("unknown reward status: {r}"))?,
tally: p.latest_tally.map(|t| t.into()).unwrap_or_default(),
deadline: p.deadline_timestamp_seconds.ok_or("deadline not set".to_string())?,
deadline: p
.deadline_timestamp_seconds
.map(|ts| ts * 1000)
.ok_or("deadline not set".to_string())?,
payload_text_rendering: proposal
.action
.map(|a| serde_json::to_string_pretty(&a).unwrap_or("Failed to serialize payload".to_string())),
Expand Down
1 change: 1 addition & 0 deletions backend/libraries/types/src/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ pub struct NnsProposal {
pub status: ProposalDecisionStatus,
pub reward_status: ProposalRewardStatus,
pub tally: Tally,
#[serde(skip_deserializing)]
pub deadline: TimestampMillis,
pub payload_text_rendering: Option<String>,
pub last_updated: TimestampMillis,
Expand Down

0 comments on commit 4d848f7

Please sign in to comment.