mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Pr/1874 (#1879)
* 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:
parent
d9667855c8
commit
d6d2606101
3
.github/workflows/generator.yml
vendored
3
.github/workflows/generator.yml
vendored
|
@ -18,9 +18,10 @@ jobs:
|
||||||
npm run gen:list
|
npm run gen:list
|
||||||
git config --local user.email "trustbot@trustwallet.com"
|
git config --local user.email "trustbot@trustwallet.com"
|
||||||
git config --local user.name "Trust Wallet Actions Bot"
|
git config --local user.name "Trust Wallet Actions Bot"
|
||||||
|
git diff
|
||||||
git commit -m "Generate whitelist and blacklist" -a
|
git commit -m "Generate whitelist and blacklist" -a
|
||||||
- name: Push changes
|
- name: Push changes
|
||||||
uses: ad-m/github-push-action@master
|
uses: ad-m/github-push-action@master
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
|
github_token: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
|
||||||
branch: ${GITHUB_REF}
|
branch: ${GITHUB_REF##*/}
|
18
Dangerfile
18
Dangerfile
|
@ -2,20 +2,26 @@ require 'find'
|
||||||
require 'image_size'
|
require 'image_size'
|
||||||
require 'json-schema'
|
require 'json-schema'
|
||||||
|
|
||||||
assets_folder = './blockchains'
|
blockchains_folder = './blockchains'
|
||||||
allowed_extensions = ['png', 'json']
|
allowed_extensions = ['png', 'json']
|
||||||
allowed_file_names = ['info', 'list', 'logo', 'whitelist', 'blacklist']
|
allowed_file_names = ['info', 'list', 'logo', 'whitelist', 'blacklist']
|
||||||
|
|
||||||
|
maxAssetLogoSizeInKilobyte = 100
|
||||||
|
minLogoWidth = 64
|
||||||
|
minLogoHeight = 64
|
||||||
|
maxLogoWidth = 512
|
||||||
|
maxLogoHeight = 512
|
||||||
|
|
||||||
# Failures
|
# Failures
|
||||||
# Do not allow files in this directory
|
# Do not allow files in this directory
|
||||||
Dir.foreach(assets_folder) \
|
Dir.foreach(blockchains_folder) \
|
||||||
.map { |x| File.expand_path("#{assets_folder}/#{x}") } \
|
.map { |x| File.expand_path("#{blockchains_folder}/#{x}") } \
|
||||||
.select { |x| File.file?(x) }
|
.select { |x| File.file?(x) }
|
||||||
.map { |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)
|
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_extension = File.extname(file).delete('.')
|
||||||
file_name = File.basename(file, File.extname(file))
|
file_name = File.basename(file, File.extname(file))
|
||||||
|
|
||||||
|
@ -93,7 +99,7 @@ Find.find(assets_folder) do |file|
|
||||||
if file_extension == 'png'
|
if file_extension == 'png'
|
||||||
image_size = ImageSize.path(file)
|
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)
|
fail("Image width or height is higher than 512px for file: " + file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,7 +108,7 @@ Find.find(assets_folder) do |file|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make sure file size only 100kb
|
# 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)
|
fail("Image should less than 100kb for file: " + file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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 |
|
@ -218,28 +218,48 @@ export const isValidatorHasAllKeys = (val: ValidatorModel): boolean => {
|
||||||
&& typeof val.website === "string"
|
&& typeof val.website === "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isAssetInfoOK(chain: string, address: string): boolean {
|
export function isAssetInfoOK(chain: string, address: string): [boolean, string] {
|
||||||
if (isChainAssetInfoExistSync(chain, address)) {
|
if (!isChainAssetInfoExistSync(chain, address)) {
|
||||||
const assetInfoPath = getChainAssetInfoPath(chain, address)
|
return [true, `Info file doest exist, non eed to check`]
|
||||||
const isInfoOK = isValidJSON(assetInfoPath)
|
|
||||||
if (isInfoOK && isAssetInfoHasAllKeys(assetInfoPath)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
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 {
|
export function isAssetInfoHasAllKeys(path: string): [boolean, string] {
|
||||||
const info: AssetInfo = JSON.parse(readFileSync(path))
|
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 != ""
|
const isKeysCorrentType = typeof info.explorer === "string" && info.explorer != ""
|
||||||
&& typeof info.name === "string" && info.name != ""
|
&& typeof info.name === "string" && info.name != ""
|
||||||
&& typeof info.website === "string"
|
&& typeof info.website === "string"
|
||||||
&& typeof info.short_description === "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
|
export const getFileSizeInKilobyte = (path: string): number => fs.statSync(path).size / 1000
|
||||||
|
|
|
@ -113,9 +113,8 @@ describe(`Test "blockchains" folder`, () => {
|
||||||
const [isLogoOK, sizeMsg] = isLogoSizeOK(assetLogoPath)
|
const [isLogoOK, sizeMsg] = isLogoSizeOK(assetLogoPath)
|
||||||
expect(isLogoOK, sizeMsg).toBe(true)
|
expect(isLogoOK, sizeMsg).toBe(true)
|
||||||
|
|
||||||
if (isChainAssetInfoExistSync(chain, address)) {
|
const [isInfoOK, InfoMsg] = isAssetInfoOK(chain, address)
|
||||||
expect(isAssetInfoOK(chain, address), `Asset file info at path ${assetPath} is not OK`).toBe(true)
|
expect(isInfoOK, InfoMsg).toBe(true)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user