Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Member Functions | Public Attributes | List of all members
zeth.core.utils.EtherValue Class Reference

Public Member Functions

def __init__ (self, Union[str, int, float] val, str units='ether')
 
str __str__ (self)
 
EtherValue __add__ (self, EtherValue other)
 
EtherValue __sub__ (self, EtherValue other)
 
bool __eq__ (self, Any other)
 
bool __ne__ (self, Any other)
 
bool __lt__ (self, EtherValue other)
 
bool __le__ (self, EtherValue other)
 
bool __gt__ (self, EtherValue other)
 
bool __ge__ (self, EtherValue other)
 
bool __bool__ (self)
 
str ether (self)
 

Public Attributes

 wei
 

Detailed Description

Representation of some amount of Ether (or any token) in terms of Wei.
Disambiguates Ether values from other units such as zeth_units.

Definition at line 46 of file utils.py.

Constructor & Destructor Documentation

◆ __init__()

def zeth.core.utils.EtherValue.__init__ (   self,
Union[str, int, float]  val,
str   units = 'ether' 
)

Definition at line 51 of file utils.py.

51  def __init__(self, val: Union[str, int, float], units: str = 'ether'):
52  self.wei = Web3.toWei(val, units)
53 

Member Function Documentation

◆ __add__()

EtherValue zeth.core.utils.EtherValue.__add__ (   self,
EtherValue  other 
)

Definition at line 57 of file utils.py.

57  def __add__(self, other: EtherValue) -> EtherValue:
58  return EtherValue(self.wei + other.wei, 'wei')
59 

◆ __bool__()

bool zeth.core.utils.EtherValue.__bool__ (   self)

Definition at line 83 of file utils.py.

83  def __bool__(self) -> bool:
84  return int(self.wei) != 0
85 

◆ __eq__()

bool zeth.core.utils.EtherValue.__eq__ (   self,
Any  other 
)

Definition at line 63 of file utils.py.

63  def __eq__(self, other: Any) -> bool:
64  if not isinstance(other, EtherValue):
65  return False
66  return self.wei == other.wei
67 
Here is the caller graph for this function:

◆ __ge__()

bool zeth.core.utils.EtherValue.__ge__ (   self,
EtherValue  other 
)

Definition at line 80 of file utils.py.

80  def __ge__(self, other: EtherValue) -> bool:
81  return self.wei >= other.wei
82 

◆ __gt__()

bool zeth.core.utils.EtherValue.__gt__ (   self,
EtherValue  other 
)

Definition at line 77 of file utils.py.

77  def __gt__(self, other: EtherValue) -> bool:
78  return self.wei > other.wei
79 

◆ __le__()

bool zeth.core.utils.EtherValue.__le__ (   self,
EtherValue  other 
)

Definition at line 74 of file utils.py.

74  def __le__(self, other: EtherValue) -> bool:
75  return self.wei <= other.wei
76 

◆ __lt__()

bool zeth.core.utils.EtherValue.__lt__ (   self,
EtherValue  other 
)

Definition at line 71 of file utils.py.

71  def __lt__(self, other: EtherValue) -> bool:
72  return self.wei < other.wei
73 

◆ __ne__()

bool zeth.core.utils.EtherValue.__ne__ (   self,
Any  other 
)

Definition at line 68 of file utils.py.

68  def __ne__(self, other: Any) -> bool:
69  return not self.__eq__(other)
70 
Here is the call graph for this function:

◆ __str__()

str zeth.core.utils.EtherValue.__str__ (   self)

Definition at line 54 of file utils.py.

54  def __str__(self) -> str:
55  return str(self.wei)
56 

◆ __sub__()

EtherValue zeth.core.utils.EtherValue.__sub__ (   self,
EtherValue  other 
)

Definition at line 60 of file utils.py.

60  def __sub__(self, other: EtherValue) -> EtherValue:
61  return EtherValue(self.wei - other.wei, 'wei')
62 

◆ ether()

str zeth.core.utils.EtherValue.ether (   self)

Definition at line 86 of file utils.py.

86  def ether(self) -> str:
87  return str(Web3.fromWei(self.wei, 'ether'))
88 
89 

Member Data Documentation

◆ wei

zeth.core.utils.EtherValue.wei

Definition at line 52 of file utils.py.


The documentation for this class was generated from the following file:
test_commands.mock.str
str
Definition: mock.py:18
zeth.cli.zeth_deploy.int
int
Definition: zeth_deploy.py:27