mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Update test
This commit is contained in:
parent
5197e70a4f
commit
7223f355ea
|
@ -10,6 +10,7 @@ const isEthereumAddress = address => /^(0x)?[0-9a-f]{40}$/i.test(address) || /^(
|
||||||
const isFilePng = name => pngExp.test(name)
|
const isFilePng = name => pngExp.test(name)
|
||||||
const readDirSync = path => fs.readdirSync(path)
|
const readDirSync = path => fs.readdirSync(path)
|
||||||
const isLowerCase = str => str.toLowerCase() === str
|
const isLowerCase = str => str.toLowerCase() === str
|
||||||
|
const isPathExistsSync = path => fs.existsSync(path)
|
||||||
const blockchainsFolderPath = './blockchains'
|
const blockchainsFolderPath = './blockchains'
|
||||||
|
|
||||||
checkRootDir()
|
checkRootDir()
|
||||||
|
@ -70,11 +71,10 @@ function checkBlockhainsFolder(){
|
||||||
checkTron()
|
checkTron()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check staking supported chains
|
// Check POS chains
|
||||||
const stakingChains = ["cosmos"]
|
const posChains = ["cosmos", "tezos"]
|
||||||
if (stakingChains.indexOf(folder) !== -1) {
|
if (posChains.indexOf(folder) !== -1) {
|
||||||
const folderPath = `${blockchainsFolderPath}/${folder}`
|
checkValidatorFolder(folder)
|
||||||
checkValidatorsFolder(folderPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,11 +116,11 @@ async function checkBinance() {
|
||||||
|
|
||||||
function checkTron() {
|
function checkTron() {
|
||||||
const path = `./blockchains/tron/assets`
|
const path = `./blockchains/tron/assets`
|
||||||
const assets = readDirSync(path)
|
|
||||||
|
|
||||||
assets.forEach(asset => {
|
readDirSync(path).forEach(asset => {
|
||||||
if (!(/^\d+$/.test(asset))) {
|
if (isTRC10(asset)) {
|
||||||
exitWithMsg(`${asset} folder must contain only digits`)
|
} else {
|
||||||
|
isTRC20(asset)
|
||||||
}
|
}
|
||||||
|
|
||||||
const assetLogoPath = `${path}/${asset}/logo.png`
|
const assetLogoPath = `${path}/${asset}/logo.png`
|
||||||
|
@ -130,9 +130,25 @@ function checkTron() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkValidatorsFolder(networkPath) {
|
function isTRC10(id) {
|
||||||
const validatorsFolderPath = `${networkPath}/validators`
|
return (/^\d+$/.test(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check address to match TRC20 criteria
|
||||||
|
function isTRC20(address) {
|
||||||
|
if (!isLowerCase(address) ||
|
||||||
|
address.length !== 34
|
||||||
|
) {
|
||||||
|
exitWithMsg(`TRC20 ${address} fail to match criteria`)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkValidatorFolder(folder) {
|
||||||
|
const folderPath = `${blockchainsFolderPath}/${folder}`
|
||||||
|
const validatorsFolderPath = `${folderPath}/validators`
|
||||||
|
|
||||||
|
// Check validators folder existence
|
||||||
if (!isPathExistsSync(validatorsFolderPath)) {
|
if (!isPathExistsSync(validatorsFolderPath)) {
|
||||||
exitWithMsg(`Validators folder doesn't exists at path ${networkPath}`)
|
exitWithMsg(`Validators folder doesn't exists at path ${networkPath}`)
|
||||||
}
|
}
|
||||||
|
@ -143,7 +159,13 @@ function checkValidatorsFolder(networkPath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
readDirSync(validatorsAssetsFolderPath).forEach(address => {
|
readDirSync(validatorsAssetsFolderPath).forEach(address => {
|
||||||
|
switch (folder) {
|
||||||
|
case "cosmos":
|
||||||
testCosmosAddress(address)
|
testCosmosAddress(address)
|
||||||
|
case "tezos":
|
||||||
|
testTezosAddress(address)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
const validatoAssetLogo = `${validatorsAssetsFolderPath}/${address}/logo.png`
|
const validatoAssetLogo = `${validatorsAssetsFolderPath}/${address}/logo.png`
|
||||||
if (!isPathExistsSync(validatoAssetLogo)) {
|
if (!isPathExistsSync(validatoAssetLogo)) {
|
||||||
|
@ -175,12 +197,14 @@ function checkValidatorsFolder(networkPath) {
|
||||||
|
|
||||||
function testCosmosAddress(address) {
|
function testCosmosAddress(address) {
|
||||||
if (!isLowerCase(address)) {
|
if (!isLowerCase(address)) {
|
||||||
exitWithMsg(`${address} folder must be in lowercase`)
|
exitWithMsg(`Cosmos ${address} folder must be in lowercase`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPathExistsSync(path) {
|
function testTezosAddress(address) {
|
||||||
return fs.existsSync(path)
|
if (!isLowerCase(address)) {
|
||||||
|
exitWithMsg(`Tezos ${address} folder must be in lowercase`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBinanceTokenSymbols() {
|
async function getBinanceTokenSymbols() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user