From 597563c4a6877e2587f2858bca211ca70b11fade Mon Sep 17 00:00:00 2001 From: Oleg Koretsky Date: Wed, 28 Aug 2024 15:30:40 +0300 Subject: [PATCH] Make some BakerPoolStatus fields optional --- CHANGELOG.md | 2 ++ .../sdk/ClientV2MapperExtensions.java | 20 ++++++++++++++----- .../responses/poolstatus/BakerPoolStatus.java | 17 ++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72f409eb3..9e5b558fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Added `ProtocolVersion.V7` corresponding to Protocol version 7 - Added `cooldowns` list to `AccountInfo` - Added `availableBalance` to `AccountInfo` +- Made optional the following `BakerPoolStatus` fields: + `bakerEquityCapital`, `delegatedCapital`, `delegatedCapitalCap`, `poolInfo` ## 7.2.0 - Added `MessageSigningDigest` class to generate digests for message signing diff --git a/concordium-sdk/src/main/java/com/concordium/sdk/ClientV2MapperExtensions.java b/concordium-sdk/src/main/java/com/concordium/sdk/ClientV2MapperExtensions.java index 8a44b40ca..d3612785a 100644 --- a/concordium-sdk/src/main/java/com/concordium/sdk/ClientV2MapperExtensions.java +++ b/concordium-sdk/src/main/java/com/concordium/sdk/ClientV2MapperExtensions.java @@ -1243,14 +1243,24 @@ static BakerPoolStatus to(PoolInfoResponse grpcOutput) { return BakerPoolStatus.builder() .bakerId(to(grpcOutput.getBaker())) .bakerAddress(to(grpcOutput.getAddress())) - .bakerEquityCapital(to(grpcOutput.getEquityCapital())) - .delegatedCapital(to(grpcOutput.getDelegatedCapital())) - .delegatedCapitalCap(to(grpcOutput.getDelegatedCapitalCap())) - .poolInfo(to(grpcOutput.getPoolInfo())) + .bakerEquityCapital(grpcOutput.hasEquityCapital() + ? to(grpcOutput.getEquityCapital()) + : null) + .delegatedCapital(grpcOutput.hasDelegatedCapital() + ? to(grpcOutput.getDelegatedCapital()) + : null) + .delegatedCapitalCap(grpcOutput.hasDelegatedCapitalCap() + ? to(grpcOutput.getDelegatedCapitalCap()) + : null) + .poolInfo(grpcOutput.hasPoolInfo() + ? to(grpcOutput.getPoolInfo()) + : null) .bakerStakePendingChange(grpcOutput.hasEquityPendingChange() ? to(grpcOutput.getEquityPendingChange()) : null) - .currentPaydayStatus(grpcOutput.hasCurrentPaydayInfo() ? to(grpcOutput.getCurrentPaydayInfo()) : null) + .currentPaydayStatus(grpcOutput.hasCurrentPaydayInfo() + ? to(grpcOutput.getCurrentPaydayInfo()) + : null) .allPoolTotalCapital(to(grpcOutput.getAllPoolTotalCapital())) .build(); } diff --git a/concordium-sdk/src/main/java/com/concordium/sdk/responses/poolstatus/BakerPoolStatus.java b/concordium-sdk/src/main/java/com/concordium/sdk/responses/poolstatus/BakerPoolStatus.java index 9a17904cc..5d1183a43 100644 --- a/concordium-sdk/src/main/java/com/concordium/sdk/responses/poolstatus/BakerPoolStatus.java +++ b/concordium-sdk/src/main/java/com/concordium/sdk/responses/poolstatus/BakerPoolStatus.java @@ -47,6 +47,7 @@ public class BakerPoolStatus { /** * Any pending change to the baker's stake. + * This is not used from protocol version 7 onwards, as stake changes are immediate. */ private final PendingChange bakerStakePendingChange; @@ -60,6 +61,22 @@ public class BakerPoolStatus { */ private final CCDAmount allPoolTotalCapital; + public Optional getBakerEquityCapital() { + return Optional.ofNullable(bakerEquityCapital); + } + + public Optional getDelegatedCapital() { + return Optional.ofNullable(delegatedCapital); + } + + public Optional getDelegatedCapitalCap() { + return Optional.ofNullable(delegatedCapitalCap); + } + + public Optional getPoolInfo() { + return Optional.ofNullable(poolInfo); + } + public Optional getBakerStakePendingChange() { return Optional.ofNullable(bakerStakePendingChange); }