Changes to the API
This commit is contained in:
parent
0a27fc3422
commit
58cb925e7f
@ -341,42 +341,49 @@ async def getParticipantDetails():
|
|||||||
|
|
||||||
if floaddress in list(activeContracts[0]):
|
if floaddress in list(activeContracts[0]):
|
||||||
c.execute("select contractName from activecontracts where contractAddress=='"+floaddress+"'")
|
c.execute("select contractName from activecontracts where contractAddress=='"+floaddress+"'")
|
||||||
name = c.fetchall()
|
contract_names = c.fetchall()
|
||||||
|
|
||||||
if len(name) != 0:
|
if len(contract_names) != 0:
|
||||||
contractName = '{}-{}.db'.format(name[0][0].strip(),floaddress.strip())
|
|
||||||
filelocation = os.path.join(dbfolder,'smartContracts', contractName)
|
|
||||||
|
|
||||||
if os.path.isfile(filelocation):
|
contractlist = []
|
||||||
#Make db connection and fetch data
|
|
||||||
conn = sqlite3.connect(filelocation)
|
|
||||||
c = conn.cursor()
|
|
||||||
c.execute(
|
|
||||||
'SELECT attribute,value FROM contractstructure')
|
|
||||||
result = c.fetchall()
|
|
||||||
|
|
||||||
returnval = {'exitconditions': []}
|
for contract_name in contract_names:
|
||||||
temp = 0
|
contractName = '{}-{}.db'.format(contract_name[0].strip(),floaddress.strip())
|
||||||
for row in result:
|
filelocation = os.path.join(dbfolder,'smartContracts', contractName)
|
||||||
if row[0] == 'exitconditions':
|
|
||||||
if temp == 0:
|
|
||||||
returnval["exitconditions"] = [row[1]]
|
|
||||||
temp = temp + 1
|
|
||||||
else:
|
|
||||||
returnval['exitconditions'].append(row[1])
|
|
||||||
continue
|
|
||||||
returnval[row[0]] = row[1]
|
|
||||||
|
|
||||||
c.execute('select count(participantAddress) from contractparticipants')
|
if os.path.isfile(filelocation):
|
||||||
noOfParticipants = c.fetchall()[0][0]
|
#Make db connection and fetch data
|
||||||
returnval['numberOfParticipants'] = noOfParticipants
|
conn = sqlite3.connect(filelocation)
|
||||||
|
c = conn.cursor()
|
||||||
|
c.execute(
|
||||||
|
'SELECT attribute,value FROM contractstructure')
|
||||||
|
result = c.fetchall()
|
||||||
|
|
||||||
c.execute('select sum(tokenAmount) from contractparticipants')
|
returnval = {'exitconditions': []}
|
||||||
totalAmount = c.fetchall()[0][0]
|
temp = 0
|
||||||
returnval['tokenAmountDeposited'] = totalAmount
|
for row in result:
|
||||||
|
if row[0] == 'exitconditions':
|
||||||
|
if temp == 0:
|
||||||
|
returnval["exitconditions"] = [row[1]]
|
||||||
|
temp = temp + 1
|
||||||
|
else:
|
||||||
|
returnval['exitconditions'].append(row[1])
|
||||||
|
continue
|
||||||
|
returnval[row[0]] = row[1]
|
||||||
|
|
||||||
conn.close()
|
|
||||||
return jsonify(result='ok', address=floaddress, type='contract', contractInfo=returnval)
|
c.execute('select count(participantAddress) from contractparticipants')
|
||||||
|
noOfParticipants = c.fetchall()[0][0]
|
||||||
|
returnval['numberOfParticipants'] = noOfParticipants
|
||||||
|
|
||||||
|
c.execute('select sum(tokenAmount) from contractparticipants')
|
||||||
|
totalAmount = c.fetchall()[0][0]
|
||||||
|
returnval['tokenAmountDeposited'] = totalAmount
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
contractlist.append(returnval)
|
||||||
|
|
||||||
|
return jsonify(result='ok', address=floaddress, type='contract', contractList=contractlist)
|
||||||
|
|
||||||
# Check if its a participant address
|
# Check if its a participant address
|
||||||
queryString = "SELECT id, participantAddress,contractName, contractAddress, tokenAmount, transactionHash FROM contractParticipantMapping where participantAddress=='"+floaddress+"'"
|
queryString = "SELECT id, participantAddress,contractName, contractAddress, tokenAmount, transactionHash FROM contractParticipantMapping where participantAddress=='"+floaddress+"'"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user