File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
src/main/kotlin/org/ethereum/lists/chains/https Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ plugins {
2+ id(" maven-publish" )
3+ }
4+
5+ publishing {
6+ publications {
7+ create<MavenPublication >(" maven" ) {
8+ version = " 1.2"
9+
10+ from(components[" java" ])
11+ }
12+ }
13+ }
14+
15+ dependencies {
16+ implementation(project(" :model" ))
17+ implementation(" com.squareup.okhttp3:okhttp:4.9.3" )
18+ implementation(" com.squareup.moshi:moshi:1.14.0" )
19+ }
Original file line number Diff line number Diff line change 1+ package org.ethereum.lists.chains.https
2+
3+ import com.squareup.moshi.JsonAdapter
4+ import com.squareup.moshi.Moshi
5+ import com.squareup.moshi.Types
6+ import okhttp3.OkHttpClient
7+ import okhttp3.Request
8+ import org.ethereum.lists.chains.model.Chain
9+
10+ fun getChains (okhttpClient : OkHttpClient = OkHttpClient ()): List <Chain >? {
11+ val request = Request .Builder ()
12+ .url(" https://chainid.network/chains.json" )
13+ .build()
14+
15+ val listMyData = Types .newParameterizedType(MutableList ::class .java, Chain ::class .java)
16+ val adapter: JsonAdapter <List <Chain >> = Moshi .Builder ().build().adapter(listMyData)
17+
18+ val response = okhttpClient.newCall(request).execute()
19+ return response.body?.let { adapter.fromJson(it.source()) }
20+ }
Original file line number Diff line number Diff line change 11include(" :model" )
2+ include(" :httpsloader" )
23include(" :processor" )
You can’t perform that action at this time.
0 commit comments