Merge branch 'master' into pull-master
This commit is contained in:
commit
8973f7cfaa
111
index.html
111
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 */
|
||||||
@ -329,6 +329,7 @@
|
|||||||
async function renderHome(state) {
|
async function renderHome(state) {
|
||||||
getRef("page_header").classList.add("hidden");
|
getRef("page_header").classList.add("hidden");
|
||||||
let [data, latestTxs, latestBlocks] = await Promise.all([getBannerData(), getLatestTxs(), getAllBlocks(6)])
|
let [data, latestTxs, latestBlocks] = await Promise.all([getBannerData(), getLatestTxs(), getAllBlocks(6)])
|
||||||
|
console.log(latestTxs)
|
||||||
renderElem(getRef("page_container"), html`${render.homepage(data)}`);
|
renderElem(getRef("page_container"), html`${render.homepage(data)}`);
|
||||||
renderTransactions('top_transaction_container', latestTxs)
|
renderTransactions('top_transaction_container', latestTxs)
|
||||||
const renderedBlocks = latestBlocks.map(block => render.blockCard(block))
|
const renderedBlocks = latestBlocks.map(block => render.blockCard(block))
|
||||||
@ -668,15 +669,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 +709,16 @@
|
|||||||
</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>
|
||||||
`;
|
`;
|
||||||
@ -859,13 +868,19 @@
|
|||||||
</div>`;
|
</div>`;
|
||||||
},
|
},
|
||||||
tokenTransferCard(obj) {
|
tokenTransferCard(obj) {
|
||||||
const { hash, blockHeight, token, sender, receiver, amount } = obj;
|
const { hash, blockHeight, token, sender, receiver, amount,type } = 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>
|
|
||||||
<a href=${`#/token/${token}`} class="uppercase">${token}</a>
|
<h5 class="label">${title}</h5>
|
||||||
|
<a href=${`#/token/${token}`} class="">${token}</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="contract-info">
|
<div class="contract-info">
|
||||||
<div class="flex flex-direction-column">
|
<div class="flex flex-direction-column">
|
||||||
@ -884,12 +899,15 @@
|
|||||||
`;
|
`;
|
||||||
},
|
},
|
||||||
tokenCreationCard(obj) {
|
tokenCreationCard(obj) {
|
||||||
const { hash, blockHeight, token, incAddress, supply } = obj;
|
const { hash, blockHeight, token, incAddress, supply,type,nftHash } = 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">
|
||||||
@ -905,6 +923,12 @@
|
|||||||
<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>
|
||||||
@ -1022,12 +1046,14 @@
|
|||||||
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':
|
||||||
@ -1038,6 +1064,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
console.log(renderedTransactions)
|
||||||
renderElem(document.getElementById(container), html`${renderedTransactions.length ? renderedTransactions : html`<div class="no-results">No transactions found</div>`}`)
|
renderElem(document.getElementById(container), html`${renderedTransactions.length ? renderedTransactions : html`<div class="no-results">No transactions found</div>`}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1080,7 +1107,7 @@
|
|||||||
.then(function (latestTxs) {
|
.then(function (latestTxs) {
|
||||||
let latestTxArray = [];
|
let latestTxArray = [];
|
||||||
for (const transactionKey in latestTxs.latestTransactions) {
|
for (const transactionKey in latestTxs.latestTransactions) {
|
||||||
const { transactionDetails: { txid, blockHeight, vin, vout }, parsedFloData: { type, tokenAmount, tokenIdentification, transferType, contractName, triggerCondition, userChoice } } = latestTxs.latestTransactions[transactionKey];
|
const { transactionDetails: { txid, blockHeight, vin, vout }, parsedFloData: { type, tokenAmount, tokenIdentification, transferType, contractName, triggerCondition, userChoice,nftHash } } = latestTxs.latestTransactions[transactionKey];
|
||||||
// determine txhash and blockHeight
|
// determine txhash and blockHeight
|
||||||
let obj = {
|
let obj = {
|
||||||
hash: txid,
|
hash: txid,
|
||||||
@ -1092,7 +1119,7 @@
|
|||||||
obj["token"] = tokenIdentification;
|
obj["token"] = tokenIdentification;
|
||||||
|
|
||||||
if (type == "transfer") {
|
if (type == "transfer") {
|
||||||
if (transferType == "token") {
|
if (transferType == "token" || transferType == "nft") {
|
||||||
// token transfer
|
// token transfer
|
||||||
/* tokenTransferCard
|
/* tokenTransferCard
|
||||||
hash, blockHeight, token, sender, receiver, amount */
|
hash, blockHeight, token, sender, receiver, amount */
|
||||||
@ -1154,6 +1181,16 @@
|
|||||||
type: "tokenincorp",
|
type: "tokenincorp",
|
||||||
});
|
});
|
||||||
latestTxArray.push(obj);
|
latestTxArray.push(obj);
|
||||||
|
} else if (type === "nftIncorporation") {
|
||||||
|
// token incorporation
|
||||||
|
// smart contract incorporation
|
||||||
|
obj = Object.assign({}, obj, {
|
||||||
|
incAddress: vin[0]["addr"],
|
||||||
|
supply: tokenAmount,
|
||||||
|
type,
|
||||||
|
nftHash,
|
||||||
|
});
|
||||||
|
latestTxArray.push(obj);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// smart contract committee trigger
|
// smart contract committee trigger
|
||||||
@ -1176,6 +1213,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return latestTxArray;
|
return latestTxArray;
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log(err)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1279,18 +1318,21 @@
|
|||||||
// Object
|
// Object
|
||||||
let latestTxArray = [];
|
let latestTxArray = [];
|
||||||
for (const transactionKey in txList) {
|
for (const transactionKey in txList) {
|
||||||
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 }, parsedFloData: { contractAddress, contractType, expiryTime, contractAmount, type, tokenAmount, tokenIdentification, transferType, contractName, triggerCondition, userChoice,nftHash } } = txList[transactionKey];
|
||||||
let obj = {
|
let obj = {
|
||||||
hash: txid,
|
hash: txid,
|
||||||
blockHeight,
|
blockHeight,
|
||||||
};
|
};
|
||||||
|
|
||||||
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 +1345,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 +1380,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,7 +1394,17 @@
|
|||||||
});
|
});
|
||||||
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 {
|
||||||
// transaction is a FLO Smart Contract Committee trigger
|
// transaction is a FLO Smart Contract Committee trigger
|
||||||
@ -1412,7 +1463,7 @@
|
|||||||
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 +1473,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 +1488,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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1537,7 +1589,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