Skip to content

Commit 4b0df10

Browse files
committed
support eip712 strings
1 parent c39ccf5 commit 4b0df10

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cheatcodes/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ eyre.workspace = true
4141
itertools.workspace = true
4242
jsonpath_lib.workspace = true
4343
revm.workspace = true
44-
serde.workspace = true
4544
serde_json.workspace = true
4645
base64.workspace = true
4746
toml = { workspace = true, features = ["preserve_order"] }

crates/cheatcodes/src/json.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Implementations of [`Json`](spec::Group::Json) cheatcodes.
22
33
use crate::{string, Cheatcode, Cheatcodes, Result, Vm::*};
4-
use alloy_dyn_abi::{parser::RootType, DynSolType, DynSolValue, Resolver, Specifier};
4+
use alloy_dyn_abi::{eip712_parser::EncodeType, DynSolType, DynSolValue, Resolver};
55
use alloy_primitives::{hex, Address, B256, I256};
66
use alloy_sol_types::SolValue;
77
use foundry_common::fs;
@@ -576,18 +576,15 @@ fn resolve_type(type_description: &str) -> Result<DynSolType> {
576576
return Ok(ty);
577577
};
578578

579-
let struct_schema: StructSchema = serde_json::from_str(type_description)?;
580-
Ok(struct_schema.resolve()?)
581-
}
579+
if let Ok(encoded) = EncodeType::parse(type_description) {
580+
let main_type = encoded.types[0].type_name;
581+
let mut resolver = Resolver::default();
582+
for t in encoded.types {
583+
resolver.ingest(t.to_owned());
584+
}
582585

583-
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize)]
584-
struct StructSchema {
585-
resolver: Resolver,
586-
type_name: String,
587-
}
586+
return Ok(resolver.resolve(main_type)?)
587+
};
588588

589-
impl StructSchema {
590-
fn resolve(&self) -> alloy_dyn_abi::Result<DynSolType> {
591-
self.resolver.resolve(self.type_name.as_str())
592-
}
589+
bail!("type description should be a valid Solidity type or a EIP712 `encodeType` string")
593590
}

0 commit comments

Comments
 (0)