Minor wallet address related changes
This commit is contained in:
parent
e3a0e8e463
commit
355f8d86f2
@ -101,7 +101,7 @@ def get_cached_available_balance(blockchain_address: str) -> float:
|
|||||||
:return: Operational balance of an account.
|
:return: Operational balance of an account.
|
||||||
:rtype: float
|
:rtype: float
|
||||||
"""
|
"""
|
||||||
identifier = bytes.fromhex(blockchain_address[2:])
|
identifier = bytes.fromhex(blockchain_address)
|
||||||
key = cache_data_key(identifier, salt=':cic.balances')
|
key = cache_data_key(identifier, salt=':cic.balances')
|
||||||
cached_balances = get_cached_data(key=key)
|
cached_balances = get_cached_data(key=key)
|
||||||
if cached_balances:
|
if cached_balances:
|
||||||
|
@ -86,7 +86,7 @@ def query_statement(blockchain_address: str, limit: int = 9):
|
|||||||
:param limit: Number of transactions to be returned.
|
:param limit: Number of transactions to be returned.
|
||||||
:type limit: int
|
: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__()
|
chain_str = Chain.spec.__str__()
|
||||||
cic_eth_api = Api(
|
cic_eth_api = Api(
|
||||||
chain_str=chain_str,
|
chain_str=chain_str,
|
||||||
|
@ -37,7 +37,7 @@ class MenuProcessor:
|
|||||||
def __init__(self, account: Account, display_key: str, menu_name: str, session: Session, ussd_session: dict):
|
def __init__(self, account: Account, display_key: str, menu_name: str, session: Session, ussd_session: dict):
|
||||||
self.account = account
|
self.account = account
|
||||||
self.display_key = display_key
|
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.menu_name = menu_name
|
||||||
self.session = session
|
self.session = session
|
||||||
self.ussd_session = ussd_session
|
self.ussd_session = ussd_session
|
||||||
|
@ -113,8 +113,10 @@ def statement_callback(self, result, param: str, status_code: int):
|
|||||||
for transaction in statement_transactions:
|
for transaction in statement_transactions:
|
||||||
recipient_transaction, sender_transaction = transaction_actors(transaction)
|
recipient_transaction, sender_transaction = transaction_actors(transaction)
|
||||||
if recipient_transaction.get('blockchain_address') == param:
|
if recipient_transaction.get('blockchain_address') == param:
|
||||||
|
recipient_transaction['alt_blockchain_address'] = sender_transaction.get('blockchain_address')
|
||||||
generate(param, queue, recipient_transaction)
|
generate(param, queue, recipient_transaction)
|
||||||
if sender_transaction.get('blockchain_address') == param:
|
if sender_transaction.get('blockchain_address') == param:
|
||||||
|
sender_transaction['alt_blockchain_address'] = recipient_transaction.get('blockchain_address')
|
||||||
generate(param, queue, sender_transaction)
|
generate(param, queue, sender_transaction)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,17 +23,13 @@ logg = logging.getLogger(__file__)
|
|||||||
def generate_statement(self, querying_party: str, transaction: dict):
|
def generate_statement(self, querying_party: str, transaction: dict):
|
||||||
""""""
|
""""""
|
||||||
queue = self.request.delivery_info.get('routing_key')
|
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(
|
s_parse_transaction = celery.signature(
|
||||||
'cic_ussd.tasks.processor.parse_transaction', [transaction], queue=queue
|
'cic_ussd.tasks.processor.parse_transaction', [transaction], queue=queue
|
||||||
)
|
)
|
||||||
s_cache_statement = celery.signature(
|
s_cache_statement = celery.signature(
|
||||||
'cic_ussd.tasks.processor.cache_statement', [querying_party], queue=queue
|
'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
|
@celery_app.task
|
||||||
|
12
apps/cic-ussd/tests/fixtures/account.py
vendored
12
apps/cic-ussd/tests/fixtures/account.py
vendored
@ -54,7 +54,7 @@ def cache_account_creation_data(init_cache, account_creation_data):
|
|||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def cache_balances(activated_account, balances, init_cache):
|
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])
|
balances = json.dumps(balances[0])
|
||||||
key = cache_data_key(identifier, ':cic.balances')
|
key = cache_data_key(identifier, ':cic.balances')
|
||||||
cache_data(key, 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')
|
@pytest.fixture(scope='function')
|
||||||
def cache_person_metadata(activated_account, init_cache, person_metadata):
|
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)
|
person = json.dumps(person_metadata)
|
||||||
key = cache_data_key(identifier, ':cic.person')
|
key = cache_data_key(identifier, ':cic.person')
|
||||||
cache_data(key, person)
|
cache_data(key, person)
|
||||||
@ -78,7 +78,7 @@ def cache_person_metadata(activated_account, init_cache, person_metadata):
|
|||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def cache_preferences(activated_account, init_cache, preferences):
|
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)
|
preferences = json.dumps(preferences)
|
||||||
key = cache_data_key(identifier, ':cic.preferences')
|
key = cache_data_key(identifier, ':cic.preferences')
|
||||||
cache_data(key, preferences)
|
cache_data(key, preferences)
|
||||||
@ -86,10 +86,10 @@ def cache_preferences(activated_account, init_cache, preferences):
|
|||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def cache_statement(activated_account, init_cache, statement):
|
def cache_statement(activated_account, init_cache, statement):
|
||||||
identifier = bytes.fromhex(strip_0x(activated_account.blockchain_address))
|
identifier = bytes.fromhex(activated_account.blockchain_address)
|
||||||
preferences = json.dumps(statement)
|
statement = json.dumps(statement)
|
||||||
key = cache_data_key(identifier, ':cic.statement')
|
key = cache_data_key(identifier, ':cic.statement')
|
||||||
cache_data(key, preferences)
|
cache_data(key, statement)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
|
14
apps/cic-ussd/tests/fixtures/transaction.py
vendored
14
apps/cic-ussd/tests/fixtures/transaction.py
vendored
@ -7,6 +7,7 @@ import pytest
|
|||||||
# local import
|
# local import
|
||||||
from cic_ussd.account.balance import get_cached_available_balance
|
from cic_ussd.account.balance import get_cached_available_balance
|
||||||
|
|
||||||
|
|
||||||
# tests imports
|
# tests imports
|
||||||
|
|
||||||
|
|
||||||
@ -103,8 +104,8 @@ def transactions_list(activated_account, valid_recipient):
|
|||||||
'destination_token': '0x0000000000000000000000000000000000000000',
|
'destination_token': '0x0000000000000000000000000000000000000000',
|
||||||
'block_number': 80,
|
'block_number': 80,
|
||||||
'tx_index': 0,
|
'tx_index': 0,
|
||||||
'sender': '0x367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
|
'sender': '367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
|
||||||
'recipient': '0x103d1ed6e370dBa6267045c70d4999384c18a04A',
|
'recipient': '103d1ed6e370dBa6267045c70d4999384c18a04A',
|
||||||
'from_value': 0,
|
'from_value': 0,
|
||||||
'to_value': 0,
|
'to_value': 0,
|
||||||
'date_created': '2021-07-14T14:13:46.036198',
|
'date_created': '2021-07-14T14:13:46.036198',
|
||||||
@ -122,8 +123,8 @@ def transactions_list(activated_account, valid_recipient):
|
|||||||
'destination_token': '0x0000000000000000000000000000000000000000',
|
'destination_token': '0x0000000000000000000000000000000000000000',
|
||||||
'block_number': 78,
|
'block_number': 78,
|
||||||
'tx_index': 0,
|
'tx_index': 0,
|
||||||
'sender': '0xb41BfEE260693A473254D62b81aE1ADCC9E51AFb',
|
'sender': 'b41BfEE260693A473254D62b81aE1ADCC9E51AFb',
|
||||||
'recipient': '0x367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
|
'recipient': '367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
|
||||||
'from_value': 1800000000000000,
|
'from_value': 1800000000000000,
|
||||||
'to_value': 1800000000000000,
|
'to_value': 1800000000000000,
|
||||||
'date_created': '2021-07-14T14:13:35.839638',
|
'date_created': '2021-07-14T14:13:35.839638',
|
||||||
@ -142,8 +143,8 @@ def transactions_list(activated_account, valid_recipient):
|
|||||||
'destination_token': '0x0000000000000000000000000000000000000000',
|
'destination_token': '0x0000000000000000000000000000000000000000',
|
||||||
'block_number': 79,
|
'block_number': 79,
|
||||||
'tx_index': 0,
|
'tx_index': 0,
|
||||||
'sender': '0x367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
|
'sender': '367cB0F65137b0A845c1DB4B7Ca47D3DEF32dDe8',
|
||||||
'recipient': '0x103d1ed6e370dBa6267045c70d4999384c18a04A',
|
'recipient': '103d1ed6e370dBa6267045c70d4999384c18a04A',
|
||||||
'from_value': 0,
|
'from_value': 0,
|
||||||
'to_value': 0,
|
'to_value': 0,
|
||||||
'date_created': '2021-07-14T14:13:35.638355',
|
'date_created': '2021-07-14T14:13:35.638355',
|
||||||
@ -152,4 +153,3 @@ def transactions_list(activated_account, valid_recipient):
|
|||||||
'timestamp': 1626272015,
|
'timestamp': 1626272015,
|
||||||
'hash': '0x32ca3dd3bef06463b452f4d32f5f563d083cb4759219eed90f3d2a9c1791c5fc'}
|
'hash': '0x32ca3dd3bef06463b452f4d32f5f563d083cb4759219eed90f3d2a9c1791c5fc'}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user