Minor wallet address related changes

This commit is contained in:
PhilipWafula 2021-10-07 16:51:05 +03:00
parent e3a0e8e463
commit 355f8d86f2
Signed by untrusted user: mango-habanero
GPG Key ID: B00CE9034DA19FB7
7 changed files with 19 additions and 21 deletions

View File

@ -101,7 +101,7 @@ def get_cached_available_balance(blockchain_address: str) -> float:
:return: Operational balance of an account.
:rtype: float
"""
identifier = bytes.fromhex(blockchain_address[2:])
identifier = bytes.fromhex(blockchain_address)
key = cache_data_key(identifier, salt=':cic.balances')
cached_balances = get_cached_data(key=key)
if cached_balances:

View File

@ -86,7 +86,7 @@ def query_statement(blockchain_address: str, limit: int = 9):
:param limit: Number of transactions to be returned.
:type limit: int
"""
logg.debug(f'retrieving balance for address: {blockchain_address}')
logg.debug(f'retrieving statement for address: {blockchain_address}')
chain_str = Chain.spec.__str__()
cic_eth_api = Api(
chain_str=chain_str,

View File

@ -37,7 +37,7 @@ class MenuProcessor:
def __init__(self, account: Account, display_key: str, menu_name: str, session: Session, ussd_session: dict):
self.account = account
self.display_key = display_key
self.identifier = bytes.fromhex(self.account.blockchain_address[2:])
self.identifier = bytes.fromhex(self.account.blockchain_address)
self.menu_name = menu_name
self.session = session
self.ussd_session = ussd_session

View File

@ -113,8 +113,10 @@ def statement_callback(self, result, param: str, status_code: int):
for transaction in statement_transactions:
recipient_transaction, sender_transaction = transaction_actors(transaction)
if recipient_transaction.get('blockchain_address') == param:
recipient_transaction['alt_blockchain_address'] = sender_transaction.get('blockchain_address')
generate(param, queue, recipient_transaction)
if sender_transaction.get('blockchain_address') == param:
sender_transaction['alt_blockchain_address'] = recipient_transaction.get('blockchain_address')
generate(param, queue, sender_transaction)

View File

@ -23,17 +23,13 @@ logg = logging.getLogger(__file__)
def generate_statement(self, querying_party: str, transaction: dict):
""""""
queue = self.request.delivery_info.get('routing_key')
s_preferences = celery.signature(
'cic_ussd.tasks.metadata.query_preferences_metadata', [querying_party], queue=queue
)
s_parse_transaction = celery.signature(
'cic_ussd.tasks.processor.parse_transaction', [transaction], queue=queue
)
s_cache_statement = celery.signature(
'cic_ussd.tasks.processor.cache_statement', [querying_party], queue=queue
)
celery.chain(s_preferences, s_parse_transaction, s_cache_statement).apply_async()
celery.chain(s_parse_transaction, s_cache_statement).apply_async()
@celery_app.task

View File

@ -54,7 +54,7 @@ def cache_account_creation_data(init_cache, account_creation_data):
@pytest.fixture(scope='function')
def cache_balances(activated_account, balances, init_cache):
identifier = bytes.fromhex(strip_0x(activated_account.blockchain_address))
identifier = bytes.fromhex(activated_account.blockchain_address)
balances = json.dumps(balances[0])
key = cache_data_key(identifier, ':cic.balances')
cache_data(key, balances)
@ -70,7 +70,7 @@ def cache_default_token_data(default_token_data, init_cache, load_chain_spec):
@pytest.fixture(scope='function')
def cache_person_metadata(activated_account, init_cache, person_metadata):
identifier = bytes.fromhex(strip_0x(activated_account.blockchain_address))
identifier = bytes.fromhex(activated_account.blockchain_address)
person = json.dumps(person_metadata)
key = cache_data_key(identifier, ':cic.person')
cache_data(key, person)
@ -78,7 +78,7 @@ def cache_person_metadata(activated_account, init_cache, person_metadata):
@pytest.fixture(scope='function')
def cache_preferences(activated_account, init_cache, preferences):
identifier = bytes.fromhex(strip_0x(activated_account.blockchain_address))
identifier = bytes.fromhex(activated_account.blockchain_address)
preferences = json.dumps(preferences)
key = cache_data_key(identifier, ':cic.preferences')
cache_data(key, preferences)
@ -86,10 +86,10 @@ def cache_preferences(activated_account, init_cache, preferences):
@pytest.fixture(scope='function')
def cache_statement(activated_account, init_cache, statement):
identifier = bytes.fromhex(strip_0x(activated_account.blockchain_address))
preferences = json.dumps(statement)
identifier = bytes.fromhex(activated_account.blockchain_address)
statement = json.dumps(statement)
key = cache_data_key(identifier, ':cic.statement')
cache_data(key, preferences)
cache_data(key, statement)
@pytest.fixture(scope='function')

View File

@ -7,6 +7,7 @@ import pytest
# local import
from cic_ussd.account.balance import get_cached_available_balance
# tests imports
@ -103,8 +104,8 @@ def transactions_list(activated_account, valid_recipient):
'destination_token': '0x0000000000000000000000000000000000000000',
'block_number': 80,
'tx_index': 0,
'sender': '0x367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
'recipient': '0x103d1ed6e370dBa6267045c70d4999384c18a04A',
'sender': '367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
'recipient': '103d1ed6e370dBa6267045c70d4999384c18a04A',
'from_value': 0,
'to_value': 0,
'date_created': '2021-07-14T14:13:46.036198',
@ -122,8 +123,8 @@ def transactions_list(activated_account, valid_recipient):
'destination_token': '0x0000000000000000000000000000000000000000',
'block_number': 78,
'tx_index': 0,
'sender': '0xb41BfEE260693A473254D62b81aE1ADCC9E51AFb',
'recipient': '0x367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
'sender': 'b41BfEE260693A473254D62b81aE1ADCC9E51AFb',
'recipient': '367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
'from_value': 1800000000000000,
'to_value': 1800000000000000,
'date_created': '2021-07-14T14:13:35.839638',
@ -142,8 +143,8 @@ def transactions_list(activated_account, valid_recipient):
'destination_token': '0x0000000000000000000000000000000000000000',
'block_number': 79,
'tx_index': 0,
'sender': '0x367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
'recipient': '0x103d1ed6e370dBa6267045c70d4999384c18a04A',
'sender': '367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
'recipient': '103d1ed6e370dBa6267045c70d4999384c18a04A',
'from_value': 0,
'to_value': 0,
'date_created': '2021-07-14T14:13:35.638355',
@ -152,4 +153,3 @@ def transactions_list(activated_account, valid_recipient):
'timestamp': 1626272015,
'hash': '0x32ca3dd3bef06463b452f4d32f5f563d083cb4759219eed90f3d2a9c1791c5fc'}
]