Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,31 @@ public class JsonCallParameter extends CallParameter {

private final Optional<Boolean> strict;

public JsonCallParameter(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere outside of tests? Can we just rip the band-aid off and migrate to the new signaure? IntelliJ has a tool for this Refactor>Change Signature... (command/alt F6)

@gfukushima gfukushima Oct 27, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only used in tests, changing class to only use a single constructor. thanks for the feedback.

@JsonProperty("from") final Address from,
@JsonProperty("to") final Address to,
@JsonDeserialize(using = HexLongDeserializer.class) @JsonProperty("gas") final Long gasLimit,
@JsonProperty("gasPrice") final Wei gasPrice,
@JsonProperty("maxPriorityFeePerGas") final Wei maxPriorityFeePerGas,
@JsonProperty("maxFeePerGas") final Wei maxFeePerGas,
@JsonProperty("value") final Wei value,
@JsonDeserialize(using = HexStringDeserializer.class) @JsonProperty("data") final Bytes data,
@JsonProperty("strict") final Boolean strict,
@JsonProperty("accessList") final List<AccessListEntry> accessList) {
this(
from,
to,
gasLimit,
gasPrice,
maxPriorityFeePerGas,
maxFeePerGas,
value,
data,
null,
strict,
accessList);
}

@JsonCreator
public JsonCallParameter(
@JsonProperty("from") final Address from,
Expand All @@ -49,10 +74,12 @@ public JsonCallParameter(
@JsonProperty("maxPriorityFeePerGas") final Wei maxPriorityFeePerGas,
@JsonProperty("maxFeePerGas") final Wei maxFeePerGas,
@JsonProperty("value") final Wei value,
@JsonDeserialize(using = HexStringDeserializer.class) @JsonProperty("data")
final Bytes payload,
@JsonDeserialize(using = HexStringDeserializer.class) @JsonProperty("input")
final Bytes input,
@JsonDeserialize(using = HexStringDeserializer.class) @JsonProperty("data") final Bytes data,
@JsonProperty("strict") final Boolean strict,
@JsonProperty("accessList") final List<AccessListEntry> accessList) {

super(
from,
to,
Expand All @@ -61,8 +88,13 @@ public JsonCallParameter(
Optional.ofNullable(maxPriorityFeePerGas),
Optional.ofNullable(maxFeePerGas),
value,
payload,
Optional.ofNullable(input != null ? input : data).orElse(null),
Optional.ofNullable(accessList));

if (input != null && data != null) {
throw new IllegalArgumentException("Only one of 'input' or 'data' should be provided");
}

this.strict = Optional.ofNullable(strict);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"request": {
"id": 3,
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"from": "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"input": "0x12a7b914",
"data": "0x12a7b914"
},
"0x19"
]
},
"response": {
"jsonrpc": "2.0",
"id": 3,
"error" : {
"code" : -32602,
"message" : "Invalid params"
}
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"request": {
"id": 3,
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"from": "a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"input": "0x12a7b914"
},
"0x19"
]
},
"response": {
"jsonrpc": "2.0",
"id": 3,
"result": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"statusCode": 200
}