diff --git a/backend/canisters/proposals_bot/CHANGELOG.md b/backend/canisters/proposals_bot/CHANGELOG.md index df26f1fdbc..90f8f074a5 100644 --- a/backend/canisters/proposals_bot/CHANGELOG.md +++ b/backend/canisters/proposals_bot/CHANGELOG.md @@ -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 diff --git a/backend/canisters/proposals_bot/impl/src/model/nervous_systems.rs b/backend/canisters/proposals_bot/impl/src/model/nervous_systems.rs index 048f843bfb..a99a64ff22 100644 --- a/backend/canisters/proposals_bot/impl/src/model/nervous_systems.rs +++ b/backend/canisters/proposals_bot/impl/src/model/nervous_systems.rs @@ -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) { @@ -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); @@ -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); diff --git a/backend/external_canisters/nns_governance/api/src/types.rs b/backend/external_canisters/nns_governance/api/src/types.rs index a7ba674e30..b8d5c2284f 100644 --- a/backend/external_canisters/nns_governance/api/src/types.rs +++ b/backend/external_canisters/nns_governance/api/src/types.rs @@ -696,7 +696,10 @@ impl TryFrom 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())), diff --git a/backend/libraries/types/src/proposals.rs b/backend/libraries/types/src/proposals.rs index 09e17fd2ad..bd8e6870ea 100644 --- a/backend/libraries/types/src/proposals.rs +++ b/backend/libraries/types/src/proposals.rs @@ -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, pub last_updated: TimestampMillis,