@@ -878,7 +878,52 @@ mod tests {
878
878
879
879
#[ test]
880
880
#[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test:: wasm_bindgen_test) ]
881
- fn test_message_hash_v1_with_enum ( ) {
881
+ fn test_message_hash_v1_with_simple_enum ( ) {
882
+ let raw = r###"{
883
+ "types": {
884
+ "StarknetDomain": [
885
+ { "name": "name", "type": "shortstring" },
886
+ { "name": "version", "type": "shortstring" },
887
+ { "name": "chainId", "type": "shortstring" },
888
+ { "name": "revision", "type": "shortstring" }
889
+ ],
890
+ "Example Message": [
891
+ { "name": "Value", "type": "enum", "contains": "My Enum" }
892
+ ],
893
+ "My Enum": [
894
+ { "name": "Variant 1", "type": "()" },
895
+ { "name": "Variant 2", "type": "(string)" },
896
+ { "name": "Variant 3", "type": "(u128)" }
897
+ ]
898
+ },
899
+ "primaryType": "Example Message",
900
+ "domain": {
901
+ "name": "Starknet Example",
902
+ "version": "1",
903
+ "chainId": "SN_MAIN",
904
+ "revision": "1"
905
+ },
906
+ "message": {
907
+ "Value": {
908
+ "Variant 2": ["tuple element"]
909
+ }
910
+ }
911
+ }"### ;
912
+
913
+ let data = serde_json:: from_str :: < TypedData > ( raw) . unwrap ( ) ;
914
+
915
+ assert_eq ! (
916
+ data. message_hash( Felt :: from_hex_unchecked( "0x1234" ) )
917
+ . unwrap( ) ,
918
+ Felt :: from_hex_unchecked(
919
+ "0x06143075810eaff76810682ad4db8c97ba0fd2c80d5f12d3e7e3a9c127e6f0f3"
920
+ )
921
+ ) ;
922
+ }
923
+
924
+ #[ test]
925
+ #[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test:: wasm_bindgen_test) ]
926
+ fn test_message_hash_v1_with_enum_nested ( ) {
882
927
let raw = r###"{
883
928
"types": {
884
929
"StarknetDomain": [
0 commit comments