Skip to content
Snippets Groups Projects

Changes to rm-refactor-overloaded-assets-operators

1 file
+ 2
9
Compare changes
  • Side-by-side
  • Inline
@@ -2,6 +2,7 @@ from __future__ import annotations
@@ -2,6 +2,7 @@ from __future__ import annotations
from copy import deepcopy
from copy import deepcopy
from decimal import Decimal
from decimal import Decimal
 
from functools import total_ordering
import operator
import operator
from typing import Final, Union
from typing import Final, Union
import warnings
import warnings
@@ -9,6 +10,7 @@ import warnings
@@ -9,6 +10,7 @@ import warnings
import abstractcp as acp
import abstractcp as acp
 
@total_ordering
class AssetBase(acp.Abstract):
class AssetBase(acp.Abstract):
token: str = acp.abstract_class_property(str)
token: str = acp.abstract_class_property(str)
precision: int = acp.abstract_class_property(int)
precision: int = acp.abstract_class_property(int)
@@ -114,15 +116,6 @@ class AssetBase(acp.Abstract):
@@ -114,15 +116,6 @@ class AssetBase(acp.Abstract):
raise TypeError(f"Can't compare assets with different tokens ({self.token} and {other.token}).")
raise TypeError(f"Can't compare assets with different tokens ({self.token} and {other.token}).")
return self.amount < other.amount
return self.amount < other.amount
def __le__(self, other: Union[str, dict, AssetBase]) -> bool:
return self == other or self < other
def __gt__(self, other: Union[str, dict, AssetBase]) -> bool:
return not self < other and self != other
def __ge__(self, other: Union[str, dict, AssetBase]) -> bool:
return self == other or self > other
def __eq__(self, other: Union[str, dict, AssetBase]) -> bool:
def __eq__(self, other: Union[str, dict, AssetBase]) -> bool:
if isinstance(other, dict):
if isinstance(other, dict):
other = self.__convert_asset_from_dict(other)
other = self.__convert_asset_from_dict(other)
Loading