Check icon sizes in iconDownload

This commit is contained in:
ligi 2022-11-16 19:07:19 +01:00
parent bb436ce9bf
commit 01480709e9
19 changed files with 52 additions and 99 deletions

View File

@ -1,7 +1,6 @@
{ {
"name": "Palm Testnet", "name": "Palm Testnet",
"chain": "Palm", "chain": "Palm",
"icon": "palm",
"rpc": ["https://palm-testnet.infura.io/v3/${INFURA_API_KEY}"], "rpc": ["https://palm-testnet.infura.io/v3/${INFURA_API_KEY}"],
"faucets": [], "faucets": [],
"nativeCurrency": { "nativeCurrency": {
@ -17,8 +16,7 @@
{ {
"name": "Palm Testnet Explorer", "name": "Palm Testnet Explorer",
"url": "https://explorer.palm-uat.xyz", "url": "https://explorer.palm-uat.xyz",
"standard": "EIP3091", "standard": "EIP3091"
"icon": "palm"
} }
] ]
} }

View File

@ -1,7 +1,6 @@
{ {
"name": "Palm", "name": "Palm",
"chain": "Palm", "chain": "Palm",
"icon": "palm",
"rpc": ["https://palm-mainnet.infura.io/v3/${INFURA_API_KEY}"], "rpc": ["https://palm-mainnet.infura.io/v3/${INFURA_API_KEY}"],
"faucets": [], "faucets": [],
"nativeCurrency": { "nativeCurrency": {
@ -17,8 +16,7 @@
{ {
"name": "Palm Explorer", "name": "Palm Explorer",
"url": "https://explorer.palm.io", "url": "https://explorer.palm.io",
"standard": "EIP3091", "standard": "EIP3091"
"icon": "palm"
} }
] ]
} }

View File

@ -12,12 +12,10 @@
"shortName": "psc-s0", "shortName": "psc-s0",
"chainId": 900000, "chainId": 900000,
"networkId": 900000, "networkId": 900000,
"icon": "posichain",
"explorers": [ "explorers": [
{ {
"name": "Posichain Explorer", "name": "Posichain Explorer",
"url": "https://explorer.posichain.org", "url": "https://explorer.posichain.org",
"icon": "posichain",
"standard": "EIP3091" "standard": "EIP3091"
} }
] ]

View File

@ -12,12 +12,10 @@
"shortName": "psc-t-s0", "shortName": "psc-t-s0",
"chainId": 910000, "chainId": 910000,
"networkId": 910000, "networkId": 910000,
"icon": "posichain",
"explorers": [ "explorers": [
{ {
"name": "Posichain Explorer Testnet", "name": "Posichain Explorer Testnet",
"url": "https://explorer-testnet.posichain.org", "url": "https://explorer-testnet.posichain.org",
"icon": "posichain",
"standard": "EIP3091" "standard": "EIP3091"
} }
] ]

View File

@ -12,12 +12,10 @@
"shortName": "psc-d-s0", "shortName": "psc-d-s0",
"chainId": 920000, "chainId": 920000,
"networkId": 920000, "networkId": 920000,
"icon": "posichain",
"explorers": [ "explorers": [
{ {
"name": "Posichain Explorer Devnet", "name": "Posichain Explorer Devnet",
"url": "https://explorer-devnet.posichain.org", "url": "https://explorer-devnet.posichain.org",
"icon": "posichain",
"standard": "EIP3091" "standard": "EIP3091"
} }
] ]

View File

@ -12,12 +12,10 @@
"shortName": "psc-d-s1", "shortName": "psc-d-s1",
"chainId": 920001, "chainId": 920001,
"networkId": 920001, "networkId": 920001,
"icon": "posichain",
"explorers": [ "explorers": [
{ {
"name": "Posichain Explorer Devnet", "name": "Posichain Explorer Devnet",
"url": "https://explorer-devnet.posichain.org", "url": "https://explorer-devnet.posichain.org",
"icon": "posichain",
"standard": "EIP3091" "standard": "EIP3091"
} }
] ]

View File

@ -2,7 +2,7 @@
{ {
"url": "ipfs://QmS8zEetTb6pwdNpVjv5bz55BXiSMGP9BjTJmNcjcUT91t", "url": "ipfs://QmS8zEetTb6pwdNpVjv5bz55BXiSMGP9BjTJmNcjcUT91t",
"format": "svg", "format": "svg",
"width": 412, "width": 408,
"height": 412 "height": 408
} }
] ]

