1 | package org.cardanofoundation.explorer.api.controller; | |
2 | ||
3 | import java.util.List; | |
4 | import java.util.concurrent.ExecutionException; | |
5 | ||
6 | import jakarta.validation.Valid; | |
7 | ||
8 | import lombok.RequiredArgsConstructor; | |
9 | ||
10 | import org.springframework.data.domain.Sort; | |
11 | import org.springframework.http.ResponseEntity; | |
12 | import org.springframework.validation.annotation.Validated; | |
13 | import org.springframework.web.bind.annotation.*; | |
14 | ||
15 | import io.swagger.v3.oas.annotations.Operation; | |
16 | import io.swagger.v3.oas.annotations.Parameter; | |
17 | import io.swagger.v3.oas.annotations.tags.Tag; | |
18 | import org.springdoc.core.annotations.ParameterObject; | |
19 | ||
20 | import org.cardanofoundation.explorer.api.common.constant.CommonConstant; | |
21 | import org.cardanofoundation.explorer.api.common.enumeration.AnalyticType; | |
22 | import org.cardanofoundation.explorer.api.config.LogMessage; | |
23 | import org.cardanofoundation.explorer.api.model.response.BaseFilterResponse; | |
24 | import org.cardanofoundation.explorer.api.model.response.TxFilterResponse; | |
25 | import org.cardanofoundation.explorer.api.model.response.token.*; | |
26 | import org.cardanofoundation.explorer.api.service.TokenService; | |
27 | import org.cardanofoundation.explorer.api.service.TxService; | |
28 | import org.cardanofoundation.explorer.common.entity.ledgersync.BaseEntity_; | |
29 | import org.cardanofoundation.explorer.common.entity.ledgersyncsagg.AddressTxAmount_; | |
30 | import org.cardanofoundation.explorer.common.validation.length.LengthValid; | |
31 | import org.cardanofoundation.explorer.common.validation.pagination.Pagination; | |
32 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationDefault; | |
33 | import org.cardanofoundation.explorer.common.validation.pagination.PaginationValid; | |
34 | import org.cardanofoundation.explorer.common.validation.prefixed.PrefixedValid; | |
35 | ||
36 | @RestController | |
37 | @RequestMapping("/api/v1/tokens") | |
38 | @RequiredArgsConstructor | |
39 | @Validated | |
40 | @Tag(name = "tokens", description = "The token APIs") | |
41 | public class TokenController { | |
42 | private final TokenService tokenService; | |
43 | private final TxService txService; | |
44 | ||
45 | @GetMapping | |
46 | @LogMessage | |
47 | @Operation(summary = "Filter token") | |
48 | public ResponseEntity<BaseFilterResponse<TokenFilterResponse>> filter( | |
49 | @ParameterObject @PaginationValid @Valid Pagination pagination, | |
50 | @Parameter(description = "Token name") @RequestParam(required = false) String query) | |
51 | throws ExecutionException, InterruptedException { | |
52 |
1
1. filter : replaced return value with null for org/cardanofoundation/explorer/api/controller/TokenController::filter → SURVIVED |
return ResponseEntity.ok(tokenService.filterToken(query, pagination.toPageable())); |
53 | } | |
54 | ||
55 | @GetMapping("/{tokenId}") | |
56 | @LogMessage | |
57 | @Operation(summary = "Detail token") | |
58 | public ResponseEntity<TokenResponse> getTokenDetail( | |
59 | @PathVariable | |
60 | @PrefixedValid(CommonConstant.PREFIXED_TOKEN_FINGERPRINT) | |
61 | @LengthValid(CommonConstant.TOKEN_FINGERPRINT_LENGTH) | |
62 | @Parameter(description = "The CIP14 fingerprint for the MultiAsset.") | |
63 | String tokenId) { | |
64 |
1
1. getTokenDetail : replaced return value with null for org/cardanofoundation/explorer/api/controller/TokenController::getTokenDetail → SURVIVED |
return ResponseEntity.ok(tokenService.getTokenDetail(tokenId)); |
65 | } | |
66 | ||
67 | @GetMapping("/{tokenId}/mints") | |
68 | @LogMessage | |
69 | @Operation(summary = "Filter token mint transaction") | |
70 | public ResponseEntity<BaseFilterResponse<TokenMintTxResponse>> getTokenMintTx( | |
71 | @PathVariable | |
72 | @PrefixedValid(CommonConstant.PREFIXED_TOKEN_FINGERPRINT) | |
73 | @LengthValid(CommonConstant.TOKEN_FINGERPRINT_LENGTH) | |
74 | String tokenId, | |
75 | @ParameterObject | |
76 | @PaginationValid | |
77 | @PaginationDefault( | |
78 | sort = {BaseEntity_.ID}, | |
79 | direction = Sort.Direction.DESC) | |
80 | @Valid | |
81 | Pagination pagination) { | |
82 |
1
1. getTokenMintTx : replaced return value with null for org/cardanofoundation/explorer/api/controller/TokenController::getTokenMintTx → SURVIVED |
return ResponseEntity.ok(tokenService.getMintTxs(tokenId, pagination.toPageable())); |
83 | } | |
84 | ||
85 | @GetMapping("/{tokenId}/txs") | |
86 | @LogMessage | |
87 | @Operation(summary = "Filter transaction by token") | |
88 | public ResponseEntity<BaseFilterResponse<TxFilterResponse>> getTransactions( | |
89 | @PathVariable | |
90 | @PrefixedValid(CommonConstant.PREFIXED_TOKEN_FINGERPRINT) | |
91 | @LengthValid(CommonConstant.TOKEN_FINGERPRINT_LENGTH) | |
92 | @Parameter(description = "The CIP14 fingerprint for the MultiAsset.") | |
93 | String tokenId, | |
94 | @ParameterObject | |
95 | @PaginationValid | |
96 | @PaginationDefault( | |
97 | size = 20, | |
98 | sort = {AddressTxAmount_.SLOT}, | |
99 | direction = Sort.Direction.DESC) | |
100 | @Valid | |
101 | Pagination pagination) { | |
102 |
1
1. getTransactions : replaced return value with null for org/cardanofoundation/explorer/api/controller/TokenController::getTransactions → NO_COVERAGE |
return ResponseEntity.ok(txService.getTransactionsByToken(tokenId, pagination.toPageable())); |
103 | } | |
104 | ||
105 | @GetMapping("/analytics/{tokenId}/{type}") | |
106 | @LogMessage | |
107 | @Operation(summary = "Filter transaction by token") | |
108 | public ResponseEntity<List<TokenVolumeAnalyticsResponse>> getTokenVolumeAnalytics( | |
109 | @PathVariable | |
110 | @PrefixedValid(CommonConstant.PREFIXED_TOKEN_FINGERPRINT) | |
111 | @LengthValid(CommonConstant.TOKEN_FINGERPRINT_LENGTH) | |
112 | @Parameter(description = "The CIP14 fingerprint for the MultiAsset.") | |
113 | String tokenId, | |
114 | @PathVariable @Parameter(description = "Type analytics") AnalyticType type) { | |
115 |
1
1. getTokenVolumeAnalytics : replaced return value with null for org/cardanofoundation/explorer/api/controller/TokenController::getTokenVolumeAnalytics → KILLED |
return ResponseEntity.ok(tokenService.getTokenVolumeAnalytic(tokenId, type)); |
116 | } | |
117 | } | |
Mutations | ||
52 |
1.1 |
|
64 |
1.1 |
|
82 |
1.1 |
|
102 |
1.1 |
|
115 |
1.1 |