SwapAsset: new coin property

This commit is contained in:
The MMGen Project 2025-06-06 15:20:07 +03:00
commit 040b32704e
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 7 additions and 3 deletions

View file

@ -72,9 +72,13 @@ class SwapAsset:
def chain(self):
return self.data.full_name.split('.', 1)[0] if self.data.full_name else self.name
@property
def coin(self):
return self.data.name or self.data.full_name.split('.', 1)[0]
@property
def asset(self):
return self.data.full_name.split('.', 1)[1] if self.data.full_name else None
return None if self.data.name else self.data.full_name.split('.', 1)[1]
@property
def full_name(self):

View file

@ -116,7 +116,7 @@ class THORChainMemo:
assert trade_limit is None or isinstance(trade_limit, UniAmt), f'{type(trade_limit)} != {UniAmt}'
assert is_coin_addr(proto, addr)
assert asset.chain == proto.coin, f'{asset.chain} != {proto.coin}'
assert asset.coin == proto.coin, f'{asset.coin} != {proto.coin}'
assert asset.asset == getattr(proto, 'tokensym', None), (
f'{asset.asset} != {getattr(proto, "tokensym", None)}')
assert asset.direction == 'recv', f'{asset.direction} != ‘recv’'

View file

@ -25,7 +25,7 @@ def init_swap_proto(cfg, asset):
from ..protocol import init_proto
return init_proto(
cfg,
asset.chain,
asset.coin,
network = cfg._proto.network,
tokensym = asset.asset,
need_amt = True)