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

View File

@ -1,5 +1,6 @@
<!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" />
@ -7,6 +8,12 @@
<link rel="stylesheet" href="css/main.css" /> <link rel="stylesheet" href="css/main.css" />
</head> </head>
<!-- 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"> <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">
@ -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>
@ -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,7 +606,7 @@
} }
if (pageId === "transaction_page") { if (pageId === "transaction_page") {
let latest100txs = await getTxDetafils(); let latest100txs = await getTxDetails();
loading() loading()
} }
@ -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>