-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: better compatibility with older AST (#175)
Closes #156 Closes foundry-rs/foundry#8520
- Loading branch information
Showing
4 changed files
with
46 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use super::ExternalInlineAssemblyReference; | ||
use serde::{Deserialize, Deserializer, Serialize}; | ||
use std::collections::BTreeMap; | ||
|
||
pub fn deserialize_external_assembly_references<'de, D>( | ||
deserializer: D, | ||
) -> Result<Vec<ExternalInlineAssemblyReference>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
#[derive(Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
enum ExternalReferencesHelper { | ||
Plain(Vec<ExternalInlineAssemblyReference>), | ||
/// Older solc versions produce external referrences as arrays of mappings {"variable" => | ||
/// external reference object}, so we have to handle this. | ||
Map(Vec<BTreeMap<String, ExternalInlineAssemblyReference>>), | ||
} | ||
|
||
ExternalReferencesHelper::deserialize(deserializer).map(|v| match v { | ||
ExternalReferencesHelper::Plain(vec) => vec, | ||
ExternalReferencesHelper::Map(vec) => { | ||
vec.into_iter().flat_map(|v| v.into_values()).collect() | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters