Ussd changes to address format.
This commit is contained in:
parent
1acfff9f46
commit
2babcbdbdb
@ -4,7 +4,6 @@ import logging
|
||||
from typing import Optional
|
||||
|
||||
# external imports
|
||||
from chainlib.hash import strip_0x
|
||||
from cic_types.models.person import Person
|
||||
|
||||
# local imports
|
||||
@ -20,7 +19,7 @@ def get_cached_preferred_language(blockchain_address: str) -> Optional[str]:
|
||||
:return: Account's set preferred language | Fallback preferred language.
|
||||
:rtype: str
|
||||
"""
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
preferences_metadata_handler = PreferencesMetadata(identifier)
|
||||
cached_preferences_metadata = preferences_metadata_handler.get_cached_metadata()
|
||||
if cached_preferences_metadata:
|
||||
|
@ -2,7 +2,6 @@
|
||||
import json
|
||||
|
||||
# external imports
|
||||
from chainlib.hash import strip_0x
|
||||
from cic_eth.api import Api
|
||||
|
||||
# local imports
|
||||
@ -101,7 +100,7 @@ class Account(SessionBase):
|
||||
session.add(self)
|
||||
session.flush()
|
||||
SessionBase.release_session(session=session)
|
||||
return f'Pin reset successful.'
|
||||
return 'Pin reset successful.'
|
||||
|
||||
def standard_metadata_id(self) -> str:
|
||||
"""This function creates an account's standard metadata identification information that contains an account owner's
|
||||
@ -109,7 +108,7 @@ class Account(SessionBase):
|
||||
:return: Standard metadata identification information | e164 formatted phone number.
|
||||
:rtype: str
|
||||
"""
|
||||
identifier = bytes.fromhex(strip_0x(self.blockchain_address))
|
||||
identifier = bytes.fromhex(self.blockchain_address)
|
||||
key = cache_data_key(identifier, ':cic.person')
|
||||
account_metadata = get_cached_data(key)
|
||||
if not account_metadata:
|
||||
|
@ -5,7 +5,6 @@ from datetime import timedelta
|
||||
|
||||
# third-party imports
|
||||
import celery
|
||||
from chainlib.hash import strip_0x
|
||||
|
||||
# local imports
|
||||
from cic_ussd.account.balance import get_balances, calculate_available_balance
|
||||
@ -55,6 +54,7 @@ def account_creation_callback(self, result: str, url: str, status_code: int):
|
||||
session.add(account)
|
||||
session.commit()
|
||||
session.close()
|
||||
logg.debug(f'recorded account with identifier: {result}')
|
||||
|
||||
queue = self.request.delivery_info.get('routing_key')
|
||||
s_phone_pointer = celery.signature(
|
||||
@ -86,7 +86,7 @@ def balances_callback(result: list, param: str, status_code: int):
|
||||
raise ValueError(f'Unexpected status code: {status_code}.')
|
||||
|
||||
balances = result[0]
|
||||
identifier = bytes.fromhex(strip_0x(param))
|
||||
identifier = bytes.fromhex(param)
|
||||
key = cache_data_key(identifier, ':cic.balances')
|
||||
cache_data(key, json.dumps(balances))
|
||||
|
||||
|
@ -3,7 +3,6 @@ import logging
|
||||
|
||||
# third-party imports
|
||||
import celery
|
||||
from hexathon import strip_0x
|
||||
|
||||
# local imports
|
||||
from cic_ussd.metadata import CustomMetadata, PersonMetadata, PhonePointerMetadata, PreferencesMetadata
|
||||
@ -21,7 +20,7 @@ def query_person_metadata(blockchain_address: str):
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
person_metadata_client = PersonMetadata(identifier=identifier)
|
||||
person_metadata_client.query()
|
||||
|
||||
@ -36,14 +35,14 @@ def create_person_metadata(blockchain_address: str, data: dict):
|
||||
:return:
|
||||
:rtype:
|
||||
"""
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
person_metadata_client = PersonMetadata(identifier=identifier)
|
||||
person_metadata_client.create(data=data)
|
||||
|
||||
|
||||
@celery_app.task
|
||||
def edit_person_metadata(blockchain_address: str, data: dict):
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
person_metadata_client = PersonMetadata(identifier=identifier)
|
||||
person_metadata_client.edit(data=data)
|
||||
|
||||
@ -51,21 +50,21 @@ def edit_person_metadata(blockchain_address: str, data: dict):
|
||||
@celery_app.task(bind=True, base=CriticalMetadataTask)
|
||||
def add_phone_pointer(self, blockchain_address: str, phone_number: str):
|
||||
identifier = phone_number.encode('utf-8')
|
||||
stripped_address = strip_0x(blockchain_address)
|
||||
stripped_address = blockchain_address
|
||||
phone_metadata_client = PhonePointerMetadata(identifier=identifier)
|
||||
phone_metadata_client.create(data=stripped_address)
|
||||
|
||||
|
||||
@celery_app.task()
|
||||
def add_custom_metadata(blockchain_address: str, data: dict):
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
custom_metadata_client = CustomMetadata(identifier=identifier)
|
||||
custom_metadata_client.create(data=data)
|
||||
|
||||
|
||||
@celery_app.task()
|
||||
def add_preferences_metadata(blockchain_address: str, data: dict):
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
preferences_metadata_client = PreferencesMetadata(identifier=identifier)
|
||||
preferences_metadata_client.create(data=data)
|
||||
|
||||
@ -76,7 +75,7 @@ def query_preferences_metadata(blockchain_address: str):
|
||||
:param blockchain_address: Blockchain address of an account.
|
||||
:type blockchain_address: str | Ox-hex
|
||||
"""
|
||||
identifier = bytes.fromhex(strip_0x(blockchain_address))
|
||||
identifier = bytes.fromhex(blockchain_address)
|
||||
logg.debug(f'Retrieving preferences metadata for address: {blockchain_address}.')
|
||||
person_metadata_client = PreferencesMetadata(identifier=identifier)
|
||||
return person_metadata_client.query()
|
||||
|
@ -5,7 +5,6 @@ import logging
|
||||
# third-party imports
|
||||
import celery
|
||||
import i18n
|
||||
from chainlib.hash import strip_0x
|
||||
|
||||
# local imports
|
||||
from cic_ussd.account.metadata import get_cached_preferred_language
|
||||
@ -53,7 +52,7 @@ def cache_statement(parsed_transaction: dict, querying_party: str):
|
||||
statement_transactions = json.loads(cached_statement)
|
||||
statement_transactions.append(parsed_transaction)
|
||||
data = json.dumps(statement_transactions)
|
||||
identifier = bytes.fromhex(strip_0x(querying_party))
|
||||
identifier = bytes.fromhex(querying_party)
|
||||
key = cache_data_key(identifier, ':cic.statement')
|
||||
cache_data(key, data)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user