diff --git a/_data/iconsDownload/bafybeideqgs54hqx23deytbf4ljbjxgt7tyqkr5b6o5y2yglwjjjf6c4uq b/_data/iconsDownload/bafybeideqgs54hqx23deytbf4ljbjxgt7tyqkr5b6o5y2yglwjjjf6c4uq deleted file mode 100644 index 931b13fc..00000000 Binary files a/_data/iconsDownload/bafybeideqgs54hqx23deytbf4ljbjxgt7tyqkr5b6o5y2yglwjjjf6c4uq and /dev/null differ diff --git a/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt b/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt index a7cefa2e..82c83d9e 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/Main.kt @@ -4,15 +4,10 @@ import com.beust.klaxon.JsonArray import java.io.File import com.beust.klaxon.JsonObject import com.beust.klaxon.Klaxon -import com.squareup.moshi.Moshi -import io.ipfs.kotlin.IPFS -import io.ipfs.kotlin.IPFSConfiguration -import okhttp3.OkHttpClient import org.ethereum.lists.chains.model.* import org.kethereum.erc55.isValid import org.kethereum.model.Address import org.kethereum.rpc.HttpEthereumRPC -import java.time.Duration import kotlin.io.OnErrorAction.* val parsedShortNames = mutableSetOf() @@ -97,8 +92,13 @@ private fun doChecks(doRPCConnect: Boolean, doIconDownload: Boolean) { } val allIcons = iconsPath.listFiles() ?: return + val allIconCIDs = mutableSetOf() allIcons.forEach { - checkIcon(it, doIconDownload) + checkIcon(it, doIconDownload, allIconCIDs) + } + + iconsDownloadPath.listFiles().forEach { + if (!allIconCIDs.contains(it.name)) throw UnreferencedIcon(it.name, iconsDownloadPath) } allFiles.filter { it.isDirectory }.forEach { _ -> @@ -106,7 +106,7 @@ private fun doChecks(doRPCConnect: Boolean, doIconDownload: Boolean) { } } -fun checkIcon(icon: File, withIconDownload: Boolean) { +fun checkIcon(icon: File, withIconDownload: Boolean, allIconCIDs: MutableSet) { println("checking Icon " + icon.name) val obj: JsonArray<*> = Klaxon().parseJsonArray(icon.reader()) println("found variants " + obj.size) @@ -121,6 +121,8 @@ fun checkIcon(icon: File, withIconDownload: Boolean) { error("url must start with ipfs://") } + allIconCIDs.add(url.removePrefix("ipfs://")) + if (withIconDownload) { @@ -329,7 +331,7 @@ fun checkChain(chainFile: File, connectRPC: Boolean) { } } -fun String.normalizeName() = replace(" ","").uppercase() +fun String.normalizeName() = replace(" ", "").uppercase() /* moshi fails for extra commas @@ -359,6 +361,6 @@ private fun getNumber(jsonObject: JsonObject, field: String): Long { return when (val chainId = jsonObject[field]) { is Int -> chainId.toLong() is Long -> chainId - else -> throw(Exception("not a number at $field")) + else -> throw (Exception("not a number at $field")) } } \ No newline at end of file diff --git a/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt b/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt index 92633ccf..f8503500 100644 --- a/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt +++ b/processor/src/main/kotlin/org/ethereum/lists/chains/model/Exceptions.kt @@ -1,5 +1,7 @@ package org.ethereum.lists.chains.model +import java.io.File + class FileNameMustMatchChainId : Exception("chainId must match the filename") class ExtensionMustBeJSON : Exception("filename extension must be json") class ShouldHaveNoExtraFields(fields: Set) : Exception("should have no extra field $fields") @@ -33,4 +35,6 @@ class NativeCurrencySymbolMustBeString: Exception("Native currency symbol must b class NativeCurrencySymbolMustHaveLessThan7Chars: Exception("Native currency symbol must have less than 7 chars") class NativeCurrencyCanOnlyHaveSymbolNameAndDecimals: Exception("Native currency can only have symbol decimals and name") class NativeCurrencyDecimalMustBeInt: Exception("Native currency decimals must be int") -class NativeCurrencyNameMustBeString: Exception("Native currency name must be string") \ No newline at end of file +class NativeCurrencyNameMustBeString: Exception("Native currency name must be string") + +class UnreferencedIcon(fileName: String, iconsDownloadPath: File): Exception("Found file $fileName in $iconsDownloadPath that is not referenced") \ No newline at end of file