rain_metadata/solc/
mod.rs1use serde_json::Value;
2use strum::EnumString;
3use crate::error::Error;
4
5#[derive(Copy, Clone, EnumString, strum::Display)]
7#[strum(serialize_all = "kebab-case")]
8pub enum ArtifactComponent {
9 Abi,
10 Bytecode,
11 DeployedBytecode,
12}
13
14pub fn extract_artifact_component_json(
20 component: ArtifactComponent,
21 data: &[u8],
22) -> Result<Value, Error> {
23 let json = serde_json::from_str::<Value>(std::str::from_utf8(data)?)?;
24 match component {
25 ArtifactComponent::Abi => Ok(json["abi"].clone()),
26 ArtifactComponent::Bytecode => Ok(json["bytecode"].clone()),
27 ArtifactComponent::DeployedBytecode => Ok(json["deployedBytecode"].clone()),
28 }
29}