View File

@ -1,8 +1,8 @@
[ [
{ {
"url": "ipfs://QmV8UmSwqGF2fxrqVEBTHbkyZueahqyYtkfH2RBF5pNysM", "url": "ipfs://QmV8UmSwqGF2fxrqVEBTHbkyZueahqyYtkfH2RBF5pNysM",
"width": 524, "width": 519,
"height": 524, "height": 519,
"format": "svg" "format": "svg"
} }
] ]

View File

@ -1,8 +1,8 @@
[ [
{ {
"url": "ipfs://bafkreie4uhrsk3vxxnpjm7tidupfxgib5ahnwqopf6elykdatshuo6yb4m", "url": "ipfs://bafkreie4uhrsk3vxxnpjm7tidupfxgib5ahnwqopf6elykdatshuo6yb4m",
"width": 781, "width": 773,
"height": 781, "height": 773,
"format": "svg" "format": "svg"
} }
] ]

View File

@ -1,6 +1,8 @@
[ [
{ {
"url": "ipfs://QmdpRTk6oL1HRW9xC6cAc4Rnf9gs6zgdAcr4Z3HcLztusm", "url": "ipfs://QmdpRTk6oL1HRW9xC6cAc4Rnf9gs6zgdAcr4Z3HcLztusm",
"width": 1186,
"height": 360,
"format": "svg" "format": "svg"
} }
] ]

View File

@ -1,8 +1,8 @@
[ [
{ {
"url": "ipfs://QmNzwHAmaaQyuvKudrzGkrTT2GMshcmCmJ9FH8gG2mNJtM", "url": "ipfs://QmNzwHAmaaQyuvKudrzGkrTT2GMshcmCmJ9FH8gG2mNJtM",
"width": 300, "width": 401,
"height": 300, "height": 401,
"format": "svg" "format": "svg"
} }
] ]

View File

@ -1,8 +0,0 @@
[
{
"url": "ipfs://QmX6h8xm4em77oNpFRtmAqrZ734MH4VGCC68dEKHUfdfPs",
"width": 1080,
"height": 1080,
"format": "svg"
}
]

View File

@ -1,8 +0,0 @@
[
{
"url": "ipfs://QmXqprM1TPafQFLirQ7dMPMgou1hoUGuCvHYSWU9g8ocv8",
"width": 24,
"height": 24,
"format": "svg"
}
]

View File

@ -1,8 +1,8 @@
[ [
{ {
"url": "ipfs://QmdfbjjF3ZzN2jTkH9REgrA8jDS6A6c21n7rbWSVbSnvQc", "url": "ipfs://QmdfbjjF3ZzN2jTkH9REgrA8jDS6A6c21n7rbWSVbSnvQc",
"width": 313, "width": 310,
"height": 253, "height": 251,
"format": "svg" "format": "svg"
} }
] ]

View File

@ -1,8 +1,8 @@
[ [
{ {
"url": "ipfs://QmQyTyJUnhD1dca35Vyj96pm3v3Xyw8xbG9m8HXHw3k2zR", "url": "ipfs://QmQyTyJUnhD1dca35Vyj96pm3v3Xyw8xbG9m8HXHw3k2zR",
"width": 584, "width": 578,
"height": 707, "height": 701,
"format": "svg" "format": "svg"
} }
] ]

View File

@ -1,8 +1,8 @@
[ [
{ {
"url": "ipfs://QmNoyUXxnak8B3xgFxErkVfyVEPJUMHBzq7qJcYzkUrPR4", "url": "ipfs://QmNoyUXxnak8B3xgFxErkVfyVEPJUMHBzq7qJcYzkUrPR4",
"width": 500, "width": 1920,
"height": 500, "height": 1920,
"format": "png" "format": "png"
} }
] ]

View File

