Skip to content

Commit

Permalink
5098 branch 5 update invalid auth params (#7406)
Browse files Browse the repository at this point in the history
* 5098: Add RpcErrorTypes

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestException, apply spotless

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Modify InvalidJsonRpcParameters and InvalidJsonRpcRequestException, apply spotless

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Add JsonRpcParameterException for later use

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update locations for RpcErrorType.INVALID_ACCOUNTS_PARAMS

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Address review comments, apply spotless

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update with changes from branch 1

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update code to use RpcErrorType.INVALID_ADDRESS_HASH_PARAMS

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: apply spotless

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update plugin-api gradle hash

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Add comment on INVALID_PARAMS_ERROR_CODE

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Apply spotless on latest changes

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update code to use RpcErrorType.INVALID_ADDRESS_PARAMS

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Fix broken unit test

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Fix broken unit test

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update with usage of RpcErrorType.INVALID_AUTH_PARAMS

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Add index to exception messages

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: apoply spotless

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Update BaseJsonRpcProcessor to utilise RpcErrorType from InvalidJsonRpcParameters

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Include parameter index in INVALID_AUTH_PARAMS

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Rename INVALID_AUTH_PARAMS to INVALID_PROPOSAL_PARAMS

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda-Clerke <matilda.clerke@consensys.net>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
Matilda-Clerke and macfarla authored Aug 2, 2024
1 parent 4199952 commit 1958df9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
throw new InvalidJsonRpcParameters(
"Invalid address parameter (index 0)", RpcErrorType.INVALID_ADDRESS_PARAMS, e);
}
final Boolean auth = requestContext.getRequiredParameter(1, Boolean.class);
final Boolean auth;
try {
auth = requestContext.getRequiredParameter(1, Boolean.class);
} catch (Exception e) { // TODO:replace with JsonRpcParameter.JsonRpcParameterException
throw new InvalidJsonRpcParameters(
"Invalid auth parameter (index 1)", RpcErrorType.INVALID_PROPOSAL_PARAMS, e);
}
if (address.equals(CliqueBlockInterface.NO_VOTE_SUBJECT)) {
return new JsonRpcErrorResponse(
requestContext.getRequest().getId(), RpcErrorType.INVALID_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public JsonRpcResponse process(
case INVALID_ACCOUNT_PARAMS:
case INVALID_ADDRESS_HASH_PARAMS:
case INVALID_ADDRESS_PARAMS:
case INVALID_AUTH_PARAMS:
case INVALID_BLOB_COUNT:
case INVALID_BLOB_GAS_USED_PARAMS:
case INVALID_BLOCK_PARAMS:
Expand Down Expand Up @@ -104,6 +103,7 @@ public JsonRpcResponse process(
case INVALID_PRIVACY_GROUP_PARAMS:
case INVALID_PRIVATE_FROM_PARAMS:
case INVALID_PRIVATE_FOR_PARAMS:
case INVALID_PROPOSAL_PARAMS:
case INVALID_REMOTE_CAPABILITIES_PARAMS:
case INVALID_REWARD_PERCENTILES_PARAMS:
case INVALID_SEALER_ID_PARAMS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public enum RpcErrorType implements RpcMethodError {
INVALID_ACCOUNT_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid account params"),
INVALID_ADDRESS_HASH_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid address hash params"),
INVALID_ADDRESS_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid address params"),
INVALID_AUTH_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid auth params"),
INVALID_BLOB_COUNT(
INVALID_PARAMS_ERROR_CODE,
"Invalid blob count (blob transactions must have at least one blob)"),
Expand Down Expand Up @@ -89,6 +88,7 @@ public enum RpcErrorType implements RpcMethodError {
INVALID_PRIVACY_GROUP_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid privacy group params"),
INVALID_PRIVATE_FROM_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid private from params"),
INVALID_PRIVATE_FOR_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid private for params"),
INVALID_PROPOSAL_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid proposal params"),
INVALID_REMOTE_CAPABILITIES_PARAMS(
INVALID_PARAMS_ERROR_CODE, "Invalid remote capabilities params"),
INVALID_REWARD_PERCENTILES_PARAMS(INVALID_PARAMS_ERROR_CODE, "Invalid reward percentiles params"),
Expand Down

0 comments on commit 1958df9

Please sign in to comment.