-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ETCM-110] Add eth_chainId RPC method #683
Conversation
da5d362
to
749f5fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments only. LGTM!
implicit val eth_chainId = new JsonDecoder[ChainIdRequest] with JsonEncoder[ChainIdResponse] { | ||
def decodeJson(params: Option[JArray]) = params match { | ||
case None | Some(JArray(Nil)) => Right(ChainIdRequest()) | ||
case other => Left(InvalidParams("eth_chainId method does not take params")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that other parameterless methods don't check if params
is empty. Maybe we could improve that in this PR. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If only @pslaski agrees (this will result in quite huge PR due to formatting)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR is already huge so go for it ;)
1d59a1f
to
d7fa62c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor: I'm not sure if there are tests in JRC specs for the non-params case
@@ -23,11 +25,32 @@ object JsonRpcController { | |||
trait JsonDecoder[T] { | |||
def decodeJson(params: Option[JArray]): Either[JsonRpcError, T] | |||
} | |||
object JsonDecoder { | |||
abstract class NoParamsDecoder[T](request: => T) extends JsonDecoder[T] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
d7fa62c
to
8f34a23
Compare
@pslaski From what I've checked there usually are such tests for happy path and I think it's enough since the behavior is uniform now across whole RPC API |
Description
According to Ethereum RPC Spec, Mantis lacks
eth_chainId
method, which makes it much harder to issue transactions from Luna.PS. This PR got so big due to auto-formatting. Changes crucial for this task are really minimal (test for eth service, test for rpc controller, insomnia entry, controller entry, json codec, eth service method).
Testing
eth_chainId
in Insomnia should return configured value in hex format according to spec (https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/etclabscore/ethereum-json-rpc-specification/master/openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false)