-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1133 from cardano-foundation/1.1.0
1.1.0
- Loading branch information
Showing
66 changed files
with
2,995 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/org/cardanofoundation/explorer/api/common/enumeration/GovActionStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.cardanofoundation.explorer.api.common.enumeration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.FieldDefaults; | ||
|
||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) | ||
@RequiredArgsConstructor | ||
@Getter | ||
public enum GovActionStatus { | ||
ANY("ANY"), | ||
OPEN_BALLOT("OPEN_BALLOT"), | ||
RATIFIED("RATIFIED"), | ||
ENACTED("ENACTED"), | ||
EXPIRED("EXPIRED"); | ||
|
||
String value; | ||
|
||
private static final Map<String, GovActionStatus> govActionStatusMap = new HashMap<>(); | ||
|
||
static { | ||
for (GovActionStatus type : GovActionStatus.values()) { | ||
govActionStatusMap.put(type.value, type); | ||
} | ||
} | ||
|
||
public static GovActionStatus fromValue(String value) { | ||
return govActionStatusMap.get(value); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/cardanofoundation/explorer/api/common/enumeration/GovActionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.cardanofoundation.explorer.api.common.enumeration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.FieldDefaults; | ||
|
||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) | ||
@RequiredArgsConstructor | ||
@Getter | ||
public enum GovActionType { | ||
PARAMETER_CHANGE_ACTION("PARAMETER_CHANGE_ACTION"), | ||
HARD_FORK_INITIATION_ACTION("HARD_FORK_INITIATION_ACTION"), | ||
TREASURY_WITHDRAWALS_ACTION("TREASURY_WITHDRAWALS_ACTION"), | ||
NO_CONFIDENCE("NO_CONFIDENCE"), | ||
UPDATE_COMMITTEE("UPDATE_COMMITTEE"), | ||
NEW_CONSTITUTION("NEW_CONSTITUTION"), | ||
INFO_ACTION("INFO_ACTION"), | ||
ALL("ALL"); | ||
String value; | ||
|
||
private static final Map<String, GovActionType> govActionTypeMap = new HashMap<>(); | ||
|
||
static { | ||
for (GovActionType type : GovActionType.values()) { | ||
govActionTypeMap.put(type.value, type); | ||
} | ||
} | ||
|
||
public static GovActionType fromValue(String value) { | ||
return govActionTypeMap.get(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/org/cardanofoundation/explorer/api/common/enumeration/VoteType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.cardanofoundation.explorer.api.common.enumeration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.FieldDefaults; | ||
|
||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) | ||
@RequiredArgsConstructor | ||
@Getter | ||
public enum VoteType { | ||
NO("NO"), | ||
YES("YES"), | ||
ABSTAIN("ABSTAIN"), | ||
ANY("ANY"), | ||
NONE("NONE"); | ||
|
||
String value; | ||
|
||
private static final Map<String, VoteType> voteTypeMap = new HashMap<>(); | ||
|
||
static { | ||
for (VoteType type : VoteType.values()) { | ||
voteTypeMap.put(type.value, type); | ||
} | ||
} | ||
|
||
public static VoteType fromValue(String value) { | ||
return voteTypeMap.get(value); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/main/java/org/cardanofoundation/explorer/api/controller/DRepController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package org.cardanofoundation.explorer.api.controller; | ||
|
||
import jakarta.validation.Valid; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import org.springframework.data.domain.Sort; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springdoc.core.annotations.ParameterObject; | ||
|
||
import org.cardanofoundation.explorer.api.common.enumeration.GovActionType; | ||
import org.cardanofoundation.explorer.api.config.LogMessage; | ||
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | ||
import org.cardanofoundation.explorer.api.model.response.drep.DRepCertificateHistoryResponse; | ||
import org.cardanofoundation.explorer.api.model.response.drep.DRepDelegatorsResponse; | ||
import org.cardanofoundation.explorer.api.model.response.drep.DRepDetailsResponse; | ||
import org.cardanofoundation.explorer.api.model.response.drep.VotingProcedureChartResponse; | ||
import org.cardanofoundation.explorer.api.service.DRepService; | ||
import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | ||
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | ||
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/dreps") | ||
@RequiredArgsConstructor | ||
@Validated | ||
@Tag(name = "dRep", description = "The delegated representatives APIs") | ||
public class DRepController { | ||
|
||
private final DRepService dRepService; | ||
|
||
@GetMapping("/{drepHashOrDrepId}/certificates-history") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get list of DRep certificate history", | ||
tags = {"dRep"}) | ||
public ResponseEntity<BaseFilterResponse<DRepCertificateHistoryResponse>> | ||
getTxDRepCertificatesHistory( | ||
@PathVariable @Parameter(description = "The DRep id or DRep hash") | ||
String drepHashOrDrepId, | ||
@ParameterObject | ||
@PaginationValid | ||
@PaginationDefault( | ||
size = 20, | ||
sort = {"createdAt"}, | ||
direction = Sort.Direction.DESC) | ||
Pagination pagination) { | ||
return ResponseEntity.ok( | ||
dRepService.getTxDRepCertificateHistory(drepHashOrDrepId, pagination.toPageable())); | ||
} | ||
|
||
@GetMapping("/{dRepHashOrId}/vote-procedure-chart") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get chart of DRep vote on Governance Action", | ||
tags = {"dRep"}) | ||
public ResponseEntity<VotingProcedureChartResponse> getChartOfDRepVotesOnGovernanceAction( | ||
@PathVariable @Parameter(description = "The DRep hash or id") String dRepHashOrId, | ||
@RequestParam(value = "govActionType") | ||
@Parameter(description = "The type of Governance Action") | ||
GovActionType govActionType) { | ||
return ResponseEntity.ok(dRepService.getVoteProcedureChart(dRepHashOrId, govActionType)); | ||
} | ||
|
||
@GetMapping("/{dRepHashOrDRepId}/drep-details") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get details of Delegated Representative (DRep)", | ||
tags = {"dRep"}) | ||
public ResponseEntity<DRepDetailsResponse> getDRepDetails( | ||
@Valid @PathVariable @Parameter(description = "The DRep id or DRep hash") | ||
String dRepHashOrDRepId) { | ||
return ResponseEntity.ok(dRepService.getDRepDetails(dRepHashOrDRepId)); | ||
} | ||
|
||
@GetMapping("/{dRepHashOrDRepId}/get-delegation") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get stake that delegated to Delegated Representative (DRep)", | ||
tags = {"dRep"}) | ||
public ResponseEntity<BaseFilterResponse<DRepDelegatorsResponse>> getDRepDelegation( | ||
@Valid @PathVariable @Parameter(description = "dRepHashOrDRepId") String dRepHashOrDRepId, | ||
@ParameterObject @PaginationValid @Valid Pagination pagination) { | ||
return ResponseEntity.ok( | ||
dRepService.getDRepDelegators(dRepHashOrDRepId, pagination.toPageable())); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
src/main/java/org/cardanofoundation/explorer/api/controller/GovernanceActionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package org.cardanofoundation.explorer.api.controller; | ||
|
||
import jakarta.validation.Valid; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
import org.springframework.data.domain.Sort; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springdoc.core.annotations.ParameterObject; | ||
|
||
import org.cardanofoundation.explorer.api.config.LogMessage; | ||
import org.cardanofoundation.explorer.api.model.request.governanceAction.GovernanceActionFilter; | ||
import org.cardanofoundation.explorer.api.model.request.governanceAction.GovernanceActionRequest; | ||
import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | ||
import org.cardanofoundation.explorer.api.model.response.governanceAction.GovernanceActionDetailsResponse; | ||
import org.cardanofoundation.explorer.api.model.response.governanceAction.GovernanceActionResponse; | ||
import org.cardanofoundation.explorer.api.model.response.governanceAction.VotingChartResponse; | ||
import org.cardanofoundation.explorer.api.service.GovernanceActionService; | ||
import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | ||
import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | ||
import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/gov-actions") | ||
@RequiredArgsConstructor | ||
@Validated | ||
@Tag(name = "gov-actions", description = "The governance action APIs") | ||
public class GovernanceActionController { | ||
|
||
private final GovernanceActionService governanceActionService; | ||
|
||
@GetMapping("{dRepHashOrPoolHash}") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get governance action that vote by DRep or pool", | ||
tags = {"gov-actions"}) | ||
public ResponseEntity<BaseFilterResponse<GovernanceActionResponse>> getGovActionByFilter( | ||
@PathVariable @Parameter(description = "The DRep hash or pool hash or pool view") | ||
String dRepHashOrPoolHash, | ||
@ParameterObject GovernanceActionFilter governanceActionFilter, | ||
@ParameterObject | ||
@PaginationValid | ||
@PaginationDefault( | ||
size = 20, | ||
sort = {"blockTime"}, | ||
direction = Sort.Direction.DESC) | ||
@Valid | ||
Pagination pagination) { | ||
return ResponseEntity.ok( | ||
governanceActionService.getGovernanceActions( | ||
dRepHashOrPoolHash, governanceActionFilter, pagination.toPageable())); | ||
} | ||
|
||
@GetMapping("{dRepHashOrPoolHash}/voting-procedure-detail") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get governance action that vote by DRep or pool", | ||
tags = {"gov-actions"}) | ||
public ResponseEntity<GovernanceActionDetailsResponse> getGovActionByTxHashAndVoterHash( | ||
@PathVariable @Parameter(description = "The DRep hash or pool hash") | ||
String dRepHashOrPoolHash, | ||
@ParameterObject GovernanceActionRequest governanceActionRequest) { | ||
return ResponseEntity.ok( | ||
governanceActionService.getGovernanceActionDetails( | ||
dRepHashOrPoolHash, governanceActionRequest)); | ||
} | ||
|
||
@GetMapping("voting-chart") | ||
@LogMessage | ||
@Operation( | ||
summary = "Get voting chart of governance action", | ||
tags = {"gov-actions"}) | ||
public ResponseEntity<VotingChartResponse> getVotingChartByGovAction( | ||
@RequestParam @Parameter(description = "The tx hash of governance action") String txHash, | ||
@RequestParam @Parameter(description = "The index of governance action") Integer index) { | ||
return ResponseEntity.ok( | ||
governanceActionService.getVotingChartByGovActionTxHashAndIndex(txHash, index)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/org/cardanofoundation/explorer/api/mapper/DRepCertificateMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.cardanofoundation.explorer.api.mapper; | ||
|
||
import java.util.Date; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
import org.cardanofoundation.explorer.api.model.response.drep.DRepCertificateHistoryResponse; | ||
import org.cardanofoundation.explorer.api.model.response.drep.projection.DRepCertificateProjection; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface DRepCertificateMapper { | ||
|
||
@Mapping(source = "blockTime", target = "createdAt") | ||
DRepCertificateHistoryResponse fromDRepCertProjection( | ||
DRepCertificateProjection dRepCertificateProjection); | ||
|
||
default Date fromLong(Long value) { | ||
return value == null ? null : new Date(value * 1000); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/org/cardanofoundation/explorer/api/mapper/DRepMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.cardanofoundation.explorer.api.mapper; | ||
|
||
import java.util.Date; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
|
||
import org.cardanofoundation.explorer.api.model.response.drep.DRepDelegatorsResponse; | ||
import org.cardanofoundation.explorer.api.model.response.drep.DRepDetailsResponse; | ||
import org.cardanofoundation.explorer.api.projection.DRepDelegatorProjection; | ||
import org.cardanofoundation.explorer.common.entity.explorer.DRepInfo; | ||
|
||
@Mapper(componentModel = "spring") | ||
public interface DRepMapper { | ||
@Mapping(target = "createdAt", expression = "java(fromLong(dRepInfo.getCreatedAt()))") | ||
DRepDetailsResponse fromDrepInfo(DRepInfo dRepInfo); | ||
|
||
@Mapping( | ||
target = "createdAt", | ||
expression = "java(fromLong(dRepDelegatorProjection.getBlockTime()))") | ||
DRepDelegatorsResponse fromDRepDelegatorProjection( | ||
DRepDelegatorProjection dRepDelegatorProjection); | ||
|
||
default Date fromLong(Long value) { | ||
return value == null ? null : new Date(value * 1000); | ||
} | ||
} |
Oops, something went wrong.