Further UI tweaks

This commit is contained in:
Vivek Teega 2020-06-24 02:03:59 +05:30
parent 2dbb56a8d0
commit 72ead02bb3

View File

@ -132,7 +132,7 @@
<h2 class="token">${topToken}</h2> <h2 class="token">${topToken}</h2>
</div> </div>
<div class="highlight-item"> <div class="highlight-item">
<h4 class="label">Latest transactions</h4> <h4 class="label">Total transactions</h4>
<h2>${totalTransactions}</h2> <h2>${totalTransactions}</h2>
</div> </div>
<div class="highlight-item"> <div class="highlight-item">
@ -772,10 +772,11 @@
} }
if (pageId === "block_page") { if (pageId === "block_page") {
let blockInfo = await getBlockInfo(field); let [blockInfo, blockTransactions] = await Promise.all([getBlockInfo(field), getBlockTransactions(field)])
pageContainer.append(create.blockPage(blockInfo)); pageContainer.append(create.blockPage(blockInfo));
pageTitle.textContent = "block"; pageTitle.textContent = "block";
loading() loading()
appendTransactions('block_transaction_container', blockTransactions)
} }
if (pageId === "homepage") { if (pageId === "homepage") {
@ -1323,7 +1324,6 @@
const response = await fetch(`${tokenapiUrl}/api/v1.0/getTokenTransactions?token=` + tokenName), const response = await fetch(`${tokenapiUrl}/api/v1.0/getTokenTransactions?token=` + tokenName),
transactions = await response.json() transactions = await response.json()
return transactions.transactions return transactions.transactions
} }
async function getBlockInfo(thisBlock) { async function getBlockInfo(thisBlock) {
@ -1341,6 +1341,13 @@
} }
} }
async function getBlockTransactions(thisBlock) {
const response = await fetch(`${tokenapiUrl}/api/v1.0/getBlockTransactions/${thisBlock}`),
transactions = await response.json()
return transactions.transactions
}
async function getContractInfo(contract) { async function getContractInfo(contract) {
const response = await fetch(`${tokenapiUrl}/api/v1.0/getSmartContractInfo?contractName=${contract.name}&contractAddress=${contract.address}`), const response = await fetch(`${tokenapiUrl}/api/v1.0/getSmartContractInfo?contractName=${contract.name}&contractAddress=${contract.address}`),
info = await response.json(), info = await response.json(),
@ -1399,28 +1406,16 @@
let transferType = txList[txids[i]]["parsedFloData"]["transferType"] let transferType = txList[txids[i]]["parsedFloData"]["transferType"]
if (transferType == "token") { if (transferType == "token") {
let receiveraddress = ""; let receiveraddress = "";
for ( for (let i = 0, voutlist = txList[txids[i]]["transactionDetails"]["vout"]; i<voutlist.length; i++) {
let i = 0, if(txList[txids[i]] != undefined){
voutlist = if (voutlist[i]["scriptPubKey"]["addresses"][0] != txList[txids[i]]["transactionDetails"]["vin"][0]["addr"]) {
txList[txids[i]][ receiveraddress = voutlist[i]["scriptPubKey"]["addresses"][0];
"transactionDetails" }
]["vout"]; i < voutlist.length; i++
) {
if (
voutlist[i]["scriptPubKey"]["addresses"][0] !=
txList[txids[i]][
"transactionDetails"
]["vin"][0]["addr"]
) {
receiveraddress =
voutlist[i]["scriptPubKey"]["addresses"][0];
} }
} }
obj = Object.assign({}, obj, { obj = Object.assign({}, obj, {
sender: txList[txids[i]][ sender: txList[txids[i]]["transactionDetails"]["vin"][0]["addr"],
"transactionDetails"
]["vin"][0]["addr"],
receiver: receiveraddress, receiver: receiveraddress,
amount: `${ amount: `${
txList[txids[i]][ txList[txids[i]][
@ -1544,7 +1539,7 @@
} }
obj = Object.assign({}, obj, { obj = Object.assign({}, obj, {
hash: txList[txids[i]]['txid'], hash: txList[txids[i]]['transactionDetails']['txid'],
blockHeight: txList[txids[i]]['transactionDetails']['blockheight'], blockHeight: txList[txids[i]]['transactionDetails']['blockheight'],
contractName: txList[txids[i]]['parsedFloData']['contractName'], contractName: txList[txids[i]]['parsedFloData']['contractName'],
contractAddress: receiver, contractAddress: receiver,