From 9addb901ccc6abc7ef88373d04e1753a934968b7 Mon Sep 17 00:00:00 2001 From: PhilipWafula Date: Mon, 22 Nov 2021 13:22:04 +0300 Subject: [PATCH] Adds notion of last received and last token for ordering of the tokens list. --- apps/cic-ussd/cic_ussd/tasks/processor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/cic-ussd/cic_ussd/tasks/processor.py b/apps/cic-ussd/cic_ussd/tasks/processor.py index 599938ab..7796ad12 100644 --- a/apps/cic-ussd/cic_ussd/tasks/processor.py +++ b/apps/cic-ussd/cic_ussd/tasks/processor.py @@ -74,6 +74,14 @@ def parse_transaction(transaction: dict) -> dict: role = transaction.get('role') alt_blockchain_address = transaction.get('alt_blockchain_address') blockchain_address = transaction.get('blockchain_address') + identifier = bytes.fromhex(blockchain_address) + token_symbol = transaction.get('token_symbol') + if role == 'recipient': + key = cache_data_key(identifier=identifier, salt=MetadataPointer.TOKEN_LAST_RECEIVED) + cache_data(key, token_symbol) + if role == 'sender': + key = cache_data_key(identifier=identifier, salt=MetadataPointer.TOKEN_LAST_SENT) + cache_data(key, token_symbol) account = validate_transaction_account(blockchain_address, role, session) alt_account = session.query(Account).filter_by(blockchain_address=alt_blockchain_address).first() if alt_account: