Philip/dry run prep
This commit is contained in:
@@ -102,9 +102,9 @@ def process_exit_successful_transaction(display_key: str, user: User, ussd_sessi
|
||||
transaction_amount = to_wei(int(ussd_session.get('session_data').get('transaction_amount')))
|
||||
token_symbol = 'SRF'
|
||||
recipient_phone_number = ussd_session.get('session_data').get('recipient_phone_number')
|
||||
sender_phone_number = user.phone_number
|
||||
tx_recipient_information = recipient_phone_number
|
||||
tx_sender_information = sender_phone_number
|
||||
recipient = get_user_by_phone_number(phone_number=recipient_phone_number)
|
||||
tx_recipient_information = define_account_tx_metadata(user=recipient)
|
||||
tx_sender_information = define_account_tx_metadata(user=user)
|
||||
|
||||
return translation_for(
|
||||
key=display_key,
|
||||
@@ -184,10 +184,10 @@ def format_transactions(transactions: list, preferred_language: str):
|
||||
for transaction in transactions:
|
||||
recipient_phone_number = transaction.get('recipient_phone_number')
|
||||
sender_phone_number = transaction.get('sender_phone_number')
|
||||
value = transaction.get('destination_value')
|
||||
value = transaction.get('to_value')
|
||||
timestamp = transaction.get('timestamp')
|
||||
action_tag = transaction.get('action_tag')
|
||||
token_symbol = transaction.get('destination_token_symbol')
|
||||
token_symbol = 'SRF'
|
||||
|
||||
if action_tag == 'SENT' or action_tag == 'ULITUMA':
|
||||
formatted_transactions += f'{action_tag} {value} {token_symbol} {recipient_phone_number} {timestamp}.\n'
|
||||
@@ -222,6 +222,8 @@ def process_account_statement(user: User, display_key: str, ussd_session: dict):
|
||||
middle_transaction_set = []
|
||||
last_transaction_set = []
|
||||
|
||||
transactions = json.loads(transactions)
|
||||
|
||||
if len(transactions) > 6:
|
||||
last_transaction_set += transactions[6:]
|
||||
middle_transaction_set += transactions[3:][:3]
|
||||
@@ -233,10 +235,7 @@ def process_account_statement(user: User, display_key: str, ussd_session: dict):
|
||||
else:
|
||||
first_transaction_set += transactions[:3]
|
||||
|
||||
logg.debug(f'TRANSACTIONS: {transactions}')
|
||||
|
||||
if display_key == 'ussd.kenya.first_transaction_set':
|
||||
logg.debug(f'FIRST TRANSACTION SET: {first_transaction_set}')
|
||||
return translation_for(
|
||||
key=display_key,
|
||||
preferred_language=user.preferred_language,
|
||||
|
||||
@@ -101,9 +101,9 @@ InMemoryUssdSession.redis_cache = InMemoryStore.cache
|
||||
UserMetadata.base_url = config.get('CIC_META_URL')
|
||||
|
||||
# define signer values
|
||||
Signer.gpg_path = '/tmp/.gpg'
|
||||
Signer.gpg_passphrase = config.get('KEYS_PASSPHRASE')
|
||||
Signer.key_file_path = config.get('KEYS_PRIVATE')
|
||||
Signer.gpg_path = config.get('PGP_EXPORT_DIR')
|
||||
Signer.gpg_passphrase = config.get('PGP_PASSPHRASE')
|
||||
Signer.key_file_path = f"{config.get('PGP_KEYS_PATH')}{config.get('PGP_PRIVATE_KEYS')}"
|
||||
|
||||
# initialize celery app
|
||||
celery.Celery(backend=config.get('CELERY_RESULT_URL'), broker=config.get('CELERY_BROKER_URL'))
|
||||
|
||||
@@ -39,7 +39,6 @@ config.censor('PASSWORD', 'DATABASE')
|
||||
# define log levels
|
||||
if args.vv:
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)
|
||||
elif args.v:
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
|
||||
@@ -66,9 +65,9 @@ InMemoryUssdSession.redis_cache = InMemoryStore.cache
|
||||
UserMetadata.base_url = config.get('CIC_META_URL')
|
||||
|
||||
# define signer values
|
||||
Signer.gpg_path = '/tmp/.gpg'
|
||||
Signer.gpg_passphrase = config.get('KEYS_PASSPHRASE')
|
||||
Signer.key_file_path = config.get('KEYS_PRIVATE')
|
||||
Signer.gpg_path = config.get('PGP_EXPORT_DIR')
|
||||
Signer.gpg_passphrase = config.get('PGP_PASSPHRASE')
|
||||
Signer.key_file_path = f"{config.get('PGP_KEYS_PATH')}{config.get('PGP_PRIVATE_KEYS')}"
|
||||
|
||||
# set up celery
|
||||
current_app = celery.Celery(__name__)
|
||||
|
||||
@@ -165,7 +165,6 @@ def process_statement_callback(result, param: str, status_code: int):
|
||||
sender_blockchain_address = transaction.get('sender')
|
||||
recipient_address = transaction.get('recipient')
|
||||
source_token = transaction.get('source_token')
|
||||
destination_token_symbol = transaction.get('destination_token_symbol')
|
||||
|
||||
# filter out any transactions that are "gassy"
|
||||
if '0x0000000000000000000000000000000000000000' in source_token:
|
||||
@@ -198,9 +197,8 @@ def process_statement_callback(result, param: str, status_code: int):
|
||||
logg.warning(f'Tx with recipient not found in cic-ussd')
|
||||
|
||||
# add transaction values
|
||||
processed_transaction['destination_value'] = from_wei(value=transaction.get('destination_value'))
|
||||
processed_transaction['destination_token_symbol'] = destination_token_symbol
|
||||
processed_transaction['source_value'] = from_wei(value=transaction.get('source_value'))
|
||||
processed_transaction['to_value'] = from_wei(value=transaction.get('to_value'))
|
||||
processed_transaction['from_value'] = from_wei(value=transaction.get('from_value'))
|
||||
|
||||
raw_timestamp = transaction.get('timestamp')
|
||||
timestamp = datetime.utcfromtimestamp(raw_timestamp).strftime('%d/%m/%y, %H:%M')
|
||||
|
||||
Reference in New Issue
Block a user