From 15bc31c4a737ebe283a714d95fe5c6dca4b7754d Mon Sep 17 00:00:00 2001 From: RanchiMall Dev Date: Wed, 26 Apr 2023 15:58:23 +0000 Subject: [PATCH 1/3] Fix for multisig support --- tracktokens_smartcontracts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tracktokens_smartcontracts.py b/tracktokens_smartcontracts.py index 698346b..604f3e9 100755 --- a/tracktokens_smartcontracts.py +++ b/tracktokens_smartcontracts.py @@ -884,7 +884,9 @@ def processTransaction(transaction_data, parsed_data, blockinfo): addresscounter = 0 inputcounter = 0 for obj in transaction_data["vout"]: - if obj["scriptPubKey"]["type"] == "pubkeyhash": + if 'type' not in obj["scriptPubKey"].keys(): + continue + if obj["scriptPubKey"]["type"] in ["pubkeyhash","scripthash"]: addresscounter = addresscounter + 1 if inputlist[0] == obj["scriptPubKey"]["addresses"][0]: inputcounter = inputcounter + 1 From cd1b36a246a9121c887146d6dd762baad0f6e223 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 29 Apr 2023 22:10:55 +0000 Subject: [PATCH 2/3] Critical bug fix for fetching time action related active smart contracts --- tracktokens_smartcontracts.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tracktokens_smartcontracts.py b/tracktokens_smartcontracts.py index 698346b..25b9510 100755 --- a/tracktokens_smartcontracts.py +++ b/tracktokens_smartcontracts.py @@ -8,7 +8,7 @@ import sys import pyflo import requests import socketio -from sqlalchemy import create_engine, func +from sqlalchemy import create_engine, func, and_ from sqlalchemy.orm import sessionmaker import time import arrow @@ -298,9 +298,10 @@ def processBlock(blockindex=None, blockhash=None): blockhash = response['blockHash'] blockinfo = newMultiRequest(f"block/{blockhash}") - pause_index = [2211699, 2211700, 2211701, 2170000, 2468107, 2468108, 2489267, 2449017] + pause_index = [2211699, 2211700, 2211701, 2170000, 2468107, 2468108, 2489267, 2449017, 2509873, 2509874] if blockindex in pause_index: print(f'Paused at {blockindex}') + pdb.set_trace() # Check smartContracts which will be triggered locally, and not by the contract committee #checkLocaltriggerContracts(blockinfo) @@ -331,8 +332,10 @@ def processBlock(blockindex=None, blockhash=None): '22dc9327bcb504fedbd07741aa9f32c17cc5e34cab22579acfc5cc412a4c4187', 'ef4cf64c0b8f04b2c876545e6d4f558be49b740c24b31b30c62efb1517796546', '22dc9327bcb504fedbd07741aa9f32c17cc5e34cab22579acfc5cc412a4c4187', - '06e0a1195fc36c5d7c568aa9c004d4fcb2e5f0c3f91749ba8f5e8e93192c3bef']: + '06e0a1195fc36c5d7c568aa9c004d4fcb2e5f0c3f91749ba8f5e8e93192c3bef', + 'f31d8bd57798b86787d3f831230f053ca32237d7915994a6313b5561486451c0']: print(f'Paused at transaction {transaction}') + pdb.set_trace() # TODO CLEANUP - REMOVE THIS WHILE SECTION, WHY IS IT HERE? while(current_index == -1): @@ -626,11 +629,8 @@ def close_expire_contract(contractStructure, contractStatus, transactionHash, bl def return_active_contracts(session): - # find all the contracts which are active - contract_ids = session.query(func.max(TimeActions.id)).group_by(TimeActions.contractName, TimeActions.contractAddress).all() - if len(contract_ids) == 0: - return [] - active_contracts = session.query(TimeActions).filter(TimeActions.id.in_(contract_ids[0]), TimeActions.status=='active', TimeActions.activity=='contract-time-trigger').all() + + active_contracts = session.execute('''SELECT t1.* FROM time_actions t1 JOIN ( SELECT contractName, contractAddress, MAX(id) AS max_id FROM time_actions GROUP BY contractName, contractAddress ) t2 ON t1.contractName = t2.contractName AND t1.contractAddress = t2.contractAddress AND t1.id = t2.max_id WHERE t1.status = 'active' AND t1.activity = 'contract-time-trigger' ''').all() return active_contracts @@ -653,6 +653,8 @@ def checkLocal_expiry_trigger_deposit(blockinfo): query_time = convert_datetime_to_arrowobject(query.time) blocktime = parsing.arrow.get(blockinfo['time']).to('Asia/Kolkata') if query.activity == 'contract-time-trigger': + if query.contractName == 'album-fund-1' and query.contractAddress == 'oQkpZCBcAWc945viKqFmJVbVG4aKY4V3Gz': + print('Breakpoint') contractStructure = extract_contractStructure(query.contractName, query.contractAddress) connection = create_database_connection('smart_contract', {'contract_name':f"{query.contractName}", 'contract_address':f"{query.contractAddress}"}) if contractStructure['contractType'] == 'one-time-event': From 096607023967dd8d7ad3bcbd79e261c8ee361ee2 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Sat, 29 Apr 2023 22:11:40 +0000 Subject: [PATCH 3/3] Added more automated tests --- test_parsing.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test_parsing.py b/test_parsing.py index d9e1b89..eb6fe3c 100644 --- a/test_parsing.py +++ b/test_parsing.py @@ -182,5 +182,11 @@ class TestParsing(unittest.TestCase): 'stateF': False} self.assertEqual(result, expected_result) + def test_deposit_invalid(self): + text = 'Deposit 1 bioscope# to swap-rupee-bioscope-1@ its FLO address being oTzrcpLPRXsejSdYQ3XN6V4besrAPuJQrk$ with deposit-conditions: (1) expiryTime= Tue, 25 Apr 2023 13:40:00 GMT' + result = parsing.parse_flodata(text, TestParsing.blockinfo_stub, 'testnet') + expected_result = {'type': 'noise'} + self.assertEqual(result, expected_result) + if __name__ == '__main__': unittest.main() \ No newline at end of file