2021-11-07 08:52:57 +00:00
|
|
|
use actix_web::{get, web, HttpResponse, Scope};
|
2021-04-09 00:22:17 +00:00
|
|
|
|
|
|
|
use crate::config::Config;
|
|
|
|
use crate::errors::HttpError;
|
2022-06-28 23:02:31 +00:00
|
|
|
use crate::ethereum::contracts::ContractSet;
|
2021-11-10 14:32:27 +00:00
|
|
|
use super::types::InstanceInfo;
|
2021-04-09 00:22:17 +00:00
|
|
|
|
2021-11-07 08:52:57 +00:00
|
|
|
#[get("")]
|
|
|
|
async fn instance_view(
|
|
|
|
config: web::Data<Config>,
|
2022-06-28 23:02:31 +00:00
|
|
|
maybe_blockchain: web::Data<Option<ContractSet>>,
|
2021-04-09 00:22:17 +00:00
|
|
|
) -> Result<HttpResponse, HttpError> {
|
2022-06-28 23:02:31 +00:00
|
|
|
let instance = InstanceInfo::create(
|
|
|
|
config.as_ref(),
|
|
|
|
maybe_blockchain.as_ref().as_ref(),
|
|
|
|
);
|
2021-04-09 00:22:17 +00:00
|
|
|
Ok(HttpResponse::Ok().json(instance))
|
|
|
|
}
|
2021-11-07 08:52:57 +00:00
|
|
|
|
|
|
|
pub fn instance_api_scope() -> Scope {
|
|
|
|
web::scope("/api/v1/instance")
|
|
|
|
.service(instance_view)
|
|
|
|
}
|