Bug fixes with tokenSum calculation right before a contract is triggered

This commit is contained in:
RanchiMall Dev 2023-10-09 07:52:48 +00:00
parent 78b05be204
commit 08168cac5e

View File

@ -285,7 +285,6 @@ def add_contract_transaction_history(contract_name, contract_address, transactio
session.close() session.close()
def rejected_transaction_history(transaction_data, parsed_data, sourceFloAddress, destFloAddress, rejectComment): def rejected_transaction_history(transaction_data, parsed_data, sourceFloAddress, destFloAddress, rejectComment):
session = create_database_session_orm('system_dbs', {'db_name': "system"}, TokenBase) session = create_database_session_orm('system_dbs', {'db_name': "system"}, TokenBase)
blockchainReference = neturl + 'tx/' + transaction_data['txid'] blockchainReference = neturl + 'tx/' + transaction_data['txid']
@ -493,6 +492,9 @@ def processBlock(blockindex=None, blockhash=None):
for transaction_data in blockinfo["txs"]: for transaction_data in blockinfo["txs"]:
transaction = transaction_data["txid"] transaction = transaction_data["txid"]
# if transaction == 'cd1176b2567ca2ae15624962008d3d935ebd36b99e419f5ad745dadd5858669f':
# pdb.set_trace()
try: try:
text = transaction_data["floData"] text = transaction_data["floData"]
except: except:
@ -822,6 +824,7 @@ def checkLocal_expiry_trigger_deposit(blockinfo):
for query in active_contracts: for query in active_contracts:
query_time = convert_datetime_to_arrowobject(query.time) query_time = convert_datetime_to_arrowobject(query.time)
blocktime = parsing.arrow.get(blockinfo['time']).to('Asia/Kolkata') blocktime = parsing.arrow.get(blockinfo['time']).to('Asia/Kolkata')
if query.activity == 'contract-time-trigger': if query.activity == 'contract-time-trigger':
contractStructure = extract_contractStructure(query.contractName, query.contractAddress) contractStructure = extract_contractStructure(query.contractName, query.contractAddress)
connection = create_database_connection('smart_contract', {'contract_name':f"{query.contractName}", 'contract_address':f"{query.contractAddress}"}) connection = create_database_connection('smart_contract', {'contract_name':f"{query.contractName}", 'contract_address':f"{query.contractAddress}"})
@ -875,6 +878,7 @@ def checkLocal_expiry_trigger_deposit(blockinfo):
tokenAmount_sum = connection.execute('SELECT IFNULL(sum(tokenAmount), 0) FROM contractparticipants').fetchall()[0][0] tokenAmount_sum = connection.execute('SELECT IFNULL(sum(tokenAmount), 0) FROM contractparticipants').fetchall()[0][0]
if tokenAmount_sum >= maximumsubscriptionamount: if tokenAmount_sum >= maximumsubscriptionamount:
# Trigger the contract # Trigger the contract
# pdb.set_trace()
success_returnval = trigger_internal_contract(tokenAmount_sum, contractStructure, transaction_data, blockinfo, parsed_data, connection, contract_name=query.contractName, contract_address=query.contractAddress, transaction_subType='maximumsubscriptionamount') success_returnval = trigger_internal_contract(tokenAmount_sum, contractStructure, transaction_data, blockinfo, parsed_data, connection, contract_name=query.contractName, contract_address=query.contractAddress, transaction_subType='maximumsubscriptionamount')
if not success_returnval: if not success_returnval:
return 0 return 0
@ -889,6 +893,8 @@ def checkLocal_expiry_trigger_deposit(blockinfo):
return return
# Trigger the contract # Trigger the contract
tokenAmount_sum = connection.execute('SELECT IFNULL(sum(tokenAmount), 0) FROM contractparticipants').fetchall()[0][0]
# pdb.set_trace()
success_returnval = trigger_internal_contract(tokenAmount_sum, contractStructure, transaction_data, blockinfo, parsed_data, connection, contract_name=query.contractName, contract_address=query.contractAddress, transaction_subType='expiryTime') success_returnval = trigger_internal_contract(tokenAmount_sum, contractStructure, transaction_data, blockinfo, parsed_data, connection, contract_name=query.contractName, contract_address=query.contractAddress, transaction_subType='expiryTime')
if not success_returnval: if not success_returnval:
return 0 return 0
@ -1226,6 +1232,11 @@ def processTransaction(transaction_data, parsed_data, blockinfo):
return 0 return 0
else: else:
partialTransferCounter = 1 partialTransferCounter = 1
rejectComment = f"Transaction {transaction_data['txid']} rejected as the partial transfer of token {contractStructure['tokenIdentification'].upper()} is not allowed, for the Smart contract named {parsed_data['contractName']} at the address {outputlist[0]}"
logger.info(rejectComment)
rejected_contract_transaction_history(transaction_data, parsed_data, 'participation', outputlist[0], inputadd, outputlist[0], rejectComment)
pushData_SSEapi(rejectComment)
return 0
# Check if exitcondition exists as part of contractstructure and is given in right format # Check if exitcondition exists as part of contractstructure and is given in right format
if 'exitconditions' in contractStructure: if 'exitconditions' in contractStructure:
@ -1939,7 +1950,7 @@ def processTransaction(transaction_data, parsed_data, blockinfo):
participantAdd_txhash = connection.execute(f"SELECT sourceFloAddress, transactionHash FROM contractTransactionHistory WHERE transactionType != 'incorporation'").fetchall() participantAdd_txhash = connection.execute(f"SELECT sourceFloAddress, transactionHash FROM contractTransactionHistory WHERE transactionType != 'incorporation'").fetchall()
participantAdd_txhash_T = list(zip(*participantAdd_txhash)) participantAdd_txhash_T = list(zip(*participantAdd_txhash))
if len(participantAdd_txhash) != 0 and transaction_data['txid'] in list(participantAdd_txhash_T[1]): if len(participantAdd_txhash) != 0 and transaction_data['txid'] in participantAdd_txhash_T[1]:
logger.warning(f"Transaction {transaction_data['txid']} rejected as it already exists in the Smart Contract db. This is unusual, please check your code") logger.warning(f"Transaction {transaction_data['txid']} rejected as it already exists in the Smart Contract db. This is unusual, please check your code")
pushData_SSEapi(f"Error | Transaction {transaction_data['txid']} rejected as it already exists in the Smart Contract db. This is unusual, please check your code") pushData_SSEapi(f"Error | Transaction {transaction_data['txid']} rejected as it already exists in the Smart Contract db. This is unusual, please check your code")
return 0 return 0