ui: Allow users to select which coins to show prices for on offers page.

This commit is contained in:
tecnovert committed 2024-04-14 23:23:22 +02:00
1 parent 8a279dc71f
commit e20516ef71
8 files changed
+154 -129

No files matched your search

+24 -4
View File
@@ -9,14 +9,15 @@ import time
from urllib import parse
from .util import (
PAGE_LIMIT,
getCoinType,
inputAmount,
setCoinFilter,
get_data_entry,
have_data_entry,
get_data_entry_or,
have_data_entry,
inputAmount,
known_chart_coins,
listAvailableCoins,
PAGE_LIMIT,
setCoinFilter,
set_pagination_filters,
)
from basicswap.db import (
@@ -815,6 +816,24 @@ def page_offers(self, url_split, post_string, sent=False):
offers_count = len(formatted_offers)
enabled_chart_coins = []
enabled_chart_coins_setting = swap_client.settings.get('enabled_chart_coins', '')
if enabled_chart_coins_setting.lower() == 'all':
enabled_chart_coins = known_chart_coins
elif enabled_chart_coins_setting.strip() == '':
for coin_id in swap_client.coin_clients:
if not swap_client.isCoinActive(coin_id):
continue
enabled_ticker = swap_client.ci(coin_id).ticker_mainnet()
if enabled_ticker not in enabled_chart_coins and enabled_ticker in known_chart_coins:
enabled_chart_coins.append(enabled_ticker)
else:
for ticker in enabled_chart_coins_setting.split(','):
upcased_ticker = ticker.strip().upper()
if upcased_ticker not in enabled_chart_coins and upcased_ticker in known_chart_coins:
enabled_chart_coins.append(upcased_ticker)
template = server.env.get_template('offers.html')
return self.render_template(template, {
'page_type': 'Your Offers' if sent else 'Network Order Book',
@@ -834,4 +853,5 @@ def page_offers(self, url_split, post_string, sent=False):
'offers_count': offers_count,
'tla_from': tla_from,
'tla_to': tla_to,
'enabled_chart_coins': enabled_chart_coins,
})
+3 -1
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2022-2023 tecnovert
# Copyright (c) 2022-2024 tecnovert
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
@@ -46,6 +46,7 @@ def page_settings(self, url_split, post_string):
'show_chart': toBool(get_data_entry(form_data, 'showchart')),
'chart_api_key': html.unescape(get_data_entry_or(form_data, 'chartapikey', '')),
'coingecko_api_key': html.unescape(get_data_entry_or(form_data, 'coingeckoapikey', '')),
'enabled_chart_coins': get_data_entry_or(form_data, 'enabledchartcoins', ''),
}
swap_client.editGeneralSettings(data)
elif have_data_entry(form_data, 'apply_tor'):
@@ -141,6 +142,7 @@ def page_settings(self, url_split, post_string):
'show_chart': swap_client.settings.get('show_chart', True),
'chart_api_key': chart_api_key,
'coingecko_api_key': coingecko_api_key,
'enabled_chart_coins': swap_client.settings.get('enabled_chart_coins', ''),
}
tor_control_password = '' if swap_client.tor_control_password is None else swap_client.tor_control_password
+1
View File
@@ -33,6 +33,7 @@ from basicswap.protocols.xmr_swap_1 import getChainBSplitKey, getChainBRemoteSpl
PAGE_LIMIT = 25
invalid_coins_from = []
known_chart_coins = ['BTC', 'PART', 'XMR', 'LTC', 'FIRO', 'DASH', 'PIVX', 'DOGE', 'ETH', 'DCR', 'ZANO', 'WOW']
def tickerToCoinId(ticker):