Skip to content

Commit

Permalink
changes to views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yukonet committed Nov 17, 2023
1 parent bfe772b commit 56c359f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 56c359f

Please sign in to comment.