From e892ed8e45555aa44d97e73555bca37fe1f41f73 Mon Sep 17 00:00:00 2001 From: Satya <35016438+satran004@users.noreply.github.com> Date: Sat, 16 Sep 2023 11:38:27 +0800 Subject: [PATCH] Entropy field type change (#25) * fix: Change extraEntropy to Tuple * fix: Bump snapshot version --- .../yaci/core/model/ProtocolParamUpdate.java | 3 ++- .../core/model/serializers/UpdateSerializer.java | 6 +++--- .../bloxbean/cardano/yaci/core/util/Tuple.java | 16 ++++++++++++++++ gradle.properties | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/com/bloxbean/cardano/yaci/core/util/Tuple.java diff --git a/core/src/main/java/com/bloxbean/cardano/yaci/core/model/ProtocolParamUpdate.java b/core/src/main/java/com/bloxbean/cardano/yaci/core/model/ProtocolParamUpdate.java index 623bbd3..8685431 100644 --- a/core/src/main/java/com/bloxbean/cardano/yaci/core/model/ProtocolParamUpdate.java +++ b/core/src/main/java/com/bloxbean/cardano/yaci/core/model/ProtocolParamUpdate.java @@ -1,5 +1,6 @@ package com.bloxbean.cardano.yaci.core.model; +import com.bloxbean.cardano.yaci.core.util.Tuple; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; @@ -28,7 +29,7 @@ public class ProtocolParamUpdate { private BigDecimal expansionRate; //unit interval //10 private BigDecimal treasuryGrowthRate; //11 private BigDecimal decentralisationParam; //12 - private String extraEntropy; //TODO //13 + private Tuple extraEntropy; //13 private Integer protocolMajorVer; //14 private Integer protocolMinorVer; //14 private BigInteger minUtxo; //TODO //15 diff --git a/core/src/main/java/com/bloxbean/cardano/yaci/core/model/serializers/UpdateSerializer.java b/core/src/main/java/com/bloxbean/cardano/yaci/core/model/serializers/UpdateSerializer.java index f8bc91c..3bd32b1 100644 --- a/core/src/main/java/com/bloxbean/cardano/yaci/core/model/serializers/UpdateSerializer.java +++ b/core/src/main/java/com/bloxbean/cardano/yaci/core/model/serializers/UpdateSerializer.java @@ -2,12 +2,12 @@ import co.nstant.in.cbor.model.*; import com.bloxbean.cardano.client.crypto.Blake2bUtil; -import com.bloxbean.cardano.client.util.Tuple; import com.bloxbean.cardano.yaci.core.model.ProtocolParamUpdate; import com.bloxbean.cardano.yaci.core.model.Update; import com.bloxbean.cardano.yaci.core.protocol.Serializer; import com.bloxbean.cardano.yaci.core.util.CborSerializationUtil; import com.bloxbean.cardano.yaci.core.util.HexUtil; +import com.bloxbean.cardano.yaci.core.util.Tuple; import java.math.BigDecimal; import java.math.BigInteger; @@ -90,7 +90,7 @@ public ProtocolParamUpdate getProtocolParams(Map genesisProtocolParamsMap) { itemDI = genesisProtocolParamsMap.get(new UnsignedInteger(12)); BigDecimal decentralizationParam = itemDI != null ? toRationalNumber(itemDI) : null; - String extraEntropy = null; + Tuple extraEntropy = null; // $nonce /= [ 0 // 1, bytes .size 32 ] itemDI = genesisProtocolParamsMap.get(new UnsignedInteger(13)); //Removed if (itemDI != null) { @@ -100,7 +100,7 @@ public ProtocolParamUpdate getProtocolParams(Map genesisProtocolParamsMap) { if (extraEntropyDIList.size() == 2) { extraEntropy_2 = HexUtil.encodeHexString(toBytes(extraEntropyDIList.get(1))); } - extraEntropy = List.of(extraEntropy_1, extraEntropy_2).toString(); + extraEntropy = new Tuple<>(extraEntropy_1, extraEntropy_2); } Integer protocolMajorVersion = null; diff --git a/core/src/main/java/com/bloxbean/cardano/yaci/core/util/Tuple.java b/core/src/main/java/com/bloxbean/cardano/yaci/core/util/Tuple.java new file mode 100644 index 0000000..40b43fc --- /dev/null +++ b/core/src/main/java/com/bloxbean/cardano/yaci/core/util/Tuple.java @@ -0,0 +1,16 @@ +package com.bloxbean.cardano.yaci.core.util; + +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@ToString +@EqualsAndHashCode +public class Tuple { + public T _1; + public Z _2; + + public Tuple(T _1, Z _2) { + this._1 = _1; + this._2 = _2; + } +} diff --git a/gradle.properties b/gradle.properties index a166eb9..81f4f14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group = com.bloxbean.cardano artifactId = yaci -version = 0.2.3.2-SNAPSHOT +version = 0.2.3.3-SNAPSHOT