2024-08-06 20:50:11 +00:00
|
|
|
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,
|
2024-08-28 23:45:09 +00:00
|
|
|
pub contract_manifest: PathBuf,
|
2024-08-06 20:50:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ContractDeployRequest> for Request {
|
|
|
|
fn from(request: ContractDeployRequest) -> Self {
|
|
|
|
Self::ContractDeploy(request)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ContractDeployRequest {
|
|
|
|
pub fn checked_init(init_msg: String) -> Result<GenericQuartzInit, Error> {
|
|
|
|
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<String, serde_json::Value>,
|
|
|
|
}
|