Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import grpc
from google.protobuf import json_format

from pyinjective import constant
from pyinjective.client.chain.grpc.chain_grpc_auth_api import ChainGrpcAuthApi
from pyinjective.client.chain.grpc.chain_grpc_authz_api import ChainGrpcAuthZApi
from pyinjective.client.chain.grpc.chain_grpc_bank_api import ChainGrpcBankApi
Expand Down Expand Up @@ -2659,22 +2658,13 @@ async def _initialize_tokens_and_markets(self):
)

for market_info in valid_markets:
ticker = market_info["ticker"]
if "/" in ticker:
base_token_symbol, quote_token_symbol = ticker.split(constant.TICKER_TOKENS_SEPARATOR)
else:
base_token_symbol = market_info["baseTokenMeta"]["symbol"]
quote_token_symbol = market_info["quoteTokenMeta"]["symbol"]

base_token = self._token_representation(
symbol=base_token_symbol,
token_meta=market_info["baseTokenMeta"],
denom=market_info["baseDenom"],
tokens_by_denom=tokens_by_denom,
tokens_by_symbol=tokens_by_symbol,
)
quote_token = self._token_representation(
symbol=quote_token_symbol,
token_meta=market_info["quoteTokenMeta"],
denom=market_info["quoteDenom"],
tokens_by_denom=tokens_by_denom,
Expand Down Expand Up @@ -2704,10 +2694,7 @@ async def _initialize_tokens_and_markets(self):
)

for market_info in valid_markets:
quote_token_symbol = market_info["quoteTokenMeta"]["symbol"]

quote_token = self._token_representation(
symbol=quote_token_symbol,
token_meta=market_info["quoteTokenMeta"],
denom=market_info["quoteDenom"],
tokens_by_denom=tokens_by_denom,
Expand Down Expand Up @@ -2769,22 +2756,21 @@ async def _initialize_tokens_and_markets(self):

def _token_representation(
self,
symbol: str,
token_meta: Dict[str, Any],
denom: str,
tokens_by_denom: Dict[str, Token],
tokens_by_symbol: Dict[str, Token],
) -> Token:
if denom not in tokens_by_denom:
unique_symbol = denom
for symbol_candidate in [symbol, token_meta["symbol"], token_meta["name"]]:
for symbol_candidate in [token_meta["symbol"], token_meta["name"]]:
if symbol_candidate not in tokens_by_symbol:
unique_symbol = symbol_candidate
break

token = Token(
name=token_meta["name"],
symbol=symbol,
symbol=token_meta["symbol"],
denom=denom,
address=token_meta["address"],
decimals=token_meta["decimals"],
Expand Down