2020-01-18 22:21:09 +00:00
|
|
|
const bluebird = require("bluebird")
|
2020-08-06 19:17:38 +00:00
|
|
|
import { writeFileSync, readDirSync } from "../script/common/filesystem";
|
2020-01-18 22:21:09 +00:00
|
|
|
import {
|
|
|
|
chainsFolderPath,
|
|
|
|
getChainInfoPath,
|
|
|
|
isChainInfoExistSync,
|
2020-08-06 19:17:38 +00:00
|
|
|
} from "./helpers"
|
|
|
|
import { CoinInfoList } from "./models";
|
2020-01-18 22:21:09 +00:00
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
const dafaultInfoTemplate: CoinInfoList =
|
2020-01-18 22:21:09 +00:00
|
|
|
{
|
|
|
|
"name": "",
|
|
|
|
"website": "",
|
|
|
|
"source_code": "",
|
|
|
|
"whitepaper": "",
|
2020-02-17 03:52:14 +00:00
|
|
|
"short_description": "",
|
2020-03-26 18:43:45 +00:00
|
|
|
"explorer": "",
|
2020-01-18 22:21:09 +00:00
|
|
|
"socials": [
|
|
|
|
{
|
|
|
|
"name": "Twitter",
|
2020-01-28 20:55:19 +00:00
|
|
|
"url": "",
|
|
|
|
"handle": ""
|
2020-01-18 22:21:09 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "Reddit",
|
2020-01-28 20:55:19 +00:00
|
|
|
"url": "",
|
|
|
|
"handle": ""
|
2020-01-18 22:21:09 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"details": [
|
|
|
|
{
|
|
|
|
"language": "en",
|
|
|
|
"description": ""
|
|
|
|
}
|
2020-03-22 03:12:51 +00:00
|
|
|
]
|
2020-01-18 22:21:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bluebird.mapSeries(readDirSync(chainsFolderPath), (chain: string) => {
|
|
|
|
const chainInfoPath = getChainInfoPath(chain)
|
|
|
|
|
2020-01-28 20:55:19 +00:00
|
|
|
// Create intial info.json file base off template if doesn't exist
|
|
|
|
if (!isChainInfoExistSync(chain)) {
|
|
|
|
writeToInfo(chainInfoPath, dafaultInfoTemplate)
|
2020-01-18 22:21:09 +00:00
|
|
|
}
|
|
|
|
|
2020-03-22 03:12:51 +00:00
|
|
|
// const infoList: InfoList = JSON.parse(readFileSync(chainInfoPath))
|
|
|
|
// delete infoList["data_source"]
|
|
|
|
// const newExplorer = nestedProperty.get(infoList, "explorers")
|
|
|
|
// console.log({newExplorer}, chain)
|
|
|
|
// nestedProperty.set(infoList, "explorer", newExplorer)
|
|
|
|
// delete infoList["explorers"]
|
|
|
|
// writeToInfo(chainInfoPath, infoList)
|
|
|
|
|
|
|
|
// if (isPathExistsSync(getChainAssetsPath(chain))) {
|
|
|
|
// readDirSync(getChainAssetsPath(chain)).forEach(asset => {
|
|
|
|
// const assetInfoPath = getChainAssetInfoPath(chain, asset)
|
|
|
|
// if (isPathExistsSync(assetInfoPath)) {
|
|
|
|
// const assetInfoList = JSON.parse(readFileSync(assetInfoPath))
|
|
|
|
// delete assetInfoList["data_source"]
|
|
|
|
|
|
|
|
// const newExplorers = nestedProperty.get(assetInfoList, "explorers.0.url")
|
|
|
|
// delete assetInfoList["explorers"]
|
|
|
|
// nestedProperty.set(assetInfoList, "explorer", newExplorers)
|
|
|
|
|
|
|
|
// writeToInfo(assetInfoPath, assetInfoList)
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// }
|
2020-01-28 20:55:19 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// Get handle from Twitter and Reddit url
|
|
|
|
export function getHandle(url: string): string {
|
|
|
|
if (!url) return ""
|
|
|
|
return url.slice(url.lastIndexOf("/") + 1, url.length)
|
|
|
|
}
|
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
function writeToInfo(path: string, info: CoinInfoList) {
|
2020-01-28 20:55:19 +00:00
|
|
|
writeFileSync(path, JSON.stringify(info, null, 4))
|
|
|
|
}
|