Fixed issue with double smart contracts returns in /api/v2/tokenSmartContractList
This commit is contained in:
parent
70061a0bec
commit
9b50ee8af3
@ -2332,11 +2332,21 @@ async def tokenSmartContractList():
|
|||||||
filelist.append(item[:-3])
|
filelist.append(item[:-3])
|
||||||
|
|
||||||
# list of smart contracts
|
# list of smart contracts
|
||||||
|
contractName = request.args.get('contractName')
|
||||||
|
if contractName is not None:
|
||||||
|
contractName = contractName.strip().lower()
|
||||||
|
|
||||||
|
# todo - Add validation for contractAddress and contractName to prevent SQL injection attacks
|
||||||
|
contractAddress = request.args.get('contractAddress')
|
||||||
|
if contractAddress is not None:
|
||||||
|
contractAddress = contractAddress.strip()
|
||||||
|
if not check_flo_address(contractAddress, is_testnet):
|
||||||
|
return jsonify(description='contractAddress validation failed'), 400
|
||||||
conn = sqlite3.connect(os.path.join(dbfolder, 'system.db'))
|
conn = sqlite3.connect(os.path.join(dbfolder, 'system.db'))
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('select * from activecontracts')
|
smart_contracts = return_smart_contracts(c, contractName, contractAddress)
|
||||||
allcontractsDetailList = c.fetchall()
|
smart_contracts_morphed = smartcontract_morph_helper(smart_contracts)
|
||||||
smart_contracts_morphed = smartcontract_morph_helper(allcontractsDetailList)
|
conn.close()
|
||||||
return jsonify(tokens=filelist, smartContracts=smart_contracts_morphed), 200
|
return jsonify(tokens=filelist, smartContracts=smart_contracts_morphed), 200
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user