|
1 | 1 | //! Implementations of [`Json`](spec::Group::Json) cheatcodes.
|
2 | 2 |
|
3 | 3 | 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}; |
5 | 5 | use alloy_primitives::{hex, Address, B256, I256};
|
6 | 6 | use alloy_sol_types::SolValue;
|
7 | 7 | use foundry_common::fs;
|
@@ -576,18 +576,15 @@ fn resolve_type(type_description: &str) -> Result<DynSolType> {
|
576 | 576 | return Ok(ty);
|
577 | 577 | };
|
578 | 578 |
|
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 | + } |
582 | 585 |
|
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 | + }; |
588 | 588 |
|
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") |
593 | 590 | }
|
0 commit comments