remove altcoins.eth.obj module

- ETHAmt -> mmgen.amt
- ETHNonce -> mmgen.obj
This commit is contained in:
The MMGen Project 2022-01-27 11:08:06 +00:00
commit 307ccfa87d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
11 changed files with 37 additions and 66 deletions

View file

@ -28,7 +28,7 @@ from mmgen.globalvars import g
from mmgen.base_obj import AsyncInit
from mmgen.obj import MMGenObject,CoinTxID
from mmgen.addr import CoinAddr,TokenAddr
from .obj import ETHAmt
from mmgen.amt import ETHAmt
def parse_abi(s):
return [s[:8]] + [s[8+x*64:8+(x+1)*64] for x in range(len(s[8:])//64)]

View file

@ -1,43 +0,0 @@
#!/usr/bin/env python3
#
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
altcoins.eth.obj: Ethereum data type classes for the MMGen suite
"""
from decimal import Decimal
from mmgen.obj import Int
from mmgen.amt import CoinAmt
# Kwei (babbage) 3, Mwei (lovelace) 6, Gwei (shannon) 9, µETH (szabo) 12, mETH (finney) 15, ETH 18
class ETHAmt(CoinAmt):
max_prec = 18
wei = Decimal('0.000000000000000001')
Kwei = Decimal('0.000000000000001')
Mwei = Decimal('0.000000000001')
Gwei = Decimal('0.000000001')
szabo = Decimal('0.000001')
finney = Decimal('0.001')
units = ('wei','Kwei','Mwei','Gwei','szabo','finney')
amt_fs = '4.18'
def toWei(self):
return int(Decimal(self) // self.wei)
class ETHNonce(Int):
min_val = 0

View file

@ -23,8 +23,8 @@ altcoins.eth.twctl: Ethereum tracking wallet control class for the MMGen suite
from mmgen.util import msg,ymsg,write_mode
from mmgen.twctl import TrackingWallet
from mmgen.addr import is_coin_addr,is_mmgen_id
from mmgen.amt import ETHAmt
from .contract import Token,TokenResolve
from .obj import ETHAmt
class EthereumTrackingWallet(TrackingWallet):

View file

@ -20,8 +20,8 @@
altcoins.eth.twuo: Ethereum tracking wallet unspent outputs class for the MMGen suite
"""
from mmgen.tw import TwLabel
from mmgen.twuo import TwUnspentOutputs
from ...tw import TwLabel
from ...twuo import TwUnspentOutputs
# No unspent outputs with Ethereum, but naming must be consistent
class EthereumTwUnspentOutputs(TwUnspentOutputs):
@ -46,9 +46,9 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view,
'l':'a_lbl_add','D':'a_addr_delete','R':'a_balance_refresh' }
async def __init__(self,proto,*args,**kwargs):
from mmgen.globalvars import g
from ...globalvars import g
if g.cached_balances:
from mmgen.color import yellow
from ...color import yellow
self.hdr_fmt += '\n' + yellow('WARNING: Using cached balances. These may be out of date!')
await TwUnspentOutputs.__init__(self,proto,*args,**kwargs)

View file

@ -25,19 +25,18 @@ from collections import namedtuple
from decimal import Decimal
from mmgen.globalvars import g
from mmgen.color import red,yellow,blue,pink
from mmgen.opts import opt
from mmgen.util import msg,msg_r,ymsg,dmsg,fmt,line_input,is_int,is_hex_str,make_chksum_6,die,suf,capfirst,pp_fmt
from mmgen.exception import TransactionChainMismatch
from mmgen.obj import Int,Str,HexStr,CoinTxID,MMGenTxID
from mmgen.addr import MMGenID,CoinAddr,TokenAddr,is_mmgen_id,is_coin_addr
from mmgen.tx import MMGenTX
from mmgen.twctl import TrackingWallet
from ...globalvars import g
from ...color import red,yellow,blue,pink
from ...opts import opt
from ...util import msg,msg_r,ymsg,dmsg,fmt,line_input,is_int,is_hex_str,make_chksum_6,die,suf,capfirst,pp_fmt
from ...exception import TransactionChainMismatch
from ...obj import Int,Str,HexStr,CoinTxID,MMGenTxID,ETHNonce
from ...addr import MMGenID,CoinAddr,TokenAddr,is_mmgen_id,is_coin_addr
from ...amt import ETHAmt
from ...tx import MMGenTX
from ...twctl import TrackingWallet
from .contract import Token
from .obj import ETHAmt,ETHNonce
class EthereumMMGenTX:

View file

@ -174,3 +174,18 @@ class XMRAmt(CoinAmt):
atomic = Decimal('0.000000000001')
units = ('atomic',)
amt_fs = '4.12'
# Kwei (babbage) 3, Mwei (lovelace) 6, Gwei (shannon) 9, µETH (szabo) 12, mETH (finney) 15, ETH 18
class ETHAmt(CoinAmt):
max_prec = 18
wei = Decimal('0.000000000000000001')
Kwei = Decimal('0.000000000000001')
Mwei = Decimal('0.000000000001')
Gwei = Decimal('0.000000001')
szabo = Decimal('0.000001')
finney = Decimal('0.001')
units = ('wei','Kwei','Mwei','Gwei','szabo','finney')
amt_fs = '4.18'
def toWei(self):
return int(Decimal(self) // self.wei)

View file

@ -294,6 +294,9 @@ class Int(int,Hilite,InitErrors):
class MMGenIdx(Int):
min_val = 1
class ETHNonce(Int):
min_val = 0
class Str(str,Hilite):
pass

View file

@ -26,9 +26,8 @@ from collections import namedtuple
from .util import msg,ymsg,Msg,ydie
from .devtools import *
from .globalvars import g
from .amt import BTCAmt,LTCAmt,BCHAmt,XMRAmt
from .altcoins.eth.obj import ETHAmt
import mmgen.bech32 as bech32
from .amt import BTCAmt,LTCAmt,BCHAmt,XMRAmt,ETHAmt
parsed_wif = namedtuple('parsed_wif',['sec','pubkey_type','compressed'])
parsed_addr = namedtuple('parsed_addr',['bytes','fmt'])

View file

@ -31,7 +31,6 @@ os.environ['MMGEN_TEST_SUITE'] = '1'
# Import these _after_ local path's been added to sys.path
from mmgen.common import *
from mmgen.obj import *
from mmgen.altcoins.eth.obj import *
from mmgen.seedsplit import *
from mmgen.addr import *
from mmgen.addrlist import *

View file

@ -29,7 +29,7 @@ from mmgen.globalvars import g
from mmgen.opts import opt
from mmgen.util import die
from mmgen.exception import *
from mmgen.altcoins.eth.obj import ETHAmt
from mmgen.amt import ETHAmt
from mmgen.protocol import CoinProtocol
from ..include.common import *
from .common import *

View file

@ -9,8 +9,7 @@ class unit_tests:
def coinamt(self,name,ut):
from mmgen.amt import BTCAmt,LTCAmt,XMRAmt
from mmgen.altcoins.eth.obj import ETHAmt
from mmgen.amt import BTCAmt,LTCAmt,XMRAmt,ETHAmt
for cls,aa,bb in (
( BTCAmt, '1.2345', '11234567.897' ),