From 506a37fed6c6ff59de5b47c374e2116a3eaa16bf Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Tue, 19 Dec 2023 16:43:58 +0530 Subject: [PATCH] shifting download all away from RM API to GH API --- index.html | 233 ++++++++++++++++++++--------------------------------- 1 file changed, 87 insertions(+), 146 deletions(-) diff --git a/index.html b/index.html index 7a3d456..c55bee8 100644 --- a/index.html +++ b/index.html @@ -390,6 +390,52 @@ `) }) let dappsList = [ + { + "name": "Blockbook", + "description": "A blockchain explorer for FLO", + "icon": html``, + "appLink": "https://blockbook.ranchimall.net/", + "moreLink": "#/dapps/blockbook", + "tags": [ + "blockbook", + "flo", + "blockchain" + ], + "category": "blockchain-explorer", + "allowDownload": false, + "repoHash": "1d5cc442744f429fba5ad97ada001bfed2556d0ec7e1443b4ededb65f6ba5c61", + "repoLink": "https://github.com/ranchimall/blockbook" + }, + { + "name": "Blockchain Bonds", + "description": "Monitor Bitcoin bonds performance", + "icon": html` `, + "appLink": "https://ranchimall.github.io/blockchainbonds", + "moreLink": "#/dapps/blockchain-bonds", + "tags": [ + "bitcoin", + "bonds", + "blockchain" + ], + "category": "finance", + "appHash": "5a8795102c2914a2bbf7c4755de288062e1fddfdfa9eef22a52b8f86f92e3fb3", + "repoHash": "807eeae3644cee213b324c56f0079ffdfeb128f5e69584ea3ff47df41f53db05" + }, + { + "name": "Bob's Fund", + "description": "A 20 year Bitcoin fund with 100% profit sharing", + "icon": html``, + "appLink": "https://ranchimall.github.io/bobsfund", + "moreLink": "#/dapps/bobs-fund", + "tags": [ + "fund", + "bobs", + "bitcoin" + ], + "category": "finance", + "appHash": "012c2ef05a0d2d0d551b068cad4aadc2a80c1019d741110f4f94da1bae742825", + "repoHash": "3ea01907b09693cf11fa190100d2522bc645077f407775c54853cc5db9867dfb" + }, { "name": "BTC Mortgage", "description": "Borrow or Lend USD against Bitcoin", @@ -403,7 +449,7 @@ "borrow" ], "category": "finance", - "repoHash": "197f0c491e8cabf866603d03c437f9b96ad5b58ce55de2f6bc0d39a633fdf5e1", + "repoHash": "996c8ff61eef8f9a9d1b6e290fd6ebe683044f64f09f86c76025298b74f82932", "appHash": "8a0cc53e479a1c7fb205b38d53a61b670f1b809c82ef1e5bcfddb39b5488d473" }, { @@ -417,7 +463,7 @@ "wallet" ], "category": "wallet", - "repoHash": "15908cd7e375d577132d22309a8d85f801dcb9c6b838ddc8ee2d6da590c6a0fc", + "repoHash": "28de47f70ab8e4e424baf127e195ece192735810a8acfa3345c265cb3f9b095c", "appHash": "37d7002211272d841b93803c69e79351758bc89c348167805b216ecfd85a5289" }, { @@ -432,7 +478,7 @@ "certification" ], "category": "identity", - "repoHash": "99f2b66dcd62b2156b4f64cd4eab8a4efc182284fe13cdb8e2a9876d865c0123", + "repoHash": "8dd4e065038eee5450ec537a377519940a5e43a9436dac9d24b1101d7be09d7a", "appHash": "563a97cc5be968d5ffc1511925766bc624df5ae3f71dca5ef48a5030ebe3b5ba" }, { @@ -447,7 +493,7 @@ "content" ], "category": "content", - "repoHash": "debdda5bd18f0f4d06876967de5f6dd55f514b9048ec978d435acdbe720a5ff8", + "repoHash": "faea71e27b0f39038e642358796ea5b53c83894aec1704e823400e30cd3932f9", "appHash": "78834ea328f5f3ed247c76cf92086f711dc7e56a14d2e4548d7ef36f358d3380" }, { @@ -463,7 +509,7 @@ "rupee" ], "category": "finance", - "repoHash": "a5dbba6043d82ae04e99a8a522f4ab2d1ba2a2779cdcf4f28c1da2b2acf11df6", + "repoHash": "a76df3ee4c7c1e3de7a278f5968a9fb4dc2da7b5b3f6483ec1768564d6673af0", "appHash": "1af17ee38d4b6c7c0ae4ca08fe526899c05fe56074ccac633183e400e039c9f2" }, { @@ -478,7 +524,7 @@ "flo" ], "category": "wallet", - "repoHash": "6e647729eb0f179045f764d08c44d61178bb84e36e327d026c34a701a9875132", + "repoHash": "faffb85ab277cce6ae9dd718056eebf66a79acb809315ad2430a8689b3f98637", "appHash": "2f55bd07e27cf2e869854b41883b733b9cd6eb6e4809f6a92e66d62d747a2f91" }, { @@ -493,7 +539,7 @@ "smart contracts" ], "category": "blockchain-explorer", - "repoHash": "cb84c51f35d03e224b4a76d1a27dd19a75f4ac9b785e059696c16206557cfee3", + "repoHash": "371ed1fc9e29a89a795f69c552ed78ebe1bd1f97fa9edb14552157e7b4122f05", "appHash": "0d81003141a2b586bd2272a64341e118b70746da35ef7d66662c282173c1752e" }, { @@ -507,7 +553,7 @@ "wallet" ], "category": "wallet", - "repoHash": "a6ba8112b57a033cc0124aa3f1761e27b2066226b6604d035e8596d2c662b6b6", + "repoHash": "f3a8bb4c3b8e2e7db8bd7af9bfa8043402ce38042f2068758080577225622e7b", "appHash": "b1ec2cca4c2e083dc9154608224d9b254fb9c4635743b59ccec6363828ca8a39" }, { @@ -522,9 +568,27 @@ "rupee" ], "category": "wallet", - "repoHash": "8cc4313d43468138f26cf13a776876fc21560714d8e5eb1217599af585105a8f", + "repoHash": "2080bcc32a390556eb51f3f405f29aca755b8b8d3871e7838f520e0ac82902a4", "appHash": "255b4d1c89974fdd59463d92e84cf8fee3d095be9f1e17f6ff8e1ee52bc24a58" }, + { + "name": "ICO Exchange", + "description": "An exchange for ICO token trading", + "icon": html``, + "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" + }, { "name": "KYC", "description": "An app to verify your identity", @@ -536,7 +600,7 @@ "identity" ], "category": "identity", - "repoHash": "247423654e501dab943296ab9a55e60bf4204164aee469f401cecf0b53290671", + "repoHash": "ff88183ab2cb23bb8cb952ea8c4b45e2aac9c20da51e2443eda076f1af762052", "appHash": "4d683316fdc512b375bfc529d5a9aa7eb291ade7460bdf080db6450dc3fb430e" }, { @@ -551,7 +615,7 @@ "logsheets" ], "category": "content", - "repoHash": "5c04711bbeaede85010e26d281a0a246a6f7f104e07a7bfcc5bc5208908647b6", + "repoHash": "c17313a043d157cf66c6196d12154355fef08e0287402a2f4d96acbb40aae9a4", "appHash": "1650c9888e9b418507d41af3ba76ee14753cfa0faa4f9753dff46fcd2a44047d" }, { @@ -569,7 +633,7 @@ "multisig" ], "category": "social", - "repoHash": "8713c516c826f10a5258a0962c87e3a26bd54f25d9034d7d2b7dbb7a33e4e914", + "repoHash": "e0d3b9335c587355bcb125d7a57fb934aebc4f8b87758bfc29221ea349448e3b", "appHash": "188174ab439516d25fe3ba30b18ca7fae07277f97c6df019331b8300d1f68c14" }, { @@ -584,7 +648,7 @@ "content" ], "category": "content", - "repoHash": "840823abe525a8be560d58e45af2499de6f45eaf973ce69a500b1df31ca295be", + "repoHash": "d1391ee455d51bd340a1d542353ed6fa15793e84c172c754fc15d8727cde8a20", "appHash": "d63d7fbd5ba8795977a30178ee426705ec41f58ce26a5fd0c6e281492a012766" }, { @@ -599,7 +663,7 @@ "ribc" ], "category": "management", - "repoHash": "9e0e44c5d50d7a0f28fb0f8ac4a168b5a1ec93a6e29e41503e1a6a579c567ed8", + "repoHash": "e26a9b73724b82f9d2bc3660299278fc062473b2ff813f5dba8753e5a40a650f", "appHash": "ad5145d8526868fe5358ce00d64fc98b1f3f2b02b5e2ee482ef7068a044055ef" }, { @@ -614,72 +678,9 @@ "taproot" ], "category": "wallet", - "repoHash": "592bdad38e1b45e41247f054de33b9d71c58d4178d70ca03c22f1def7c97e2c0", + "repoHash": "1ce9876835b9640b16962dcf31194338df3fceb26b76f2eb5594207f80e00ae7", "appHash": "ecad64071b9c4026e94d4e57e76ade152b63f2619d44025f6a7f4f9f31184bc2", - automatedChecking: true - }, - { - "name": "Blockchain Bonds", - "description": "Monitor Bitcoin bonds performance", - "icon": html` `, - "appLink": "https://ranchimall.github.io/blockchainbonds", - "moreLink": "#/dapps/blockchain-bonds", - "tags": [ - "bitcoin", - "bonds", - "blockchain" - ], - "category": "finance", - "appHash": "5a8795102c2914a2bbf7c4755de288062e1fddfdfa9eef22a52b8f86f92e3fb3", - "repoHash": "661ebe8b28bcf0a14ffe3a485e44dbc65cceab77d1de3bf8f6b2bccfdb1d57b5" - }, - { - "name": "Bob's Fund", - "description": "A 20 year Bitcoin fund with 100% profit sharing", - "icon": html``, - "appLink": "https://ranchimall.github.io/bobsfund", - "moreLink": "#/dapps/bobs-fund", - "tags": [ - "fund", - "bobs", - "bitcoin" - ], - "category": "finance", - "appHash": "012c2ef05a0d2d0d551b068cad4aadc2a80c1019d741110f4f94da1bae742825", - "repoHash": "b5b466e8b3e818ad8c95710edc9a770e4964b0ed74cb32366edec646a8f3372d" - }, - { - "name": "Blockbook", - "description": "A blockchain explorer for FLO", - "icon": html``, - "appLink": "https://blockbook.ranchimall.net/", - "moreLink": "#/dapps/blockbook", - "tags": [ - "blockbook", - "flo", - "blockchain" - ], - "category": "blockchain-explorer", - "allowDownload": false, - "repoHash": "1d5cc442744f429fba5ad97ada001bfed2556d0ec7e1443b4ededb65f6ba5c61", - "repoLink": "https://github.com/ranchimall/blockbook" - }, { - "name": "ICO Exchange", - "description": "An exchange for ICO token trading", - "icon": html``, - "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" + "automatedChecking": true } ].sort((a, b) => a.name.localeCompare(b.name)); @@ -855,9 +856,9 @@ - + ${['all', 'blockchain-explorer', 'content', 'finance', 'identity', 'management', 'social', 'wallet'].map((value, index) => html` @@ -898,48 +899,6 @@ ); }) } - async function downloadAllDapps() { - const downloadAllButton = getRef('download_all_button') - const downloadAllButtonContent = downloadAllButton.innerHTML - downloadAllButton.innerHTML = 'Downloading...' - pseudoDisable(downloadAllButton, true) - const verificationPromises = dappsList - .filter(({ allowDownload = true }) => allowDownload) // remove dapps that don't allow download - .map(({ appLink }) => { - return new Promise((resolve, reject) => { - const appRepoName = appLink.split('/').pop() - getRepoHash(appRepoName).then(latestHash => { - const { repoHash: knownHash } = dappsList.find(dapp => dapp.appLink === appLink) - if (latestHash !== knownHash) { - notify(`The dapp '${appRepoName}' has failed integrity check. Dapp won't be downloaded.`, 'error') - reject() - } else { - resolve(`https://github.com/ranchimall/${appRepoName}`) - } - }).catch(e => { - console.error(e) - notify('There was an error while trying to download the dapp. Please try again later.', 'error', { - timeout: 10000, - }) - reject() - }) - }) - }) - try { - let downloadLinks = await Promise.allSettled(verificationPromises) - downloadLinks = downloadLinks.filter(({ status }) => status === 'fulfilled').map(({ value }) => value) - await downloadReposZipped(downloadLinks) - notify('All verified dapps have been downloaded', 'success') - } catch (e) { - console.error(e) - notify('There was an error while trying to download the dapps. Please try again later.', 'error', { - timeout: 10000, - }) - } finally { - downloadAllButton.innerHTML = downloadAllButtonContent - pseudoDisable(downloadAllButton, false) - } - } function addProtocolToUrl(url) { if (!url.startsWith('http://') && !url.startsWith('https://')) { url = 'https://' + url; @@ -1229,7 +1188,8 @@ }) }) - async function getRepoHash(repoName = 'messenger') { + async function getRepoHash(repoName) { + if (!repoName) return null const response = await fetch(`https://api.github.com/repos/ranchimall/${repoName}/contents/`) const json = await response.json() const combinedSHA = json.reduce((acc, { sha }) => acc + sha, '') @@ -1249,6 +1209,9 @@ */ async function getLinkContentHash(link) { try { + if (!link) return null + if (!Array.isArray(link)) + link = [link] const data = JSON.stringify({ urls: link }) return await (await fetch('https://integrity-api.ranchimall.net/hash', { headers: { @@ -1262,28 +1225,6 @@ return null } } - - async function downloadReposZipped(repoUrls) { - try { - const data = JSON.stringify({ urls: repoUrls }) - const blob = await (await fetch('https://integrity-api.ranchimall.net/download-repos', { - headers: { - "Content-Type": "application/json", - }, - method: "POST", - body: data - })).blob() - // download as zip - const a = document.createElement('a') - a.href = URL.createObjectURL(blob) - a.download = 'dapps.zip' - a.click() - URL.revokeObjectURL(a.href) - } catch (e) { - console.error(e) - return null - } - }