From 45b686df5f765b1cdffb8d4a440013a7d60cb19b Mon Sep 17 00:00:00 2001 From: Dudi Edri Date: Mon, 2 Sep 2024 19:14:51 +0300 Subject: [PATCH] Koios Java Client Alignment with v1.19.0 + Governance Endpoints --- .../blockfrost/service/BFBackendService.java | 5 + backend-modules/koios/build.gradle | 3 + .../koios/it/KoiosGovernanceServiceIT.java | 146 +++++++++++++++ .../backend/koios/KoiosBackendService.java | 5 + .../backend/koios/KoiosGovernanceService.java | 168 ++++++++++++++++++ .../backend/koios/KoiosScriptService.java | 1 - .../koios/mapper/GovernanceMapper.java | 39 ++++ .../ogmios/http/OgmiosBackendService.java | 5 + .../websocket/Ogmios5BackendService.java | 5 + .../client/backend/api/BackendService.java | 7 + .../client/backend/api/GovernanceService.java | 148 +++++++++++++++ .../client/backend/model/CommitteeInfo.java | 49 +++++ .../client/backend/model/CommitteeMember.java | 51 ++++++ .../client/backend/model/CommitteeVote.java | 57 ++++++ .../cardano/client/backend/model/DRep.java | 37 ++++ .../client/backend/model/DRepDelegator.java | 42 +++++ .../backend/model/DRepEpochSummary.java | 32 ++++ .../client/backend/model/DRepInfo.java | 67 +++++++ .../client/backend/model/DRepMetadata.java | 67 +++++++ .../client/backend/model/DRepUpdate.java | 73 ++++++++ .../client/backend/model/DRepVote.java | 57 ++++++ .../client/backend/model/PoolVote.java | 57 ++++++ .../client/backend/model/Proposal.java | 128 +++++++++++++ .../client/backend/model/ProposalVote.java | 57 ++++++ .../backend/model/ProposalVotingSummary.java | 107 +++++++++++ .../client/backend/model/TxWithdrawal.java | 29 +++ build.gradle | 1 - gradle/libs.versions.toml | 2 +- 28 files changed, 1442 insertions(+), 3 deletions(-) create mode 100644 backend-modules/koios/src/it/java/com/bloxbean/cardano/client/backend/koios/it/KoiosGovernanceServiceIT.java create mode 100644 backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosGovernanceService.java create mode 100644 backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/mapper/GovernanceMapper.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/api/GovernanceService.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeInfo.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeMember.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeVote.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRep.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepDelegator.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepEpochSummary.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepInfo.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepMetadata.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepUpdate.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepVote.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/PoolVote.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/Proposal.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVote.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVotingSummary.java create mode 100644 backend/src/main/java/com/bloxbean/cardano/client/backend/model/TxWithdrawal.java diff --git a/backend-modules/blockfrost/src/main/java/com/bloxbean/cardano/client/backend/blockfrost/service/BFBackendService.java b/backend-modules/blockfrost/src/main/java/com/bloxbean/cardano/client/backend/blockfrost/service/BFBackendService.java index f6ffa4f1..6aa7b69a 100644 --- a/backend-modules/blockfrost/src/main/java/com/bloxbean/cardano/client/backend/blockfrost/service/BFBackendService.java +++ b/backend-modules/blockfrost/src/main/java/com/bloxbean/cardano/client/backend/blockfrost/service/BFBackendService.java @@ -62,4 +62,9 @@ public MetadataService getMetadataService() { public ScriptService getScriptService() { return new BFScriptService(getBaseUrl(), getProjectId()); } + + @Override + public GovernanceService getGovernanceService() { + throw new UnsupportedOperationException("Not supported yet"); + } } diff --git a/backend-modules/koios/build.gradle b/backend-modules/koios/build.gradle index 52d2e97f..a2e78d5c 100644 --- a/backend-modules/koios/build.gradle +++ b/backend-modules/koios/build.gradle @@ -9,6 +9,9 @@ dependencies { exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core' exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations ' } + + implementation 'org.mapstruct:mapstruct:1.5.5.Final' + annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final' } publishing { diff --git a/backend-modules/koios/src/it/java/com/bloxbean/cardano/client/backend/koios/it/KoiosGovernanceServiceIT.java b/backend-modules/koios/src/it/java/com/bloxbean/cardano/client/backend/koios/it/KoiosGovernanceServiceIT.java new file mode 100644 index 00000000..9cb162d1 --- /dev/null +++ b/backend-modules/koios/src/it/java/com/bloxbean/cardano/client/backend/koios/it/KoiosGovernanceServiceIT.java @@ -0,0 +1,146 @@ +package com.bloxbean.cardano.client.backend.koios.it; + +import com.bloxbean.cardano.client.api.exception.ApiException; +import com.bloxbean.cardano.client.api.model.Result; +import com.bloxbean.cardano.client.backend.api.GovernanceService; +import com.bloxbean.cardano.client.backend.model.*; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.List; + +@Slf4j +class KoiosGovernanceServiceIT extends KoiosBaseTest { + + private GovernanceService governanceService; + + @BeforeEach + public void setup() { + governanceService = backendService.getGovernanceService(); + } + + @Test + void getDRepsEpochSummaryTest() throws ApiException { + Integer epochNo = 31; // Example epoch number + Result> result = governanceService.getDRepsEpochSummary(epochNo); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps Epoch Summary: " + result.getValue()); + } + + @Test + void getDRepsListTest() throws ApiException { + Result> result = governanceService.getDRepsList(); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps List: " + result.getValue()); + } + + @Test + void getDRepsInfoTest() throws ApiException { + List drepIds = List.of("drep1kxtwaqtayj6vklc57u93xayjvkwgvefh8drscqp5a5y6jz7m6rd", "drep14x62vyme8l8dkhvxg6rauc6vpcd2va9fquz8k3jstsqczwlvqqh"); + Result> result = governanceService.getDRepsInfo(drepIds); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps Info: " + result.getValue()); + } + + @Test + void getDRepsMetadataTest() throws ApiException { + List drepIds = List.of("drep1kxtwaqtayj6vklc57u93xayjvkwgvefh8drscqp5a5y6jz7m6rd", "drep14x62vyme8l8dkhvxg6rauc6vpcd2va9fquz8k3jstsqczwlvqqh"); + Result> result = governanceService.getDRepsMetadata(drepIds); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps Metadata: " + result.getValue()); + } + + @Test + void getDRepsUpdatesTest() throws ApiException { + String drepId = "drep1kxtwaqtayj6vklc57u93xayjvkwgvefh8drscqp5a5y6jz7m6rd"; + Result> result = governanceService.getDRepsUpdates(drepId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps Updates: " + result.getValue()); + } + + @Test + void getDRepsVotesTest() throws ApiException { + String drepId = "drep1kxtwaqtayj6vklc57u93xayjvkwgvefh8drscqp5a5y6jz7m6rd"; + Result> result = governanceService.getDRepsVotes(drepId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps Votes: " + result.getValue()); + } + + @Test + void getDRepsDelegatorsTest() throws ApiException { + String drepId = "drep1kxtwaqtayj6vklc57u93xayjvkwgvefh8drscqp5a5y6jz7m6rd"; + Result> result = governanceService.getDRepsDelegators(drepId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("DReps Delegators: " + result.getValue()); + } + + @Test + void getCommitteeInformationTest() throws ApiException { + Result> result = governanceService.getCommitteeInformation(); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Committee Information: " + result.getValue()); + } + + @Test + void getCommitteeVotesTest() throws ApiException { + String ccHotId = "cc_hot1qgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvcdjk7"; + Result> result = governanceService.getCommitteeVotes(ccHotId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Committee Votes: " + result.getValue()); + } + + @Test + void getProposalListTest() throws ApiException { + Result> result = governanceService.getProposalList(); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Proposal List: " + result.getValue()); + } + + @Test + void getVoterProposalsTest() throws ApiException { + String voterId = "drep1kxtwaqtayj6vklc57u93xayjvkwgvefh8drscqp5a5y6jz7m6rd"; + Result> result = governanceService.getVoterProposals(voterId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Voter Proposals: " + result.getValue()); + } + + @Test + void getProposalVotingSummaryTest() throws ApiException { + String proposalId = "gov_action1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpzklpgpf"; + Result> result = governanceService.getProposalVotingSummary(proposalId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Proposal Voting Summary: " + result.getValue()); + } + + @Test + void getProposalVotesTest() throws ApiException { + String proposalId = "gov_action1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqpzklpgpf"; + Result> result = governanceService.getProposalVotes(proposalId); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Proposal Votes: " + result.getValue()); + } + + @Test + void getPoolVotesTest() throws ApiException { + String poolBech32 = "pool1x4p3cwemsm356vpxnjwuud7w76jz64hyss729zp7xa6wuey6yr9"; + Result> result = governanceService.getPoolVotes(poolBech32); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + System.out.println("Pool Votes: " + result.getValue()); + } +} diff --git a/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosBackendService.java b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosBackendService.java index 54a4b87d..b109548c 100644 --- a/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosBackendService.java +++ b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosBackendService.java @@ -86,4 +86,9 @@ public MetadataService getMetadataService() { public ScriptService getScriptService() { return new KoiosScriptService(backendServiceImpl.getScriptService(), backendServiceImpl.getTransactionsService()); } + + @Override + public GovernanceService getGovernanceService() { + return new KoiosGovernanceService(backendServiceImpl.getGovernanceService()); + } } diff --git a/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosGovernanceService.java b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosGovernanceService.java new file mode 100644 index 00000000..6c4a3225 --- /dev/null +++ b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosGovernanceService.java @@ -0,0 +1,168 @@ +package com.bloxbean.cardano.client.backend.koios; + +import com.bloxbean.cardano.client.api.exception.ApiException; +import com.bloxbean.cardano.client.api.model.Result; +import com.bloxbean.cardano.client.backend.api.GovernanceService; +import com.bloxbean.cardano.client.backend.koios.mapper.GovernanceMapper; +import com.bloxbean.cardano.client.backend.model.*; + +import java.util.List; +import java.util.function.Function; + +/** + * Koios Governance Service + */ +public class KoiosGovernanceService implements GovernanceService { + + private final rest.koios.client.backend.api.governance.GovernanceService governanceService; + private final GovernanceMapper mapper = GovernanceMapper.INSTANCE; + + public KoiosGovernanceService(rest.koios.client.backend.api.governance.GovernanceService governanceService) { + this.governanceService = governanceService; + } + + @Override + public Result> getDRepsEpochSummary(Integer epochNo) throws ApiException { + try { + rest.koios.client.backend.api.base.Result> result = governanceService.getDRepsEpochSummary(epochNo, null); + return map(result, mapper::mapToDRepEpochSummaryList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getDRepsList() throws ApiException { + try { + return map(governanceService.getDRepsList(null), mapper::mapToDRepList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getDRepsInfo(List drepIds) throws ApiException { + try { + return map(governanceService.getDRepsInfo(drepIds, null), mapper::mapToDRepInfoList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getDRepsMetadata(List drepIds) throws ApiException { + try { + return map(governanceService.getDRepsMetadata(drepIds, null), mapper::mapToDRepMetadataList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getDRepsUpdates(String drepId) throws ApiException { + try { + return map(governanceService.getDRepsUpdates(drepId, null), mapper::mapToDRepUpdateList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getDRepsVotes(String drepId) throws ApiException { + try { + return map(governanceService.getDRepsVotes(drepId, null), mapper::mapToDRepVoteList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getDRepsDelegators(String drepId) throws ApiException { + try { + return map(governanceService.getDRepsDelegators(drepId, null), mapper::mapToDRepDelegatorList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getCommitteeInformation() throws ApiException { + try { + rest.koios.client.backend.api.base.Result> result = governanceService.getCommitteeInformation(null); + return map(result, mapper::mapToCommitteeInfoList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getCommitteeVotes(String ccHotId) throws ApiException { + try { + return map(governanceService.getCommitteeVotes(ccHotId, null), mapper::mapToCommitteeVoteList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getProposalList() throws ApiException { + try { + return map(governanceService.getProposalList(null), mapper::mapToProposalList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getVoterProposals(String voterId) throws ApiException { + try { + return map(governanceService.getVoterProposals(voterId, null), mapper::mapToProposalList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getProposalVotingSummary(String proposalId) throws ApiException { + try { + return map(governanceService.getProposalVotingSummary(proposalId, null), mapper::mapToProposalVotingSummaryList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getProposalVotes(String proposalId) throws ApiException { + try { + return map(governanceService.getProposalVotes(proposalId, null), mapper::mapToProposalVoteList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getPoolVotes(String poolBech32) throws ApiException { + try { + return map(governanceService.getPoolVotes(poolBech32, null), mapper::mapToPoolVoteList); + } catch (rest.koios.client.backend.api.base.exception.ApiException e) { + throw new ApiException(e.getMessage(), e); + } + } + + /** + * Utility method to map a KoiosResult to the Result used by this API. + * + * @param koiosResult The result from Koios API + * @param mapperFunc The mapping function to convert Koios model to API model + * @param The type of data in the Koios result + * @param The type of data in the mapped result + * @return The mapped result + */ + private Result map(rest.koios.client.backend.api.base.Result koiosResult, Function mapperFunc) { + if (koiosResult.isSuccessful()) { + return Result.success("OK").withValue(mapperFunc.apply(koiosResult.getValue())); + } else { + return Result.error(koiosResult.getResponse()).code(koiosResult.getCode()); + } + } +} diff --git a/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosScriptService.java b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosScriptService.java index 26baafbf..99769db2 100644 --- a/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosScriptService.java +++ b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/KoiosScriptService.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.databind.JsonNode; import rest.koios.client.backend.api.script.ScriptService; import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; import rest.koios.client.backend.api.script.model.PlutusScript; import rest.koios.client.backend.api.script.model.ScriptInfo; import rest.koios.client.backend.api.transactions.TransactionsService; diff --git a/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/mapper/GovernanceMapper.java b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/mapper/GovernanceMapper.java new file mode 100644 index 00000000..ee32b48b --- /dev/null +++ b/backend-modules/koios/src/main/java/com/bloxbean/cardano/client/backend/koios/mapper/GovernanceMapper.java @@ -0,0 +1,39 @@ +package com.bloxbean.cardano.client.backend.koios.mapper; + +import com.bloxbean.cardano.client.backend.model.*; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +@Mapper +public interface GovernanceMapper { + + GovernanceMapper INSTANCE = Mappers.getMapper(GovernanceMapper.class); + + List mapToDRepEpochSummaryList(List dRepEpochSummaryList); + + List mapToDRepList(List dRepList); + + List mapToDRepInfoList(List dRepInfoList); + + List mapToDRepMetadataList(List dRepMetadataList); + + List mapToDRepUpdateList(List dRepUpdateList); + + List mapToDRepVoteList(List dRepVoteList); + + List mapToDRepDelegatorList(List dRepDelegators); + + List mapToCommitteeInfoList(List committeeInfo); + + List mapToCommitteeVoteList(List committeeVoteList); + + List mapToProposalList(List proposalList); + + List mapToProposalVotingSummaryList(List proposalVotingSummaryList); + + List mapToProposalVoteList(List proposalVoteList); + + List mapToPoolVoteList(List poolVoteList); +} diff --git a/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/http/OgmiosBackendService.java b/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/http/OgmiosBackendService.java index b3464609..2dc53770 100644 --- a/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/http/OgmiosBackendService.java +++ b/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/http/OgmiosBackendService.java @@ -65,4 +65,9 @@ public MetadataService getMetadataService() { public ScriptService getScriptService() { throw new UnsupportedOperationException("Not supported yet"); } + + @Override + public GovernanceService getGovernanceService() { + throw new UnsupportedOperationException("Not supported yet"); + } } diff --git a/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/websocket/Ogmios5BackendService.java b/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/websocket/Ogmios5BackendService.java index 50f5389c..045e1547 100644 --- a/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/websocket/Ogmios5BackendService.java +++ b/backend-modules/ogmios/src/main/java/com/bloxbean/cardano/client/backend/ogmios/websocket/Ogmios5BackendService.java @@ -85,4 +85,9 @@ public MetadataService getMetadataService() { public ScriptService getScriptService() { throw new UnsupportedOperationException("Not supported yet"); } + + @Override + public GovernanceService getGovernanceService() { + throw new UnsupportedOperationException("Not supported yet"); + } } diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/api/BackendService.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/api/BackendService.java index 98fb3f41..d7ce6b36 100644 --- a/backend/src/main/java/com/bloxbean/cardano/client/backend/api/BackendService.java +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/api/BackendService.java @@ -86,6 +86,13 @@ public interface BackendService { */ ScriptService getScriptService(); + /** + * Get GovernanceService + * + * @return {@link GovernanceService} + */ + GovernanceService getGovernanceService(); + /** * Get TransactionHelperService * diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/api/GovernanceService.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/api/GovernanceService.java new file mode 100644 index 00000000..544a4a29 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/api/GovernanceService.java @@ -0,0 +1,148 @@ +package com.bloxbean.cardano.client.backend.api; + +import com.bloxbean.cardano.client.api.exception.ApiException; +import com.bloxbean.cardano.client.api.model.Result; +import com.bloxbean.cardano.client.backend.model.*; + +import java.util.List; + +public interface GovernanceService { + + /** + * DReps Epoch Summary + * Summary of voting power and DRep count for each epoch + * + * @param epochNo Epoch Number to fetch details for + * @return Summary of voting power and DRep count for each epoch + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsEpochSummary(Integer epochNo) throws ApiException; + + /** + * DReps List + * List of all active delegated representatives (DReps) + * + * @return List of all active delegated representatives (DReps) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsList() throws ApiException; + + /** + * DReps Info + * Get detailed information about requested delegated representatives (DReps) + * + * @param drepIds List of DRep Ids + * @return Detailed information about requested delegated representatives (DReps) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsInfo(List drepIds) throws ApiException; + + /** + * DReps Metadata + * List metadata for requested delegated representatives (DReps) + * + * @param drepIds List of DRep Ids + * @return Metadata for requested delegated representatives (DReps) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsMetadata(List drepIds) throws ApiException; + + /** + * DReps Updates + * List of updates for requested (or all) delegated representatives (DReps) + * + * @param drepId DRep ID in bech32 format + * @return List of updates for requested (or all) delegated representatives (DReps) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsUpdates(String drepId) throws ApiException; + + /** + * DReps Votes + * List of all votes casted by requested delegated representative (DRep) + * + * @param drepId DRep ID in bech32 format + * @return List of all votes casted by requested delegated representative (DRep) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsVotes(String drepId) throws ApiException; + + /** + * DReps Delegators + * List of all delegators to requested delegated representative (DRep) + * + * @param drepId DRep ID in bech32 format + * @return List of all delegators to requested delegated representative (DRep) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsDelegators(String drepId) throws ApiException; + + /** + * Committee Information + * Information about active committee and its members + * + * @return Current governance committee information + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getCommitteeInformation() throws ApiException; + + /** + * Committee Votes + * List of all votes casted by a given committee member or collective + * + * @param ccHotId Committee member hot key ID in Bech32 format (CIP-5 | CIP-129) + + * @return List of all votes casted by a given committee member or collective + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getCommitteeVotes(String ccHotId) throws ApiException; + + /** + * Proposals List + * List of all governance proposals + * + * @return List of all governance action proposals + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getProposalList() throws ApiException; + + /** + * Voter's Proposal List + * List of all governance proposals for specified DRep, SPO or Committee credential + * + * @param voterId Voter ID (DRep, SPO, Committee Member) in Bech32 format (CIP-5 | CIP-129) + * @return List of all governance action proposals for the specified voter + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getVoterProposals(String voterId) throws ApiException; + + /** + * Proposal Voting Summary + * Summary of votes for a given proposal + * + * @param proposalId Government proposal ID in CIP-129 Bech32 format + * @return Summary of votes for the given proposal + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getProposalVotingSummary(String proposalId) throws ApiException; + + /** + * Proposal Votes + * List of all votes cast on a specified governance action + * + * @param proposalId Government proposal ID in CIP-129 Bech32 format + * @return List of all votes cast on the specified governance action + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getProposalVotes(String proposalId) throws ApiException; + + /** + * Pool Votes + * List of all votes casted by a pool + * + * @param poolBech32 Pool ID in bech32 format + * @return List of all votes casted by the requested pool + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolVotes(String poolBech32) throws ApiException; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeInfo.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeInfo.java new file mode 100644 index 00000000..ba6ecc15 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeInfo.java @@ -0,0 +1,49 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +import java.util.List; + +/** + * Committee Info + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class CommitteeInfo { + + /** + * Proposal Action ID in accordance with CIP-129 format + */ + private String proposalId; + + /** + * Hash identifier of the transaction + */ + private String proposalTxHash; + + /** + * Index of governance proposal in transaction + */ + private Integer proposalIndex; + + /** + * Quorum numerator for governance proposal + */ + private Integer quorumNumerator; + + /** + * Quorum denominator for governance proposal + */ + private Integer quorumDenominator; + + /** + * Array of all members part of active governance committee + */ + private List members; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeMember.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeMember.java new file mode 100644 index 00000000..ee16d0a3 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeMember.java @@ -0,0 +1,51 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Committee Member + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class CommitteeMember { + + /** + * Member authentication status (authorized, not_authorized, resigned) + */ + private String status; + + private String ccHotd; + + private String ccColdId; + + /** + * Committee member key hash from last valid hot key authorization certificate in hex format (null if not applicable) + */ + private String ccHotHex; + + /** + * Committee member cold key hash in hex format + */ + private String ccColdHex; + + /** + * Epoch number in which the committee member vote rights expire + */ + private Integer expirationEpoch; + + /** + * Flag which shows if this credential is a script hash (null if not applicable) + */ + private Boolean ccHotHasScript; + + /** + * Flag which shows if this credential is a script hash + */ + private Boolean ccColdHasScript; +} \ No newline at end of file diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeVote.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeVote.java new file mode 100644 index 00000000..9757bba4 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/CommitteeVote.java @@ -0,0 +1,57 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Committee Vote + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class CommitteeVote { + + /** + * Proposal Action ID in accordance with CIP-129 format + */ + private String proposalId; + + /** + * Hash identifier of the proposal transaction + */ + private String proposalTxHash; + + /** + * Index of governance proposal in transaction + */ + private Integer proposalIndex; + + /** + * Hash identifier of the vote transaction + */ + private String voteTxHash; + + /** + * UNIX timestamp of the block + */ + private Long blockTime; + + /** + * Actual Vote casted (Yes, No, Abstain) + */ + private String vote; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRep.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRep.java new file mode 100644 index 00000000..70f6ddc2 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRep.java @@ -0,0 +1,37 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRep { + + /** + * DRep ID in CIP-129 bech32 format + */ + private String drepId; + + /** + * DRep ID in hex format + */ + private String hex; + + /** + * Flag which shows if this credential is a script hash + */ + private Boolean hasScript; + + /** + * Flag to show if the DRep is currently registered + */ + private Boolean registered; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepDelegator.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepDelegator.java new file mode 100644 index 00000000..49b72a98 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepDelegator.java @@ -0,0 +1,42 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Delegator + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepDelegator { + + /** + * Cardano staking address (reward account) in bech32 format + */ + private String stakeAddress; + + /** + * Cardano staking address (reward account) in hex format + */ + private String stakeAddressHex; + + /** + * Script hash in case the stake address is locked by a script (null if not applicable) + */ + private String scriptHash; + + /** + * Epoch when vote delegation was made + */ + private Integer epochNo; + + /** + * Total balance of the account including UTxO, rewards, and MIRs (in number) + */ + private String amount; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepEpochSummary.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepEpochSummary.java new file mode 100644 index 00000000..42366b71 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepEpochSummary.java @@ -0,0 +1,32 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Epoch Summary + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepEpochSummary { + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * The total amount of voting power between all DReps including pre-defined roles for the epoch + */ + private String amount; + + /** + * The total number of DReps with vote power for the epoch + */ + private Integer dreps; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepInfo.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepInfo.java new file mode 100644 index 00000000..d8be1464 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepInfo.java @@ -0,0 +1,67 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Information + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepInfo { + + /** + * DRep ID in CIP-129 bech32 format + */ + private String drepId; + + /** + * DRep ID in hex format + */ + private String hex; + + /** + * Flag which shows if this credential is a script hash + */ + private Boolean hasScript; + + /** + * Flag to show if the DRep is currently registered + */ + private Boolean registered; + + /** + * DRep's registration deposit in number (null if not applicable) + */ + private String deposit; + + /** + * Flag to show if the DRep is active (i.e., not expired) + */ + private Boolean active; + + /** + * After which epoch DRep is considered inactive (null if not applicable) + */ + private Integer expiresEpochNo; + + /** + * The total amount of voting power this DRep is delegated + */ + private String amount; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String url; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String hash; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepMetadata.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepMetadata.java new file mode 100644 index 00000000..9ad7d4ae --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepMetadata.java @@ -0,0 +1,67 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Metadata + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepMetadata { + + /** + * DRep ID in CIP-129 bech32 format + */ + private String drepId; + + /** + * DRep ID in hex format + */ + private String hex; + + /** + * Flag which shows if this credential is a script hash + */ + private Boolean hasScript; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String url; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String hash; + + /** + * The raw bytes of the payload (null if not applicable) + */ + private String json; + + /** + * A warning that occurred while validating the metadata (null if not applicable) + */ + private String warning; + + /** + * The language described in the context of the metadata as per CIP-100 (null if not applicable) + */ + private String language; + + /** + * Comment attached to the metadata (null if not applicable) + */ + private String comment; + + /** + * Indicate whether data is invalid + */ + private Boolean isValid; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepUpdate.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepUpdate.java new file mode 100644 index 00000000..da981db2 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepUpdate.java @@ -0,0 +1,73 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Update + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepUpdate { + + /** + * DRep ID in CIP-129 bech32 format + */ + private String drepId; + + /** + * DRep ID in hex format + */ + private String hex; + + /** + * Flag which shows if this credential is a script hash + */ + private Boolean hasScript; + + /** + * Hash identifier of the transaction + */ + private String updateTxHash; + + /** + * The index of this certificate within the transaction + */ + private Integer certIndex; + + /** + * UNIX timestamp of the block + */ + private Long blockTime; + + /** + * Effective action for this DRep Update certificate (updated, registered, deregistered) + */ + private String action; + + /** + * DRep's registration deposit in number (null if not applicable) + */ + private String deposit; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; + + /** + * JSON object containing the metadata payload + */ + private JsonNode metaJson; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepVote.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepVote.java new file mode 100644 index 00000000..65ac5ec7 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/DRepVote.java @@ -0,0 +1,57 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Vote + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepVote { + + /** + * Proposal Action ID in accordance with CIP-129 format + */ + private String proposalId; + + /** + * Hash identifier of the proposal transaction + */ + private String proposalTxHash; + + /** + * Index of governance proposal in transaction + */ + private Integer proposalIndex; + + /** + * Hash identifier of the vote transaction + */ + private String voteTxHash; + + /** + * UNIX timestamp of the block + */ + private Long blockTime; + + /** + * Actual Vote casted (Yes, No, Abstain) + */ + private String vote; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/PoolVote.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/PoolVote.java new file mode 100644 index 00000000..2e7820bc --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/PoolVote.java @@ -0,0 +1,57 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Pool Vote + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class PoolVote { + + /** + * Proposal Action ID in accordance with CIP-129 format + */ + private String proposalId; + + /** + * Hash identifier of the proposal transaction + */ + private String proposalTxHash; + + /** + * Index of governance proposal in transaction + */ + private Integer proposalIndex; + + /** + * Hash identifier of the vote transaction + */ + private String voteTxHash; + + /** + * UNIX timestamp of the block + */ + private Long blockTime; + + /** + * Actual Vote casted (Yes, No, Abstain) + */ + private String vote; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/Proposal.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/Proposal.java new file mode 100644 index 00000000..121cb427 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/Proposal.java @@ -0,0 +1,128 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Proposal + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class Proposal { + + /** + * UNIX timestamp of the block + */ + private Long blockTime; + + /** + * Proposal Action ID in accordance with CIP-129 format + */ + private String proposalId; + + /** + * Hash identifier of the transaction + */ + private String proposalTxHash; + + /** + * Index of governance proposal in transaction + */ + private Integer proposalIndex; + + /** + * Proposal Action Type (ParameterChange, HardForkInitiation, TreasuryWithdrawals, NoConfidence, NewCommittee, NewConstitution, InfoAction) + */ + private String proposalType; + + /** + * Description for Proposal Action + */ + private JsonNode proposalDescription; + + /** + * DRep's registration deposit in number (null if not applicable) + */ + private String deposit; + + /** + * The StakeAddress index of the reward address to receive the deposit when it is repaid + */ + private String returnAddress; + + /** + * Shows the epoch at which this governance action was proposed + */ + private Integer proposedEpoch; + + /** + * If not null, then this proposal has been ratified at the specified epoch + */ + private Integer ratifiedEpoch; + + /** + * If not null, then this proposal has been enacted at the specified epoch + */ + private Integer enactedEpoch; + + /** + * If not null, then this proposal has been dropped (expired/enacted) at the specified epoch + */ + private Integer droppedEpoch; + + /** + * If not null, then this proposal has been expired at the specified epoch + */ + private Integer expiredEpoch; + + /** + * Shows the epoch at which this governance action is expected to expire + */ + private Integer expiration; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; + + /** + * JSON object containing the metadata payload + */ + private JsonNode metaJson; + + /** + * Comment attached to the metadata (null if not applicable) + */ + private String metaComment; + + /** + * The language described in the context of the metadata as per CIP-100 (null if not applicable) + */ + private String metaLanguage; + + /** + * Indicate whether data is invalid + */ + private Boolean metaIsValid; + + /** + * Object containing the withdrawal details or null if not applicable + */ + private TxWithdrawal withdrawal; + + /** + * Object containing parameter proposal details + */ + private JsonNode paramProposal; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVote.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVote.java new file mode 100644 index 00000000..86410ad0 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVote.java @@ -0,0 +1,57 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Proposal Vote + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class ProposalVote { + + /** + * UNIX timestamp of the block + */ + private Long blockTime; + + /** + * The role of the voter (ConstitutionalCommittee, DRep, SPO) + */ + private String voterRole; + + /** + * Voter's DRep ID (CIP-129 bech32 format), pool ID (bech32 format) or committee hot ID (CIP-129 bech32 format) + */ + private String voterId; + + /** + * Voter's DRep ID, pool ID, or committee hash in hex format + */ + private String voterHex; + + /** + * Flag which shows if this credential is a script hash + */ + private Boolean voterHasScript; + + /** + * Actual Vote casted (Yes, No, Abstain) + */ + private String vote; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVotingSummary.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVotingSummary.java new file mode 100644 index 00000000..b8e346db --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/ProposalVotingSummary.java @@ -0,0 +1,107 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Proposal Voting Summary + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class ProposalVotingSummary { + + /** + * Proposal Action Type (ParameterChange, HardForkInitiation, TreasuryWithdrawals, NoConfidence, NewCommittee, NewConstitution, InfoAction) + */ + private String proposalType; + + /** + * Epoch for which data was collated + */ + private Integer epochNo; + + /** + * Number of 'yes' votes casted by dreps + */ + private Integer drepYesVotesCast; + + /** + * Power of 'yes' votes from dreps + */ + private Integer drepYesVotePower; + + /** + * Percentage of 'yes' votes from dreps + */ + private Double drepYesPct; + + /** + * Number of 'no' votes casted by dreps + */ + private Integer drepNoVotesCast; + + /** + * Power of 'no' votes from dreps + */ + private Integer drepNoVotePower; + + /** + * Percentage of 'no' votes from dreps + */ + private Double drepNoPct; + + /** + * Number of 'yes' votes casted by pools + */ + private Integer poolYesVotesCast; + + /** + * Power of 'yes' votes from pools + */ + private Integer poolYesVotePower; + + /** + * Percentage of 'yes' votes from pools + */ + private Double poolYesPct; + + /** + * Number of 'no' votes casted by pools + */ + private Integer poolNoVotesCast; + + /** + * Power of 'no' votes from pools + */ + private Integer poolNoVotePower; + + /** + * Percentage of 'no' votes from pools + */ + private Double poolNoPct; + + /** + * Number of 'yes' votes casted by committee + */ + private Integer committeeYesVotesCast; + + /** + * Percentage of 'yes' votes from committee + */ + private Double committeeYesPct; + + /** + * Number of 'no' votes casted by committee + */ + private Integer committeeNoVotesCast; + + /** + * Percentage of 'no' votes from committee + */ + private Double committeeNoPct; +} diff --git a/backend/src/main/java/com/bloxbean/cardano/client/backend/model/TxWithdrawal.java b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/TxWithdrawal.java new file mode 100644 index 00000000..608dc9c9 --- /dev/null +++ b/backend/src/main/java/com/bloxbean/cardano/client/backend/model/TxWithdrawal.java @@ -0,0 +1,29 @@ +package com.bloxbean.cardano.client.backend.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * withdrawals within a transaction + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class TxWithdrawal { + + /** + * Withdrawal amount (in lovelaces) + */ + private String amount; + + /** + * List of withdrawals with-in a transaction (if any) + */ + private String stakeAddr; +} diff --git a/build.gradle b/build.gradle index fc5ef6bc..96d746b9 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,6 @@ dependencies { api project(':function') api project(':cip') api project(':quicktx') - } compileJava { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 429a7f8b..e12b6dc9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [libraries] -koios-java = "io.github.cardano-community:koios-java-client:1.18.2" +koios-java = "io.github.cardano-community:koios-java-client:1.19.0" ogmios-java = "io.adabox:ogmios-java-client:1.0.0" slf4j-api = "org.slf4j:slf4j-api:2.0.11"