feat: implement Artifact for serde_json (#885)
This commit is contained in:
parent
6453b1e833
commit
67271eba68
|
@ -565,3 +565,16 @@ impl ArtifactOutput for MinimalCombinedArtifactsHardhatFallback {
|
||||||
MinimalCombinedArtifacts::contract_to_artifact(file, name, contract)
|
MinimalCombinedArtifacts::contract_to_artifact(file, name, contract)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn is_artifact() {
|
||||||
|
fn assert_artifact<T: Artifact>() {}
|
||||||
|
|
||||||
|
assert_artifact::<CompactContractBytecode>();
|
||||||
|
assert_artifact::<serde_json::Value>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -801,7 +801,7 @@ impl From<Contract> for ContractBytecode {
|
||||||
///
|
///
|
||||||
/// Unlike `CompactContractSome` which contains the `BytecodeObject`, this holds the whole
|
/// Unlike `CompactContractSome` which contains the `BytecodeObject`, this holds the whole
|
||||||
/// `Bytecode` object.
|
/// `Bytecode` object.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
|
||||||
pub struct CompactContractBytecode {
|
pub struct CompactContractBytecode {
|
||||||
/// The Ethereum Contract ABI. If empty, it is represented as an empty
|
/// The Ethereum Contract ABI. If empty, it is represented as an empty
|
||||||
/// array. See https://docs.soliditylang.org/en/develop/abi-spec.html
|
/// array. See https://docs.soliditylang.org/en/develop/abi-spec.html
|
||||||
|
@ -1002,6 +1002,12 @@ impl From<serde_json::Value> for CompactContract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<serde_json::Value> for CompactContractBytecode {
|
||||||
|
fn from(val: serde_json::Value) -> Self {
|
||||||
|
serde_json::from_value(val).unwrap_or_default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<ContractBytecode> for CompactContract {
|
impl From<ContractBytecode> for CompactContract {
|
||||||
fn from(c: ContractBytecode) -> Self {
|
fn from(c: ContractBytecode) -> Self {
|
||||||
let ContractBytecode { abi, bytecode, deployed_bytecode } = c;
|
let ContractBytecode { abi, bytecode, deployed_bytecode } = c;
|
||||||
|
|
Loading…
Reference in New Issue