Skip to content

Commit

Permalink
adding dto objects and move service logic into the paxsdk
Browse files Browse the repository at this point in the history
  • Loading branch information
dekm committed Mar 28, 2024
1 parent 3e26d8b commit bb3f716
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pax-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.unigrid</groupId>
<artifactId>pax-sdk</artifactId>
<version>0.0.17</version>
<version>0.0.18</version>
<packaging>jar</packaging>
<!-- Project Information -->
<name>pax-sdk</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.unigrid.pax.sdk.cosmos.model.dto;

import java.time.Instant;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class UnbondingEntryDTO {
private String account;
private long amount;
private long completionTime;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ of the License (see COPYING and COPYING.addendum).
import com.google.protobuf.Any;
import cosmos.auth.v1beta1.Auth;
import cosmos.auth.v1beta1.QueryOuterClass;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.List;
import java.util.stream.Collectors;
import org.unigrid.pax.sdk.cosmos.SignUtil;
import org.unigrid.pax.sdk.cosmos.model.ApiConfig;
import org.unigrid.pax.sdk.cosmos.model.dto.UnbondingEntryDTO;

@ApplicationScoped
public class UnigridService {

@Inject
Expand Down Expand Up @@ -94,4 +99,22 @@ public long convertBigDecimalInUugd(double amount) {
return (long) result;
}

}
public List<UnbondingEntryDTO> getUnbondingEntries(String address) {
// Stub setup and request preparation
gridnode.gridnode.v1.QueryGrpc.QueryBlockingStub delegateStub = gridnode.gridnode.v1.QueryGrpc.newBlockingStub(grpcService.getChannel());
gridnode.gridnode.v1.QueryOuterClass.QueryUnbondingEntriesRequest unbondingRequest = gridnode.gridnode.v1.QueryOuterClass.QueryUnbondingEntriesRequest.newBuilder()
.setBondingAccountAddress(address)
.build();

// Get the response
gridnode.gridnode.v1.QueryOuterClass.QueryUnbondingEntriesResponse response = delegateStub.unbondingEntries(unbondingRequest);
return response.getUnbondingEntriesList().stream()
.map(protoEntry -> new UnbondingEntryDTO(
protoEntry.getAccount(),
protoEntry.getAmount(),
protoEntry.getCompletionTime()))
.collect(Collectors.toList());

}

}

0 comments on commit bb3f716

Please sign in to comment.