Skip to content

Commit 1668edf

Browse files
authored
[ETCM-110] Add eth_chainId RPC method (#683)
1 parent c894610 commit 1668edf

File tree

10 files changed

+727
-462
lines changed

10 files changed

+727
-462
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project/plugins/project/
55
.ensime
66
.ensime_cache/
77
.bloop
8+
out/
89

910
# IDE folders
1011
.idea/
@@ -20,4 +21,4 @@ metals.sbt
2021
.evm-runner_history
2122

2223
# Nix
23-
result
24+
result

insomnia_workspace.json

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"_type": "export",
33
"__export_format": 4,
4-
"__export_date": "2020-09-16T09:48:00.794Z",
4+
"__export_date": "2020-09-21T12:39:47.334Z",
55
"__export_source": "insomnia.desktop.app:v2020.3.3",
66
"resources": [
77
{
@@ -198,6 +198,50 @@
198198
"parentId": "wrk_097d43914a4d4aea8b6f73f647921182",
199199
"_type": "request_group"
200200
},
201+
{
202+
"_id": "req_0ff71c4f648c4d3782612e9c53179321",
203+
"authentication": {},
204+
"body": {
205+
"mimeType": "application/json",
206+
"text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"eth_chainId\", \n\t\"params\": [],\n \"id\": 1\n}"
207+
},
208+
"created": 1600691926224,
209+
"description": "",
210+
"headers": [
211+
{
212+
"id": "pair_c33a6ada19dd4aa8b75527639519f427",
213+
"name": "Content-Type",
214+
"value": "application/json"
215+
}
216+
],
217+
"isPrivate": false,
218+
"metaSortKey": -1600691926224,
219+
"method": "POST",
220+
"modified": 1600691932451,
221+
"name": "eth_chainId",
222+
"parameters": [],
223+
"parentId": "fld_a06eb77e183c4727800eb7dc43ceabe1",
224+
"settingDisableRenderRequestBody": false,
225+
"settingEncodeUrl": true,
226+
"settingFollowRedirects": "global",
227+
"settingRebuildPath": true,
228+
"settingSendCookies": true,
229+
"settingStoreCookies": true,
230+
"url": "{{node_url}}",
231+
"_type": "request"
232+
},
233+
{
234+
"_id": "fld_a06eb77e183c4727800eb7dc43ceabe1",
235+
"created": 1552939140291,
236+
"description": "",
237+
"environment": {},
238+
"environmentPropertyOrder": null,
239+
"metaSortKey": -1552939140292,
240+
"modified": 1599825661277,
241+
"name": "Eth",
242+
"parentId": "wrk_097d43914a4d4aea8b6f73f647921182",
243+
"_type": "request_group"
244+
},
201245
{
202246
"_id": "req_b60c1a4f9d604d868910f967c6a070d7",
203247
"authentication": {},
@@ -235,18 +279,6 @@
235279
"url": "{{ node_url }}",
236280
"_type": "request"
237281
},
238-
{
239-
"_id": "fld_a06eb77e183c4727800eb7dc43ceabe1",
240-
"created": 1552939140291,
241-
"description": "",
242-
"environment": {},
243-
"environmentPropertyOrder": null,
244-
"metaSortKey": -1552939140292,
245-
"modified": 1599825661277,
246-
"name": "Eth",
247-
"parentId": "wrk_097d43914a4d4aea8b6f73f647921182",
248-
"_type": "request_group"
249-
},
250282
{
251283
"_id": "req_97fa82439e3e46bfb8ee26400af6215d",
252284
"authentication": {},
@@ -797,4 +829,4 @@
797829
"_type": "environment"
798830
}
799831
]
800-
}
832+
}

src/main/scala/io/iohk/ethereum/jsonrpc/DebugJsonMethodsImplicits.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package io.iohk.ethereum.jsonrpc
22

3-
import io.iohk.ethereum.jsonrpc.DebugService.{ ListPeersInfoRequest, ListPeersInfoResponse }
4-
import org.json4s.JsonAST.{ JArray, JString, JValue }
3+
import io.iohk.ethereum.jsonrpc.DebugService.{ListPeersInfoRequest, ListPeersInfoResponse}
4+
import io.iohk.ethereum.jsonrpc.JsonRpcController.{Codec, JsonEncoder}
5+
import io.iohk.ethereum.jsonrpc.JsonRpcController.JsonDecoder.NoParamsDecoder
6+
import org.json4s.JsonAST.{JArray, JString, JValue}
57

68
object DebugJsonMethodsImplicits extends JsonMethodsImplicits {
79

810
implicit val debug_listPeersInfo: Codec[ListPeersInfoRequest, ListPeersInfoResponse] =
9-
new Codec[ListPeersInfoRequest, ListPeersInfoResponse] {
10-
def decodeJson(params: Option[JArray]): Either[JsonRpcError, ListPeersInfoRequest] =
11-
Right(ListPeersInfoRequest())
12-
11+
new NoParamsDecoder(ListPeersInfoRequest()) with JsonEncoder[ListPeersInfoResponse] {
1312
def encodeJson(t: ListPeersInfoResponse): JValue =
1413
JArray(t.peers.map(a => JString(a.toString)))
1514
}

0 commit comments

Comments
 (0)