|
14 | 14 | package tech.pegasys.teku.beaconrestapi.handlers.v1.validator;
|
15 | 15 |
|
16 | 16 | import static tech.pegasys.teku.beaconrestapi.BeaconRestApiTypes.EPOCH_PARAMETER;
|
17 |
| -import static tech.pegasys.teku.ethereum.json.types.EthereumTypes.PUBLIC_KEY_TYPE; |
| 17 | +import static tech.pegasys.teku.ethereum.json.types.validator.AttesterDutiesBuilder.ATTESTER_DUTIES_RESPONSE_TYPE; |
18 | 18 | import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
|
19 | 19 | import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_SERVICE_UNAVAILABLE;
|
20 |
| -import static tech.pegasys.teku.infrastructure.http.RestApiConstants.EXECUTION_OPTIMISTIC; |
21 | 20 | import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR;
|
22 | 21 | import static tech.pegasys.teku.infrastructure.http.RestApiConstants.TAG_VALIDATOR_REQUIRED;
|
23 |
| -import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BOOLEAN_TYPE; |
24 |
| -import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.BYTES32_TYPE; |
25 | 22 | import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.INTEGER_TYPE;
|
26 |
| -import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.UINT64_TYPE; |
27 | 23 |
|
28 | 24 | import com.fasterxml.jackson.core.JsonProcessingException;
|
29 | 25 | import it.unimi.dsi.fastutil.ints.IntArrayList;
|
|
33 | 29 | import tech.pegasys.teku.api.DataProvider;
|
34 | 30 | import tech.pegasys.teku.api.SyncDataProvider;
|
35 | 31 | import tech.pegasys.teku.api.ValidatorDataProvider;
|
| 32 | +import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties; |
36 | 33 | import tech.pegasys.teku.infrastructure.async.SafeFuture;
|
37 | 34 | import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
|
38 |
| -import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition; |
39 | 35 | import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse;
|
40 | 36 | import tech.pegasys.teku.infrastructure.restapi.endpoints.EndpointMetadata;
|
41 | 37 | import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiEndpoint;
|
42 | 38 | import tech.pegasys.teku.infrastructure.restapi.endpoints.RestApiRequest;
|
43 | 39 | import tech.pegasys.teku.infrastructure.unsigned.UInt64;
|
44 |
| -import tech.pegasys.teku.validator.api.AttesterDuties; |
45 |
| -import tech.pegasys.teku.validator.api.AttesterDuty; |
46 | 40 |
|
47 | 41 | public class PostAttesterDuties extends RestApiEndpoint {
|
48 | 42 | public static final String ROUTE = "/eth/v1/validator/duties/attester/{epoch}";
|
49 | 43 | private final ValidatorDataProvider validatorDataProvider;
|
50 | 44 | private final SyncDataProvider syncDataProvider;
|
51 | 45 |
|
52 |
| - private static final SerializableTypeDefinition<AttesterDuty> ATTESTER_DUTY_TYPE = |
53 |
| - SerializableTypeDefinition.object(AttesterDuty.class) |
54 |
| - .name("AttesterDuty") |
55 |
| - .withField("pubkey", PUBLIC_KEY_TYPE, AttesterDuty::getPublicKey) |
56 |
| - .withField("validator_index", INTEGER_TYPE, AttesterDuty::getValidatorIndex) |
57 |
| - .withField("committee_index", INTEGER_TYPE, AttesterDuty::getCommitteeIndex) |
58 |
| - .withField("committee_length", INTEGER_TYPE, AttesterDuty::getCommitteeLength) |
59 |
| - .withField("committees_at_slot", INTEGER_TYPE, AttesterDuty::getCommitteesAtSlot) |
60 |
| - .withField( |
61 |
| - "validator_committee_index", INTEGER_TYPE, AttesterDuty::getValidatorCommitteeIndex) |
62 |
| - .withField("slot", UINT64_TYPE, AttesterDuty::getSlot) |
63 |
| - .build(); |
64 |
| - |
65 |
| - private static final SerializableTypeDefinition<AttesterDuties> RESPONSE_TYPE = |
66 |
| - SerializableTypeDefinition.object(AttesterDuties.class) |
67 |
| - .name("GetAttesterDutiesResponse") |
68 |
| - .withField("dependent_root", BYTES32_TYPE, AttesterDuties::getDependentRoot) |
69 |
| - .withField(EXECUTION_OPTIMISTIC, BOOLEAN_TYPE, AttesterDuties::isExecutionOptimistic) |
70 |
| - .withField( |
71 |
| - "data", |
72 |
| - SerializableTypeDefinition.listOf(ATTESTER_DUTY_TYPE), |
73 |
| - AttesterDuties::getDuties) |
74 |
| - .build(); |
75 |
| - |
76 | 46 | public PostAttesterDuties(final DataProvider dataProvider) {
|
77 | 47 | this(dataProvider.getSyncDataProvider(), dataProvider.getValidatorDataProvider());
|
78 | 48 | }
|
@@ -100,7 +70,7 @@ public PostAttesterDuties(final DataProvider dataProvider) {
|
100 | 70 | .tags(TAG_VALIDATOR, TAG_VALIDATOR_REQUIRED)
|
101 | 71 | .requestBodyType(DeserializableTypeDefinition.listOf(INTEGER_TYPE, 1))
|
102 | 72 | .pathParam(EPOCH_PARAMETER)
|
103 |
| - .response(SC_OK, "Success response", RESPONSE_TYPE) |
| 73 | + .response(SC_OK, "Success response", ATTESTER_DUTIES_RESPONSE_TYPE) |
104 | 74 | .withServiceUnavailableResponse()
|
105 | 75 | .build());
|
106 | 76 | this.validatorDataProvider = validatorDataProvider;
|
|
0 commit comments