Merge pull request #4 from vivekteega/master
Pushing code compatible with v2 of the API
This commit is contained in:
commit
a45b79fce1
@ -981,6 +981,9 @@ p {
|
|||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
background: rgba(var(--text-color), 0.1);
|
background: rgba(var(--text-color), 0.1);
|
||||||
}
|
}
|
||||||
|
.transaction time {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
#loading {
|
#loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
2
css/main.min.css
vendored
2
css/main.min.css
vendored
File diff suppressed because one or more lines are too long
@ -894,6 +894,9 @@ p {
|
|||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
background: rgba(var(--text-color), 0.1);
|
background: rgba(var(--text-color), 0.1);
|
||||||
}
|
}
|
||||||
|
time {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#loading {
|
#loading {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
290
index.html
290
index.html
@ -60,8 +60,8 @@
|
|||||||
<!-- Set urls for token and flo Apis -->
|
<!-- Set urls for token and flo Apis -->
|
||||||
<script>
|
<script>
|
||||||
let floGlobals = {}
|
let floGlobals = {}
|
||||||
tokenApiUrl = 'https://ranchimallflo.duckdns.org'
|
tokenApiUrl = 'https://ranchimallflov2.ranchimall.net'
|
||||||
floApiUrl = 'https://flosight.duckdns.org'
|
floApiUrl = 'https://flosight.ranchimall.net'
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
/*jshint esversion: 8 */
|
/*jshint esversion: 8 */
|
||||||
@ -408,7 +408,7 @@
|
|||||||
router.addRoute('block', async state => {
|
router.addRoute('block', async state => {
|
||||||
const [blockId] = state.wildcards
|
const [blockId] = state.wildcards
|
||||||
if (!blockId) return;
|
if (!blockId) return;
|
||||||
let [blockInfo, blockTxs] = await Promise.all([getBlockInfo(blockId), getBlockTxs(blockId)])
|
let [blockInfo, blockTxs] = await Promise.all([getBlockInfo(blockId), getBlockTransactions(blockId)])
|
||||||
renderElem(getRef("page_container"), html`${render.blockPage(blockInfo)}`);
|
renderElem(getRef("page_container"), html`${render.blockPage(blockInfo)}`);
|
||||||
getRef("page_title").textContent = 'Block'
|
getRef("page_title").textContent = 'Block'
|
||||||
renderTransactions('block_transaction_container', blockTxs)
|
renderTransactions('block_transaction_container', blockTxs)
|
||||||
@ -668,15 +668,17 @@
|
|||||||
`;
|
`;
|
||||||
},
|
},
|
||||||
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, nftHash } = obj;
|
||||||
// todo : This is a temporary fix. Fix this on the Database and API level
|
// todo : This is a temporary fix. Fix this on the Database and API level
|
||||||
if (type == 'smartContractPays' || type == ' smartContractPays') {
|
if (type == 'smartContractPays' || type == ' smartContractPays') {
|
||||||
name = ''
|
name = ''
|
||||||
}
|
}
|
||||||
// split camel case to words
|
|
||||||
type = type.replace(/([A-Z])/g, ' $1').replace(/^./, function (str) {
|
if (type.trim() === 'nftIncorporation')
|
||||||
return str.toUpperCase();
|
type = 'NFT Incorporation'
|
||||||
});
|
else if (type.trim() === 'nft transfer')
|
||||||
|
type = 'NFT Transfer'
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div id="transaction_page" class="page">
|
<div id="transaction_page" class="page">
|
||||||
<div class='head'>
|
<div class='head'>
|
||||||
@ -706,10 +708,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5 class="label">FLO Data</h5>
|
<h5 class="label">FLO Data</h5>
|
||||||
<p>${floData}</p>
|
<p>${floData}</p>
|
||||||
<h5 class="label">Block Confirmations</h5>
|
<h5 class="label">Block Confirmations</h5>
|
||||||
<h4>${confirmations}</h4>
|
<h4>${confirmations}</h4>
|
||||||
|
${nftHash ? html`
|
||||||
|
<h5 class="label">NFT hash</h5>
|
||||||
|
<sm-copy value=${nftHash} clip-text></sm-copy>
|
||||||
|
`: ''
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -743,7 +750,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="uppercase">${token}</h2>
|
<h2 class="uppercase">${token}</h2>
|
||||||
<h5 class="label">Supply</h5>
|
<h5 class="label">Supply</h5>
|
||||||
<h4>${formatAmount(supply, token.toLowerCase() === 'rupee' ? 'inr' : 'usd')}</h4>
|
<h4> ${supply ? formatAmount(supply, token.toLowerCase() === 'rupee' ? 'inr' : 'usd') : 'Infinite'} </h4>
|
||||||
<h5 class="label">Incorporation address</h5>
|
<h5 class="label">Incorporation address</h5>
|
||||||
<h4 class="wrap-around">${incAddress}</h4>
|
<h4 class="wrap-around">${incAddress}</h4>
|
||||||
</div>
|
</div>
|
||||||
@ -831,7 +838,7 @@
|
|||||||
return card;
|
return card;
|
||||||
},
|
},
|
||||||
contractTransferCard(obj) {
|
contractTransferCard(obj) {
|
||||||
const { hash, blockHeight, token, sender, receiver, amount, contractName, userChoice } = obj;
|
const { hash, blockHeight, token, sender, receiver, amount, contractName, userChoice, time } = obj;
|
||||||
return html`
|
return html`
|
||||||
<div id=${hash} class="transaction token-transfer">
|
<div id=${hash} class="transaction token-transfer">
|
||||||
<svg class="icon" viewBox="0 0 64 64"> <title>contract</title> <path d="M4.75,49.27A8,8,0,0,0,4.2,61.14a7.82,7.82,0,0,0,4.34,2.24,7.42,7.42,0,0,0,1.34.12H47.41a8.06,8.06,0,0,0,8.05-8V7.87"/> <path d="M8.54,56.13V8.54a8.06,8.06,0,0,1,8.05-8H54.12a7.42,7.42,0,0,1,1.34.12A7.82,7.82,0,0,1,59.8,2.86a8,8,0,0,1-.55,11.87"/> <line x1="17.93" y1="22.62" x2="46.07" y2="22.62"/> <line x1="17.93" y1="32" x2="46.07" y2="32"/> <line x1="17.93" y1="41.38" x2="38.03" y2="41.38"/> </svg>
|
<svg class="icon" viewBox="0 0 64 64"> <title>contract</title> <path d="M4.75,49.27A8,8,0,0,0,4.2,61.14a7.82,7.82,0,0,0,4.34,2.24,7.42,7.42,0,0,0,1.34.12H47.41a8.06,8.06,0,0,0,8.05-8V7.87"/> <path d="M8.54,56.13V8.54a8.06,8.06,0,0,1,8.05-8H54.12a7.42,7.42,0,0,1,1.34.12A7.82,7.82,0,0,1,59.8,2.86a8,8,0,0,1-.55,11.87"/> <line x1="17.93" y1="22.62" x2="46.07" y2="22.62"/> <line x1="17.93" y1="32" x2="46.07" y2="32"/> <line x1="17.93" y1="41.38" x2="38.03" y2="41.38"/> </svg>
|
||||||
@ -840,6 +847,7 @@
|
|||||||
<a href=${`#/token/${token}`} class="">${token}</a>
|
<a href=${`#/token/${token}`} class="">${token}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
|
<time>${getFormattedTime(time)}</time>
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
<h5 class="label">Amount</h5>
|
<h5 class="label">Amount</h5>
|
||||||
<h4>${formatAmount(amount, token.toLowerCase() === 'rupee' ? 'inr' : 'usd')} ${token}</h4>
|
<h4>${formatAmount(amount, token.toLowerCase() === 'rupee' ? 'inr' : 'usd')} ${token}</h4>
|
||||||
@ -859,15 +867,30 @@
|
|||||||
</div>`;
|
</div>`;
|
||||||
},
|
},
|
||||||
tokenTransferCard(obj) {
|
tokenTransferCard(obj) {
|
||||||
const { hash, blockHeight, token, sender, receiver, amount } = obj;
|
const { hash, blockHeight, token, sender, receiver, amount, type, time } = obj;
|
||||||
|
let title = 'Token transfer';
|
||||||
|
console.log(type)
|
||||||
|
if (type === 'nfttransfer')
|
||||||
|
title = 'NFT transfer';
|
||||||
return html`
|
return html`
|
||||||
<div id=${hash} class="transaction token-transfer">
|
<div id=${hash} class="transaction token-transfer">
|
||||||
<svg class="icon" viewBox="0 0 64 64"> <title>transfer</title> <polyline points="17.04 35.97 14.57 33.5 40.15 7.9 32.75 0.5 55.52 0.5 55.52 23.28 48.12 15.87 23.86 40.14 15.88 48.13 8.48 40.72 8.48 63.5 31.25 63.5 23.85 56.1 49.43 30.5 46.96 28.03"/> </svg>
|
<svg class="icon" viewBox="0 0 64 64"> <title>transfer</title> <polyline points="17.04 35.97 14.57 33.5 40.15 7.9 32.75 0.5 55.52 0.5 55.52 23.28 48.12 15.87 23.86 40.14 15.88 48.13 8.48 40.72 8.48 63.5 31.25 63.5 23.85 56.1 49.43 30.5 46.96 28.03"/> </svg>
|
||||||
<div class="contract-type">
|
<div class="contract-type">
|
||||||
<h5 class="label">Token transfer</h5>
|
<h5 class="label">${title}</h5>
|
||||||
<a href=${`#/token/${token}`} class="uppercase">${token}</a>
|
<a href=${`#/token/${token}`} class="">${token}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
|
<time>${getFormattedTime(time)}</time>
|
||||||
|
<div class="flex flex-wrap gap-1">
|
||||||
|
<div class="flex flex-direction-column">
|
||||||
|
<h5 class="label">Sender</h5>
|
||||||
|
<a href=${`#/address/${sender}`} class="address wrap-around">${sender}</a>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-direction-column">
|
||||||
|
<h5 class="label">Receiver</h5>
|
||||||
|
<a href=${`#/address/${receiver}`} class="address wrap-around">${receiver}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
<h5 class="label">Amount</h5>
|
<h5 class="label">Amount</h5>
|
||||||
<h4>${formatAmount(amount, token.toLowerCase() === 'rupee' ? 'inr' : 'usd')} ${token}</h4>
|
<h4>${formatAmount(amount, token.toLowerCase() === 'rupee' ? 'inr' : 'usd')} ${token}</h4>
|
||||||
@ -884,15 +907,19 @@
|
|||||||
`;
|
`;
|
||||||
},
|
},
|
||||||
tokenCreationCard(obj) {
|
tokenCreationCard(obj) {
|
||||||
const { hash, blockHeight, token, incAddress, supply } = obj;
|
const { hash, blockHeight, token, incAddress, supply, type, nftHash, time } = obj;
|
||||||
|
let title = 'Token creation';
|
||||||
|
if (type === 'nftincorp')
|
||||||
|
title = 'NFT creation';
|
||||||
return html`
|
return html`
|
||||||
<div id=${hash} class="transaction token-creation">
|
<div id=${hash} class="transaction token-creation">
|
||||||
<svg class="icon" viewBox="0 0 64 64"> <title>token</title> <circle cx="32" cy="32" r="31"/> <circle cx="32" cy="32" r="25.19"/> <line x1="37" y1="21.74" x2="43.14" y2="21.74"/> <path d="M20.86,21.74H32V43.23"/> </svg>
|
<svg class="icon" viewBox="0 0 64 64"> <title>token</title> <circle cx="32" cy="32" r="31"/> <circle cx="32" cy="32" r="25.19"/> <line x1="37" y1="21.74" x2="43.14" y2="21.74"/> <path d="M20.86,21.74H32V43.23"/> </svg>
|
||||||
<div class="contract-type">
|
<div class="contract-type">
|
||||||
<h5 class="label">token creation</h5>
|
<h5 class="label">${title}</h5>
|
||||||
<a href=${`#/token/${token}`} class="token uppercase">${token}</a>
|
<a href=${`#/token/${token}`} class="token uppercase">${token}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
|
<time>${getFormattedTime(time)}</time>
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
<h5 class="label">Incorporation address</h5>
|
<h5 class="label">Incorporation address</h5>
|
||||||
<a href=${`#/address/${incAddress}`} class="address wrap-around">${incAddress}</a>
|
<a href=${`#/address/${incAddress}`} class="address wrap-around">${incAddress}</a>
|
||||||
@ -905,6 +932,11 @@
|
|||||||
<h5 class="label">supply</h5>
|
<h5 class="label">supply</h5>
|
||||||
<h4>${supply}</h4>
|
<h4>${supply}</h4>
|
||||||
</div>
|
</div>
|
||||||
|
${type === 'nftincorp' ? html`<div class="flex flex-direction-column">
|
||||||
|
<h5 class="label">NFT hash</h5>
|
||||||
|
<sm-copy value="${nftHash}"></sm-copy>
|
||||||
|
</div>`: ''
|
||||||
|
}
|
||||||
<div class="flex align-center space-between flex-wrap gap-1">
|
<div class="flex align-center space-between flex-wrap gap-1">
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
<h5 class="label">Transaction ID</h5>
|
<h5 class="label">Transaction ID</h5>
|
||||||
@ -916,7 +948,7 @@
|
|||||||
</div>`;
|
</div>`;
|
||||||
},
|
},
|
||||||
contractTriggerCard(obj) {
|
contractTriggerCard(obj) {
|
||||||
const { hash, blockHeight, contractName, contractAddress, winningChoice, committeeAddress } = obj;
|
const { hash, blockHeight, contractName, contractAddress, winningChoice, committeeAddress, time } = obj;
|
||||||
return html`
|
return html`
|
||||||
<div id=${hash} class="transaction contract-trigger">
|
<div id=${hash} class="transaction contract-trigger">
|
||||||
<svg class="icon" viewBox="0 0 64 64"> <circle cx="32" cy="32" r="31"/> <polyline points="32 13.47 32 32 43.4 43.4"/> </svg>
|
<svg class="icon" viewBox="0 0 64 64"> <circle cx="32" cy="32" r="31"/> <polyline points="32 13.47 32 32 43.4 43.4"/> </svg>
|
||||||
@ -925,6 +957,7 @@
|
|||||||
<h4 class="uppercase">trigger</h4>
|
<h4 class="uppercase">trigger</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
|
<time>${getFormattedTime(time)}</time>
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
<h5 class="label">Contract name</h5>
|
<h5 class="label">Contract name</h5>
|
||||||
<h4>${contractName}</h4>
|
<h4>${contractName}</h4>
|
||||||
@ -953,7 +986,7 @@
|
|||||||
`;
|
`;
|
||||||
},
|
},
|
||||||
contractCreationCard(obj) {
|
contractCreationCard(obj) {
|
||||||
const { hash, blockHeight, token, contractName, incAddress, contractType, expiration, participationFees, availableChoices } = obj;
|
const { hash, blockHeight, token, contractName, incAddress, contractType, expiration, participationFees, availableChoices, time } = obj;
|
||||||
return html`
|
return html`
|
||||||
<div id=${hash} class="transaction contract-creation">
|
<div id=${hash} class="transaction contract-creation">
|
||||||
<svg class="icon" viewBox="0 0 64 64"> <title>contract creation</title> <path d="M47.07,23.85V11"/> <path d="M3,47A7,7,0,0,0,.48,52.39a6.89,6.89,0,0,0,2.05,4.93,6.78,6.78,0,0,0,3.78,2,6.34,6.34,0,0,0,1.16.1H40.09a7,7,0,0,0,7-7V44"/> <path d="M6.31,53V11.61a7,7,0,0,1,7-7H45.91a6.26,6.26,0,0,1,1.16.1,6.74,6.74,0,0,1,3.78,1.95A7,7,0,0,1,50.37,17"/> <line x1="14.46" y1="23.85" x2="38.92" y2="23.85"/> <line x1="14.46" y1="32" x2="38.92" y2="32"/> <line x1="14.46" y1="40.15" x2="31.93" y2="40.15"/> <path d="M57.79,24.44l-2.88-2.9,3.79-3.79a1,1,0,0,1,1.39,0l3.11,3.11a1,1,0,0,1,0,1.39L40.34,45.1a1,1,0,0,1-.52.28L36,46A1,1,0,0,1,34.9,44.9l.67-3.77a1,1,0,0,1,.27-.52L52.65,23.8"/> </svg>
|
<svg class="icon" viewBox="0 0 64 64"> <title>contract creation</title> <path d="M47.07,23.85V11"/> <path d="M3,47A7,7,0,0,0,.48,52.39a6.89,6.89,0,0,0,2.05,4.93,6.78,6.78,0,0,0,3.78,2,6.34,6.34,0,0,0,1.16.1H40.09a7,7,0,0,0,7-7V44"/> <path d="M6.31,53V11.61a7,7,0,0,1,7-7H45.91a6.26,6.26,0,0,1,1.16.1,6.74,6.74,0,0,1,3.78,1.95A7,7,0,0,1,50.37,17"/> <line x1="14.46" y1="23.85" x2="38.92" y2="23.85"/> <line x1="14.46" y1="32" x2="38.92" y2="32"/> <line x1="14.46" y1="40.15" x2="31.93" y2="40.15"/> <path d="M57.79,24.44l-2.88-2.9,3.79-3.79a1,1,0,0,1,1.39,0l3.11,3.11a1,1,0,0,1,0,1.39L40.34,45.1a1,1,0,0,1-.52.28L36,46A1,1,0,0,1,34.9,44.9l.67-3.77a1,1,0,0,1,.27-.52L52.65,23.8"/> </svg>
|
||||||
@ -962,6 +995,7 @@
|
|||||||
<a href=${`#/token/${token}`} class="">${token}</a>
|
<a href=${`#/token/${token}`} class="">${token}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
|
<time>${getFormattedTime(time)}</time>
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
<h5 class="label">Contract name</h5>
|
<h5 class="label">Contract name</h5>
|
||||||
<h4>${contractName}</h4>
|
<h4>${contractName}</h4>
|
||||||
@ -1018,16 +1052,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function renderTransactions(container, transactions = []) {
|
async function renderTransactions(container, transactions = []) {
|
||||||
let txFrag = getTxFrag(transactions);
|
let txFrag = parseTransactions(transactions);
|
||||||
const renderedTransactions = txFrag.map(tx => {
|
const renderedTransactions = txFrag.map(tx => {
|
||||||
switch (tx.type) {
|
switch (tx.type) {
|
||||||
case 'tokentransfer':
|
case 'tokentransfer':
|
||||||
|
case 'nfttransfer':
|
||||||
return render.tokenTransferCard(tx)
|
return render.tokenTransferCard(tx)
|
||||||
break;
|
break;
|
||||||
case 'contracttransfer':
|
case 'contracttransfer':
|
||||||
return render.contractTransferCard(tx);
|
return render.contractTransferCard(tx);
|
||||||
break;
|
break;
|
||||||
case 'tokenincorp':
|
case 'tokenincorp':
|
||||||
|
case 'nftincorp':
|
||||||
return render.tokenCreationCard(tx);
|
return render.tokenCreationCard(tx);
|
||||||
break;
|
break;
|
||||||
case 'contractincorp':
|
case 'contractincorp':
|
||||||
@ -1060,7 +1096,7 @@
|
|||||||
renderElem(getRef('suggestions'), html`${renderedSuggestions}`)
|
renderElem(getRef('suggestions'), html`${renderedSuggestions}`)
|
||||||
}, 100))
|
}, 100))
|
||||||
async function getBannerData() {
|
async function getBannerData() {
|
||||||
const { systemTransactionCount, systemAddressCount } = await fetchJson(`${tokenApiUrl}/api/v1.0/getSystemData`)
|
const { systemTransactionCount, systemAddressCount } = await fetchJson(`${tokenApiUrl}/api/v2/info`)
|
||||||
return {
|
return {
|
||||||
topToken: "RMT",
|
topToken: "RMT",
|
||||||
totalTransactions: systemTransactionCount,
|
totalTransactions: systemTransactionCount,
|
||||||
@ -1076,123 +1112,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLatestTxs() {
|
function getLatestTxs() {
|
||||||
return fetchJson(`${tokenApiUrl}/api/v1.0/getLatestTransactionDetails?numberOfLatestBlocks=4`)
|
return new Promise((resolve, reject) => {
|
||||||
.then(function (latestTxs) {
|
fetchJson(`${tokenApiUrl}/api/v2/latestTransactionDetails?limit=4`)
|
||||||
let latestTxArray = [];
|
.then(function (latestTxs) {
|
||||||
for (const transactionKey in latestTxs.latestTransactions) {
|
resolve(latestTxs.latestTransactions)
|
||||||
const { transactionDetails: { txid, blockHeight, vin, vout }, parsedFloData: { type, tokenAmount, tokenIdentification, transferType, contractName, triggerCondition, userChoice } } = latestTxs.latestTransactions[transactionKey];
|
}).catch((err) => {
|
||||||
// determine txhash and blockHeight
|
reject(err)
|
||||||
let obj = {
|
});
|
||||||
hash: txid,
|
})
|
||||||
blockHeight,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (type != "smartContractPays") {
|
|
||||||
// determine token
|
|
||||||
obj["token"] = tokenIdentification;
|
|
||||||
|
|
||||||
if (type == "transfer") {
|
|
||||||
if (transferType == "token") {
|
|
||||||
// token transfer
|
|
||||||
/* tokenTransferCard
|
|
||||||
hash, blockHeight, token, sender, receiver, amount */
|
|
||||||
|
|
||||||
let receiverAddress = "";
|
|
||||||
for (const output of vout) {
|
|
||||||
if (output["scriptPubKey"]["addresses"][0] !== vin[0]["addr"]) {
|
|
||||||
receiverAddress = output["scriptPubKey"]["addresses"][0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = Object.assign({}, obj, {
|
|
||||||
sender: vin[0]["addr"],
|
|
||||||
receiver: receiverAddress,
|
|
||||||
amount: tokenAmount,
|
|
||||||
type: "tokentransfer",
|
|
||||||
});
|
|
||||||
latestTxArray.push(obj);
|
|
||||||
} else if (transferType === "smartContract") {
|
|
||||||
// smart contract transfer
|
|
||||||
let receiverAddress = "";
|
|
||||||
for (const output of vout) {
|
|
||||||
if (output["scriptPubKey"]["addresses"][0] != vin[0]["addr"]) {
|
|
||||||
receiverAddress = output["scriptPubKey"]["addresses"][0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
obj = Object.assign({}, obj, {
|
|
||||||
sender: vin[0]["addr"],
|
|
||||||
receiver: receiverAddress,
|
|
||||||
amount: tokenAmount,
|
|
||||||
contractName: contractName,
|
|
||||||
userChoice: userChoice,
|
|
||||||
type: "contracttransfer",
|
|
||||||
});
|
|
||||||
latestTxArray.push(obj);
|
|
||||||
}
|
|
||||||
} else if (type === "smartContractIncorporation") {
|
|
||||||
// smart contract incorporation
|
|
||||||
// todo : add checks to determine obj for different types of smart contract incorporation
|
|
||||||
obj = Object.assign({}, obj, {
|
|
||||||
contractName: contractName,
|
|
||||||
incAddress: contractAddress,
|
|
||||||
contractType: contractType,
|
|
||||||
expiration: expiryTime,
|
|
||||||
participationFees: contractAmount,
|
|
||||||
availableChoices: "",
|
|
||||||
type: "contractincorp",
|
|
||||||
});
|
|
||||||
latestTxArray.push(obj);
|
|
||||||
} else if (type === "tokenIncorporation") {
|
|
||||||
// token incorporation
|
|
||||||
// smart contract incorporation
|
|
||||||
obj = Object.assign({}, obj, {
|
|
||||||
incAddress: vin[0]["addr"],
|
|
||||||
supply: tokenAmount,
|
|
||||||
type: "tokenincorp",
|
|
||||||
});
|
|
||||||
latestTxArray.push(obj);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// smart contract committee trigger
|
|
||||||
// smart contract incorporation
|
|
||||||
let receiverAddress = "";
|
|
||||||
for (const output of vout) {
|
|
||||||
if (output["scriptPubKey"]["addresses"][0] != vin[0]["addr"]) {
|
|
||||||
receiverAddress = output["scriptPubKey"]["addresses"][0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
obj = Object.assign({}, obj, {
|
|
||||||
contractName,
|
|
||||||
contractAddress: receiverAddress,
|
|
||||||
winningChoice: triggerCondition,
|
|
||||||
committeeAddress: vin[0]["addr"],
|
|
||||||
type: "contracttrigger",
|
|
||||||
});
|
|
||||||
latestTxArray.push(obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return latestTxArray;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLatestBlocks() {
|
|
||||||
return fetchJson(
|
|
||||||
`${tokenApiUrl}/api/v1.0/getLatestBlockDetails?numberOfLatestBlocks=4`
|
|
||||||
)
|
|
||||||
.then(function (latestBlocks) {
|
|
||||||
let obj = {};
|
|
||||||
return obj;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTokenInfo(thisToken) {
|
function getTokenInfo(thisToken) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fetchJson(
|
fetchJson(
|
||||||
`${tokenApiUrl}/api/v1.0/getTokenInfo?token=${thisToken.toLowerCase()}`
|
`${tokenApiUrl}/api/v2/tokenInfo/${thisToken.toLowerCase()}`
|
||||||
).then(function (tokenInfo) {
|
).then(function (tokenInfo) {
|
||||||
if (tokenInfo.result === "error")
|
if (tokenInfo.result === "error")
|
||||||
reject(tokenInfo.description);
|
reject(tokenInfo.description);
|
||||||
@ -1214,17 +1147,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getTokenBalances(tokenName) {
|
async function getTokenBalances(tokenName) {
|
||||||
const tokenDetails = await fetchJson(`${tokenApiUrl}/api/v1.0/getTokenBalances?token=` + tokenName)
|
const tokenDetails = await fetchJson(`${tokenApiUrl}/api/v2/tokenBalances/` + tokenName)
|
||||||
return tokenDetails.balances
|
return tokenDetails.balances
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTokenTransactions(tokenName) {
|
async function getTokenTransactions(tokenName) {
|
||||||
const transactions = await fetchJson(`${tokenApiUrl}/api/v1.0/getTokenTransactions?token=` + tokenName)
|
const transactions = await fetchJson(`${tokenApiUrl}/api/v2/tokenTransactions/` + tokenName)
|
||||||
return transactions.transactions
|
return transactions.transactions
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBlockInfo(thisBlock) {
|
async function getBlockInfo(thisBlock) {
|
||||||
const info = await fetchJson(`${tokenApiUrl}/api/v1.0/getBlockDetails/${thisBlock}`);
|
const info = await fetchJson(`${tokenApiUrl}/api/v2/blockDetails/${thisBlock}`);
|
||||||
const { height, size, reward, hash, difficulty, nonce, tx } = info.blockDetails
|
const { height, size, reward, hash, difficulty, nonce, tx } = info.blockDetails
|
||||||
return {
|
return {
|
||||||
blockHeight: height,
|
blockHeight: height,
|
||||||
@ -1237,14 +1170,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function getBlockTransactions(thisBlock) {
|
async function getBlockTransactions(thisBlock) {
|
||||||
const blockTransactions = await fetchJson(`${tokenApiUrl}/api/v1.0/getBlockTransactions/${thisBlock}`)
|
const blockTransactions = await fetchJson(`${tokenApiUrl}/api/v2/blockTransactions/${thisBlock}`)
|
||||||
return blockTransactions.transactions
|
return blockTransactions.transactions
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getContractInfo(contract) {
|
async function getContractInfo(contract) {
|
||||||
const info = await fetchJson(`${tokenApiUrl}/api/v1.0/getSmartContractInfo?contractName=${contract.name}&contractAddress=${contract.address}`);
|
const info = await fetchJson(`${tokenApiUrl}/api/v2/smartContractInfo?contractName=${contract.name}&contractAddress=${contract.address}`);
|
||||||
console.log(info, contract)
|
console.log(info, contract)
|
||||||
const { contractInfo: { contractType, status, expiryTime, payeeAddress, userChoice, tokenIdentification, contractAmount, minimumsubscriptionamount, maximumsubscriptionamount }, contractAddress, contractName } = info
|
const { contractInfo: { contractType, status, expiryTime, payeeAddress, userChoice, tokenIdentification, contractAmount, minimumsubscriptionamount, maximumsubscriptionamount }, contractAddress, contractName } = info
|
||||||
return {
|
return {
|
||||||
@ -1263,34 +1195,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getContractParticipants(contract) {
|
async function getContractParticipants(contract) {
|
||||||
const participants = await fetchJson(`${tokenApiUrl}/api/v1.0/getSmartContractParticipants?contractName=${contract.name}&contractAddress=${contract.address}`)
|
const participants = await fetchJson(`${tokenApiUrl}/api/v2/smartContractParticipants?contractName=${contract.name}&contractAddress=${contract.address}`)
|
||||||
return participants.participantInfo
|
return participants.participantInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getContractTransactions(contract) {
|
async function getContractTransactions(contract) {
|
||||||
const transactions = await fetchJson(`${tokenApiUrl}/api/v1.0/getSmartContractTransactions?contractName=${contract.name}&contractAddress=${contract.address}`)
|
const transactions = await fetchJson(`${tokenApiUrl}/api/v2/smartContractTransactions?contractName=${contract.name}&contractAddress=${contract.address}`)
|
||||||
return transactions.contractTransactions
|
return transactions.contractTransactions
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTxFrag(txList) {
|
function parseTransactions(txList) {
|
||||||
// Check if "txList" is array or object
|
if (!Array.isArray(txList))
|
||||||
if (Array.isArray(txList))
|
txList = Object.values(txList)
|
||||||
return txList;
|
|
||||||
// Object
|
|
||||||
let latestTxArray = [];
|
let latestTxArray = [];
|
||||||
for (const transactionKey in txList) {
|
txList.forEach(tx => {
|
||||||
const { transactionDetails: { txid, blockHeight, vin, vout }, parsedFloData: { contractAddress, contractType, expiryTime, contractAmount, type, tokenAmount, tokenIdentification, transferType, contractName, triggerCondition, userChoice } } = txList[transactionKey];
|
// console.log(transactionKey)
|
||||||
|
// if(transactionKey == '11571ce7e5eed0bce30e24de89bb1ba6cc432df7b5b40bbc9f0225b98968cb47'){
|
||||||
|
// //debugger
|
||||||
|
// }
|
||||||
|
const {
|
||||||
|
transactionDetails: {
|
||||||
|
txid, blockHeight, vin, vout, time },
|
||||||
|
parsedFloData: {
|
||||||
|
contractAddress, contractType, expiryTime, contractAmount, type, tokenAmount, tokenIdentification, transferType, contractName, triggerCondition, userChoice, nftHash
|
||||||
|
}
|
||||||
|
} = tx;
|
||||||
let obj = {
|
let obj = {
|
||||||
hash: txid,
|
hash: txid,
|
||||||
blockHeight,
|
blockHeight,
|
||||||
|
time
|
||||||
};
|
};
|
||||||
|
|
||||||
if (type != "smartContractPays") {
|
if (type != "smartContractPays") {
|
||||||
// determine token
|
// determine token
|
||||||
obj["token"] = tokenIdentification;
|
obj["token"] = tokenIdentification;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'transfer':
|
case 'transfer':
|
||||||
if (transferType == "token") {
|
if (transferType == "token" || transferType == 'nft') {
|
||||||
let receiverAddress = "";
|
let receiverAddress = "";
|
||||||
for (const output of vout) {
|
for (const output of vout) {
|
||||||
if (output["scriptPubKey"]["addresses"][0] !== vin[0]["addr"]) {
|
if (output["scriptPubKey"]["addresses"][0] !== vin[0]["addr"]) {
|
||||||
@ -1303,7 +1243,7 @@
|
|||||||
sender: vin[0]["addr"],
|
sender: vin[0]["addr"],
|
||||||
receiver: receiverAddress,
|
receiver: receiverAddress,
|
||||||
amount: tokenAmount,
|
amount: tokenAmount,
|
||||||
type: "tokentransfer",
|
type: transferType == "token" ? "tokentransfer" : "nfttransfer",
|
||||||
});
|
});
|
||||||
latestTxArray.push(obj);
|
latestTxArray.push(obj);
|
||||||
break;
|
break;
|
||||||
@ -1338,7 +1278,6 @@
|
|||||||
});
|
});
|
||||||
latestTxArray.push(obj);
|
latestTxArray.push(obj);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'smartContractIncorporation':
|
case 'smartContractIncorporation':
|
||||||
// smart contract incorporation
|
// smart contract incorporation
|
||||||
// todo : add checks to determine obj for different types of smart contract incorporation
|
// todo : add checks to determine obj for different types of smart contract incorporation
|
||||||
@ -1353,6 +1292,16 @@
|
|||||||
});
|
});
|
||||||
latestTxArray.push(obj);
|
latestTxArray.push(obj);
|
||||||
break;
|
break;
|
||||||
|
case 'nftIncorporation':
|
||||||
|
// nft incorporation
|
||||||
|
obj = Object.assign({}, obj, {
|
||||||
|
incAddress: vin[0]["addr"],
|
||||||
|
supply: tokenAmount,
|
||||||
|
type: "nftincorp",
|
||||||
|
nftHash
|
||||||
|
});
|
||||||
|
latestTxArray.push(obj);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1377,22 +1326,23 @@
|
|||||||
});
|
});
|
||||||
latestTxArray.push(obj);
|
latestTxArray.push(obj);
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
return latestTxArray;
|
return latestTxArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllBlocks(number) {
|
async function getAllBlocks(number) {
|
||||||
const allBlocks = await fetchJson(`${tokenApiUrl}/api/v1.0/getLatestBlockDetails${number ? `?limit=${number}` : ''}`)
|
const allBlocks = await fetchJson(`${tokenApiUrl}/api/v2/latestBlockDetails${number ? `?limit=${number}` : ''}`)
|
||||||
return Object.values(allBlocks.latestBlocks).sort((a, b) => b.height - a.height)
|
return Object.values(allBlocks.latestBlocks).sort((a, b) => b.height - a.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAllTxs() {
|
async function getAllTxs() {
|
||||||
const allTxs = await fetchJson(`${tokenApiUrl}/api/v1.0/getLatestTransactionDetails?limit=200`)
|
const allTxs = await fetchJson(`${tokenApiUrl}/api/v2/latestTransactionDetails?limit=200`)
|
||||||
return allTxs.latestTransactions
|
return allTxs.latestTransactions
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAddressInfo(floAddress) {
|
async function getAddressInfo(floAddress) {
|
||||||
const addressInfo = await fetchJson(`${tokenApiUrl}/api/v1.0/getFloAddressInfo?floAddress=${floAddress}`)
|
const addressInfo = await fetchJson(`${tokenApiUrl}/api/v2/floAddressInfo/${floAddress}`)
|
||||||
return addressInfo.floAddressBalances
|
return addressInfo.floAddressBalances
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1401,18 +1351,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getAddressTxs(floAddress) {
|
async function getAddressTxs(floAddress) {
|
||||||
const transactions = await fetchJson(`${tokenApiUrl}/api/v1.0/getFloAddressTransactions?floAddress=${floAddress}`)
|
const transactions = await fetchJson(`${tokenApiUrl}/api/v2/floAddressTransactions/${floAddress}`)
|
||||||
return transactions.transactions
|
return transactions.transactions
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTxInfo(thisTx) {
|
async function getTxInfo(thisTx) {
|
||||||
try {
|
try {
|
||||||
const transaction = await fetchJson(`${tokenApiUrl}/api/v1.0/getTransactionDetails/${thisTx}`)
|
const transaction = await fetchJson(`${tokenApiUrl}/api/v2/transactionDetails/${thisTx}`)
|
||||||
if (transaction.result === 'error') {
|
if (transaction.result === 'error') {
|
||||||
return [false, transaction.description]
|
return [false, transaction.description]
|
||||||
} else {
|
} else {
|
||||||
let transactionHash = transaction.transactionHash,
|
let transactionHash = transaction.transactionHash,
|
||||||
{ flodata, tokenAmount, tokenIdentification, type } = transaction.parsedFloData,
|
{ flodata, tokenAmount, tokenIdentification, type, nftHash } = transaction.parsedFloData,
|
||||||
{ blockheight, vin, vout, confirmations } = transaction.transactionDetails;
|
{ blockheight, vin, vout, confirmations } = transaction.transactionDetails;
|
||||||
let receiver = "",
|
let receiver = "",
|
||||||
sender = vin[0].addr;
|
sender = vin[0].addr;
|
||||||
@ -1422,7 +1372,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(transaction)
|
console.log(transaction)
|
||||||
// todo - temporary fixes below. Fix these on the Databse and API level
|
// todo - temporary fixes below. Fix these on the Database and API level
|
||||||
let transactionType = ''
|
let transactionType = ''
|
||||||
if (type == 'transfer') {
|
if (type == 'transfer') {
|
||||||
transactionType = transaction.parsedFloData?.transferType
|
transactionType = transaction.parsedFloData?.transferType
|
||||||
@ -1437,11 +1387,12 @@
|
|||||||
name: tokenIdentification,
|
name: tokenIdentification,
|
||||||
blockHeight: blockheight,
|
blockHeight: blockheight,
|
||||||
amount: tokenAmount,
|
amount: tokenAmount,
|
||||||
sender: sender,
|
sender,
|
||||||
receiver: receiver,
|
receiver,
|
||||||
floData: flodata,
|
floData: flodata,
|
||||||
hash: transactionHash,
|
hash: transactionHash,
|
||||||
confirmations: confirmations
|
confirmations,
|
||||||
|
nftHash
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1493,9 +1444,9 @@
|
|||||||
location.href = `#/contract/${text}`
|
location.href = `#/contract/${text}`
|
||||||
resolve('contract')
|
resolve('contract')
|
||||||
} else if (text.length == 64 && returnHexNumber(text)) {
|
} else if (text.length == 64 && returnHexNumber(text)) {
|
||||||
fetchJson(`${window.tokenApiUrl}/api/v1.0/categoriseString/` + text)
|
fetchJson(`${window.tokenApiUrl}/api/v2/categoriseString/` + text)
|
||||||
.then(function (myJson) {
|
.then(function (myJson) {
|
||||||
console.log(`${window.tokenApiUrl}/api/v1.0/categoriseString/` + text)
|
console.log(`${window.tokenApiUrl}/api/v2/categoriseString/` + text)
|
||||||
if (myJson['type'] == 'transaction') {
|
if (myJson['type'] == 'transaction') {
|
||||||
//console.log('data entered is a transaction hash');
|
//console.log('data entered is a transaction hash');
|
||||||
location.href = `#/transaction/${text}`
|
location.href = `#/transaction/${text}`
|
||||||
@ -1529,7 +1480,7 @@
|
|||||||
async function getAllSuggestions() {
|
async function getAllSuggestions() {
|
||||||
window.allSuggestions = [];
|
window.allSuggestions = [];
|
||||||
window.ranchimallFlo = {};
|
window.ranchimallFlo = {};
|
||||||
let { tokens, smartContracts } = await fetchJson(`${window.tokenApiUrl}/api/v1.0/getTokenSmartContractList`);
|
let { tokens, smartContracts } = await fetchJson(`${window.tokenApiUrl}/api/v2/tokenSmartContractList`);
|
||||||
//console.log('first line of the fetch result');
|
//console.log('first line of the fetch result');
|
||||||
ranchimallFlo.tokenList = tokens;
|
ranchimallFlo.tokenList = tokens;
|
||||||
ranchimallFlo.smartContractList = smartContracts;
|
ranchimallFlo.smartContractList = smartContracts;
|
||||||
@ -1537,7 +1488,6 @@
|
|||||||
ranchimallFlo.smartContractNameAddressList = [];
|
ranchimallFlo.smartContractNameAddressList = [];
|
||||||
//console.log(ranchimallFlo.smartContractList.length);
|
//console.log(ranchimallFlo.smartContractList.length);
|
||||||
ranchimallFlo.smartContractList.forEach(contract => {
|
ranchimallFlo.smartContractList.forEach(contract => {
|
||||||
console.log(contract.contractName);
|
|
||||||
allSuggestions.push(`${contract.contractName}-${contract.contractAddress}`);
|
allSuggestions.push(`${contract.contractName}-${contract.contractAddress}`);
|
||||||
ranchimallFlo.smartContractNameList.push(contract.contractName);
|
ranchimallFlo.smartContractNameList.push(contract.contractName);
|
||||||
ranchimallFlo.smartContractNameAddressList.push(`${contract.contractName}-${contract.contractAddress}`);
|
ranchimallFlo.smartContractNameAddressList.push(`${contract.contractName}-${contract.contractAddress}`);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user