mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-03 09:19:26 +00:00
api: Add include_sent offers filter.
This commit is contained in:
parent
9729dcf526
commit
553af1a3e8
7 changed files with 19 additions and 7 deletions
|
@ -1,3 +1,3 @@
|
||||||
name = "basicswap"
|
name = "basicswap"
|
||||||
|
|
||||||
__version__ = "0.11.57"
|
__version__ = "0.11.58"
|
||||||
|
|
|
@ -5838,6 +5838,9 @@ class BasicSwap(BaseApp):
|
||||||
filter_coin_to = filters.get('coin_to', None)
|
filter_coin_to = filters.get('coin_to', None)
|
||||||
if filter_coin_to and filter_coin_to > -1:
|
if filter_coin_to and filter_coin_to > -1:
|
||||||
q = q.filter(Offer.coin_to == int(filter_coin_to))
|
q = q.filter(Offer.coin_to == int(filter_coin_to))
|
||||||
|
filter_include_sent = filters.get('include_sent', None)
|
||||||
|
if filter_include_sent and filter_include_sent is not True:
|
||||||
|
q = q.filter(Offer.was_sent == False) # noqa: E712
|
||||||
|
|
||||||
order_dir = filters.get('sort_dir', 'desc')
|
order_dir = filters.get('sort_dir', 'desc')
|
||||||
order_by = filters.get('sort_by', 'created_at')
|
order_by = filters.get('sort_by', 'created_at')
|
||||||
|
|
|
@ -171,6 +171,8 @@ def js_offers(self, url_split, post_string, is_json, sent=False) -> bytes:
|
||||||
assert (filters['limit'] > 0 and filters['limit'] <= PAGE_LIMIT), 'Invalid limit'
|
assert (filters['limit'] > 0 and filters['limit'] <= PAGE_LIMIT), 'Invalid limit'
|
||||||
if have_data_entry(post_data, 'active'):
|
if have_data_entry(post_data, 'active'):
|
||||||
filters['active'] = get_data_entry(post_data, 'active')
|
filters['active'] = get_data_entry(post_data, 'active')
|
||||||
|
if have_data_entry(post_data, 'include_sent'):
|
||||||
|
filters['include_sent'] = toBool(get_data_entry(post_data, 'include_sent'))
|
||||||
|
|
||||||
offers = swap_client.listOffers(sent, filters)
|
offers = swap_client.listOffers(sent, filters)
|
||||||
rv = []
|
rv = []
|
||||||
|
|
|
@ -47,6 +47,8 @@ def ensure(v, err_string):
|
||||||
|
|
||||||
|
|
||||||
def toBool(s) -> bool:
|
def toBool(s) -> bool:
|
||||||
|
if isinstance(s, bool):
|
||||||
|
return s
|
||||||
return s.lower() in ['1', 'true']
|
return s.lower() in ['1', 'true']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -663,7 +663,7 @@ def prepareCore(coin, version_data, settings, data_dir, extra_opts={}):
|
||||||
for key in rv.fingerprints:
|
for key in rv.fingerprints:
|
||||||
gpg.trust_keys(rv.fingerprints[0], 'TRUST_FULLY')
|
gpg.trust_keys(rv.fingerprints[0], 'TRUST_FULLY')
|
||||||
|
|
||||||
if coin in ('pivx', 'firo'):
|
if coin in ('firo', ):
|
||||||
pubkey_filename = '{}_{}.pgp'.format('particl', signing_key_name)
|
pubkey_filename = '{}_{}.pgp'.format('particl', signing_key_name)
|
||||||
else:
|
else:
|
||||||
pubkey_filename = '{}_{}.pgp'.format(coin, signing_key_name)
|
pubkey_filename = '{}_{}.pgp'.format(coin, signing_key_name)
|
||||||
|
|
6
guix.scm
6
guix.scm
|
@ -117,15 +117,15 @@
|
||||||
(define-public basicswap
|
(define-public basicswap
|
||||||
(package
|
(package
|
||||||
(name "basicswap")
|
(name "basicswap")
|
||||||
(version "0.11.55")
|
(version "0.11.58")
|
||||||
(source (origin
|
(source (origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
(url "https://github.com/tecnovert/basicswap")
|
(url "https://github.com/tecnovert/basicswap")
|
||||||
(commit "ac07727da7ec0f6bf2df832843dcaafc7dd7046a")))
|
(commit "9729dcf526917eb5e128dd72b091464d1e72fe54")))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"1xg70jyvggkcr0la7lnj96w34pxrr0sp59d174jpgmlfs625ybbk"))
|
"0sjxk4c9vzn5fr8dqxrmvgw1267njjkblajxvqf3kls5b2s7l41k"))
|
||||||
(file-name (git-file-name name version))))
|
(file-name (git-file-name name version))))
|
||||||
(build-system python-build-system)
|
(build-system python-build-system)
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ def readTemplates(known_coins):
|
||||||
offer_template['minrate'] = float(row_data[3])
|
offer_template['minrate'] = float(row_data[3])
|
||||||
offer_template['ratetweakpercent'] = float(row_data[4])
|
offer_template['ratetweakpercent'] = float(row_data[4])
|
||||||
offer_template['amount_variable'] = row_data[5].lower() in ('true', 1)
|
offer_template['amount_variable'] = row_data[5].lower() in ('true', 1)
|
||||||
|
offer_template['address'] = row_data[6]
|
||||||
offer_templates.append(offer_template)
|
offer_templates.append(offer_template)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Warning: Skipping row {i}, {e}')
|
print(f'Warning: Skipping row {i}, {e}')
|
||||||
|
@ -91,7 +92,8 @@ def main():
|
||||||
|
|
||||||
if not os.path.exists('offer_rules.csv'):
|
if not os.path.exists('offer_rules.csv'):
|
||||||
with open('offer_rules.csv', 'w') as fp:
|
with open('offer_rules.csv', 'w') as fp:
|
||||||
fp.write('coin from,coin to,offer value,min rate,rate tweak percent,amount variable')
|
# Set address to -1 to use new addresses
|
||||||
|
fp.write('coin from,coin to,offer value,min rate,rate tweak percent,amount variable,address')
|
||||||
|
|
||||||
known_coins = read_json_api(args.port, 'coins')
|
known_coins = read_json_api(args.port, 'coins')
|
||||||
coins_map = {}
|
coins_map = {}
|
||||||
|
@ -104,6 +106,9 @@ def main():
|
||||||
offer_templates = readTemplates(known_coins)
|
offer_templates = readTemplates(known_coins)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
recieved_offers = read_json_api(args.port, 'offers', {'active': 'active', 'include_sent': False})
|
||||||
|
print('recieved_offers', recieved_offers)
|
||||||
|
|
||||||
sent_offers = read_json_api(args.port, 'sentoffers', {'active': 'active'})
|
sent_offers = read_json_api(args.port, 'sentoffers', {'active': 'active'})
|
||||||
|
|
||||||
for offer_template in offer_templates:
|
for offer_template in offer_templates:
|
||||||
|
@ -133,7 +138,7 @@ def main():
|
||||||
|
|
||||||
print('Creating offer for: {} at rate: {}'.format(offer_template, use_rate))
|
print('Creating offer for: {} at rate: {}'.format(offer_template, use_rate))
|
||||||
offer_data = {
|
offer_data = {
|
||||||
'addr_from': '-1',
|
'addr_from': offer_template['address'],
|
||||||
'coin_from': coin_from_data['ticker'],
|
'coin_from': coin_from_data['ticker'],
|
||||||
'coin_to': coin_to_data['ticker'],
|
'coin_to': coin_to_data['ticker'],
|
||||||
'amt_from': offer_template['amount'],
|
'amt_from': offer_template['amount'],
|
||||||
|
|
Loading…
Reference in a new issue