mirror of
https://github.com/Instadapp/chains.git
synced 2024-07-29 22:37:19 +00:00
Add RPC check for changed chains
This commit is contained in:
parent
a1d1cab997
commit
36997bcead
10
.github/workflows/build_and_deploy.yml
vendored
10
.github/workflows/build_and_deploy.yml
vendored
|
@ -7,6 +7,16 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.1
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v35
|
||||
|
||||
- name: Check changed files
|
||||
run: |
|
||||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||
./gradlew clean run --args="verbose singleChainCheck $file"
|
||||
done
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
./gradlew run
|
||||
|
|
|
@ -29,12 +29,23 @@ private val allIconFiles = allIconFilesList.filter { !it.isDirectory }
|
|||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
doChecks(
|
||||
doRPCConnect = args.contains("rpcConnect"),
|
||||
doIconDownload = args.contains("iconDownload"),
|
||||
verbose = args.contains("verbose")
|
||||
)
|
||||
createOutputFiles()
|
||||
val argsList = args.toMutableList()
|
||||
|
||||
val verbose = argsList.contains("verbose").also { argsList.remove("verbose") }
|
||||
if (argsList.firstOrNull() == "singleChainCheck") {
|
||||
val file = File(File(".."), args.last())
|
||||
if (file.exists() && file.parentFile == chainsPath ) {
|
||||
println("checking single chain " + args.last())
|
||||
checkChain(file, true, verbose)
|
||||
}
|
||||
} else {
|
||||
doChecks(
|
||||
verbose = verbose,
|
||||
doRPCConnect = argsList.firstOrNull() == "rpcConnect",
|
||||
doIconDownload = argsList.firstOrNull() == "iconDownload",
|
||||
)
|
||||
createOutputFiles()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createOutputFiles() {
|
||||
|
@ -131,7 +142,7 @@ private fun doChecks(doRPCConnect: Boolean, doIconDownload: Boolean, verbose: Bo
|
|||
checkIcon(it, doIconDownload, allIconCIDs, verbose)
|
||||
}
|
||||
|
||||
iconsDownloadPath.listFiles().forEach {
|
||||
iconsDownloadPath.listFiles()?.forEach {
|
||||
if (!allIconCIDs.contains(it.name)) throw UnreferencedIcon(it.name, iconsDownloadPath)
|
||||
}
|
||||
|
||||
|
@ -425,18 +436,18 @@ fun checkChain(chainFile: File, connectRPC: Boolean, verbose: Boolean = false) {
|
|||
if (jsonObject["rpc"] !is List<*>) {
|
||||
throw (RPCMustBeList())
|
||||
} else {
|
||||
(jsonObject["rpc"] as List<*>).forEach {
|
||||
if (it !is String) {
|
||||
(jsonObject["rpc"] as List<*>).forEach { rpcURL ->
|
||||
if (rpcURL !is String) {
|
||||
throw (RPCMustBeListOfStrings())
|
||||
} else if (rpcPrefixes.none { prefix -> it.startsWith(prefix) }) {
|
||||
throw (InvalidRPCPrefix(it))
|
||||
} else if (rpcPrefixes.none { prefix -> rpcURL.startsWith(prefix) }) {
|
||||
throw (InvalidRPCPrefix(rpcURL))
|
||||
} else {
|
||||
it.checkString("RPC URL")
|
||||
rpcURL.checkString("RPC URL")
|
||||
if (connectRPC) {
|
||||
var chainId: BigInteger? = null
|
||||
try {
|
||||
println("connecting to $it")
|
||||
val ethereumRPC = HttpEthereumRPC(it)
|
||||
println("connecting to $rpcURL")
|
||||
val ethereumRPC = HttpEthereumRPC(rpcURL)
|
||||
|
||||
println("Client:" + ethereumRPC.clientVersion())
|
||||
println("BlockNumber:" + ethereumRPC.blockNumber())
|
||||
|
|
Loading…
Reference in New Issue
Block a user