use serde_json::Value;
use strum::EnumString;
use crate::error::Error;
#[derive(Copy, Clone, EnumString, strum::Display)]
#[strum(serialize_all = "kebab-case")]
pub enum ArtifactComponent {
Abi,
Bytecode,
DeployedBytecode,
}
pub fn extract_artifact_component_json(
component: ArtifactComponent,
data: &[u8],
) -> Result<Value, Error> {
let json = serde_json::from_str::<Value>(std::str::from_utf8(data)?)?;
match component {
ArtifactComponent::Abi => Ok(json["abi"].clone()),
ArtifactComponent::Bytecode => Ok(json["bytecode"].clone()),
ArtifactComponent::DeployedBytecode => Ok(json["deployedBytecode"].clone()),
}
}