Skip to content

Commit

Permalink
Merge pull request #120 from dom-jiang/main
Browse files Browse the repository at this point in the history
add list token
  • Loading branch information
dom-jiang authored Apr 3, 2024
2 parents 2f1fe9f + eb4b7c9 commit c01c3cb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import logging
from indexer_provider import get_proposal_id_hash
from redis_provider import list_farms, list_top_pools, list_pools, list_token_price, list_whitelist, get_token_price, list_base_token_price
from redis_provider import list_pools_by_id_list, list_token_metadata, list_pools_by_tokens, get_pool
from redis_provider import list_pools_by_id_list, list_token_metadata, list_pools_by_tokens, get_pool, list_token_metadata_v2
from redis_provider import list_token_price_by_id_list, get_proposal_hash_by_id, get_24h_pool_volume, get_account_pool_assets
from redis_provider import get_dcl_pools_volume_list, get_24h_pool_volume_list, get_dcl_pools_tvl_list, get_token_price_ratio_report
from utils import combine_pools_info, compress_response_content, get_ip_address, pools_filter, get_tx_id, combine_dcl_pool_log, handle_dcl_point_bin, handle_point_data, handle_top_bin_fee, handle_dcl_point_bin_by_account, get_circulating_supply
Expand All @@ -28,7 +28,7 @@
import time
import datetime

service_version = "20240328.01"
service_version = "20240403.01"
Welcome = 'Welcome to ref datacenter API server, version ' + service_version + ', indexer %s' % \
Cfg.NETWORK[Cfg.NETWORK_ID]["INDEXER_HOST"][-3:]
# Instantiation, which can be regarded as fixed format
Expand Down Expand Up @@ -207,6 +207,16 @@ def handle_list_token():
return compress_response_content(ret)


@app.route('/list-token-v2', methods=['GET'])
@flask_cors.cross_origin()
def handle_list_token_v2():
"""
list_token
"""
ret = list_token_metadata_v2(Cfg.NETWORK_ID)
return compress_response_content(ret)


@app.route('/get-pool', methods=['GET'])
@flask_cors.cross_origin()
def handle_get_pool():
Expand Down
13 changes: 13 additions & 0 deletions redis_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ def list_token_metadata(network_id):
return metadata_obj


def list_token_metadata_v2(network_id):
import json
r = redis.StrictRedis(connection_pool=pool)
ret = r.hgetall(Cfg.NETWORK[network_id]["REDIS_TOKEN_METADATA_KEY"])
r.close()
metadata_obj = {}
for key, value in ret.items():
token_data = json.loads(value)
token_data.pop("icon")
metadata_obj[key] = token_data
return metadata_obj


def get_proposal_hash_by_id(network_id: str, id_list: list) -> list:
proposal_list = []
r=redis.StrictRedis(connection_pool=pool)
Expand Down

0 comments on commit c01c3cb

Please sign in to comment.