Skip to content

Commit

Permalink
refactor(nns): Use governance_api instead of governance types in entr…
Browse files Browse the repository at this point in the history
…ypoint in governance (#457)

As a further step in reducing direct dependencies on the nns governance
crate, this reverses the direction of API dependencies so that the API
crate defines the types that define the API, and other crates can then
depend on the API crate instead of the governance canister crate and
library
  • Loading branch information
max-dfinity authored Jul 19, 2024
1 parent 1b9c124 commit d0a0cc7
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 62 deletions.
18 changes: 18 additions & 0 deletions rs/nns/governance/api/src/pb.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
use crate::pb::v1::{governance_error::ErrorType, GovernanceError};

#[allow(clippy::all)]
#[path = "./ic_nns_governance.pb.v1.rs"]
pub mod v1;

impl GovernanceError {
pub fn new(error_type: ErrorType) -> Self {
Self {
error_type: error_type as i32,
..Default::default()
}
}

pub fn new_with_message(error_type: ErrorType, message: impl ToString) -> Self {
Self {
error_type: error_type as i32,
error_message: message.to_string(),
}
}
}
Loading

0 comments on commit d0a0cc7

Please sign in to comment.