From 84dbe93e811f2d1492d30d373b73e23a1d80ad81 Mon Sep 17 00:00:00 2001 From: Vivek Teega Date: Mon, 12 Jun 2023 14:33:43 +0530 Subject: [PATCH] Added currentDepositBalance in the json response of /api/v2/smartContractInfo --- ranchimallflo_api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ranchimallflo_api.py b/ranchimallflo_api.py index 49e07e5..18a59a3 100644 --- a/ranchimallflo_api.py +++ b/ranchimallflo_api.py @@ -1736,6 +1736,8 @@ async def getContractInfo_v2(): returnval['totalHonorAmount'] = participation_details[0][2] c.execute('SELECT COUNT(DISTINCT transactionHash) FROM contractdeposits') returnval['numberOfDeposits'] = c.fetchall()[0][0] + c.execute('SELECT SUM(depositBalance) AS totalDepositBalance FROM contractdeposits c1 WHERE id = ( SELECT MAX(id) FROM contractdeposits c2 WHERE c1.transactionHash = c2.transactionHash);') + returnval['currentDepositBalance'] = c.fetchall()[0][0] # todo - add code to token tracker to save continuos event subtype KEY as contractSubtype as part of contractStructure and remove the following line returnval['contractSubtype'] = 'tokenswap' returnval['priceType'] = returnval['pricetype'] @@ -2088,7 +2090,11 @@ async def smartcontractdeposits(): 'time': original_deposit_balance[0][1] } deposit_info.append(obj) - return jsonify(depositInfo=deposit_info), 200 + c.execute('''SELECT depositorAddress, transactionHash, status, depositBalance FROM contractdeposits + WHERE (transactionHash, id) IN (SELECT transactionHash, MAX(id) FROM contractdeposits GROUP BY transactionHash) + ORDER BY id DESC; ''') + currentDepositBalance = c.fetchall()[0][0] + return jsonify(currentDepositBalance=currentDepositBalance, depositInfo=deposit_info), 200 else: return jsonify(description='Smart Contract with the given name doesn\'t exist'), 404