From 0448f76b70366fd5ef91dc15a1e36fe101de9b57 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 26 Nov 2022 18:55:55 +0000 Subject: [PATCH] option rename: --tx-gas -> --gas This change breaks compatibility. Scripts may need to be adjusted. --- mmgen/main_txcreate.py | 2 +- mmgen/main_txdo.py | 2 +- mmgen/proto/eth/tx/base.py | 14 +++++++------- mmgen/proto/eth/tx/new.py | 8 ++++---- mmgen/proto/eth/tx/signed.py | 2 +- mmgen/proto/eth/tx/unsigned.py | 2 +- test/test_py_d/ts_ethdev.py | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mmgen/main_txcreate.py b/mmgen/main_txcreate.py index 3a8b8696..f62a6b7e 100755 --- a/mmgen/main_txcreate.py +++ b/mmgen/main_txcreate.py @@ -44,7 +44,7 @@ opts_data = { {fu} (an integer followed by {fl!r}). See FEE SPECIFICATION below. If omitted, fee will be calculated using network fee estimation. --g, --tx-gas= g Specify start gas amount in Wei (ETH only) +-g, --gas= g Specify start gas amount in Wei (ETH only) -i, --info Display unspent outputs and exit -I, --inputs= i Specify transaction inputs (comma-separated list of MMGen IDs or coin addresses). Note that ALL unspent diff --git a/mmgen/main_txdo.py b/mmgen/main_txdo.py index 3a14adbf..665ec5be 100755 --- a/mmgen/main_txdo.py +++ b/mmgen/main_txdo.py @@ -48,7 +48,7 @@ opts_data = { {fu} (an integer followed by {fl!r}). See FEE SPECIFICATION below. If omitted, fee will be calculated using network fee estimation. --g, --tx-gas= g Specify start gas amount in Wei (ETH only) +-g, --gas= g Specify start gas amount in Wei (ETH only) -H, --hidden-incog-input-params=f,o Read hidden incognito data from file 'f' at offset 'o' (comma-separated) -i, --in-fmt= f Input is from wallet format 'f' (see FMT CODES below) diff --git a/mmgen/proto/eth/tx/base.py b/mmgen/proto/eth/tx/base.py index 6a705307..89544f9f 100755 --- a/mmgen/proto/eth/tx/base.py +++ b/mmgen/proto/eth/tx/base.py @@ -24,23 +24,23 @@ class Base(TxBase.Base): rel_fee_desc = 'gas price' rel_fee_disp = 'gas price in Gwei' txobj = None # "" - tx_gas = ETHAmt(21000,'wei') # an approximate number, used for fee estimation purposes + gas = ETHAmt(21000,'wei') # an approximate number, used for fee estimation purposes start_gas = ETHAmt(21000,'wei') # the actual startgas amt used in the transaction - # for simple sends with no data, tx_gas = start_gas = 21000 + # for simple sends with no data, gas = start_gas = 21000 contract_desc = 'contract' usr_contract_data = HexStr('') disable_fee_check = False - # given absolute fee in ETH, return gas price in Gwei using tx_gas + # given absolute fee in ETH, return gas price in Gwei using self.gas def fee_abs2rel(self,abs_fee,to_unit='Gwei'): - ret = ETHAmt(int(abs_fee.toWei() // self.tx_gas.toWei()),'wei') + ret = ETHAmt(int(abs_fee.toWei() // self.gas.toWei()),'wei') dmsg(f'fee_abs2rel() ==> {ret} ETH') return ret if to_unit == 'eth' else ret.to_unit(to_unit,show_decimal=True) - # given rel fee (gasPrice) in wei, return absolute fee using tx_gas (Ethereum-only method) + # given rel fee (gasPrice) in wei, return absolute fee using self.gas (Ethereum-only method) def fee_gasPrice2abs(self,rel_fee): assert isinstance(rel_fee,int), f'{rel_fee!r}: incorrect type for fee estimate (not an integer)' - return ETHAmt(rel_fee * self.tx_gas.toWei(),'wei') + return ETHAmt(rel_fee * self.gas.toWei(),'wei') def is_replaceable(self): return True @@ -64,6 +64,6 @@ class Base(TxBase.Base): return True class TokenBase(Base): - tx_gas = ETHAmt(52000,'wei') + gas = ETHAmt(52000,'wei') start_gas = ETHAmt(60000,'wei') contract_desc = 'token contract' diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index dd31f093..15c76635 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -35,8 +35,8 @@ class New(Base,TxBase.New): super().__init__(*args,**kwargs) - if opt.tx_gas: - self.tx_gas = self.start_gas = ETHAmt(int(opt.tx_gas),'wei') + if opt.gas: + self.gas = self.start_gas = ETHAmt(int(opt.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 @@ -109,10 +109,10 @@ class New(Base,TxBase.New): if not self.disable_fee_check: assert self.usr_fee <= self.proto.max_tx_fee - # given rel fee and units, return absolute fee using self.tx_gas + # given rel fee and units, return absolute fee using self.gas def fee_rel2abs(self,tx_size,units,amt,unit): return ETHAmt( - ETHAmt(amt,units[unit]).toWei() * self.tx_gas.toWei(), + ETHAmt(amt,units[unit]).toWei() * self.gas.toWei(), from_unit='wei' ) diff --git a/mmgen/proto/eth/tx/signed.py b/mmgen/proto/eth/tx/signed.py index cf50c0d9..f6e822d1 100755 --- a/mmgen/proto/eth/tx/signed.py +++ b/mmgen/proto/eth/tx/signed.py @@ -46,7 +46,7 @@ class Signed(Completed,TxBase.Signed): self.disable_fee_check = True txid = CoinTxID(etx.hash.hex()) assert txid == self.coin_txid,"txid in tx.serialized doesn't match value in MMGen transaction file" - self.tx_gas = o['startGas'] # approximate, but better than nothing + self.gas = o['startGas'] # approximate, but better than nothing self.txobj = o return d # 'token_addr','decimals' required by Token subclass diff --git a/mmgen/proto/eth/tx/unsigned.py b/mmgen/proto/eth/tx/unsigned.py index 33b98f5e..4bc14a84 100755 --- a/mmgen/proto/eth/tx/unsigned.py +++ b/mmgen/proto/eth/tx/unsigned.py @@ -38,7 +38,7 @@ class Unsigned(Completed,TxBase.Unsigned): 'nonce': ETHNonce(d['nonce']), 'chainId': None if d['chainId'] == 'None' else Int(d['chainId']), 'data': HexStr(d['data']) } - self.tx_gas = o['startGas'] # approximate, but better than nothing + self.gas = o['startGas'] # approximate, but better than nothing self.txobj = o return d # 'token_addr','decimals' required by Token subclass diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index ab8f300b..a7140ba9 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -922,7 +922,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): args = [ '-B', f'--fee={tx_fee}', - f'--tx-gas={gas}', + f'--gas={gas}', f'--contract-data={fn}', f'--inputs={dfl_devaddr}', '--yes',