@ -1,50 +0,0 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z" fill="#050505"/>
<path d="M19.0781 10.4621C19.0781 13.059 16.9734 15.1684 14.3719 15.1684C13.7203 15.1684 13.1953 14.6434 13.1953 13.9918C13.1953 13.3402 13.7203 12.8152 14.3719 12.8152C15.6703 12.8152 16.725 11.7605 16.725 10.4621C16.725 9.16367 15.675 8.10899 14.3719 8.10899C13.7203 8.10899 13.1953 7.58398 13.1953 6.93242C13.1953 6.29492 13.7062 5.77461 14.3391 5.75586C14.3484 5.75586 14.3578 5.75586 14.3672 5.75586C14.3766 5.75586 14.3859 5.75586 14.3953 5.75586C16.9875 5.77461 19.0781 7.87461 19.0781 10.4621Z" fill="url(#paint0_linear_19833_112540)"/>
<path d="M15.5484 6.93242C15.5484 7.58398 15.0234 8.10898 14.3719 8.10898C13.7203 8.10898 13.1953 7.58398 13.1953 6.93242C13.1953 6.29492 13.7062 5.77461 14.3391 5.75586C14.3484 5.75586 14.3578 5.75586 14.3672 5.75586C14.3766 5.75586 14.3859 5.75586 14.3953 5.75586C15.0375 5.77461 15.5484 6.29492 15.5484 6.93242Z" fill="url(#paint1_linear_19833_112540)"/>
<path d="M14.3719 15.1686C15.0217 15.1686 15.5484 14.6418 15.5484 13.992C15.5484 13.3422 15.0217 12.8154 14.3719 12.8154C13.7221 12.8154 13.1953 13.3422 13.1953 13.992C13.1953 14.6418 13.7221 15.1686 14.3719 15.1686Z" fill="url(#paint2_linear_19833_112540)"/>
<path d="M14.3781 12.8154H9.67188V15.1686H14.3781V12.8154Z" fill="url(#paint3_linear_19833_112540)"/>
<path d="M10.8484 19.0867C10.2016 19.0867 9.67188 18.557 9.67188 17.9102V10.4617C9.67188 9.81484 10.2016 9.28516 10.8484 9.28516C11.4953 9.28516 12.025 9.81484 12.025 10.4617V17.9102C12.025 18.557 11.4953 19.0867 10.8484 19.0867Z" fill="url(#paint4_linear_19833_112540)"/>
<path d="M14.3719 9.28516C13.725 9.28516 13.1953 9.81484 13.1953 10.4617C13.1953 11.1086 13.725 11.6383 14.3719 11.6383C15.0188 11.6383 15.5484 11.1086 15.5484 10.4617C15.5484 9.81484 15.0188 9.28516 14.3719 9.28516Z" fill="url(#paint5_linear_19833_112540)"/>
<path d="M14.368 11.6383H8.88359C8.23203 11.6383 7.70703 11.1133 7.70703 10.4617C7.70703 9.81016 8.23203 9.28516 8.88359 9.28516H14.368C15.0195 9.28516 15.5445 9.81016 15.5445 10.4617C15.5445 11.1086 15.0195 11.6383 14.368 11.6383Z" fill="url(#paint6_linear_19833_112540)"/>
<path d="M14.3719 5.75586C13.725 5.75586 13.1953 6.28555 13.1953 6.93242C13.1953 7.5793 13.725 8.10898 14.3719 8.10898C15.0188 8.10898 15.5484 7.5793 15.5484 6.93242C15.5484 6.28555 15.0188 5.75586 14.3719 5.75586Z" fill="url(#paint7_linear_19833_112540)"/>
<path d="M14.1703 8.10898H7.31719C6.66563 8.10898 6.14062 7.58398 6.14062 6.93242C6.14062 6.28086 6.66563 5.75586 7.31719 5.75586H14.1703C14.8219 5.75586 15.3469 6.28086 15.3469 6.93242C15.3469 7.58398 14.8219 8.10898 14.1703 8.10898Z" fill="url(#paint8_linear_19833_112540)"/>
<defs>
<linearGradient id="paint0_linear_19833_112540" x1="19.4326" y1="6.16948" x2="7.35754" y2="18.1295" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint1_linear_19833_112540" x1="17.309" y1="4.02547" x2="5.23396" y2="15.9855" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint2_linear_19833_112540" x1="20.8372" y1="7.58781" x2="8.76218" y2="19.5478" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint3_linear_19833_112540" x1="19.6739" y1="6.41173" x2="7.59886" y2="18.3717" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint4_linear_19833_112540" x1="19.1894" y1="5.92206" x2="7.11441" y2="17.882" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint5_linear_19833_112540" x1="19.0731" y1="5.80614" x2="6.99806" y2="17.7661" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint6_linear_19833_112540" x1="17.7136" y1="4.43284" x2="5.63862" y2="16.3928" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint7_linear_19833_112540" x1="17.3089" y1="4.02545" x2="5.23394" y2="15.9854" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
<linearGradient id="paint8_linear_19833_112540" x1="15.5114" y1="2.21063" x2="3.4364" y2="14.1706" gradientUnits="userSpaceOnUse">
<stop stop-color="#00A8A1"/>
<stop offset="1" stop-color="#41FF7A"/>
</linearGradient>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -14,6 +14,10 @@ dependencies {
implementation 'com.squareup.moshi:moshi:1.14.0' implementation 'com.squareup.moshi:moshi:1.14.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0' implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation "com.twelvemonkeys.imageio:imageio-jpeg:3.9.3"
implementation "com.twelvemonkeys.imageio:imageio-batik:3.9.3"
implementation "org.apache.xmlgraphics:batik-rasterizer-ext:1.16"
implementation project(":model") implementation project(":model")
testImplementation "org.jetbrains.kotlin:kotlin-test:${KOTLIN_VERSION}" testImplementation "org.jetbrains.kotlin:kotlin-test:${KOTLIN_VERSION}"

View File

@ -8,6 +8,7 @@ import org.ethereum.lists.chains.model.*
import org.kethereum.erc55.isValid import org.kethereum.erc55.isValid
import org.kethereum.model.Address import org.kethereum.model.Address
import org.kethereum.rpc.HttpEthereumRPC import org.kethereum.rpc.HttpEthereumRPC
import javax.imageio.ImageIO
import kotlin.io.OnErrorAction.* import kotlin.io.OnErrorAction.*
val parsedShortNames = mutableSetOf<String>() val parsedShortNames = mutableSetOf<String>()
@ -152,10 +153,11 @@ fun checkIcon(icon: File, withIconDownload: Boolean, allIconCIDs: MutableSet<Str
allIconCIDs.add(url.removePrefix("ipfs://")) allIconCIDs.add(url.removePrefix("ipfs://"))
if (withIconDownload) { val iconCID = url.removePrefix("ipfs://")
val iconDownloadFile = File(iconsDownloadPath, iconCID)
if (!iconDownloadFile.exists() && withIconDownload) {
val iconCID = url.removePrefix("ipfs://")
try { try {
println("fetching Icon from IPFS $iconCID") println("fetching Icon from IPFS $iconCID")
@ -163,14 +165,15 @@ fun checkIcon(icon: File, withIconDownload: Boolean, allIconCIDs: MutableSet<Str
val iconBytes = ipfs.get.catBytes(iconCID) val iconBytes = ipfs.get.catBytes(iconCID)
println("Icon size" + iconBytes.size) println("Icon size" + iconBytes.size)
val outFile = File(iconsDownloadPath, iconCID)
outFile.createNewFile() iconDownloadFile.createNewFile()
outFile.writeBytes(iconBytes) iconDownloadFile.writeBytes(iconBytes)
} catch (e: Exception) { } catch (e: Exception) {
println("could not fetch icon from IPFS") println("could not fetch icon from IPFS")
} }
} }
val width = it["width"] val width = it["width"]
val height = it["height"] val height = it["height"]
if (width != null || height != null) { if (width != null || height != null) {
@ -190,6 +193,28 @@ fun checkIcon(icon: File, withIconDownload: Boolean, allIconCIDs: MutableSet<Str
if (format !is String || (format != "png" && format != "svg")) { if (format !is String || (format != "png" && format != "svg")) {
error("Icon format must be a png or svg but was $format") error("Icon format must be a png or svg but was $format")
} }
if (iconDownloadFile.exists()) {
try {
val imageInputStream = ImageIO.createImageInputStream(iconDownloadFile)
val imageReader = ImageIO.getImageReaders(imageInputStream).next()
val image = ImageIO.read(imageInputStream)
if (imageReader.formatName != format) {
error("format in json ($icon) is $format but actually is in imageDownload ${imageReader.formatName}")
}
if (image.width != width) {
error("width in json ($icon) is $width but actually is in imageDownload ${image.width}")
}
if (image.raster.height != height) {
error("width in json ($icon) is $height but actually is in imageDownload ${image.height}")
}
} catch (e: Exception) {
e.printStackTrace()
error("problem with image $iconDownloadFile")
}
}
} }
} }