This commit is contained in:
sairaj mote 2020-05-23 18:48:08 +05:30
parent 9d98bf50bd
commit e9df99692b

View File

@ -1,13 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FLO Scout</title> <title>FLO Scout</title>
<link rel="stylesheet" href="css/main.css" /> <link rel="stylesheet" href="css/main.css" />
</head> </head>
<body data-theme="dark"> <!-- Set urls for token and flo Apis -->
<script>
window.tokenapiUrl = 'https://ranchimallflo.duckdns.org'
window.floapiUrl = 'https://flosight.duckdns.org'
</script>
<body data-theme="dark">
<div id="loader_page" class="hide-completely"> <div id="loader_page" class="hide-completely">
<svg id="loader" class="icon" viewBox="0 0 64 64"> <svg id="loader" class="icon" viewBox="0 0 64 64">
<title>Loading</title> <title>Loading</title>
@ -47,7 +54,7 @@
let frag = document.createDocumentFragment(); let frag = document.createDocumentFragment();
const create = { const create = {
homepage(obj) { homepage(obj) {
let {topToken,totalTransactions,walletAddresses,topContract,} = obj, let { topToken, totalTransactions, walletAddresses, topContract, } = obj,
page = document.createElement("div"); page = document.createElement("div");
page.classList.add("page"); page.classList.add("page");
page.id = "homepage"; page.id = "homepage";
@ -110,7 +117,7 @@
</div> </div>
<div class="highlight-item"> <div class="highlight-item">
<h4 class="label">top contract</h4> <h4 class="label">top contract</h4>
<h2 class="contract">${topContract}</h2> <h2 class="contract">${topContract.name}</h2>
</div> </div>
</div> </div>
</section> </section>
@ -134,7 +141,7 @@
return page; return page;
}, },
blockPage(obj) { blockPage(obj) {
let {blockHeight,size,transactions,reward,hash,difficulty,nonce, let { blockHeight, size, transactions, reward, hash, difficulty, nonce,
} = obj, } = obj,
page = document.createElement("div"), page = document.createElement("div"),
wordForm = "transaction"; wordForm = "transaction";
@ -193,7 +200,7 @@
return page; return page;
}, },
transactionPage(obj) { transactionPage(obj) {
let {type,name,blockHeight,amount,sender,receiver,floData,hash,confirmations,} = obj, let { type, name, blockHeight, amount, sender, receiver, floData, hash, confirmations, } = obj,
page = document.createElement("div"); page = document.createElement("div");
page.classList.add("page"); page.classList.add("page");
page.id = "transaction_page"; page.id = "transaction_page";
@ -270,7 +277,7 @@
return page; return page;
}, },
contractPage(obj) { contractPage(obj) {
let {status,contract,contractType,incAddress,expiration,token,participationFees} = obj, let { status, contract, contractType, incAddress, expiration, token, participationFees } = obj,
page = document.createElement("div"); page = document.createElement("div");
page.classList.add("page"); page.classList.add("page");
page.id = "contract_page"; page.id = "contract_page";
@ -329,7 +336,7 @@
return page; return page;
}, },
contractTransferCard(obj) { contractTransferCard(obj) {
let {hash,blockHeight,token,sender,receiver,amount,contractName,userChoice} = obj, let { hash, blockHeight, token, sender, receiver, amount, contractName, userChoice } = obj,
card = document.createElement("div"); card = document.createElement("div");
card.classList.add("transaction", "token-transfer"); card.classList.add("transaction", "token-transfer");
card.id = hash; card.id = hash;
@ -399,7 +406,7 @@
return card; return card;
}, },
contractTriggerCard(obj) { contractTriggerCard(obj) {
let {hash,blockHeight,contractName,contractAddress,winningChoice,committeeAddress} = obj, let { hash, blockHeight, contractName, contractAddress, winningChoice, committeeAddress } = obj,
card = document.createElement("div"); card = document.createElement("div");
card.classList.add("transaction", "contract-trigger"); card.classList.add("transaction", "contract-trigger");
card.id = hash; card.id = hash;
@ -421,7 +428,7 @@
return card; return card;
}, },
contractCreationCard(obj) { contractCreationCard(obj) {
let {hash,blockHeight,token,contractName,incAddress,contractType,expiration,participationFees,availableChoices} = obj, let { hash, blockHeight, token, contractName, incAddress, contractType, expiration, participationFees, availableChoices } = obj,
card = document.createElement("div"); card = document.createElement("div");
card.classList.add("transaction", "contract-creation"); card.classList.add("transaction", "contract-creation");
card.id = hash; card.id = hash;
@ -502,6 +509,8 @@
if (pageId === "token_page") { if (pageId === "token_page") {
let tokenInfo = await getTokenInfo(field); let tokenInfo = await getTokenInfo(field);
let tokenBalances = await getTokenBalances(field);
let tokenTransactions = await getTokenTransactions(field);
pageContainer.append(create.tokenPage(tokenInfo)); pageContainer.append(create.tokenPage(tokenInfo));
pageTitle.textContent = "Token"; pageTitle.textContent = "Token";
loading() loading()
@ -597,31 +606,31 @@
} }
if (pageId === "transaction_page") { if (pageId === "transaction_page") {
let latest100txs = await getTxDetafils(); let latest100txs = await getTxDetails();
loading() loading()
} }
currentPage = pageId; currentPage = pageId;
prevField = field; prevField = field;
if(pageContainer.querySelector('.tab.active')) if (pageContainer.querySelector('.tab.active'))
pageContainer.querySelector('.tab.active').click() pageContainer.querySelector('.tab.active').click()
tabMounted = false; tabMounted = false;
} }
function renderTransactions() {} function renderTransactions() { }
window.addEventListener("load", () => { window.addEventListener("load", () => {
render("homepage"); render("homepage");
history.pushState(appState, null, null); history.pushState(appState, null, null);
document.querySelector("main").addEventListener("click", (e) => { document.querySelector("main").addEventListener("click", (e) => {
if (e.target.closest(".address") && prevField !== e.target.textContent){ if (e.target.closest(".address") && prevField !== e.target.textContent) {
render("address_page", e.target.textContent) render("address_page", e.target.textContent)
appState = { appState = {
page: "address_page", page: "address_page",
thisField: e.target.textContent, thisField: e.target.textContent,
}; };
history.pushState(appState,null,null) history.pushState(appState, null, null)
} }
if (e.target.closest(".token") && prevField !== e.target.textContent) { if (e.target.closest(".token") && prevField !== e.target.textContent) {
render("token_page", e.target.textContent); render("token_page", e.target.textContent);
@ -660,7 +669,7 @@
}); });
let tabMounted = false; let tabMounted = false;
function showTab(tab){ function showTab(tab) {
let targetTab = tab.getAttribute('data-target'), let targetTab = tab.getAttribute('data-target'),
activeTabRank = parseInt(tab.parentNode.querySelector('.active').dataset.rank), activeTabRank = parseInt(tab.parentNode.querySelector('.active').dataset.rank),
currentTabRank = parseInt(tab.dataset.rank), currentTabRank = parseInt(tab.dataset.rank),
@ -670,13 +679,13 @@
tabGroupMembers = document.querySelectorAll(`[data-tab-group = '${targetGroup}']`), tabGroupMembers = document.querySelectorAll(`[data-tab-group = '${targetGroup}']`),
allTabs = tab.parentNode.querySelectorAll('.tab'), allTabs = tab.parentNode.querySelectorAll('.tab'),
line = tab.parentNode.querySelector('.line') line = tab.parentNode.querySelector('.line')
if(tabMounted && currentBody.isEqualNode(targetBody)) if (tabMounted && currentBody.isEqualNode(targetBody))
return return
if(activeTabRank < currentTabRank){ if (activeTabRank < currentTabRank) {
targetBody.classList.add('fly-in-from-right') targetBody.classList.add('fly-in-from-right')
currentBody.classList.add('fly-out-to-left') currentBody.classList.add('fly-out-to-left')
} }
else{ else {
targetBody.classList.add('fly-in-from-left') targetBody.classList.add('fly-in-from-left')
currentBody.classList.add('fly-out-to-right') currentBody.classList.add('fly-out-to-right')
} }
@ -686,10 +695,10 @@
}) })
targetBody.classList.remove('hide-completely') targetBody.classList.remove('hide-completely')
currentBody.classList.remove('fly-out-to-right', 'fly-out-to-left') currentBody.classList.remove('fly-out-to-right', 'fly-out-to-left')
},200) }, 200)
setTimeout(() => { setTimeout(() => {
targetBody.classList.remove('fly-in-from-right', 'fly-in-from-left') targetBody.classList.remove('fly-in-from-right', 'fly-in-from-left')
},400) }, 400)
allTabs.forEach(thisTab => { allTabs.forEach(thisTab => {
thisTab.classList.remove('active') thisTab.classList.remove('active')
}) })
@ -705,8 +714,8 @@
else loader.classList.add("hide-completely"); else loader.classList.add("hide-completely");
} }
async function getBannerData() { function getBannerData() {
return fetch("https://ranchimallflo.duckdns.org/api/v1.0/getSystemData") return fetch(`${tokenapiUrl}/api/v1.0/getSystemData`)
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
@ -715,15 +724,18 @@
topToken: "RMT", topToken: "RMT",
totalTransactions: systemdata["systemTransactionCount"], totalTransactions: systemdata["systemTransactionCount"],
walletAddresses: systemdata["systemAddressCount"], walletAddresses: systemdata["systemAddressCount"],
topContract: "India Election 2019", topContract: {
name: "India Election 2019",
address: 'F7osBpjDDV1mSSnMNrLudEQQ3cwDJ2dPR1'
}
}; };
return obj; return obj;
}); });
} }
async function getLatestTxs() { function getLatestTxs() {
return fetch( return fetch(
"https://ranchimallflo.duckdns.org/api/v1.0/getLatestTransactionDetails?numberOfLatestBlocks=4" `${tokenapiUrl}/api/v1.0/getLatestTransactionDetails?numberOfLatestBlocks=4`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -953,9 +965,9 @@
}); });
} }
async function getLatestBlocks() { function getLatestBlocks() {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getLatestBlockDetails?numberOfLatestBlocks=4` `${tokenapiUrl}/api/v1.0/getLatestBlockDetails?numberOfLatestBlocks=4`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -966,66 +978,84 @@
}); });
} }
async function getAddressBalanceInfo(thisAddress) { function getTokenInfo(thisToken) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressInfo?floAddress=${thisAddress}` `${tokenapiUrl}/api/v1.0/getTokenInfo?token=${thisToken.toLowerCase()}`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (tokenInfo) { .then(function (tokenInfo) {
let obj = { balance: "0.0001", address: thisAddress }; let associatedSC = {};
return obj; for (let i = 0, associatedScList = tokenInfo["associatedSmartContracts"]; i < associatedScList.length; i++) {
}); associatedSC[`${associatedScList[i]["contractName"]}-${associatedScList[i]["contractAddress"]}`] = associatedScList[i];
} }
async function getTokenInfo(thisToken) {
return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getTokenInfo?token=${thisToken.toLowerCase()}`
)
.then(function (response) {
return response.json();
})
.then(function (tokenInfo) {
let obj = { let obj = {
token: tokenInfo["token"], token: tokenInfo["token"],
supply: tokenInfo["tokenSupply"], supply: tokenInfo["tokenSupply"],
incAddress: tokenInfo["incorporationAddress"], incAddress: tokenInfo["incorporationAddress"],
associatedContracts: associatedSC,
blockchainReference: tokenInfo["blockchainReference"],
}; };
return obj; return obj;
}); });
} }
function getTokenBalances(tokenName) {
fetch(`${tokenapiUrl}/api/v1.0/getTokenBalances?token=` + tokenName)
.then(function (response) {
return response.json();
})
.then(function (responseJson) {
//
});
}
function getTokenTransactions(tokenName) {
fetch(`${tokenapiUrl}/api/v1.0/getTokenTransactions?token=` + tokenName)
.then(function (response) {
return response.json();
})
.then(function (responseJson) {
//
});
}
function getBlockInfo(thisBlock) { function getBlockInfo(thisBlock) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getBlockDetails/${thisBlock}` `${tokenapiUrl}/api/v1.0/getBlockDetails/${thisBlock}`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (blockInfo) { .then(function (blockInfo) {
let obj = { let obj = {
blockHeight: blockInfo["height"], blockHeight: blockInfo["blockDetails"]["height"],
size: blockInfo["size"], size: blockInfo["blockDetails"]["size"],
transactions: "", transactions: "",
reward: blockInfo["reward"], reward: blockInfo["blockDetails"]["reward"],
hash: blockInfo["hash"], hash: blockInfo["blockDetails"]["hash"],
difficulty: blockInfo["difficulty"], difficulty: blockInfo["blockDetails"]["difficulty"],
nonce: blockInfo["nonce"], nonce: blockInfo["blockDetails"]["nonce"],
}; };
return obj; return obj;
}); });
} }
async function getContractInfo(contract) {
function getContractInfo(contract) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getSmartContractInfo?contractName=${contract.name}&contractAddress=${contract.address}` `${tokenapiUrl}/api/v1.0/getSmartContractInfo?contractName=${contract.name}&contractAddress=${contract.address}`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (contractInfo) { .then(function (contractInfo) {
let obj = {
/*let obj = {
blockHeight: blockInfo["height"], blockHeight: blockInfo["height"],
size: blockInfo["size"], size: blockInfo["size"],
transactions: "", transactions: "",
@ -1033,20 +1063,28 @@
hash: blockInfo["hash"], hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"], difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"], nonce: blockInfo["nonce"],
}; }; */
return obj;
/* type 1
expirytime payeeaddress minimumsubscriptionamount maximumsubscriptionamount contractamount
// type 2
expirytime userchoices contractamount minimumsubscriptionamount maximumsubscriptionamount
*/
return obj = {};
}); });
} }
async function getContractParticipants(contract) { function getContractParticipants(contract) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getSmartContractParticipants?contractName=${contract.name}&contractAddress=${contract.address}` `${tokenapiUrl}/api/v1.0/getSmartContractParticipants?contractName=${contract.name}&contractAddress=${contract.address}`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (contractParticipants) { .then(function (contractParticipants) {
let obj = { /*let obj = {
blockHeight: blockInfo["height"], blockHeight: blockInfo["height"],
size: blockInfo["size"], size: blockInfo["size"],
transactions: "", transactions: "",
@ -1054,14 +1092,57 @@
hash: blockInfo["hash"], hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"], difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"], nonce: blockInfo["nonce"],
}; };*/
return obj = {};
});
}
function getContractTransactions(contract) {
return fetch(
`${tokenapiUrl}/api/v1.0/getSmartContractTransactions?contractName=${contract.name}&contractAddress=${contract.address}`
)
.then(function (response) {
return response.json();
})
.then(function (contractTxs) {
/*let obj = {
blockHeight: blockInfo["height"],
size: blockInfo["size"],
transactions: "",
reward: blockInfo["reward"],
hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"],
};*/
return obj = {};
});
}
function getViewallBlocks() {
return fetch(
`${tokenapiUrl}/api/v1.0/getLatestBlockDetails?limit=100`
)
.then(function (response) {
return response.json();
})
.then(function (contractTxs) {
debugger;
/*let obj = {
blockHeight: blockInfo["height"],
size: blockInfo["size"],
transactions: "",
reward: blockInfo["reward"],
hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"],
}; */
return obj; return obj;
}); });
} }
async function getContractTransactions(contract) { function getViewallTxs() {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getBlockDetails/${thisBlock}` `${tokenapiUrl}/api/v1.0/getLatestTransactionDetails?limit=200`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -1080,15 +1161,36 @@
}); });
} }
async function getViewallBlocks() { function getAddressInfo(floAddress) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getLatestBlockDetails?limit=100` `${tokenapiUrl}/api/v1.0/getFloAddressInfo?floAddress=${floAddress}`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (contractTxs) { .then(function (addressInfo) {
let obj = { // tokens
if (typeof addressInfo["floAddressBalances"] === "undefined") {
for (
let i = 0,
tokenkeys = Object.keys(addressInfo["floAddressBalances"]);
i < tokenkeys.length;
i++
) { }
}
// contracts
if (typeof addressInfo["incorporatedSmartContracts"] === "undefined") {
for (let i = 0,
contractkeys = Object.keys(
addressInfo["incorporatedSmartContracts"]
);
i < contractkeys.length;
i++
) { }
}
/*let obj = {
blockHeight: blockInfo["height"], blockHeight: blockInfo["height"],
size: blockInfo["size"], size: blockInfo["size"],
transactions: "", transactions: "",
@ -1096,78 +1198,32 @@
hash: blockInfo["hash"], hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"], difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"], nonce: blockInfo["nonce"],
}; };*/
return obj; return (obj = {});
}); });
} }
async function getViewallTxs() { function getAddressBalance(floAddress) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getLatestTransactionDetails?limit=200` `${floapiUrl}/api/addr/${floAddress}/balance`
)
.then(function (response) {
return response.json();
})
.then(function (contractTxs) {
let obj = {
blockHeight: blockInfo["height"],
size: blockInfo["size"],
transactions: "",
reward: blockInfo["reward"],
hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"],
};
return obj;
});
}
async function getAddressInfo(address){
return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressInfo?floAddress=${address}`
)
.then(function (response) {
return response.json();
}).then(console.log)
/*.then(function (addressInfo) {
let obj = {
blockHeight: blockInfo["height"],
size: blockInfo["size"],
transactions: "",
reward: blockInfo["reward"],
hash: blockInfo["hash"],
difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"],
};
return obj;
});*/
}
async function getAddressBalance(address){
return fetch(
`https://flosight.duckdns.org/api/addr/${address}/balance`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (addressBalance) { .then(function (addressBalance) {
let obj = { return addressBalance;
balance: addressBalance,
address: address,
};
return obj;
}); });
} }
async function getAddressTxs(address){ function getAddressTxs(floAddress) {
return fetch( return fetch(
`https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressTransactions?floAddress=${address}` `${tokenapiUrl}/api/v1.0/getFloAddressTransactions?floAddress=${floAddress}`
) )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}).then(console.log) })
/*.then(function (addressBalance) { .then(function (addressTxs) {
/*
let obj = { let obj = {
blockHeight: blockInfo["height"], blockHeight: blockInfo["height"],
size: blockInfo["size"], size: blockInfo["size"],
@ -1177,9 +1233,34 @@
difficulty: blockInfo["difficulty"], difficulty: blockInfo["difficulty"],
nonce: blockInfo["nonce"], nonce: blockInfo["nonce"],
}; };
return obj; */
});*/ return (obj = {});
});
} }
function getTxInfo(thisTx) {
return fetch(
`${tokenapiUrl}/api/v1.0/getTransactionDetails/${thisTx}`
)
.then(function (response) {
return response.json();
})
.then(function (txDetails) {
debugger;
let obj = {
blockHeight: blockInfo["blockDetails"]["height"],
size: blockInfo["blockDetails"]["size"],
transactions: "",
reward: blockInfo["blockDetails"]["reward"],
hash: blockInfo["blockDetails"]["hash"],
difficulty: blockInfo["blockDetails"]["difficulty"],
nonce: blockInfo["blockDetails"]["nonce"],
};
return obj;
});
}
</script> </script>
</body> </body>
</html> </html>