swap.proto.thorchain: data -> Memo
This commit is contained in:
parent
cf16972576
commit
d010c39157
8 changed files with 12 additions and 12 deletions
|
|
@ -22,8 +22,8 @@ class NewSwap(New, TxNewSwap):
|
|||
def update_data_output(self, trade_limit):
|
||||
sp = get_swap_proto_mod(self.swap_proto)
|
||||
o = self.data_output._asdict()
|
||||
parsed_memo = sp.data.parse(o['data'].decode())
|
||||
memo = sp.data(
|
||||
parsed_memo = sp.Memo.parse(o['data'].decode())
|
||||
memo = sp.Memo(
|
||||
self.recv_proto,
|
||||
self.recv_proto.coin_addr(parsed_memo.address),
|
||||
trade_limit = trade_limit)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ class NewSwap(New, TxNewSwap):
|
|||
def update_data_output(self, trade_limit):
|
||||
sp = get_swap_proto_mod(self.swap_proto)
|
||||
data = bytes.fromhex(self.txobj['data']) if self.is_bump else self.usr_contract_data
|
||||
parsed_memo = sp.data.parse(data.decode())
|
||||
memo = sp.data(
|
||||
parsed_memo = sp.Memo.parse(data.decode())
|
||||
memo = sp.Memo(
|
||||
self.recv_proto,
|
||||
self.recv_proto.coin_addr(parsed_memo.address),
|
||||
trade_limit = trade_limit)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
swap.proto.thorchain: THORChain swap protocol implementation for the MMGen Wallet suite
|
||||
"""
|
||||
|
||||
__all__ = ['data']
|
||||
__all__ = ['Memo']
|
||||
|
||||
name = 'THORChain'
|
||||
|
||||
|
|
@ -42,4 +42,4 @@ def rpc_client(tx, amt):
|
|||
from .thornode import Thornode
|
||||
return Thornode(tx, amt)
|
||||
|
||||
from .memo import Memo as data
|
||||
from .memo import THORChainMemo as Memo
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from ....amt import UniAmt
|
|||
|
||||
from . import name as proto_name
|
||||
|
||||
class Memo:
|
||||
class THORChainMemo:
|
||||
|
||||
# The trade limit, i.e., set 100000000 to get a minimum of 1 full asset, else a refund
|
||||
# Optional. 1e8 or scientific notation
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Completed(Base):
|
|||
|
||||
def check_swap_memo(self):
|
||||
if data := self.get_tx_usr_data():
|
||||
from ..swap.proto.thorchain.memo import Memo
|
||||
from ..swap.proto.thorchain import Memo
|
||||
if Memo.is_partial_memo(data):
|
||||
from ..protocol import init_proto
|
||||
text = data.decode('ascii')
|
||||
|
|
|
|||
|
|
@ -73,13 +73,13 @@ class TxInfo:
|
|||
yield f' {tx.coin} TxID: {tx.coin_txid.hl()}\n'
|
||||
|
||||
if tx.is_swap:
|
||||
from ..swap.proto.thorchain.memo import Memo, proto_name
|
||||
from ..swap.proto.thorchain import Memo, name
|
||||
data = (
|
||||
(tx.usr_contract_data or bytes.fromhex(tx.txobj['data'])) if tx.proto.is_evm
|
||||
else tx.data_output.data)
|
||||
if Memo.is_partial_memo(data):
|
||||
p = Memo.parse(data.decode('ascii'))
|
||||
yield ' {} {}\n'.format(magenta('DEX Protocol:'), blue(proto_name))
|
||||
yield ' {} {}\n'.format(magenta('DEX Protocol:'), blue(name))
|
||||
yield ' Swap: {}\n'.format(orange(f'{tx.proto.coin} => {p.asset}'))
|
||||
yield ' Dest: {}{}\n'.format(
|
||||
cyan(p.address),
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class NewSwap(New):
|
|||
'To sign this transaction, autosign or txsign must be invoked'
|
||||
' with --allow-non-wallet-swap'))
|
||||
|
||||
memo = sp.data(self.recv_proto, recv_output.addr)
|
||||
memo = sp.Memo(self.recv_proto, recv_output.addr)
|
||||
|
||||
# this goes into the transaction file:
|
||||
self.swap_recv_addr_mmid = recv_output.mmid
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class unit_tests:
|
|||
def memo(self, name, ut, desc='Swap transaction memo'):
|
||||
from mmgen.protocol import init_proto
|
||||
from mmgen.amt import UniAmt
|
||||
from mmgen.swap.proto.thorchain import data as Memo
|
||||
from mmgen.swap.proto.thorchain import Memo
|
||||
for coin, addrtype in (
|
||||
('ltc', 'bech32'),
|
||||
('bch', 'compressed'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue