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

Revert "improve governance apis" #195

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,3 @@ rand = "0.8.5"
bigdecimal = "0.4.5"
strum = "0.26.3"
strum_macros = "0.26.3"
sha256 = "1.5.0"
14 changes: 0 additions & 14 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Proposal'
/api/v1/gov/proposal/{id}/data:
get:
summary: Get a governance proposal data by proposal id
parameters:
- in: path
name: id
schema:
type: integer
minimum: 0
required: true
description: Proposal id
responses:
'200':
description: A Governance proposal data.
/api/v1/gov/proposal/{id}/votes:
get:
summary: Get all the votes for a governance proposal
Expand Down
1 change: 0 additions & 1 deletion webserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ shared.workspace = true
strum.workspace = true
strum_macros.workspace = true
axum-prometheus = "0.7.0"
sha256.workspace = true

[build-dependencies]
vergen = { version = "8.0.0", features = ["build", "git", "gitcl"] }
4 changes: 0 additions & 4 deletions webserver/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ impl ApplicationServer {
"/gov/proposal/:id",
get(gov_handlers::get_governance_proposal_by_id),
)
.route(
"/gov/proposal/:id/data",
get(gov_handlers::get_proposal_data_by_proposal_id),
)
.route(
"/gov/proposal/:id/votes",
get(gov_handlers::get_governance_proposal_votes),
Expand Down
3 changes: 0 additions & 3 deletions webserver/src/error/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ pub enum GovernanceError {
TooShortPattern(usize),
#[error("Proposal {0} not found")]
NotFound(u64),
#[error("Proposal {0} has no associated data")]
DataNotFound(u64),
#[error("Database error: {0}")]
Database(String),
#[error("Unknown error: {0}")]
Expand All @@ -23,7 +21,6 @@ impl IntoResponse for GovernanceError {
let status_code = match self {
GovernanceError::TooShortPattern(_) => StatusCode::BAD_REQUEST,
GovernanceError::NotFound(_) => StatusCode::NOT_FOUND,
GovernanceError::DataNotFound(_) => StatusCode::NOT_FOUND,
GovernanceError::Unknown(_) | GovernanceError::Database(_) => {
StatusCode::INTERNAL_SERVER_ERROR
}
Expand Down
19 changes: 0 additions & 19 deletions webserver/src/handler/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,6 @@ pub async fn get_governance_proposal_by_id(
}
}

#[debug_handler]
pub async fn get_proposal_data_by_proposal_id(
_headers: HeaderMap,
Path(proposal_id): Path<u64>,
State(state): State<CommonState>,
) -> Result<String, ApiError> {
let proposal = state.gov_service.find_proposal_data(proposal_id).await?;

if let Some(data) = proposal {
if let Some(data) = data {
Ok(data)
} else {
Err(GovernanceError::DataNotFound(proposal_id).into())
}
} else {
Err(GovernanceError::NotFound(proposal_id).into())
}
}

#[debug_handler]
pub async fn get_governance_proposal_votes(
_headers: HeaderMap,
Expand Down
8 changes: 1 addition & 7 deletions webserver/src/response/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use orm::governance_proposal::{
};
use orm::governance_votes::{GovernanceProposalVoteDb, GovernanceVoteKindDb};
use serde::{Deserialize, Serialize};
use sha256::digest;

use super::utils::{epoch_progress, time_between_epochs};

Expand Down Expand Up @@ -183,12 +182,7 @@ impl Proposal {
TallyType::LessOneHalfOverOneThirdNay
}
},
data: match value.kind {
GovernanceProposalKindDb::DefaultWithWasm => {
value.data.map(digest)
}
_ => value.data,
},
data: value.data,
author: value.author,
start_epoch: value.start_epoch.to_string(),
end_epoch: value.end_epoch.to_string(),
Expand Down
13 changes: 0 additions & 13 deletions webserver/src/service/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ impl GovernanceService {
))
}

pub async fn find_proposal_data(
&self,
proposal_id: u64,
) -> Result<Option<Option<String>>, GovernanceError> {
let db_proposal = self
.governance_repo
.find_governance_proposals_by_id(proposal_id as i32)
.await
.map_err(GovernanceError::Database)?;

Ok(db_proposal.map(|proposal| proposal.data))
}

pub async fn find_all_governance_proposals(
&self,
status: Option<ProposalStatus>,
Expand Down
Loading