latest changes
This commit is contained in:
parent
3464a81a2d
commit
ea5010fc4e
7
app.py
7
app.py
@ -1,11 +1,15 @@
|
||||
from flask import Flask, render_template, jsonify
|
||||
import os
|
||||
|
||||
from flask import Flask, jsonify
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def hello_world():
|
||||
return 'Hello, World!'
|
||||
|
||||
|
||||
@app.route('/getmarkerlist')
|
||||
def marker_list():
|
||||
dblist = os.listdir("databases/")
|
||||
@ -15,4 +19,5 @@ def marker_list():
|
||||
|
||||
return jsonify(dbdict)
|
||||
|
||||
|
||||
app.run(debug=True)
|
||||
|
||||
19
models.py
19
models.py
@ -1,11 +1,12 @@
|
||||
from sqlalchemy import Column, Integer, Float, String
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy import Column, Integer, Float, String, ForeignKey
|
||||
|
||||
Base = declarative_base()
|
||||
ContractBase = declarative_base()
|
||||
SystemBase = declarative_base()
|
||||
LatestCacheBase = declarative_base()
|
||||
|
||||
|
||||
class ActiveTable(Base):
|
||||
__tablename__ = "activeTable"
|
||||
|
||||
@ -54,6 +55,8 @@ class TransactionHistory(Base):
|
||||
transactionHash = Column('transactionHash', String)
|
||||
blockchainReference = Column('blockchainReference', String)
|
||||
jsonData = Column('jsonData', String)
|
||||
transactionType = Column('transactionType', String)
|
||||
parsedFloData = Column('parsedFloData', String)
|
||||
|
||||
|
||||
class TokenContractAssociation(Base):
|
||||
@ -69,7 +72,8 @@ class TokenContractAssociation(Base):
|
||||
transactionHash = Column('transactionHash', String)
|
||||
blockchainReference = Column('blockchainReference', String)
|
||||
jsonData = Column('jsonData', String)
|
||||
|
||||
transactionType = Column('transactionType', String)
|
||||
parsedFloData = Column('parsedFloData', String)
|
||||
|
||||
|
||||
class ContractStructure(ContractBase):
|
||||
@ -109,6 +113,7 @@ class ContractTransactionHistory(ContractBase):
|
||||
transactionHash = Column('transactionHash', String)
|
||||
blockchainReference = Column('blockchainReference', String)
|
||||
jsonData = Column('jsonData', String)
|
||||
parsedFloData = Column('parsedFloData', String)
|
||||
|
||||
|
||||
class RejectedContractTransactionHistory(SystemBase):
|
||||
@ -129,6 +134,8 @@ class RejectedContractTransactionHistory(SystemBase):
|
||||
blockchainReference = Column('blockchainReference', String)
|
||||
jsonData = Column('jsonData', String)
|
||||
rejectComment = Column('rejectComment', String)
|
||||
parsedFloData = Column('parsedFloData', String)
|
||||
|
||||
|
||||
class RejectedTransactionHistory(SystemBase):
|
||||
__tablename__ = "rejectedTransactionHistory"
|
||||
@ -145,6 +152,8 @@ class RejectedTransactionHistory(SystemBase):
|
||||
blockchainReference = Column('blockchainReference', String)
|
||||
jsonData = Column('jsonData', String)
|
||||
rejectComment = Column('rejectComment', String)
|
||||
transactionType = Column('transactionType', String)
|
||||
parsedFloData = Column('parsedFloData', String)
|
||||
|
||||
|
||||
class ActiveContracts(SystemBase):
|
||||
@ -171,6 +180,7 @@ class SystemData(SystemBase):
|
||||
attribute = Column('attribute', String)
|
||||
value = Column('value', String)
|
||||
|
||||
|
||||
class ContractAddressMapping(SystemBase):
|
||||
__tablename__ = "contractAddressMapping"
|
||||
|
||||
@ -184,6 +194,7 @@ class ContractAddressMapping(SystemBase):
|
||||
blockNumber = Column('blockNumber', Integer)
|
||||
blockHash = Column('blockHash', String)
|
||||
|
||||
|
||||
class TokenAddressMapping(SystemBase):
|
||||
__tablename__ = "tokenAddressMapping"
|
||||
|
||||
@ -194,6 +205,7 @@ class TokenAddressMapping(SystemBase):
|
||||
blockNumber = Column('blockNumber', Integer)
|
||||
blockHash = Column('blockHash', String)
|
||||
|
||||
|
||||
class LatestTransactions(LatestCacheBase):
|
||||
__tablename__ = "latestTransactions"
|
||||
id = Column('id', Integer, primary_key=True)
|
||||
@ -203,11 +215,10 @@ class LatestTransactions(LatestCacheBase):
|
||||
transactionType = Column('transactionType', String)
|
||||
parsedFloData = Column('parsedFloData', String)
|
||||
|
||||
|
||||
class LatestBlocks(LatestCacheBase):
|
||||
__tablename__ = "latestBlocks"
|
||||
id = Column('id', Integer, primary_key=True)
|
||||
blockNumber = Column('blockNumber', String)
|
||||
blockHash = Column('blockHash', String)
|
||||
jsonData = Column('jsonData', String)
|
||||
|
||||
|
||||
|
||||
19
parsing.py
19
parsing.py
@ -1,6 +1,7 @@
|
||||
import re
|
||||
import arrow
|
||||
import configparser
|
||||
import re
|
||||
|
||||
import arrow
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('config.ini')
|
||||
@ -194,11 +195,13 @@ def extractContractConditions(text, contracttype, marker, blocktime):
|
||||
|
||||
try:
|
||||
expirytime_split = expirytime.split(' ')
|
||||
parse_string = '{}/{}/{} {}'.format(expirytime_split[3], months[expirytime_split[1]], expirytime_split[2], expirytime_split[4])
|
||||
parse_string = '{}/{}/{} {}'.format(expirytime_split[3], months[expirytime_split[1]],
|
||||
expirytime_split[2], expirytime_split[4])
|
||||
expirytime_object = arrow.get(parse_string, 'YYYY/M/D HH:mm:ss').replace(tzinfo=expirytime_split[5])
|
||||
blocktime_object = arrow.get(blocktime)
|
||||
if expirytime_object < blocktime_object:
|
||||
print('Expirytime of the contract is earlier than the block it is incorporated in. This incorporation will be rejected ')
|
||||
print(
|
||||
'Expirytime of the contract is earlier than the block it is incorporated in. This incorporation will be rejected ')
|
||||
return None
|
||||
extractedRules['expiryTime'] = expirytime
|
||||
except:
|
||||
@ -245,7 +248,6 @@ def extractContractConditions(text, contracttype, marker, blocktime):
|
||||
payeeAddress = searchResult.split(marker)[0]
|
||||
extractedRules['payeeAddress'] = payeeAddress
|
||||
|
||||
|
||||
if len(extractedRules) > 1 and 'expiryTime' in extractedRules:
|
||||
return extractedRules
|
||||
else:
|
||||
@ -263,7 +265,6 @@ def extractTriggerCondition(text):
|
||||
|
||||
# Combine test
|
||||
def parse_flodata(string, blockinfo, netvariable):
|
||||
|
||||
# todo Rule 20 - remove 'text:' from the start of flodata if it exists
|
||||
if string[0:5] == 'text:':
|
||||
string = string.split('text:')[1]
|
||||
@ -336,7 +337,8 @@ def parse_flodata(string, blockinfo, netvariable):
|
||||
elif incorporation and not transfer:
|
||||
contracttype = extractContractType(cleanstring)
|
||||
contractaddress = extractAddress(nospacestring)
|
||||
contractconditions = extractContractConditions(cleanstring, contracttype, marker=hashList[0][:-1], blocktime=blockinfo['time'])
|
||||
contractconditions = extractContractConditions(cleanstring, contracttype, marker=hashList[0][:-1],
|
||||
blocktime=blockinfo['time'])
|
||||
|
||||
if config['DEFAULT']['NET'] == 'mainnet' and blockinfo['height'] < 3454510:
|
||||
if None not in [contracttype, contractconditions]:
|
||||
@ -378,7 +380,8 @@ def parse_flodata(string, blockinfo, netvariable):
|
||||
# todo Rule 37 - Extract the trigger condition given by the committee. If its missing, reject
|
||||
triggerCondition = extractTriggerCondition(cleanstring)
|
||||
if triggerCondition is not None:
|
||||
parsed_data = {'type': 'smartContractPays', 'contractName': atList[0][:-1], 'triggerCondition': triggerCondition.group().strip()[1:-1]}
|
||||
parsed_data = {'type': 'smartContractPays', 'contractName': atList[0][:-1],
|
||||
'triggerCondition': triggerCondition.group().strip()[1:-1]}
|
||||
else:
|
||||
parsed_data = {'type': 'noise'}
|
||||
else:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user