Skip to content
Open
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
8 changes: 8 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"examples/token",
"examples/escrow",
"examples/vesting",
"examples/prediction-market",
]
resolver = "2"

Expand Down
19 changes: 16 additions & 3 deletions backend/src/api/handlers/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use serde::{Deserialize, Serialize};
use std::sync::Arc;

use crate::api::contracts::ApiResponse;
use crate::error::AppError;
use crate::services::compilation::{CompilationResult, CompilationService};
use crate::services::dependency_analyzer::{DependencyAnalysis, DependencyAnalyzer};
use crate::api::handlers::profiling::AppState;
use crate::error::AppError;
use crate::services::compilation::CompilationService;
use crate::services::contract_upgrade::{ContractUpgradeManager, ContractUpgradeRequest};
use crate::services::dependency_analyzer::DependencyAnalyzer;

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand All @@ -21,6 +22,18 @@ pub struct AnalyzeRequest {
pub cargo_toml: String,
}

/// POST /api/v1/contracts/upgrade-plan
pub async fn create_upgrade_plan(
Json(payload): Json<ContractUpgradeRequest>,
) -> Result<impl IntoResponse, AppError> {
let service = ContractUpgradeManager::new();
let result = service
.plan_upgrade(payload)
.map_err(|err| AppError::ValidationError(err.to_string()))?;

Ok(Json(ApiResponse::new(result)))
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NetworkConfig {
Expand Down
3 changes: 1 addition & 2 deletions backend/src/api/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
pub mod admin;
pub mod contracts;
pub mod dashboard;
pub mod errors;
pub mod profiling;
pub mod stellar;
pub mod ws;
pub mod contracts;
pub mod admin;
29 changes: 17 additions & 12 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,23 @@ async fn main() -> Result<(), anyhow::Error> {
"/analyze-dependencies",
post(backend::api::handlers::contracts::analyze_dependencies),
)
.with_state(state.clone()),
)
.route(
"/api/v1/networks",
get(backend::api::handlers::contracts::get_networks),
)
.route("/compile", post(backend::api::handlers::contracts::compile_contract))
.route("/analyze-dependencies", post(backend::api::handlers::contracts::analyze_dependencies))
.route("/compliance-check", post(backend::api::handlers::contracts::check_compliance))
.route("/logs", post(backend::api::handlers::contracts::log_contract_call))
.route("/logs", get(backend::api::handlers::contracts::get_contract_logs))
.route("/templates", get(backend::api::handlers::contracts::get_templates))
.route(
"/upgrade-plan",
post(backend::api::handlers::contracts::create_upgrade_plan),
)
.route(
"/compliance-check",
post(backend::api::handlers::contracts::check_compliance),
)
.route(
"/logs",
post(backend::api::handlers::contracts::log_contract_call)
.get(backend::api::handlers::contracts::get_contract_logs),
)
.route(
"/templates",
get(backend::api::handlers::contracts::get_templates),
)
.with_state(state.clone()),
)
.route(
Expand Down
Loading