From 56c359f0ba0632473a7a472bf66ac39b3053d8e6 Mon Sep 17 00:00:00 2001 From: yukonet Date: Fri, 17 Nov 2023 15:12:37 +0000 Subject: [PATCH] changes to views.py --- app/api/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/views.py b/app/api/views.py index d77c79a..49ebbe2 100644 --- a/app/api/views.py +++ b/app/api/views.py @@ -94,35 +94,35 @@ def get_transaction(txid): logger.warning(f"There is not any token {g.symbol} transaction with transactionID {txid}") return {'status': 'error', 'msg': 'txid is not found for this crypto '} logger.warning(transactions_array) - transaction_found = False + related_transactions = [] for transaction in transactions_array: if (transaction['args']['to'] in list_accounts) and (transaction['args']['from'] in list_accounts): address = transaction['args']["from"] category = 'internal' amount = Decimal(transaction['args'][amount_name]) / Decimal(10** (token_instance.contract.functions.decimals().call())) confirmations = int(w3.eth.blockNumber) - int(transaction["blockNumber"]) - transaction_found = True + related_transactions.append[address, amount, confirmations, category] elif transaction['args']['to'] in list_accounts: address = transaction['args']["to"] category = 'receive' amount = Decimal(transaction['args'][amount_name]) / Decimal(10** (token_instance.contract.functions.decimals().call())) confirmations = int(w3.eth.blockNumber) - int(transaction["blockNumber"]) - transaction_found = True + related_transactions.append[address, amount, confirmations, category] elif transaction['args']['from'] in list_accounts: address = transaction['args']["from"] category = 'send' amount = Decimal(transaction['args'][amount_name]) / Decimal(10** (token_instance.contract.functions.decimals().call())) confirmations = int(w3.eth.blockNumber) - int(transaction["blockNumber"]) - transaction_found = True - if not transaction_found: + related_transactions.append[address, amount, confirmations, category] + if not related_transactions: logger.warning(f"txid {txid} is not related to any known address for {g.symbol}") return {'status': 'error', 'msg': 'txid is not related to any known address'} except Exception as e: raise e else: return {'status': 'error', 'msg': 'Currency is not defined in config'} - logger.warning(f"returning address {address}, amount {amount}, confirmations {confirmations}, category {category}") - return {'address': address, 'amount': Decimal(amount), 'confirmations': confirmations, 'category': category} + logger.warning(related_transactions) + return related_transactions @api.post('/dump')