tx.swap: self.send_proto -> self.proto
This commit is contained in:
parent
1769b100b5
commit
8cd4487e64
6 changed files with 28 additions and 13 deletions
|
|
@ -115,8 +115,14 @@ async def main():
|
|||
asi = mount_removable_device(cfg)
|
||||
Signable.automount_transaction(asi).check_create_ok()
|
||||
|
||||
if target == 'swaptx':
|
||||
from .tx.new_swap import get_send_proto
|
||||
proto = get_send_proto(cfg)
|
||||
else:
|
||||
proto = cfg._proto
|
||||
|
||||
from .tx import NewTX
|
||||
tx1 = await NewTX(cfg=cfg, proto=cfg._proto, target=target)
|
||||
tx1 = await NewTX(cfg=cfg, proto=proto, target=target)
|
||||
|
||||
tx2 = await tx1.create(
|
||||
cmd_args = cfg._args,
|
||||
|
|
|
|||
|
|
@ -155,7 +155,13 @@ seed_files = get_seed_files(cfg, cfg._args)
|
|||
|
||||
async def main():
|
||||
|
||||
tx1 = await NewTX(cfg=cfg, proto=cfg._proto, target=target)
|
||||
if target == 'swaptx':
|
||||
from .tx.new_swap import get_send_proto
|
||||
proto = get_send_proto(cfg)
|
||||
else:
|
||||
proto = cfg._proto
|
||||
|
||||
tx1 = await NewTX(cfg=cfg, proto=proto, target=target)
|
||||
|
||||
tx2 = await tx1.create(
|
||||
cmd_args = cfg._args,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Thornode:
|
|||
|
||||
def get_quote(self):
|
||||
self.get_str = '/thorchain/quote/swap?from_asset={a}.{a}&to_asset={b}.{b}&amount={c}'.format(
|
||||
a = self.tx.send_proto.coin,
|
||||
a = self.tx.proto.coin,
|
||||
b = self.tx.recv_proto.coin,
|
||||
c = self.in_amt.to_unit('satoshi'))
|
||||
self.result = self.rpc.get(self.get_str)
|
||||
|
|
@ -78,7 +78,7 @@ class Thornode:
|
|||
|
||||
d = self.data
|
||||
tx = self.tx
|
||||
in_coin = tx.send_proto.coin
|
||||
in_coin = tx.proto.coin
|
||||
out_coin = tx.recv_proto.coin
|
||||
in_amt = UniAmt(str(self.in_amt))
|
||||
out_amt = UniAmt(int(d['expected_amount_out']), from_unit='satoshi')
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ class Bump(Completed, NewSwap):
|
|||
self.rel_fee_disp))
|
||||
|
||||
if self.is_swap:
|
||||
self.send_proto = self.proto
|
||||
self.recv_proto = self.check_swap_memo().proto
|
||||
self.process_swap_options()
|
||||
fee_hint = self.update_vault_output(self.send_amt)
|
||||
|
|
|
|||
|
|
@ -445,7 +445,6 @@ class New(Base):
|
|||
if self.is_swap:
|
||||
cmd_args = await self.process_swap_cmdline_args(cmd_args, addrfile_args)
|
||||
self.process_swap_options()
|
||||
self.proto = self.send_proto # updating self.proto!
|
||||
from ..rpc import rpc_init
|
||||
self.rpc = await rpc_init(self.cfg, self.proto)
|
||||
from ..addrdata import TwAddrData
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ def init_proto_from_coin(cfg, sp, coin, desc):
|
|||
from ..protocol import init_proto
|
||||
return init_proto(cfg, coin, network=cfg._proto.network, need_amt=True)
|
||||
|
||||
def get_send_proto(cfg):
|
||||
try:
|
||||
arg = cfg._args.pop(0)
|
||||
except:
|
||||
cfg._usage()
|
||||
return init_proto_from_coin(cfg, get_swap_proto_mod(cfg.swap_proto), arg, 'send')
|
||||
|
||||
class NewSwap(New):
|
||||
desc = 'swap transaction'
|
||||
|
||||
|
|
@ -78,16 +85,14 @@ class NewSwap(New):
|
|||
|
||||
def parse():
|
||||
|
||||
# arg 1: send_coin - already popped and parsed by get_send_proto()
|
||||
|
||||
from ..amt import is_coin_amt
|
||||
arg = get_arg()
|
||||
|
||||
# arg 1: send_coin
|
||||
self.send_proto = init_proto_from_coin(self.cfg, sp, arg, 'send')
|
||||
arg = get_arg()
|
||||
|
||||
# arg 2: amt
|
||||
if is_coin_amt(self.send_proto, arg):
|
||||
args.send_amt = self.send_proto.coin_amt(arg)
|
||||
if is_coin_amt(self.proto, arg):
|
||||
args.send_amt = self.proto.coin_amt(arg)
|
||||
arg = get_arg()
|
||||
|
||||
# arg 3: chg_spec (change address spec)
|
||||
|
|
@ -112,7 +117,7 @@ class NewSwap(New):
|
|||
parse()
|
||||
|
||||
chg_output = (
|
||||
await self.get_swap_output(self.send_proto, args.chg_spec, addrfiles, 'change address')
|
||||
await self.get_swap_output(self.proto, args.chg_spec, addrfiles, 'change address')
|
||||
if args.send_amt else None)
|
||||
|
||||
if chg_output:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue