Skip to content

Commit 8b5b9a8

Browse files
authored
Merge pull request #427 from adabox-aio/master
[Koios] minFeeRefScriptCostPerByte is missing in Koios backend #425
2 parents be53e6b + 638191c commit 8b5b9a8

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosEpochService.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import rest.koios.client.backend.api.epoch.model.EpochParams;
1515

1616
import java.math.BigDecimal;
17+
import java.math.BigInteger;
1718
import java.util.*;
1819
import java.util.concurrent.atomic.AtomicInteger;
1920

@@ -178,6 +179,42 @@ private Result<ProtocolParams> convertToProtocolParams(EpochParams epochParams)
178179
if (epochParams.getCoinsPerUtxoSize() != null) {
179180
protocolParams.setCoinsPerUtxoSize(epochParams.getCoinsPerUtxoSize());
180181
}
182+
if (epochParams.getDvtPPNetworkGroup() != null) {
183+
protocolParams.setDvtPPNetworkGroup(epochParams.getDvtPPNetworkGroup());
184+
}
185+
if (epochParams.getDvtPPEconomicGroup() != null) {
186+
protocolParams.setDvtPPEconomicGroup(epochParams.getDvtPPEconomicGroup());
187+
}
188+
if (epochParams.getDvtPPTechnicalGroup() != null) {
189+
protocolParams.setDvtPPTechnicalGroup(epochParams.getDvtPPTechnicalGroup());
190+
}
191+
if (epochParams.getDvtPPGovGroup() != null) {
192+
protocolParams.setDvtPPGovGroup(epochParams.getDvtPPGovGroup());
193+
}
194+
if (epochParams.getDvtTreasuryWithdrawal() != null) {
195+
protocolParams.setDvtTreasuryWithdrawal(epochParams.getDvtTreasuryWithdrawal());
196+
}
197+
if (epochParams.getCommitteeMinSize() != null) {
198+
protocolParams.setCommitteeMinSize(epochParams.getCommitteeMinSize());
199+
}
200+
if (epochParams.getCommitteeMaxTermLength() != null) {
201+
protocolParams.setCommitteeMaxTermLength(epochParams.getCommitteeMaxTermLength());
202+
}
203+
if (epochParams.getGovActionLifetime() != null) {
204+
protocolParams.setGovActionLifetime(epochParams.getGovActionLifetime());
205+
}
206+
if (epochParams.getGovActionDeposit() != null) {
207+
protocolParams.setGovActionDeposit(new BigInteger(epochParams.getGovActionDeposit()));
208+
}
209+
if (epochParams.getDrepDeposit() != null) {
210+
protocolParams.setDrepDeposit(new BigInteger(epochParams.getDrepDeposit()));
211+
}
212+
if (epochParams.getDrepActivity() != null) {
213+
protocolParams.setDrepActivity(epochParams.getDrepActivity());
214+
}
215+
if (epochParams.getMinFeeRefScriptCostPerByte() != null) {
216+
protocolParams.setMinFeeRefScriptCostPerByte(epochParams.getMinFeeRefScriptCostPerByte());
217+
}
181218
return Result.success("OK").withValue(protocolParams).code(200);
182219
}
183220

@@ -197,6 +234,8 @@ private Map<String, Map<String, Long>> convertToCostModels(JsonNode costModelsJs
197234
Map<String, Long> plutusV1CostModelsMap = new HashMap<>();
198235
final AtomicInteger plutusV2IndexHolder = new AtomicInteger();
199236
Map<String, Long> plutusV2CostModelsMap = new HashMap<>();
237+
final AtomicInteger plutusV3IndexHolder = new AtomicInteger();
238+
Map<String, Long> plutusV3CostModelsMap = new HashMap<>();
200239
result.forEach((key, value) -> {
201240
if (key.equals("PlutusV1")) {
202241
value.forEach(aLong -> {
@@ -211,6 +250,13 @@ private Map<String, Map<String, Long>> convertToCostModels(JsonNode costModelsJs
211250
});
212251
res.put(key, plutusV2CostModelsMap);
213252
}
253+
// else if (key.equals("PlutusV3")) {
254+
// value.forEach(aLong -> {
255+
// final int index = plutusV3IndexHolder.getAndIncrement();
256+
// plutusV3CostModelsMap.put(PlutusOps.getOperations(3).get(index), aLong);
257+
// });
258+
// res.put(key, plutusV3CostModelsMap);
259+
// } TODO Uncomment after adding V3_OPS
214260
});
215261
} catch (JsonProcessingException ignored) {}
216262
return res;

integration-test/src/it/java/com/bloxbean/cardano/client/backend/api/EpochServiceIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void testGetProtocolParameters() throws ApiException {
6363
System.out.println(JsonUtil.getPrettyJson(protocolParams));
6464

6565
assertThat(protocolParams, notNullValue());
66-
assertThat(protocolParams.getMinUtxo(), is("34482"));
66+
assertThat(protocolParams.getMinUtxo(), is("0"));
6767
assertThat(protocolParams.getPoolDeposit(), is("500000000"));
6868
}
6969

plutus/src/main/java/com/bloxbean/cardano/client/plutus/util/PlutusOps.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
import java.util.stream.Collectors;
1111

1212
public class PlutusOps {
13-
private static ObjectMapper objectMapper = new ObjectMapper();
13+
14+
private static final ObjectMapper objectMapper = new ObjectMapper();
1415
private static List<String> V1_OPS;
1516
private static List<String> V2_OPS;
1617

17-
private static String PLUTUS_V1_COSTS = "{\n" +
18+
private static final String PLUTUS_V1_COSTS = "{\n" +
1819
" \"addInteger-cpu-arguments-intercept\": 205665,\n" +
1920
" \"addInteger-cpu-arguments-slope\": 812,\n" +
2021
" \"addInteger-memory-arguments-intercept\": 1,\n" +
@@ -183,7 +184,7 @@ public class PlutusOps {
183184
" \"verifyEd25519Signature-memory-arguments\": 10\n" +
184185
" }";
185186

186-
private static String PLUTUS_V2_COSTS = " {\n" +
187+
private static final String PLUTUS_V2_COSTS = " {\n" +
187188
" \"addInteger-cpu-arguments-intercept\": 205665,\n" +
188189
" \"addInteger-cpu-arguments-slope\": 812,\n" +
189190
" \"addInteger-memory-arguments-intercept\": 1,\n" +

0 commit comments

Comments
 (0)