Skip to content

Commit b9957c6

Browse files
authored
[RA-122] fix: fixes wrong assetname. Using the assetname from the unit. (#173)
* fix: fixes wrong assetname. Using the assetname from the unit. * fix: fixing tests because behaviour changed * fix: spotless issues
1 parent f3ce1a2 commit b9957c6

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

api/src/main/java/org/cardanofoundation/rosetta/api/block/mapper/AbstractToOperation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import jakarta.validation.constraints.NotNull;
77

88
import org.springframework.beans.factory.annotation.Autowired;
9-
import org.apache.commons.codec.binary.Hex;
109
import org.apache.commons.lang3.mutable.MutableInt;
1110
import org.modelmapper.builder.ConfigurableConditionExpression;
1211
import org.openapitools.client.model.Amount;
@@ -52,7 +51,7 @@ protected OperationMetadata mapToOperationMetaData(boolean spent, List<Amt> amou
5251
tokenBundleItem.setPolicyId(amount.getPolicyId());
5352
Amount amt = new Amount();
5453
amt.setValue(DataMapper.mapValue(amount.getQuantity().toString(), spent));
55-
String hexAssetName = Hex.encodeHexString(amount.getAssetName().getBytes());
54+
String hexAssetName = amount.getUnit().replace(amount.getPolicyId(), "");
5655
amt.setCurrency(Currency.builder()
5756
.symbol(hexAssetName)
5857
.decimals(0)

api/src/test/java/org/cardanofoundation/rosetta/api/block/mapper/BlockTxToRosettaTransactionTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import org.springframework.beans.factory.annotation.Autowired;
99
import com.bloxbean.cardano.yaci.core.model.certs.CertificateType;
10-
import org.apache.commons.codec.binary.Hex;
1110
import org.assertj.core.util.introspection.CaseFormatUtils;
1211
import org.openapitools.client.model.Amount;
1312
import org.openapitools.client.model.CoinAction;
@@ -285,8 +284,7 @@ void toDto_Test_getOutputsAsOperations() {
285284

286285
Amount token = bundle.getTokens().getFirst();
287286
assertThat(token.getCurrency().getSymbol())
288-
.isEqualTo(Hex.encodeHexString(
289-
from.getOutputs().getFirst().getAmounts().getFirst().getAssetName().getBytes()));
287+
.isEqualTo("unit1");
290288
assertThat(token.getCurrency().getDecimals()).isZero();
291289
}
292290

@@ -333,8 +331,7 @@ void toDto_Test_getInputsAsOperations() {
333331

334332
Amount token = bundle.getTokens().getFirst();
335333
assertThat(token.getCurrency().getSymbol())
336-
.isEqualTo(Hex.encodeHexString(
337-
from.getInputs().getFirst().getAmounts().getFirst().getAssetName().getBytes()));
334+
.isEqualTo("unit1");
338335
assertThat(token.getCurrency().getDecimals()).isZero();
339336
}
340337

0 commit comments

Comments
 (0)