1 | package org.cardanofoundation.explorer.api.mapper; | |
2 | ||
3 | import com.bloxbean.cardano.client.util.HexUtil; | |
4 | import org.mapstruct.Mapper; | |
5 | import org.mapstruct.Mapping; | |
6 | import org.mapstruct.Named; | |
7 | ||
8 | import org.cardanofoundation.explorer.api.common.enumeration.RedeemerCertType; | |
9 | import org.cardanofoundation.explorer.api.model.response.tx.ContractResponse; | |
10 | import org.cardanofoundation.explorer.api.projection.TxContractProjection; | |
11 | ||
12 | @Mapper(componentModel = "spring") | |
13 | public interface TxContractMapper { | |
14 | ||
15 | @Mapping(target = "redeemerBytes", source = "redeemerBytes", qualifiedByName = "bytesToString") | |
16 | @Mapping(target = "datumBytesIn", source = "datumBytesIn", qualifiedByName = "bytesToString") | |
17 | @Mapping(target = "datumBytesOut", source = "datumBytesOut", qualifiedByName = "bytesToString") | |
18 | @Mapping(target = "scriptBytes", source = "scriptBytes", qualifiedByName = "bytesToString") | |
19 | @Mapping( | |
20 | target = "redeemerCertType", | |
21 | expression = "java(getRedeemerCertType(txContractProjection))") | |
22 | ContractResponse fromTxContractProjectionToContractResponse( | |
23 | TxContractProjection txContractProjection); | |
24 | ||
25 | @Named("bytesToString") | |
26 | default String bytesToString(byte[] bytes) { | |
27 |
1
1. bytesToString : replaced return value with "" for org/cardanofoundation/explorer/api/mapper/TxContractMapper::bytesToString → NO_COVERAGE |
return HexUtil.encodeHexString(bytes); |
28 | } | |
29 | ||
30 | default RedeemerCertType getRedeemerCertType(TxContractProjection txContractProjection) { | |
31 |
1
1. getRedeemerCertType : negated conditional → NO_COVERAGE |
if (txContractProjection.getDelegationId() != null) { |
32 |
1
1. getRedeemerCertType : replaced return value with null for org/cardanofoundation/explorer/api/mapper/TxContractMapper::getRedeemerCertType → NO_COVERAGE |
return RedeemerCertType.DELEGATION; |
33 |
1
1. getRedeemerCertType : negated conditional → NO_COVERAGE |
} else if (txContractProjection.getStakeDeregistrationId() != null) { |
34 |
1
1. getRedeemerCertType : replaced return value with null for org/cardanofoundation/explorer/api/mapper/TxContractMapper::getRedeemerCertType → NO_COVERAGE |
return RedeemerCertType.STAKE_DEREGISTRATION; |
35 | } else { | |
36 | return null; | |
37 | } | |
38 | } | |
39 | } | |
Mutations | ||
27 |
1.1 |
|
31 |
1.1 |
|
32 |
1.1 |
|
33 |
1.1 |
|
34 |
1.1 |