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
|
- name: Checkout
|
||||||
uses: actions/checkout@v2.3.1
|
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
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
./gradlew run
|
./gradlew run
|
||||||
|
|
|
@ -29,12 +29,23 @@ private val allIconFiles = allIconFilesList.filter { !it.isDirectory }
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
|
||||||
|
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(
|
doChecks(
|
||||||
doRPCConnect = args.contains("rpcConnect"),
|
verbose = verbose,
|
||||||
doIconDownload = args.contains("iconDownload"),
|
doRPCConnect = argsList.firstOrNull() == "rpcConnect",
|
||||||
verbose = args.contains("verbose")
|
doIconDownload = argsList.firstOrNull() == "iconDownload",
|
||||||
)
|
)
|
||||||
createOutputFiles()
|
createOutputFiles()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createOutputFiles() {
|
private fun createOutputFiles() {
|
||||||
|
@ -131,7 +142,7 @@ private fun doChecks(doRPCConnect: Boolean, doIconDownload: Boolean, verbose: Bo
|
||||||
checkIcon(it, doIconDownload, allIconCIDs, verbose)
|
checkIcon(it, doIconDownload, allIconCIDs, verbose)
|
||||||
}
|
}
|
||||||
|
|
||||||
iconsDownloadPath.listFiles().forEach {
|
iconsDownloadPath.listFiles()?.forEach {
|
||||||
if (!allIconCIDs.contains(it.name)) throw UnreferencedIcon(it.name, iconsDownloadPath)
|
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<*>) {
|
if (jsonObject["rpc"] !is List<*>) {
|
||||||
throw (RPCMustBeList())
|
throw (RPCMustBeList())
|
||||||
} else {
|
} else {
|
||||||
(jsonObject["rpc"] as List<*>).forEach {
|
(jsonObject["rpc"] as List<*>).forEach { rpcURL ->
|
||||||
if (it !is String) {
|
if (rpcURL !is String) {
|
||||||
throw (RPCMustBeListOfStrings())
|
throw (RPCMustBeListOfStrings())
|
||||||
} else if (rpcPrefixes.none { prefix -> it.startsWith(prefix) }) {
|
} else if (rpcPrefixes.none { prefix -> rpcURL.startsWith(prefix) }) {
|
||||||
throw (InvalidRPCPrefix(it))
|
throw (InvalidRPCPrefix(rpcURL))
|
||||||
} else {
|
} else {
|
||||||
it.checkString("RPC URL")
|
rpcURL.checkString("RPC URL")
|
||||||
if (connectRPC) {
|
if (connectRPC) {
|
||||||
var chainId: BigInteger? = null
|
var chainId: BigInteger? = null
|
||||||
try {
|
try {
|
||||||
println("connecting to $it")
|
println("connecting to $rpcURL")
|
||||||
val ethereumRPC = HttpEthereumRPC(it)
|
val ethereumRPC = HttpEthereumRPC(rpcURL)
|
||||||
|
|
||||||
println("Client:" + ethereumRPC.clientVersion())
|
println("Client:" + ethereumRPC.clientVersion())
|
||||||
println("BlockNumber:" + ethereumRPC.blockNumber())
|
println("BlockNumber:" + ethereumRPC.blockNumber())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user