Browse Source

remove altcoins.eth.obj module

- ETHAmt -> mmgen.amt
- ETHNonce -> mmgen.obj
The MMGen Project 3 years ago
parent
commit
307ccfa87d

+ 1 - 1
mmgen/altcoins/eth/contract.py

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

+ 0 - 43
mmgen/altcoins/eth/obj.py

@@ -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

+ 1 - 1
mmgen/altcoins/eth/twctl.py

@@ -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.util import msg,ymsg,write_mode
 from mmgen.twctl import TrackingWallet
 from mmgen.twctl import TrackingWallet
 from mmgen.addr import is_coin_addr,is_mmgen_id
 from mmgen.addr import is_coin_addr,is_mmgen_id
+from mmgen.amt import ETHAmt
 from .contract import Token,TokenResolve
 from .contract import Token,TokenResolve
-from .obj import ETHAmt
 
 
 class EthereumTrackingWallet(TrackingWallet):
 class EthereumTrackingWallet(TrackingWallet):
 
 

+ 4 - 4
mmgen/altcoins/eth/twuo.py

@@ -20,8 +20,8 @@
 altcoins.eth.twuo: Ethereum tracking wallet unspent outputs class for the MMGen suite
 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
 # No unspent outputs with Ethereum, but naming must be consistent
 class EthereumTwUnspentOutputs(TwUnspentOutputs):
 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' }
 		'l':'a_lbl_add','D':'a_addr_delete','R':'a_balance_refresh' }
 
 
 	async def __init__(self,proto,*args,**kwargs):
 	async def __init__(self,proto,*args,**kwargs):
-		from mmgen.globalvars import g
+		from ...globalvars import g
 		if g.cached_balances:
 		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!')
 			self.hdr_fmt += '\n' + yellow('WARNING: Using cached balances. These may be out of date!')
 		await TwUnspentOutputs.__init__(self,proto,*args,**kwargs)
 		await TwUnspentOutputs.__init__(self,proto,*args,**kwargs)
 
 

+ 10 - 11
mmgen/altcoins/eth/tx.py

@@ -25,19 +25,18 @@ from collections import namedtuple
 
 
 from decimal import Decimal
 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 .contract import Token
-from .obj import ETHAmt,ETHNonce
 
 
 class EthereumMMGenTX:
 class EthereumMMGenTX:
 
 

+ 15 - 0
mmgen/amt.py

@@ -174,3 +174,18 @@ class XMRAmt(CoinAmt):
 	atomic = Decimal('0.000000000001')
 	atomic = Decimal('0.000000000001')
 	units = ('atomic',)
 	units = ('atomic',)
 	amt_fs = '4.12'
 	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)

+ 3 - 0
mmgen/obj.py

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

+ 1 - 2
mmgen/protocol.py

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

+ 0 - 1
test/objtest.py

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

+ 1 - 1
test/test_py_d/ts_ethdev.py

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

+ 1 - 2
test/unit_tests_d/ut_obj.py

@@ -9,8 +9,7 @@ class unit_tests:
 
 
 	def coinamt(self,name,ut):
 	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 (
 		for cls,aa,bb in (
 				( BTCAmt, '1.2345', '11234567.897' ),
 				( BTCAmt, '1.2345', '11234567.897' ),