2024-08-06 20:50:11 +00:00
|
|
|
use std::{collections::HashMap, path::PathBuf};
|
|
|
|
|
2024-10-08 08:53:49 +00:00
|
|
|
use color_eyre::{eyre::Context, Result};
|
2024-08-06 20:50:11 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2024-10-08 08:53:49 +00:00
|
|
|
use crate::request::Request;
|
2024-08-06 20:50:11 +00:00
|
|
|
|
|
|
|
#[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 {
|
2024-10-08 08:53:49 +00:00
|
|
|
pub fn checked_init(init_msg: String) -> Result<GenericQuartzInit> {
|
|
|
|
let parsed: GenericQuartzInit = serde_json::from_str(&init_msg)
|
|
|
|
.wrap_err("Init message doesn't contain mandatory quartz field")?;
|
2024-08-06 20:50:11 +00:00
|
|
|
|
|
|
|
Ok(parsed)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
|
|
|
pub struct GenericQuartzInit {
|
|
|
|
pub quartz: serde_json::Value,
|
|
|
|
#[serde(flatten)]
|
|
|
|
extra: HashMap<String, serde_json::Value>,
|
|
|
|
}
|