From cda6e2c3ce60c66ce9a7d996dc3ae01c13defd98 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 3 May 2022 21:01:04 +0000 Subject: [PATCH] base_proto.ethereum.tx.new: move __init__ from base class --- mmgen/base_proto/ethereum/tx/new.py | 15 ++++++++++++++- mmgen/tx/new.py | 17 +---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/mmgen/base_proto/ethereum/tx/new.py b/mmgen/base_proto/ethereum/tx/new.py index 19fdec21..831a8d9a 100755 --- a/mmgen/base_proto/ethereum/tx/new.py +++ b/mmgen/base_proto/ethereum/tx/new.py @@ -17,7 +17,7 @@ import json import mmgen.tx.new as TxBase from .base import Base,TokenBase from ....opts import opt -from ....obj import Int,ETHNonce,MMGenTxID,Str +from ....obj import Int,ETHNonce,MMGenTxID,Str,HexStr from ....amt import ETHAmt from ....util import msg,line_input,is_int,is_hex_str,make_chksum_6 from ....tw.ctl import TrackingWallet @@ -31,6 +31,19 @@ class New(Base,TxBase.New): usr_fee_prompt = 'Enter transaction fee or gas price: ' hexdata_type = 'hex' + def __init__(self,*args,**kwargs): + + super().__init__(*args,**kwargs) + + if opt.tx_gas: + self.tx_gas = self.start_gas = ETHAmt(int(opt.tx_gas),'wei') + if opt.contract_data: + m = "'--contract-data' option may not be used with token transaction" + assert not 'Token' in type(self).__name__, m + with open(opt.contract_data) as fp: + self.usr_contract_data = HexStr(fp.read().strip()) + self.disable_fee_check = True + async def get_nonce(self): return ETHNonce(int(await self.rpc.call('eth_getTransactionCount','0x'+self.inputs[0].addr,'pending'),16)) diff --git a/mmgen/tx/new.py b/mmgen/tx/new.py index 22d64113..587cf1e3 100755 --- a/mmgen/tx/new.py +++ b/mmgen/tx/new.py @@ -16,7 +16,7 @@ from ..globalvars import * from ..opts import opt from .base import Base from ..color import pink -from ..obj import get_obj,HexStr +from ..obj import get_obj from ..util import msg,qmsg,fmt,die,suf,remove_dups,get_extension,keypress_confirm,do_license_msg,line_input from ..addr import is_mmgen_id,CoinAddr,is_coin_addr @@ -69,21 +69,6 @@ class New(Base): only one output, specify a single output address with no {} amount """ - def __init__(self,*args,**kwargs): - - super().__init__(*args,**kwargs) - - if self.proto.base_proto == 'Ethereum': - if opt.tx_gas: - from ..amt import ETHAmt - self.tx_gas = self.start_gas = ETHAmt(int(opt.tx_gas),'wei') - if opt.contract_data: - m = "'--contract-data' option may not be used with token transaction" - assert not 'Token' in type(self).__name__, m - with open(opt.contract_data) as fp: - self.usr_contract_data = HexStr(fp.read().strip()) - self.disable_fee_check = True - def update_output_amt(self,idx,amt): o = self.outputs[idx]._asdict() o['amt'] = amt