use std::{collections::HashMap, path::PathBuf}; use serde::{Deserialize, Serialize}; use crate::{error::Error, request::Request}; #[derive(Clone, Debug)] pub struct ContractDeployRequest { pub init_msg: serde_json::Value, pub label: String, pub contract_manifest: PathBuf, } impl From for Request { fn from(request: ContractDeployRequest) -> Self { Self::ContractDeploy(request) } } impl ContractDeployRequest { pub fn checked_init(init_msg: String) -> Result { let parsed: GenericQuartzInit = serde_json::from_str(&init_msg).map_err(|_| { Error::GenericErr("Init message doesn't contain mandatory quartz field.".to_string()) })?; Ok(parsed) } } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GenericQuartzInit { pub quartz: serde_json::Value, #[serde(flatten)] extra: HashMap, }