mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
08efad8571
* Add socials param if doesn't exist * Igonre text files * Update command * Contract upgrade procedure * Checksum ERC20 addresses [skip ci] * Optimised images with calibre/image-actions * Update list again Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
const bluebird = require("bluebird")
|
|
const nestedProperty = require("nested-property");
|
|
import {
|
|
chainsFolderPath,
|
|
getChainInfoPath,
|
|
isChainInfoExistSync,
|
|
writeFileSync,
|
|
readDirSync,
|
|
readFileSync
|
|
} from "../src/test/helpers"
|
|
import { InfoList } from "../src/test/models";
|
|
|
|
const dafaultInfoTemplate: InfoList =
|
|
{
|
|
"name": "",
|
|
"website": "",
|
|
"source_code": "",
|
|
"whitepaper": "",
|
|
"short_description": "",
|
|
"explorers": [
|
|
{
|
|
"name": "",
|
|
"url": ""
|
|
}
|
|
],
|
|
"socials": [
|
|
{
|
|
"name": "Twitter",
|
|
"url": "",
|
|
"handle": ""
|
|
},
|
|
{
|
|
"name": "Reddit",
|
|
"url": "",
|
|
"handle": ""
|
|
}
|
|
],
|
|
"details": [
|
|
{
|
|
"language": "en",
|
|
"description": ""
|
|
}
|
|
],
|
|
"data_source": "crowd"
|
|
}
|
|
|
|
bluebird.mapSeries(readDirSync(chainsFolderPath), (chain: string) => {
|
|
const chainInfoPath = getChainInfoPath(chain)
|
|
|
|
// Create intial info.json file base off template if doesn't exist
|
|
if (!isChainInfoExistSync(chain)) {
|
|
writeToInfo(chainInfoPath, dafaultInfoTemplate)
|
|
}
|
|
|
|
const infoList: InfoList = JSON.parse(readFileSync(chainInfoPath))
|
|
// Add "handle" property to each social element
|
|
let newSocials = []
|
|
if ("socials" in infoList) {
|
|
infoList.socials.forEach(social => {
|
|
const handle = "handle"
|
|
if (nestedProperty.hasOwn(social, handle)) {
|
|
nestedProperty.set(social, handle, getHandle(social.url))
|
|
newSocials.push(social)
|
|
}
|
|
})
|
|
}
|
|
nestedProperty.set(infoList, "socials", newSocials)
|
|
writeToInfo(chainInfoPath, infoList)
|
|
})
|
|
|
|
// Get handle from Twitter and Reddit url
|
|
export function getHandle(url: string): string {
|
|
if (!url) return ""
|
|
|
|
return url.slice(url.lastIndexOf("/") + 1, url.length)
|
|
}
|
|
|
|
function writeToInfo(path: string, info: InfoList) {
|
|
writeFileSync(path, JSON.stringify(info, null, 4))
|
|
} |