Fixed receiver address bug in token transaction rendering

This commit is contained in:
Vivek Teega 2022-04-08 19:43:15 +05:30
parent 227c45c2c2
commit 75f0e7fde1

View File

@ -169,7 +169,6 @@
return page; return page;
}, },
blockPage(obj) { blockPage(obj) {
debugger;
let { let {
blockHeight, blockHeight,
size, size,
@ -795,7 +794,6 @@
case "block_page": case "block_page":
let [blockInfo, blockTransactions] = await Promise.all([getBlockInfo(field), getBlockTransactions(field)]) let [blockInfo, blockTransactions] = await Promise.all([getBlockInfo(field), getBlockTransactions(field)])
debugger
pageContainer.append(create.blockPage(blockInfo)); pageContainer.append(create.blockPage(blockInfo));
pageTitle.textContent = "block"; pageTitle.textContent = "block";
loading() loading()
@ -1143,10 +1141,9 @@
} }
} }
function getLatestTxs() { function getLatestTxs() {
return fetch( return fetch(`${tokenapiUrl}/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();
}) })
@ -1157,18 +1154,11 @@
for (let i = 0; i < txids.length; i++) { for (let i = 0; i < txids.length; i++) {
// determine txhash and blockHeight // determine txhash and blockHeight
let obj = { let obj = {
hash: latestTxs["latestTransactions"][txids[i]][ hash: latestTxs["latestTransactions"][txids[i]]["transactionDetails"]["txid"],
"transactionDetails" blockHeight: latestTxs["latestTransactions"][txids[i]]["transactionDetails"]["blockheight"],
]["txid"],
blockHeight: latestTxs["latestTransactions"][txids[i]][
"transactionDetails"
]["blockheight"],
}; };
let txtype = let txtype = latestTxs["latestTransactions"][txids[i]]["parsedFloData"]["type"];
latestTxs["latestTransactions"][txids[i]]["parsedFloData"][
"type"
];
if (txtype != "smartContractPays") { if (txtype != "smartContractPays") {
// determine token // determine token
@ -1188,28 +1178,16 @@
hash, blockHeight, token, sender, receiver, amount */ hash, blockHeight, token, sender, receiver, amount */
let receiveraddress = ""; let receiveraddress = "";
for ( for (let j = 0, voutlist = latestTxs["latestTransactions"][txids[i]]["transactionDetails"]["vout"]; j < voutlist.length; j++) {
let i = 0,
voutlist =
latestTxs["latestTransactions"][txids[i]][
"transactionDetails"
]["vout"]; i < voutlist.length; i++
) {
if ( if (
voutlist[i]["scriptPubKey"]["addresses"][0] != voutlist[j]["scriptPubKey"]["addresses"][0] != latestTxs["latestTransactions"][txids[i]]["transactionDetails"]["vin"][0]["addr"]
latestTxs["latestTransactions"][txids[i]][
"transactionDetails"
]["vin"][0]["addr"]
) { ) {
receiveraddress = receiveraddress = voutlist[j]["scriptPubKey"]["addresses"][0];
voutlist[i]["scriptPubKey"]["addresses"][0];
} }
} }
obj = Object.assign({}, obj, { obj = Object.assign({}, obj, {
sender: latestTxs["latestTransactions"][txids[i]][ sender: latestTxs["latestTransactions"][txids[i]]["transactionDetails"]["vin"][0]["addr"],
"transactionDetails"
]["vin"][0]["addr"],
receiver: receiveraddress, receiver: receiveraddress,
amount: `${latestTxs["latestTransactions"][txids[i]][ amount: `${latestTxs["latestTransactions"][txids[i]][
"parsedFloData" "parsedFloData"