File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
sol-types/tests/macros/sol
syn-solidity/src/variable Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -63,3 +63,30 @@ fn encode_data_nesting() {
6363 "25c3d40a39e639a4d0b6e4d2ace5e1281e039c88494d97d8d08f99a6ea75d775" . parse:: <B256 >( ) . unwrap( )
6464 )
6565}
66+
67+ #[ test]
68+ fn test_eip712_interface_prefix ( ) {
69+ sol ! {
70+ interface IParentInterfaceA {
71+ struct ParentStructA {
72+ uint256 numberA;
73+ }
74+ }
75+
76+ interface IParentInterfaceB {
77+ struct ParentStructB {
78+ uint256 numberB;
79+ }
80+ }
81+
82+ struct MyStruct {
83+ IParentInterfaceA . ParentStructA structA;
84+ IParentInterfaceB . ParentStructB structB;
85+ }
86+ }
87+
88+ assert_eq ! (
89+ MyStruct :: eip712_encode_type( ) ,
90+ "MyStruct(ParentStructA structA,ParentStructB structB)ParentStructA(uint256 numberA)ParentStructB(uint256 numberB)"
91+ ) ;
92+ }
Original file line number Diff line number Diff line change @@ -78,7 +78,15 @@ impl VariableDeclaration {
7878
7979 /// Formats `self` as an EIP-712 field: `<ty> <name>`
8080 pub fn fmt_eip712 ( & self , f : & mut impl Write ) -> fmt:: Result {
81- write ! ( f, "{}" , self . ty) ?;
81+ // According to EIP-712, type strings should only contain struct name, not interface prefix
82+ match & self . ty {
83+ crate :: Type :: Custom ( path) => {
84+ write ! ( f, "{}" , path. last( ) ) ?;
85+ }
86+ _ => {
87+ write ! ( f, "{}" , self . ty) ?;
88+ }
89+ }
8290 if let Some ( name) = & self . name {
8391 write ! ( f, " {name}" ) ?;
8492 }
You can’t perform that action at this time.
0 commit comments