minor fixes and cleanups
This commit is contained in:
parent
67ef5d3987
commit
835914ca3e
9 changed files with 41 additions and 21 deletions
|
|
@ -99,7 +99,7 @@ elif not cfg._args and cfg.autosign:
|
|||
si = Signable.automount_transaction(asi)
|
||||
if cfg.abort:
|
||||
si.shred_abortable() # prompts user, then raises exception or exits
|
||||
elif cfg.status:
|
||||
elif cfg.status or cfg.receipt:
|
||||
if si.unsent:
|
||||
die(1, 'Transaction is unsent')
|
||||
if si.unsigned:
|
||||
|
|
@ -120,7 +120,7 @@ async def main():
|
|||
|
||||
global cfg
|
||||
|
||||
if cfg.status and cfg.autosign:
|
||||
if (cfg.status or cfg.receipt) and cfg.autosign:
|
||||
tx = await si.get_last_created()
|
||||
else:
|
||||
tx = await OnlineSignedTX(
|
||||
|
|
@ -144,7 +144,7 @@ async def main():
|
|||
await tx.post_send(asi)
|
||||
sys.exit(0)
|
||||
|
||||
if not cfg.status or cfg.receipt:
|
||||
if not (cfg.status or cfg.receipt):
|
||||
if tx.is_swap and not tx.check_swap_expiry():
|
||||
die(1, 'Swap quote has expired. Please re-create the transaction')
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ class Token(Contract):
|
|||
from_decimal = True)
|
||||
|
||||
def create_transfer_data(self, to_addr, amt, *, op):
|
||||
# Method IDs: 0xa9059cbb (transfer), 0x095ea7b3 (approve)
|
||||
assert op in ('transfer', 'approve'), f'{op}: invalid operation (not ‘transfer’ or ‘approve’)'
|
||||
return (
|
||||
self.create_method_id(f'{op}(address,uint256)')
|
||||
|
|
|
|||
|
|
@ -56,7 +56,11 @@ class OnlineSigned(Signed, TxBase.OnlineSigned):
|
|||
if res.status == 0:
|
||||
if res.gas_used == res.gas_sent:
|
||||
msg(yellow('All gas was used!'))
|
||||
die(1, f'Send of {coin_txid.hl()} failed (status=0)')
|
||||
msg('{} {} {}'.format(
|
||||
yellow('Send of'),
|
||||
coin_txid.hl(),
|
||||
yellow('failed (status=0)')))
|
||||
return False
|
||||
msg(f'Status: {green(str(res.status))}')
|
||||
if res.contract_addr:
|
||||
msg('Contract address: {}'.format(res.contract_addr.hl(0)))
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
# https://gitlab.com/mmgen/mmgen-wallet
|
||||
|
||||
"""
|
||||
swap.asset: THORChain swap asset class the MMGen Wallet suite
|
||||
swap.asset: THORChain swap asset class for the MMGen Wallet suite
|
||||
"""
|
||||
|
||||
from ...asset import SwapAsset
|
||||
|
|
|
|||
|
|
@ -236,4 +236,9 @@ class Base(MMGenObject):
|
|||
|
||||
@cached_property
|
||||
def recv_asset(self):
|
||||
return self.swap_proto_mod.SwapAsset(self.swap_recv_asset_spec, 'recv')
|
||||
if hasattr(self, 'swap_recv_asset_spec'):
|
||||
return self.swap_proto_mod.SwapAsset(self.swap_recv_asset_spec, 'recv')
|
||||
else: # backwards-compatibility workaround
|
||||
from ..swap.asset import SwapAsset
|
||||
x = '[unknown]'
|
||||
return SwapAsset._ad(x, x, x, x, x)
|
||||
|
|
|
|||
|
|
@ -105,11 +105,13 @@ class OnlineSigned(Signed):
|
|||
if idx != '' and not cfg.test_suite:
|
||||
await asyncio.sleep(2)
|
||||
from .tx_proxy import send_tx
|
||||
msg(f'Sending TX: {coin_txid.hl()}')
|
||||
msg('{} TX: {}'.format('Testing' if cfg.test else 'Sending', coin_txid.hl()))
|
||||
if ret := send_tx(cfg, txhex):
|
||||
if ret != coin_txid:
|
||||
ymsg(f'Warning: txid mismatch (after sending) ({ret} != {coin_txid})')
|
||||
sent_status = 'confirm_post_send'
|
||||
if cfg.test:
|
||||
break
|
||||
elif cfg.test:
|
||||
await self.test_sendable(txhex)
|
||||
else: # node send
|
||||
|
|
|
|||
|
|
@ -39,14 +39,9 @@ def {name}(self):
|
|||
|
||||
class CmdTestEthBumpMethods:
|
||||
|
||||
def init_block_period(self):
|
||||
d = self.daemon
|
||||
bp = self.cfg.devnet_block_period or self.dfl_devnet_block_period[d.id]
|
||||
d.usr_coind_args = {
|
||||
'reth': [f'--dev.block-time={bp}s'],
|
||||
'geth': [f'--dev.period={bp}']
|
||||
}[d.id]
|
||||
self.devnet_block_period = bp
|
||||
@property
|
||||
def devnet_block_period(self):
|
||||
return self.cfg.devnet_block_period or self.dfl_devnet_block_period[self.daemon.id]
|
||||
|
||||
def _txcreate(self, args, acct):
|
||||
self.get_file_with_ext('rawtx', delete_all=True)
|
||||
|
|
@ -133,6 +128,7 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthSwapMethods, CmdTestSwapMe
|
|||
('subgroup.token_init', ['eth_init']),
|
||||
('subgroup.token_feebump', ['token_init']),
|
||||
('subgroup.token_new_outputs', ['token_init']),
|
||||
('ltc_stop', ''),
|
||||
('stop', 'stopping daemon'),
|
||||
)
|
||||
cmd_subgroups = {
|
||||
|
|
@ -243,6 +239,11 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthSwapMethods, CmdTestSwapMe
|
|||
if not trunner:
|
||||
return
|
||||
|
||||
self.daemon.usr_coind_args = {
|
||||
'reth': [f'--dev.block-time={self.devnet_block_period}s'],
|
||||
'geth': [f'--dev.period={self.devnet_block_period}']
|
||||
}[self.daemon.id]
|
||||
|
||||
global ethbump_ltc
|
||||
cfg = Config({
|
||||
'_clone': trunner.cfg,
|
||||
|
|
@ -294,7 +295,7 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthSwapMethods, CmdTestSwapMe
|
|||
return self._bal_check(pat=rf'{dfl_sid}:E:2\s+777\s')
|
||||
|
||||
def bal3(self):
|
||||
return self._bal_check(pat=rf'{dfl_sid}:E:11\s+99987\.653466900170247\s')
|
||||
return self._bal_check(pat=rf'{dfl_sid}:E:11\s+99987\.653431389777251448\s')
|
||||
|
||||
def bal4(self):
|
||||
return self._bal_check(pat=rf'{dfl_sid}:E:12\s+4444\.3333\s')
|
||||
|
|
@ -356,4 +357,5 @@ class CmdTestEthBumpLTC(CmdTestSwapMethods, CmdTestRegtest):
|
|||
('walletconv_bob', 'LTC wallet generation'),
|
||||
('addrgen_bob', 'LTC address generation'),
|
||||
('addrimport_bob', 'importing LTC addresses'),
|
||||
('stop', 'stopping the Litecoin daemon'),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -250,18 +250,18 @@ class CmdTestEthSwapEth(CmdTestEthSwapMethods, CmdTestSwapMethods, CmdTestEthdev
|
|||
}[k]
|
||||
|
||||
cmd_group_in = CmdTestEthdev.cmd_group_in + (
|
||||
# eth_fund:
|
||||
('fund_mmgen_addr1', 'funding user address :1)'),
|
||||
('fund_mmgen_addr2', 'funding user address :11)'),
|
||||
('bal1', 'the ETH balance'),
|
||||
# eth_swap:
|
||||
('swaptxcreate1', 'creating an ETH->BTC swap transaction'),
|
||||
('swaptxcreate2', 'creating an ETH->BTC swap transaction (spec address, trade limit)'),
|
||||
('swaptxsign1', 'signing the transaction'),
|
||||
('swaptxsend1', 'sending the transaction'),
|
||||
('swaptxstatus1', 'getting the transaction status (with --verbose)'),
|
||||
('swaptxcreate3', 'creating an ETH->MM1 swap transaction'),
|
||||
('swaptxsign3', 'signing the transaction'),
|
||||
('swaptxsend3', 'sending the transaction'),
|
||||
('bal1', 'the ETH balance'),
|
||||
('bal2', 'the ETH balance'),
|
||||
# token_init:
|
||||
('token_compile1', 'compiling ERC20 token #1'),
|
||||
('token_deploy_a', 'deploying ERC20 token MM1 (SafeMath)'),
|
||||
('token_deploy_b', 'deploying ERC20 token MM1 (Owned)'),
|
||||
|
|
@ -270,6 +270,12 @@ class CmdTestEthSwapEth(CmdTestEthSwapMethods, CmdTestSwapMethods, CmdTestEthdev
|
|||
('token_addrgen', 'generating token addresses'),
|
||||
('token_addrimport', 'importing token addresses using token address (MM1)'),
|
||||
('token_bal1', 'the token balance'),
|
||||
|
||||
# eth_token_swap:
|
||||
# ETH -> MM1
|
||||
('swaptxcreate3', 'creating an ETH->MM1 swap transaction'),
|
||||
('swaptxsign3', 'signing the transaction'),
|
||||
('swaptxsend3', 'sending the transaction'),
|
||||
)
|
||||
|
||||
def swaptxcreate1(self):
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import time, re, json
|
|||
|
||||
from mmgen.cfg import Config
|
||||
from mmgen.amt import UniAmt
|
||||
from mmgen.protocol import init_proto
|
||||
|
||||
from . import HTTPD
|
||||
|
||||
|
|
@ -152,7 +153,6 @@ class ThornodeServer(HTTPD):
|
|||
}
|
||||
|
||||
if send_asset != 'RUNE':
|
||||
from mmgen.protocol import init_proto
|
||||
send_proto = init_proto(cfg, send_chain, network='regtest', need_amt=True)
|
||||
data.update({
|
||||
'inbound_address': make_inbound_addr(send_proto, send_proto.preferred_mmtypes[0]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue