Commit 81df1a2f authored by Moul's avatar Moul

[enh] Transaction Unlock parameters: add __eq__() and __hash__() methods

parent fc30ac27
...@@ -230,6 +230,19 @@ class SIGParameter: ...@@ -230,6 +230,19 @@ class SIGParameter:
""" """
self.index = index self.index = index
def __eq__(self, other: Any) -> bool:
"""
Check SIGParameter instances equality
"""
if not isinstance(other, SIGParameter):
return NotImplemented
return self.index == other.index
def __hash__(self) -> int:
return hash((self.index))
@classmethod @classmethod
def from_parameter(cls: Type[SIGParameterType], parameter: str) -> Optional[SIGParameterType]: def from_parameter(cls: Type[SIGParameterType], parameter: str) -> Optional[SIGParameterType]:
""" """
...@@ -272,6 +285,19 @@ class XHXParameter: ...@@ -272,6 +285,19 @@ class XHXParameter:
""" """
self.integer = integer self.integer = integer
def __eq__(self, other: Any) -> bool:
"""
Check XHXParameter instances equality
"""
if not isinstance(other, XHXParameter):
return NotImplemented
return self.integer == other.integer
def __hash__(self) -> int:
return hash((self.integer))
@classmethod @classmethod
def from_parameter(cls: Type[XHXParameterType], parameter: str) -> Optional[XHXParameterType]: def from_parameter(cls: Type[XHXParameterType], parameter: str) -> Optional[XHXParameterType]:
""" """
...@@ -348,6 +374,24 @@ class Unlock: ...@@ -348,6 +374,24 @@ class Unlock:
self.index = index self.index = index
self.parameters = parameters self.parameters = parameters
def __eq__(self, other: Any) -> bool:
"""
Check Unlock instances equality
"""
if not isinstance(other, Unlock):
return NotImplemented
params_equals = True
for spar, opar in zip(self.parameters, other.parameters):
if spar != opar:
params_equals = False
return self.index == other.index and params_equals
def __hash__(self) -> int:
return hash((self.index, self.parameters))
@classmethod @classmethod
def from_inline(cls: Type[UnlockType], inline: str) -> UnlockType: def from_inline(cls: Type[UnlockType], inline: str) -> UnlockType:
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment