diff --git a/config.ini b/config.ini index a533fcd..b5241c2 100644 --- a/config.ini +++ b/config.ini @@ -1,4 +1,4 @@ [DEFAULT] NET = testnet FLO_CLI_PATH = /usr/local/bin/flo-cli -START_BLOCK = 525300 +START_BLOCK = 525360 diff --git a/models.py b/models.py index 80e590f..ff2ca56 100644 --- a/models.py +++ b/models.py @@ -35,6 +35,18 @@ class TransferLogs(Base): destinationId = Column('destinationId', Integer) blockNumber = Column('blockNumber', Integer) time = Column('time', Integer) + transactionHash = Column('transactionHash', String) + +class TransactionHistory(Base): + __tablename__ = "transactionHistory" + + primary_key = Column('id', Integer, primary_key=True) + sourceFloAddress = Column('sourceFloAddress', String) + destFloAddress = Column('destFloAddress', String) + transferAmount = Column('transferAmount', Float) + blockNumber = Column('blockNumber', Integer) + time = Column('time', Integer) + transactionHash = Column('transactionHash', String) blockchainReference = Column('blockchainReference', String) class ContractStructure(ContractBase): diff --git a/parsing.py b/parsing.py index f4eaaa7..3568e78 100644 --- a/parsing.py +++ b/parsing.py @@ -85,19 +85,20 @@ def extractInitTokens(text): counter = 0 value = None for idx,word in enumerate(textList): - for unit in base_units: - result = word.split(unit) - if len(result) == 1: - try: - result = float(word) - if textList[idx+1] in base_units: - value = result*base_units[textList[idx+1]] - counter = counter + 1 - except: - continue - elif len(result) == 2 and result[1]=='': - value = float(result[0])*base_units[unit] + try: + result = float(word) + if textList[idx + 1] in base_units: + value = result * base_units[textList[idx + 1]] counter = counter + 1 + except: + for unit in base_units: + result = word.split(unit) + if len(result) == 2 and result[1]=='' and result[0]!='': + try: + value = float(result[0])*base_units[unit] + counter = counter + 1 + except: + continue if counter == 1: return value diff --git a/system.db b/system.db index adfac0e..fb747a6 100644 Binary files a/system.db and b/system.db differ diff --git a/tokens/FxCodeShell.jsp.db b/tokens/FxCodeShell.jsp.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/Main.db b/tokens/Main.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/azenv.php.db b/tokens/azenv.php.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/dbk_put1.jsp.db b/tokens/dbk_put1.jsp.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/favicon.ico.db b/tokens/favicon.ico.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/gettokeninfo.db b/tokens/gettokeninfo.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/orders.xhtml.db b/tokens/orders.xhtml.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/rmt.db b/tokens/rmt.db index 49d5091..844b85c 100644 Binary files a/tokens/rmt.db and b/tokens/rmt.db differ diff --git a/tokens/robots.txt.db b/tokens/robots.txt.db new file mode 100644 index 0000000..e69de29 diff --git a/tokens/teega.db b/tokens/teega.db new file mode 100644 index 0000000..2a4d11d Binary files /dev/null and b/tokens/teega.db differ diff --git a/tokens/users.db b/tokens/users.db new file mode 100644 index 0000000..e69de29 diff --git a/tracktokens-smartcontracts.py b/tracktokens-smartcontracts.py index da86d5e..d994eb9 100644 --- a/tracktokens-smartcontracts.py +++ b/tracktokens-smartcontracts.py @@ -11,7 +11,7 @@ import os import shutil from sqlalchemy.orm import sessionmaker, relationship from sqlalchemy import create_engine, func, desc -from models import SystemData, ActiveTable, ConsumedTable, TransferLogs, Base, ContractStructure, ContractBase, ContractParticipants, SystemBase, ActiveContracts +from models import SystemData, ActiveTable, ConsumedTable, TransferLogs, TransactionHistory, Base, ContractStructure, ContractBase, ContractParticipants, SystemBase, ActiveContracts committeeAddressList = ['oUc4dVvxwK7w5MHUHtev8UawN3eDjiZnNx'] @@ -57,7 +57,7 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress) session.add(TransferLogs(sourceFloAddress=inputAddress, destFloAddress=outputAddress, transferAmount=entry[0].transferBalance, sourceId=piditem[0], destinationId=lastid+1, blockNumber=block_data['height'], time=block_data['time'], - blockchainReference=transaction_data['txid'])) + transactionHash=transaction_data['txid'])) entry[0].transferBalance = 0 if len(consumedpid_string)>1: @@ -100,7 +100,7 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress) transferAmount=entry[0].transferBalance, sourceId=piditem[0], destinationId=lastid + 1, blockNumber=block_data['height'], time=block_data['time'], - blockchainReference=transaction_data['txid'])) + transactionHash=transaction_data['txid'])) entry[0].transferBalance = 0 consumedpid_string = consumedpid_string + '{},'.format(piditem[0]) else: @@ -108,7 +108,7 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress) transferAmount=piditem[1]-(checksum - commentTransferAmount), sourceId=piditem[0], destinationId=lastid + 1, blockNumber=block_data['height'], time=block_data['time'], - blockchainReference=transaction_data['txid'])) + transactionHash=transaction_data['txid'])) entry[0].transferBalance = checksum - commentTransferAmount @@ -140,6 +140,15 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress) session.execute('DELETE FROM activeTable WHERE id={}'.format(piditem[0])) session.commit() session.commit() + + string = "{} getblock {}".format(localapi, transaction_data['blockhash']) + response = subprocess.check_output(string, shell=True) + block_data = json.loads(response.decode("utf-8")) + blockchainReference = neturl + 'tx/' + transaction_data['txid'] + session.add(TransactionHistory(sourceFloAddress=inputAddress, destFloAddress=outputAddress, + transferAmount=tokenAmount, blockNumber=block_data['height'], time=block_data['time'], + transactionHash=transaction_data['txid'], blockchainReference=blockchainReference)) + session.commit() session.close() return 1 @@ -232,9 +241,12 @@ def startWorking(transaction_data, parsed_data): # todo Rule 45 - If the transfer type is token, then call the function transferToken to adjust the balances if parsed_data['transferType'] == 'token': - returnval = transferToken(parsed_data['tokenIdentification'], parsed_data['tokenAmount'], inputlist[0], outputlist[0]) - if returnval is None: - print("Something went wrong in the token transfer method") + if parsed_data['address'] == outputlist[0]: + returnval = transferToken(parsed_data['tokenIdentification'], parsed_data['tokenAmount'], inputlist[0], outputlist[0]) + if returnval is None: + print("Something went wrong in the token transfer method") + else: + print('Address mentioned in flodata doesn\'t match the address in blockchain\'s outputlist') # todo Rule 46 - If the transfer type is smart contract, then call the function transferToken to do sanity checks & lock the balance elif parsed_data['transferType'] == 'smartContract': @@ -266,7 +278,13 @@ def startWorking(transaction_data, parsed_data): string = "{} getblock {}".format(localapi, transaction_data['blockhash']) response = subprocess.check_output(string, shell=True) block_data = json.loads(response.decode("utf-8")) - session.add(TransferLogs(sourceFloAddress=inputadd, destFloAddress=outputlist[0][0], transferAmount=parsed_data['tokenAmount'], sourceId=0, destinationId=1, blockNumber=block_data['height'], time=block_data['time'], blockchainReference=transaction_data['txid'])) + session.add(TransferLogs(sourceFloAddress=inputadd, destFloAddress=outputlist[0], transferAmount=parsed_data['tokenAmount'], sourceId=0, destinationId=1, blockNumber=block_data['height'], time=block_data['time'], transactionHash=transaction_data['txid'])) + blockchainReference = neturl + 'tx/' + transaction_data['txid'] + session.add(TransactionHistory(sourceFloAddress=inputadd, destFloAddress=outputlist[0], + transferAmount=parsed_data['tokenAmount'], blockNumber=block_data['height'], + time=block_data['time'], + transactionHash=transaction_data['txid'], + blockchainReference=blockchainReference)) session.commit() session.close() else: