@@ -19,14 +19,25 @@ def encode_value(self, value) -> bytes:
1919 """
2020 pass
2121
22+ def __eq__ (self , other ):
23+ self_type = getattr (self , 'type_name' )
24+ other_type = getattr (other , 'type_name' )
25+
26+ return self_type is not None and self_type == other_type
27+
28+ def __hash__ (self ):
29+ return hash (self .type_name )
30+
2231
2332class Array (EIP712Type ):
2433 def __init__ (self , member_type : Union [EIP712Type , Type [EIP712Type ]], fixed_length : int = 0 ):
34+ fixed_length = int (fixed_length )
2535 if fixed_length == 0 :
2636 type_name = f'{ member_type .type_name } []'
2737 else :
2838 type_name = f'{ member_type .type_name } [{ fixed_length } ]'
2939 self .member_type = member_type
40+ self .fixed_length = fixed_length
3041 super (Array , self ).__init__ (type_name )
3142
3243 def encode_value (self , value ):
@@ -65,6 +76,7 @@ def encode_value(self, value):
6576
6677class Bytes (EIP712Type ):
6778 def __init__ (self , length : int = 0 ):
79+ length = int (length )
6880 if length == 0 :
6981 # Special case: Length of 0 means a dynamic bytes type
7082 type_name = 'bytes'
@@ -87,6 +99,7 @@ def encode_value(self, value):
8799
88100class Int (EIP712Type ):
89101 def __init__ (self , length : int ):
102+ length = int (length )
90103 if length < 8 or length > 256 or length % 8 != 0 :
91104 raise ValueError (f'Int length must be a multiple of 8, between 8 and 256. Got: { length } ' )
92105 self .length = length
@@ -107,6 +120,7 @@ def encode_value(self, value):
107120
108121class Uint (EIP712Type ):
109122 def __init__ (self , length : int ):
123+ length = int (length )
110124 if length < 8 or length > 256 or length % 8 != 0 :
111125 raise ValueError (f'Uint length must be a multiple of 8, between 8 and 256. Got: { length } ' )
112126 self .length = length
@@ -145,13 +159,13 @@ def from_solidity_type(solidity_type: str):
145159
146160 base_type = solidity_type_map [type_name ]
147161 if opt_len :
148- type_instance = base_type (opt_len )
162+ type_instance = base_type (int ( opt_len ) )
149163 else :
150164 type_instance = base_type ()
151165
152166 if is_array :
153167 if array_len :
154- result = Array (type_instance , array_len )
168+ result = Array (type_instance , int ( array_len ) )
155169 else :
156170 result = Array (type_instance )
157171 return result
0 commit comments