Compare commits
5 Commits
86946b4c38
...
84504a135e
Author | SHA1 | Date | |
---|---|---|---|
84504a135e | |||
4ecac371cf | |||
d5a1809733 | |||
cbef99704f | |||
ce38e6c6f7 |
@ -26,6 +26,7 @@ from chainlib.chain import ChainSpec
|
||||
from chainqueue.db.models.otx import Otx
|
||||
from cic_eth_registry.error import UnknownContractError
|
||||
from cic_eth_registry.erc20 import ERC20Token
|
||||
from cic_eth.eth.util import MAXIMUM_FEE_UNITS
|
||||
from hexathon import add_0x
|
||||
import liveness.linux
|
||||
|
||||
@ -232,6 +233,7 @@ def main():
|
||||
if config.get('ETH_MIN_FEE_PRICE'):
|
||||
BaseTask.min_fee_price = int(config.get('ETH_MIN_FEE_PRICE'))
|
||||
CriticalWeb3Task.safe_gas_threshold_amount *= BaseTask.min_fee_price
|
||||
CriticalWeb3Task.safe_gas_refill_amount = CriticalWeb3Task.safe_gas_refill_amount + MAXIMUM_FEE_UNITS
|
||||
CriticalWeb3Task.safe_gas_refill_amount *= BaseTask.min_fee_price
|
||||
CriticalWeb3Task.safe_gas_gifter_balance *= BaseTask.min_fee_price
|
||||
|
||||
|
@ -12,4 +12,4 @@ erc20-faucet~=0.3.2
|
||||
erc20-transfer-authorization~=0.3.6
|
||||
sarafu-faucet~=0.0.7
|
||||
moolb~=0.2.0
|
||||
okota~=0.2.5
|
||||
okota~=0.2.6
|
||||
|
@ -66,14 +66,15 @@ def parse_statement_transactions(statement: list):
|
||||
:rtype:
|
||||
"""
|
||||
parsed_transactions = []
|
||||
statement.sort(key=lambda d: d['timestamp'], reverse=True)
|
||||
for transaction in statement:
|
||||
action_tag = transaction.get('action_tag')
|
||||
decimals = transaction.get('token_decimals')
|
||||
amount = from_wei(decimals, transaction.get('token_value'))
|
||||
direction_tag = transaction.get('direction_tag')
|
||||
token_symbol = transaction.get('token_symbol')
|
||||
metadata_id = transaction.get('metadata_id')
|
||||
timestamp = datetime.datetime.now().strftime('%d/%m/%y, %H:%M')
|
||||
metadata_id = transaction.get('alt_metadata_id')
|
||||
timestamp = transaction.get('timestamp')
|
||||
transaction_repr = f'{action_tag} {amount} {token_symbol} {direction_tag} {metadata_id} {timestamp}'
|
||||
parsed_transactions.append(transaction_repr)
|
||||
return parsed_transactions
|
||||
|
@ -265,8 +265,9 @@ def process_token_data(blockchain_address: str, token_symbol: str):
|
||||
query_token_metadata(identifier=identifier)
|
||||
token_info = query_token_info(identifier=identifier)
|
||||
hashed_token_info = hashed_token_proof(token_proof=token_info)
|
||||
hashed_token_symbol = hashed_token_proof(token_symbol)
|
||||
query_token_data(blockchain_address=blockchain_address,
|
||||
hashed_proofs=[hashed_token_info],
|
||||
hashed_proofs=[[hashed_token_info, hashed_token_symbol]],
|
||||
token_symbols=[token_symbol])
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import json
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
# external imports
|
||||
import celery
|
||||
@ -143,9 +143,11 @@ def statement_callback(self, result, param: str, status_code: int):
|
||||
recipient_transaction, sender_transaction = transaction_actors(transaction)
|
||||
if recipient_transaction.get('blockchain_address') == param:
|
||||
recipient_transaction['alt_blockchain_address'] = sender_transaction.get('blockchain_address')
|
||||
recipient_transaction['timestamp'] = datetime.utcfromtimestamp(transaction.get('timestamp')).strftime('%d/%m/%y, %H:%M')
|
||||
generate(param, queue, recipient_transaction)
|
||||
if sender_transaction.get('blockchain_address') == param:
|
||||
sender_transaction['alt_blockchain_address'] = recipient_transaction.get('blockchain_address')
|
||||
sender_transaction['timestamp'] = datetime.utcfromtimestamp(transaction.get('timestamp')).strftime('%d/%m/%y, %H:%M')
|
||||
generate(param, queue, sender_transaction)
|
||||
|
||||
|
||||
@ -231,6 +233,10 @@ def transaction_callback(result: dict, param: str, status_code: int):
|
||||
if status_code != 0:
|
||||
raise ValueError(f'Unexpected status code: {status_code}.')
|
||||
|
||||
print(f'THE RETURNING TRANSACTION IS: {result}')
|
||||
print(f'STATUS CODE: {status_code}')
|
||||
print(f'WITH PARAM: {param}')
|
||||
|
||||
chain_str = Chain.spec.__str__()
|
||||
destination_token_symbol = result.get('destination_token_symbol')
|
||||
destination_token_value = result.get('destination_token_value')
|
||||
|
@ -1,4 +1,5 @@
|
||||
# standard imports
|
||||
import datetime
|
||||
import json
|
||||
|
||||
# external imports
|
||||
@ -119,8 +120,11 @@ def test_statement_callback(activated_account, mocker, transactions_list):
|
||||
[transactions_list, activated_account.blockchain_address, status_code])
|
||||
s_statement_callback.apply_async().get()
|
||||
statement_transactions = filter_statement_transactions(transactions_list)
|
||||
timestamp = transactions_list[0].get('timestamp')
|
||||
timestamp = datetime.datetime.utcfromtimestamp(timestamp).strftime('%d/%m/%y, %H:%M')
|
||||
recipient_transaction, sender_transaction = transaction_actors(statement_transactions[0])
|
||||
sender_transaction['alt_blockchain_address'] = recipient_transaction.get('blockchain_address')
|
||||
sender_transaction['timestamp'] = timestamp
|
||||
mock_statement_generate.assert_called_with(
|
||||
(activated_account.blockchain_address, sender_transaction), {}, queue='cic-ussd')
|
||||
|
||||
|
4
apps/cic-ussd/tests/fixtures/transaction.py
vendored
4
apps/cic-ussd/tests/fixtures/transaction.py
vendored
@ -1,6 +1,5 @@
|
||||
# standard import
|
||||
import random
|
||||
|
||||
from datetime import datetime
|
||||
# external import
|
||||
import pytest
|
||||
|
||||
@ -46,6 +45,7 @@ def statement(activated_account):
|
||||
'direction_tag': 'To',
|
||||
'metadata_id': activated_account.standard_metadata_id(),
|
||||
'phone_number': activated_account.phone_number,
|
||||
'timestamp': datetime.now().strftime('%d/%m/%y, %H:%M')
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"trigger": "scan_data",
|
||||
"source": "first_transaction_set",
|
||||
"dest": "middle_transaction_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_one_selected"
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_eleven_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
@ -20,13 +20,13 @@
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_transaction_set",
|
||||
"dest": "last_transaction_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_one_selected"
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_eleven_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_transaction_set",
|
||||
"dest": "first_transaction_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_two_selected"
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
@ -43,7 +43,7 @@
|
||||
"trigger": "scan_data",
|
||||
"source": "last_transaction_set",
|
||||
"dest": "middle_transaction_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_two_selected"
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
|
@ -6,6 +6,13 @@
|
||||
"after": "cic_ussd.state_machine.logic.account.process_account_creation",
|
||||
"conditions": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_language_selection",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless":"cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_language_selection",
|
||||
@ -16,15 +23,20 @@
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_language_selection",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless":"cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_middle_language_set",
|
||||
"dest": "initial_language_selection",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected",
|
||||
"dest": "account_creation_prompt",
|
||||
"after": "cic_ussd.state_machine.logic.account.process_account_creation",
|
||||
"conditions": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_middle_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
@ -37,6 +49,25 @@
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_middle_language_set",
|
||||
"dest": "initial_language_selection",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_middle_language_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_last_language_set",
|
||||
"dest": "account_creation_prompt",
|
||||
"after": "cic_ussd.state_machine.logic.account.process_account_creation",
|
||||
"conditions": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_last_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
@ -51,58 +82,46 @@
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_last_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_middle_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "initial_language_selection",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_language_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "select_preferred_language",
|
||||
"dest": "exit",
|
||||
"after": "cic_ussd.state_machine.logic.language.change_preferred_language",
|
||||
"dest": "account_creation_prompt",
|
||||
"after": "cic_ussd.state_machine.logic.account.process_account_creation",
|
||||
"conditions": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "select_preferred_language",
|
||||
"dest": "middle_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless":"cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "select_preferred_language",
|
||||
"dest": "initial_middle_language_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_eleven_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "select_preferred_language",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "select_preferred_language",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected",
|
||||
"dest": "account_creation_prompt",
|
||||
"after": "cic_ussd.state_machine.logic.account.process_account_creation",
|
||||
"conditions": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
@ -115,41 +134,36 @@
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "select_preferred_langauge",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_language_set",
|
||||
"dest": "account_creation_prompt",
|
||||
"after": "cic_ussd.state_machine.logic.account.process_account_creation",
|
||||
"conditions": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_language_set",
|
||||
"dest": "middle_language_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected",
|
||||
"unless": "cic_ussd.state_machine.logic.language.is_valid_language_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "select_preferred_language",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_language_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_language_set",
|
||||
|
@ -1,16 +1,4 @@
|
||||
[
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "first_account_tokens_set",
|
||||
"dest": "middle_account_tokens_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_eleven_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "first_account_tokens_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "first_account_tokens_set",
|
||||
@ -18,11 +6,36 @@
|
||||
"conditions": "cic_ussd.state_machine.logic.tokens.is_valid_token_selection",
|
||||
"after": "cic_ussd.state_machine.logic.tokens.process_token_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "first_account_tokens_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "first_account_tokens_set",
|
||||
"dest": "middle_account_tokens_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_eleven_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "first_account_tokens_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_account_tokens_set",
|
||||
"dest": "token_selection_pin_authorization",
|
||||
"conditions": "cic_ussd.state_machine.logic.tokens.is_valid_token_selection",
|
||||
"after": "cic_ussd.state_machine.logic.tokens.process_token_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_account_tokens_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_account_tokens_set",
|
||||
@ -38,20 +51,20 @@
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_account_tokens_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected"
|
||||
"dest": "exit_invalid_menu_option"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_account_tokens_set",
|
||||
"source": "last_account_tokens_set",
|
||||
"dest": "token_selection_pin_authorization",
|
||||
"conditions": "cic_ussd.state_machine.logic.tokens.is_valid_token_selection",
|
||||
"after": "cic_ussd.state_machine.logic.tokens.process_token_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "middle_account_tokens_set",
|
||||
"dest": "exit_invalid_menu_option"
|
||||
"source": "last_account_tokens_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
@ -59,19 +72,6 @@
|
||||
"dest": "middle_account_tokens_set",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_twenty_two_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_account_tokens_set",
|
||||
"dest": "exit",
|
||||
"conditions": "cic_ussd.state_machine.logic.menu.menu_zero_zero_selected"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_account_tokens_set",
|
||||
"dest": "token_selection_pin_authorization",
|
||||
"conditions": "cic_ussd.state_machine.logic.tokens.is_valid_token_selection",
|
||||
"after": "cic_ussd.state_machine.logic.tokens.process_token_selection"
|
||||
},
|
||||
{
|
||||
"trigger": "scan_data",
|
||||
"source": "last_account_tokens_set",
|
||||
|
@ -9,4 +9,4 @@ erc20-faucet==0.3.2
|
||||
sarafu-faucet==0.0.7
|
||||
confini~=0.5.3
|
||||
eth-token-index==0.2.4
|
||||
okota==0.2.5a1
|
||||
okota==0.2.6
|
||||
|
Loading…
Reference in New Issue
Block a user