
    ;j4                     l   d dl Z d dl mZ d dlmZ ddlmZmZ ddlmZ  G d d          Zd Z	d	d
z  dz
  Z
eeeee j        f         Zdede j        deee j        f         fdZdede j        defdZdededeee j        f         fdZdededefdZdededeee j        f         fdZdededefdZdS )    N)localcontext)Union   )
is_integer	is_string)unitsc                      e Zd Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z	 eed                   Z
 eed                   Z eed                   Z eed	                   Z eed
                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   Z eed                   ZdS )denomsweikweibabbage
femtoethermweilovelace	picoethergweishannon	nanoethernanoszabo
microethermicrofinney
milliethermillietherkethergrandmethergethertetherN)__name__
__module____qualname__intr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!        k/home/agent/projects/CryptoTradingBot/Crypto_Agent/.venv/lib/python3.11/site-packages/eth_utils/currency.pyr
   r
      s       
#eEl

C3uV}Dc%	"##GU<())J3uV}Ds5$%%HE+&''I3uV}Dc%	"##GE+&''I3uV}DCgEU<())JCgESx!!FU<())JCgECgESx!!FCgESx!!FSx!!FSx!!FFFr'   r
         number
unit_valuereturnc                     | dk    rdS | t           k     s| t          k    rt          d          t                      5 }d|_        t          j        | |          }||z  }d d d            n# 1 swxY w Y   |S )Nr   z&value must be between 0 and 2**256 - 1  valuecontext)MIN_WEIMAX_WEI
ValueErrorr   precdecimalDecimal)r+   r,   ctxd_numberresult_values        r(   	_from_weir<   2   s    {{q6G++ABBB	 -3?===*,- - - - - - - - - - - - - - -
 s   #A++A/2A/c                 ~   t          |           st          |           rt          j        |           }ndt	          | t
                    r#t          j        t          |                     }n,t	          | t          j                  r| }nt          d          |t          j        d          k    rdS t          |           }|dk     r}d|v ryt                      5 }t          |          |
                    d          z
  dz
  }||_        t          j        | |          d|z  z  }d d d            n# 1 swxY w Y   |d|z  z  }t                      5 }d|_        t          j        ||          |z  }d d d            n# 1 swxY w Y   |t          k     s|t          k    rt          d	          t          |          S )
Nr1   z:Unsupported type. Must be one of integer, float, or stringr   r   .r0   
   r/   z4Resulting wei value must be between 0 and 2**256 - 1)r   r   r7   r8   
isinstancefloatstr	TypeErrorr   lenindexr6   r3   r4   r5   r%   )r+   r,   r:   s_numberr9   
multiplierr;   s          r(   _to_weirI   A   sF   & VYv.. V?000	FE	"	" V?V555	FGO	,	, VTUUU7?1%%%%q6{{H!||x^^ 	SsX)<)<<q@J!CHVSAAAB
NRH	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	b*n$
	 Q3XsCCCjPQ Q Q Q Q Q Q Q Q Q Q Q Q Q Q g!7!7OPPP|s%   AD22D69D6!F  FFunitc                    |                                 t          vr6t          dd                    t          j                                         t          |                                          }t          | |          S )zH
    Takes a number of wei and converts it to any other ether unit.
    Unknown unit. Must be one of /)lowerr   r5   joinkeysr<   r+   rJ   r,   s      r(   from_weirR   a   sb     zz||5  Q%*,,9O9OQQRRRtzz||$JVZ(((r'   c                    |                                 t          vr6t          dd                    t          j                                         t          |                                          }t          | |          S )z:
    Takes a number of a unit and converts it to wei.
    rL   rM   )rN   r   r5   rO   rP   rI   rQ   s      r(   to_weirT   m   sb     zz||5  Q%*,,9O9OQQRRRtzz||$J6:&&&r'   decimalsc                 v    t          j        d          t          j        |          z  }t          | |          S )zg
    Takes a number of wei and converts it to a decimal with the specified
    number of decimals.
    r@   r>   )r7   r8   r<   r+   rU   r,   s      r(   from_wei_decimalsrX   y   s5    
 $$h(G(G(GGJVZ(((r'   c                 v    t          j        d          t          j        |          z  }t          | |          S )zd
    Takes a number of a unit and converts it to wei with the specified
    number of decimals.
    r@   r>   )r7   r8   rI   rW   s      r(   to_wei_decimalsrZ      s5    
 $$h(G(G(GGJ6:&&&r'   )r7   r   typingr   typesr   r   r   r
   r3   r4   r%   rB   rC   r8   _NumberTyper<   rI   rR   rT   rX   rZ   r&   r'   r(   <module>r^      s
                         
" " " " " " " "4 
S&1*CW_45c w 5goAU;V    K W_     @	)S 	) 	)c7?.B(C 	) 	) 	) 	)	'; 	'c 	'c 	' 	' 	' 	')c )S )U3;O5P ) ) ) )'K '3 '3 ' ' ' ' ' 'r'   