diff --git a/crates/context/src/lib.rs b/crates/context/src/lib.rs index c322c4487..61c77ef37 100644 --- a/crates/context/src/lib.rs +++ b/crates/context/src/lib.rs @@ -1421,4 +1421,15 @@ impl ContextManager { .map_err(|err| eyre::eyre!("Failed to fetch context storage entries: {}", err))?; Ok(response) } + + pub async fn get_proxy_id(&self, context_id: ContextId) -> EyreResult { + let handle = self.store.handle(); + let Some(context_config) = handle.get(&ContextConfigKey::new(context_id))? else { + bail!("Context not found"); + }; + + let proxy_contract = context_config.proxy_contract.as_ref().into(); + + Ok(proxy_contract) + } } diff --git a/crates/server/src/admin/handlers/proposals.rs b/crates/server/src/admin/handlers/proposals.rs index a8e8e4e7f..2edec97b6 100644 --- a/crates/server/src/admin/handlers/proposals.rs +++ b/crates/server/src/admin/handlers/proposals.rs @@ -110,6 +110,12 @@ pub struct GetProposalResponse { pub data: ProposalConfig, } +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct GetProxyContractResponse { + pub data: String, +} + #[derive(Copy, Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct GetProposalsRequest { @@ -181,6 +187,21 @@ pub async fn get_proposal_handler( } } +pub async fn get_proxy_contract_handler( + Path(context_id): Path, + Extension(state): Extension>, +) -> impl IntoResponse { + match state.ctx_manager.get_proxy_id(context_id).await { + Ok(proxy_contract) => ApiResponse { + payload: GetProxyContractResponse { + data: proxy_contract, + }, + } + .into_response(), + Err(err) => parse_api_error(err).into_response(), + } +} + pub async fn get_context_value_handler( Path(context_id): Path, Extension(state): Extension>, diff --git a/crates/server/src/admin/service.rs b/crates/server/src/admin/service.rs index f31e31d1a..567df78e6 100644 --- a/crates/server/src/admin/service.rs +++ b/crates/server/src/admin/service.rs @@ -22,7 +22,7 @@ use super::handlers::did::delete_did_handler; use super::handlers::proposals::{ get_context_storage_entries_handler, get_context_value_handler, get_number_of_active_proposals_handler, get_number_of_proposal_approvals_handler, - get_proposal_approvers_handler, get_proposal_handler, get_proposals_handler, + get_proposal_approvers_handler, get_proposal_handler, get_proposals_handler, get_proxy_contract_handler, }; use super::storage::ssl::get_ssl; use crate::admin::handlers::add_client_key::{ @@ -173,6 +173,10 @@ pub(crate) fn setup( .route( "/contexts/:context_id/proposals/context-storage-entries", post(get_context_storage_entries_handler), + ) + .route( + "/contexts/:context_id/proxy-contract", + get(get_proxy_contract_handler), ); let dev_router = Router::new()