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

Show proposal payloads for NNS proposals #5072

Merged
merged 6 commits into from
Jan 1, 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
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions backend/canisters/community/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]

### Added

- Show proposal payloads for NNS proposals ([#5072](https://github.com/open-chat-labs/open-chat/pull/5072))

### Changed

- Add `subtype` to channel search results ([#5084](https://github.com/open-chat-labs/open-chat/pull/5084))
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/group/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]

### Added

- Show proposal payloads for NNS proposals ([#5072](https://github.com/open-chat-labs/open-chat/pull/5072))

### Fixed

- Prevent latest messages of payment gated groups from being public ([#5080](https://github.com/open-chat-labs/open-chat/pull/5080))
Expand Down
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]

### Added

- Show proposal payloads for NNS proposals ([#5072](https://github.com/open-chat-labs/open-chat/pull/5072))

## [[2.0.960](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.960-proposals_bot)] - 2023-12-05

### Changed
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/proposals_bot/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ icrc-ledger-types = { workspace = true }
itertools = { workspace = true }
ledger_utils = { path = "../../../libraries/ledger_utils" }
msgpack = { path = "../../../libraries/msgpack" }
nns_governance_canister = { path = "../../../external_canisters/nns_governance/api" }
nns_governance_canister_c2c_client = { path = "../../../external_canisters/nns_governance/c2c_client" }
proposals_bot_canister = { path = "../api" }
rand = { workspace = true }
registry_canister = { path = "../../../canisters/registry/api" }
Expand Down

This file was deleted.

This file was deleted.

108 changes: 0 additions & 108 deletions backend/canisters/proposals_bot/impl/src/governance_clients/nns.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use crate::governance_clients::common::{RawProposal, REWARD_STATUS_ACCEPT_VOTES, REWARD_STATUS_READY_TO_SETTLE};
use crate::governance_clients::nns::governance_response_types::ProposalInfo;
use crate::governance_clients::nns::{ListProposalInfo, TOPIC_EXCHANGE_RATE, TOPIC_NEURON_MANAGEMENT};
use crate::jobs::{push_proposals, update_proposals};
use crate::proposals::{RawProposal, REWARD_STATUS_ACCEPT_VOTES, REWARD_STATUS_READY_TO_SETTLE};
use crate::timer_job_types::{ProcessUserRefundJob, TopUpNeuronJob};
use crate::{governance_clients, mutate_state, RuntimeState};
use crate::{mutate_state, RuntimeState};
use canister_timer_jobs::Job;
use ic_cdk::api::call::CallResult;
use nns_governance_canister::types::{ListProposalInfo, ProposalInfo};
use sns_governance_canister::types::ProposalData;
use std::collections::HashSet;
use std::time::Duration;
use types::{CanisterId, Milliseconds, Proposal};
use utils::time::MINUTE_IN_MS;

pub const NNS_TOPIC_NEURON_MANAGEMENT: i32 = 1;
pub const NNS_TOPIC_EXCHANGE_RATE: i32 = 2;

const BATCH_SIZE_LIMIT: u32 = 50;
const RETRIEVE_PROPOSALS_INTERVAL: Milliseconds = MINUTE_IN_MS;

Expand Down Expand Up @@ -51,12 +53,15 @@ async fn get_nns_proposals(governance_canister_id: CanisterId) -> CallResult<Vec
let list_proposals_args = ListProposalInfo {
limit: BATCH_SIZE_LIMIT,
before_proposal: proposals.iter().next_back().and_then(|p| p.id.clone()),
exclude_topic: vec![TOPIC_NEURON_MANAGEMENT, TOPIC_EXCHANGE_RATE],
exclude_topic: vec![NNS_TOPIC_NEURON_MANAGEMENT, NNS_TOPIC_EXCHANGE_RATE],
include_reward_status: vec![REWARD_STATUS_ACCEPT_VOTES, REWARD_STATUS_READY_TO_SETTLE],
..Default::default()
};

let response = governance_clients::nns::list_proposals(governance_canister_id, &list_proposals_args).await?;
let response = nns_governance_canister_c2c_client::list_proposals(governance_canister_id, &list_proposals_args)
.await?
.proposal_info;

let finished = response.len() < BATCH_SIZE_LIMIT as usize;
proposals.extend(response);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::governance_clients::common::WrappedProposalId;
use crate::governance_clients::nns::ListProposalInfo;
use crate::jobs::update_proposals;
use crate::{generate_message_id, governance_clients, mutate_state, RuntimeState};
use crate::{generate_message_id, mutate_state, RuntimeState};
use ic_cdk::api::call::CallResult;
use ic_cdk_timers::TimerId;
use nns_governance_canister::types::ListProposalInfo;
use sns_governance_canister::types::ListProposals;
use std::cell::Cell;
use std::time::Duration;
Expand Down Expand Up @@ -74,15 +73,16 @@ async fn process_proposal(governance_canister_id: CanisterId, proposal_id: Propo
}

async fn get_nns_proposal(governance_canister_id: CanisterId, proposal_id: ProposalId) -> CallResult<Option<ProposalUpdate>> {
let response = governance_clients::nns::list_proposals(
let response = nns_governance_canister_c2c_client::list_proposals(
governance_canister_id,
&ListProposalInfo {
limit: 1,
before_proposal: Some(WrappedProposalId { id: proposal_id + 1 }),
before_proposal: Some(nns_governance_canister::types::ProposalId { id: proposal_id + 1 }),
..Default::default()
},
)
.await?;
.await?
.proposal_info;

Ok(response.into_iter().next().map(|p| ProposalUpdate {
message_id: generate_message_id(governance_canister_id, proposal_id),
Expand Down
2 changes: 1 addition & 1 deletion backend/canisters/proposals_bot/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use types::{
};
use utils::env::Environment;

mod governance_clients;
mod guards;
mod jobs;
mod lifecycle;
mod memory;
mod model;
mod proposals;
mod queries;
mod timer_job_types;
mod updates;
Expand Down
22 changes: 22 additions & 0 deletions backend/canisters/proposals_bot/impl/src/proposals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use nns_governance_canister::types::ProposalInfo;
use sns_governance_canister::types::ProposalData;
use types::{Proposal, ProposalId};

pub const REWARD_STATUS_ACCEPT_VOTES: i32 = 1;
pub const REWARD_STATUS_READY_TO_SETTLE: i32 = 2;

pub trait RawProposal: TryInto<Proposal, Error = String> {
fn id(&self) -> ProposalId;
}

impl RawProposal for ProposalData {
fn id(&self) -> ProposalId {
self.id.as_ref().map_or(ProposalId::default(), |p| p.id)
}
}

impl RawProposal for ProposalInfo {
fn id(&self) -> ProposalId {
self.id.as_ref().map_or(ProposalId::default(), |p| p.id)
}
}
3 changes: 3 additions & 0 deletions backend/external_canisters/nns_governance/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ edition = "2021"

[dependencies]
candid = { workspace = true }
canister_time = { path = "../../../libraries/canister_time" }
ic-ledger-types = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
types = { path = "../../../libraries/types" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub type Args = crate::types::ListProposalInfo;
pub type Response = crate::types::ListProposalInfoResponse;
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod list_neurons;
pub mod list_proposals;
Loading
Loading