* LikeApp Update Logo and Info

popular global platform for creating and sharing original videos.

* move

* short_description

* Check info asset keys

* f

* Try access gituhb token

* Optimised images with calibre/image-actions

* Use corret size to match agains existing file

* Access branch name

Co-authored-by: likeappofc18 <63719781+likeappofc18@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
mykola.eth 2020-04-15 16:29:52 -07:00 committed by GitHub
parent d9667855c8
commit d6d2606101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 23 deletions

View File

@ -18,9 +18,10 @@ jobs:
npm run gen:list
git config --local user.email "trustbot@trustwallet.com"
git config --local user.name "Trust Wallet Actions Bot"
git diff
git commit -m "Generate whitelist and blacklist" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
branch: ${GITHUB_REF}
branch: ${GITHUB_REF##*/}

View File

@ -2,20 +2,26 @@ require 'find'
require 'image_size'
require 'json-schema'
assets_folder = './blockchains'
blockchains_folder = './blockchains'
allowed_extensions = ['png', 'json']
allowed_file_names = ['info', 'list', 'logo', 'whitelist', 'blacklist']
maxAssetLogoSizeInKilobyte = 100
minLogoWidth = 64
minLogoHeight = 64
maxLogoWidth = 512
maxLogoHeight = 512
# Failures
# Do not allow files in this directory
Dir.foreach(assets_folder) \
.map { |x| File.expand_path("#{assets_folder}/#{x}") } \
Dir.foreach(blockchains_folder) \
.map { |x| File.expand_path("#{blockchains_folder}/#{x}") } \
.select { |x| File.file?(x) }
.map { |x|
fail("Not allowed to have files inside blockchains folder itself. You have to add them inside specific blockchain folder as blockchain/ethereum or blockchain/binance for file: " + x)
}
Find.find(assets_folder) do |file|
Find.find(blockchains_folder) do |file|
file_extension = File.extname(file).delete('.')
file_name = File.basename(file, File.extname(file))
@ -93,7 +99,7 @@ Find.find(assets_folder) do |file|
if file_extension == 'png'
image_size = ImageSize.path(file)
if image_size.width > 512 || image_size.height > 512
if image_size.width > maxLogoWidth || image_size.height > maxLogoHeight
fail("Image width or height is higher than 512px for file: " + file)
end
@ -102,7 +108,7 @@ Find.find(assets_folder) do |file|
end
# Make sure file size only 100kb
if File.size(file).to_f / 1024 > 100
if File.size(file).to_f / 1024 > maxAssetLogoSizeInKilobyte
fail("Image should less than 100kb for file: " + file)
end
end

View File

@ -0,0 +1,14 @@
{
"name": "LikeApp",
"short_description": "popular global platform for creating and sharing original videos.",
"website": "",
"socials": [
{
"name": "Telegram",
"url": "https://t.me/likeapptoken",
"handle": "likeapptoken"
}
],
"explorer": "https://etherscan.io/token/0x92298Fa0647b5dcFf6eEaBAb97c9Bd81b5c30D06"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -218,28 +218,48 @@ export const isValidatorHasAllKeys = (val: ValidatorModel): boolean => {
&& typeof val.website === "string"
}
export function isAssetInfoOK(chain: string, address: string): boolean {
if (isChainAssetInfoExistSync(chain, address)) {
const assetInfoPath = getChainAssetInfoPath(chain, address)
const isInfoOK = isValidJSON(assetInfoPath)
if (isInfoOK && isAssetInfoHasAllKeys(assetInfoPath)) {
return true
}
return false
export function isAssetInfoOK(chain: string, address: string): [boolean, string] {
if (!isChainAssetInfoExistSync(chain, address)) {
return [true, `Info file doest exist, non eed to check`]
}
return true
const assetInfoPath = getChainAssetInfoPath(chain, address)
const isInfoJSONValid = isValidJSON(assetInfoPath)
if (!isInfoJSONValid) {
console.log(`JSON at path: ${assetInfoPath} is invalid`)
return [false, `JSON at path: ${assetInfoPath} is invalid`]
}
const [hasAllKeys, msg] = isAssetInfoHasAllKeys(assetInfoPath)
if (!hasAllKeys) {
console.log({msg})
return [false, msg]
}
return [true, ``]
}
export function isAssetInfoHasAllKeys(path: string): boolean {
const info: AssetInfo = JSON.parse(readFileSync(path))
export function isAssetInfoHasAllKeys(path: string): [boolean, string] {
const info = JSON.parse(readFileSync(path))
const infoKeys = Object.keys(info)
const requiredKeys = ["explorer", "name", "website", "short_description"] // Find better solution getting AssetInfo interface keys
const hasAllKeys = requiredKeys.every(k => info.hasOwnProperty(k))
if (!hasAllKeys) {
return [false, `Info at path ${path} missing next key(s): ${getArraysDiff(requiredKeys, infoKeys)}`]
}
const isKeysCorrentType = typeof info.explorer === "string" && info.explorer != ""
&& typeof info.name === "string" && info.name != ""
&& typeof info.website === "string"
&& typeof info.short_description === "string"
return isKeysCorrentType
return [isKeysCorrentType, `Check keys ${requiredKeys} vs ${infoKeys}`]
}
function getArraysDiff(arr1 :string[], arr2: string[]): string[] {
return arr1.filter(d => !arr2.includes(d))
}
export const getFileSizeInKilobyte = (path: string): number => fs.statSync(path).size / 1000

View File

@ -113,9 +113,8 @@ describe(`Test "blockchains" folder`, () => {
const [isLogoOK, sizeMsg] = isLogoSizeOK(assetLogoPath)
expect(isLogoOK, sizeMsg).toBe(true)
if (isChainAssetInfoExistSync(chain, address)) {
expect(isAssetInfoOK(chain, address), `Asset file info at path ${assetPath} is not OK`).toBe(true)
}
const [isInfoOK, InfoMsg] = isAssetInfoOK(chain, address)
expect(isInfoOK, InfoMsg).toBe(true)
})
})
})