Browse Source

SwapAsset: new `coin` property

The MMGen Project 6 months ago
parent
commit
040b32704e
3 changed files with 7 additions and 3 deletions
  1. 5 1
      mmgen/swap/asset.py
  2. 1 1
      mmgen/swap/proto/thorchain/memo.py
  3. 1 1
      mmgen/tx/new_swap.py

+ 5 - 1
mmgen/swap/asset.py

@@ -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):

+ 1 - 1
mmgen/swap/proto/thorchain/memo.py

@@ -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’'

+ 1 - 1
mmgen/tx/new_swap.py

@@ -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)