This commit is contained in:
sairaj mote 2023-12-13 03:24:47 +05:30
parent fa1a9a3229
commit 7744ce6dfa

View File

@ -661,9 +661,25 @@
],
"category": "blockchain-explorer",
"allowDownload": false,
"appHash": "012cd0b6bcb6de664cdecfb93bbdeb4bce53497bf549917dc717ef8b8d35858d",
"repoHash": "1d5cc442744f429fba5ad97ada001bfed2556d0ec7e1443b4ededb65f6ba5c61",
"repoLink": "https://github.com/ranchimall/blockbook"
}, {
"name": "ICO Exchange",
"description": "An exchange for ICO token trading",
"icon": html`<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"><g><path d="M0,0h24v24H0V0z" fill="none"/><path d="M20,2H4C2.9,2,2,2.9,2,4v16c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V4C22,2.9,21.1,2,20,2z M7,17H5v-2h2V17z M7,13H5v-2h2V13z M7,9H5 V7h2V9z M11,17H9v-2h2V17z M11,13H9v-2h2V13z M11,9H9V7h2V9z M15,17h-2v-2h2V17z M15,13h-2v-2h2V13z M15,9h-2V7h2V9z M19,17h-2v-2h2V17z M19,13h-2v-2h2V13z M19,9h-2V7h2V9z"/></g></svg>`,
"appLink": "https://ranchimall.net/exchange",
"moreLink": "#/dapps/ico-exchange",
"tags": [
"exchange",
"ICO",
"RMT",
"RanchiMall",
"tokens",
],
"category": "finance",
"allowDownload": false,
"repoHash": "bcd943193b9a76991e8d1ebd4bd88a30ece97f69efe80c37f3c5a733c76a2b6b",
"repoLink": "https://github.com/ranchimall/flo-exchange"
}
].sort((a, b) => a.name.localeCompare(b.name));
@ -753,7 +769,6 @@
renderElem(e.target.closest('.flex'), html`
<strong style="color: var(--danger-color)">Failed integrity check</strong>
`)
} else {
renderElem(getRef('integrity_check_popup__content'), html`
<div class="flex flex-direction-column gap-0-5">
<svg class="icon icon--big icon--danger" style="fill: var(--danger-color)" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>
@ -764,6 +779,7 @@
</p>
${hashes}
`)
} else {
renderElem(getRef('integrity_check_popup__content'), html`
<div class="flex flex-direction-column gap-0-5">
<svg class="icon icon--big icon--green" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M23,12l-2.44-2.79l0.34-3.69l-3.61-0.82L15.4,1.5L12,2.96L8.6,1.5L6.71,4.69L3.1,5.5L3.44,9.2L1,12l2.44,2.79l-0.34,3.7 l3.61,0.82L8.6,22.5l3.4-1.47l3.4,1.46l1.89-3.19l3.61-0.82l-0.34-3.69L23,12z M10.09,16.72l-3.8-3.81l1.48-1.48l2.32,2.33 l5.85-5.87l1.48,1.48L10.09,16.72z"/></g></svg>
@ -939,22 +955,31 @@
try {
linkToVerify = addProtocolToUrl(linkToVerify);
linkToVerify = parseUrlWithoutHashAndQuery(linkToVerify)
let knownHash, hasValidHash
let knownHash, latestHash, hasValidHash
const dappInfo = dappsList.find(({ appLink }) => linkToVerify.includes(appLink))
if (!dappInfo) return false
const { appHash, repoHash } = dappInfo
if (linkToVerify.includes('https://blockbook.ranchimall.net')) {
// blockbook is special case
// it is a server side rendered app
// so we need to check the hash of the repo
// and not the hash of the link content
latestHash = await getRepoHash('blockbook')
knownHash = dappInfo.repoHash
knownHash = repoHash
} else {
latestHash = await getLinkContentHash(linkToVerify)
latestHash = latestHash[linkToVerify]
knownHash = dappInfo.appHash
const [contentHash, latestRepoHash] = await Promise.all([
getLinkContentHash(linkToVerify),
getRepoHash(dappInfo.appLink.split('/').pop())
])
latestHash = contentHash[linkToVerify]
knownHash = appHash
hasValidHash = latestHash === knownHash && repoHash === latestRepoHash;
if (!hasValidHash && repoHash !== latestRepoHash) {
latestHash = latestRepoHash
knownHash = repoHash
}
}
return { hasValidHash: latestHash === knownHash, latestHash, knownHash }
return { hasValidHash, latestHash, knownHash }
} catch (e) {
console.error(e)
return false