File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,9 +29,17 @@ class ProjectPublic(CamelModel):
2929class AbiPublic (CamelModel ):
3030 model_config = ConfigDict (from_attributes = True )
3131
32+ abi_hash : str | None = None
3233 abi_json : list [dict ] | dict | None
3334 modified : datetime
3435
36+ @field_validator ("abi_hash" , mode = "before" )
37+ @classmethod
38+ def bytes_to_hex (cls , v : bytes | str | None ) -> str | None :
39+ if isinstance (v , bytes ):
40+ return "0x" + v .hex ()
41+ return v
42+
3543
3644class ContractsPublic (CamelModel ):
3745 model_config = ConfigDict (from_attributes = True )
Original file line number Diff line number Diff line change @@ -409,7 +409,7 @@ async def test_abi_hash_generated_column(self):
409409 await abi .create ()
410410
411411 self .assertIsNotNone (abi .abi_hash )
412- assert abi .abi_hash is not None # narrow type for len()
412+ assert abi .abi_hash is not None
413413 self .assertEqual (len (abi .abi_hash ), 32 )
414414 first_hash = abi .abi_hash
415415
Original file line number Diff line number Diff line change @@ -79,6 +79,8 @@ async def test_view_contracts(self):
7979 self .assertEqual (results [0 ]["address" ], address_expected )
8080 self .assertEqual (results [0 ]["abi" ]["abiJson" ], mock_abi_json )
8181 self .assertEqual (results [0 ]["abi" ]["modified" ], datetime_to_str (abi .modified ))
82+ assert abi .abi_hash is not None
83+ self .assertEqual (results [0 ]["abi" ]["abiHash" ], "0x" + abi .abi_hash .hex ())
8284 self .assertEqual (results [0 ]["displayName" ], None )
8385 self .assertEqual (results [0 ]["chainId" ], 1 )
8486 self .assertEqual (results [0 ]["project" ], None )
You can’t perform that action at this time.
0 commit comments