From 67271eba68841ab2c3f1c95e7c3773149896dc3b Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 8 Feb 2022 23:48:53 +0100 Subject: [PATCH] feat: implement Artifact for serde_json (#885) --- ethers-solc/src/artifact_output.rs | 13 +++++++++++++ ethers-solc/src/artifacts.rs | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ethers-solc/src/artifact_output.rs b/ethers-solc/src/artifact_output.rs index 899f6c0e..d307050d 100644 --- a/ethers-solc/src/artifact_output.rs +++ b/ethers-solc/src/artifact_output.rs @@ -565,3 +565,16 @@ impl ArtifactOutput for MinimalCombinedArtifactsHardhatFallback { MinimalCombinedArtifacts::contract_to_artifact(file, name, contract) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn is_artifact() { + fn assert_artifact() {} + + assert_artifact::(); + assert_artifact::(); + } +} diff --git a/ethers-solc/src/artifacts.rs b/ethers-solc/src/artifacts.rs index 77f17437..1c500a68 100644 --- a/ethers-solc/src/artifacts.rs +++ b/ethers-solc/src/artifacts.rs @@ -801,7 +801,7 @@ impl From for ContractBytecode { /// /// Unlike `CompactContractSome` which contains the `BytecodeObject`, this holds the whole /// `Bytecode` object. -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] pub struct CompactContractBytecode { /// The Ethereum Contract ABI. If empty, it is represented as an empty /// array. See https://docs.soliditylang.org/en/develop/abi-spec.html @@ -1002,6 +1002,12 @@ impl From for CompactContract { } } +impl From for CompactContractBytecode { + fn from(val: serde_json::Value) -> Self { + serde_json::from_value(val).unwrap_or_default() + } +} + impl From for CompactContract { fn from(c: ContractBytecode) -> Self { let ContractBytecode { abi, bytecode, deployed_bytecode } = c;