Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.casper.sdk.identifier.entity;
package com.casper.sdk.model.account;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
Expand All @@ -12,7 +12,7 @@
@Setter
@Builder
@AllArgsConstructor
public class AccountHashEntityIdentifier implements EntityIdentifier {
public class AccountHashIdentifier implements AccountIdentifier {

/** Account hash */
@JsonProperty("AccountHash")
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/casper/sdk/model/account/AccountIdentifier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.casper.sdk.model.account;

import com.casper.sdk.identifier.entity.EntityIdentifier;

/**
* Identifier of an account. A public key or account hash.
*
* @author ian@meywood.com
*/
public interface AccountIdentifier extends EntityIdentifier {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.casper.sdk.model.account;

import com.casper.sdk.exception.CasperClientException;
import com.casper.sdk.model.key.PublicKey;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.security.NoSuchAlgorithmException;

/**
* The public key of an account.
*
* @author carl@stormeye.co.uk
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
public class PublicKeyIdentifier implements AccountIdentifier {

/** Public key hash */
@JsonProperty("PublicKey")
private PublicKey publicKey;

public PublicKeyIdentifier(final String hexKey) {
try {
this.publicKey = PublicKey.fromTaggedHexString(hexKey);
} catch (NoSuchAlgorithmException e) {
throw new CasperClientException("Invalid public key bytes", e);
}
}
}
24 changes: 24 additions & 0 deletions src/main/java/com/casper/sdk/model/bid/DelegatorEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.casper.sdk.model.bid;

import com.casper.sdk.model.key.PublicKey;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
* Represents a party delegating their stake to a validator (or "delegatee")
*
* @author ian@meywood.com
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class DelegatorEntry {

@JsonProperty("delegator_public_key")
private PublicKey delegatorPublicKey;
private JsonDelegator delegator;
}
9 changes: 8 additions & 1 deletion src/main/java/com/casper/sdk/model/bid/JsonBid.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.math.BigInteger;
import java.util.List;

import com.casper.sdk.model.key.PublicKey;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.casper.sdk.annotation.ExcludeFromJacocoGeneratedReport;
Expand All @@ -28,6 +29,9 @@
@NoArgsConstructor
public class JsonBid {

@JsonProperty("validator_public_key")
private PublicKey validatorPublicKey;

/**
* The purse that was used for bonding.
*/
Expand All @@ -40,12 +44,15 @@ public class JsonBid {
@JsonProperty("delegation_rate")
private int delegationRate;

@JsonProperty("vesting_schedule")
private VestingSchedule vestingSchedule;

/**
* The delegators
*
* @see JsonDelegator
*/
private List<JsonDelegator> delegators;
private List<DelegatorEntry> delegators;

/**
* Is this an inactive validator?
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/casper/sdk/model/bid/JsonDelegator.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ public class JsonDelegator {
/**
* @see PublicKey
*/
private PublicKey delegatee;
@JsonProperty("validator_public_key")
private PublicKey validatorPublicKey;

/**
* @see PublicKey
*/
@JsonProperty("public_key")
private PublicKey publicKey;
@JsonProperty("delegator_public_key")
private PublicKey delegatorPublicKey;

@JsonProperty("vesting_schedule")
private VestingSchedule vestingSchedule;

/**
* amount
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/com/casper/sdk/model/block/BlockBodyV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import com.casper.sdk.model.common.Digest;
import com.casper.sdk.model.transaction.TransactionCategory;
import com.casper.sdk.model.transaction.TransactionHash;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* V2 of the block body
Expand All @@ -23,10 +28,6 @@ public class BlockBodyV2 extends BlockBody {
@JsonProperty("hash")
private Digest hash;

/** List of Hex-encoded hash digest */
@JsonProperty("deploy_hashes")
private List<Digest> deployHashes;

/** List of Hex-encoded hash digest */
@JsonProperty("transfer_hashes")
private List<Digest> transferHashes;
Expand All @@ -35,5 +36,21 @@ public class BlockBodyV2 extends BlockBody {
private List<List<Long>> rewardedSignatures;

@JsonProperty("transactions")
private Map<TransactionCategory, List<Digest>> transactions;
private Map<TransactionCategory, List<TransactionHash>> transactions;

public List<List<Long>> getRewardedSignatures() {
return rewardedSignatures != null ? rewardedSignatures : Collections.emptyList();
}

public List<Digest> getTransferHashes() {
return transferHashes != null ? transferHashes : Collections.emptyList();
}

@JsonIgnore
public List<Digest> getFlatTransactions() {
return transactions.values()
.stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
@JsonTypeResolver(CLValueResolver.class)
@EqualsAndHashCode(of = {"bytes", "value"})
@JsonPropertyOrder({"cl_type", "bytes", "parsed"})
public abstract class AbstractCLValue<T, P extends AbstractCLType>
implements CasperSerializableObject, CasperDeserializableObject {

Expand All @@ -46,6 +47,7 @@ public abstract class AbstractCLValue<T, P extends AbstractCLType>
@JsonIgnore
private T value;

@SuppressWarnings("LombokGetterMayBeUsed")
public T getValue() {
return this.value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueBool(final Boolean value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/casper/sdk/model/clvalue/CLValueI32.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected String getJsonClType() {

public CLValueI32(final Integer value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/casper/sdk/model/clvalue/CLValueI64.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueI64(final Long value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void setClType(final CLTypeOption clType) {
public CLValueOption(final Optional<AbstractCLValue<?, ?>> value) throws ValueSerializationException {
setChildTypes(value);
this.setValue(value);
this.setParsed(value.map(AbstractCLValue::getParsed).orElse(null));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueString(final String value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected String getJsonClType() {

public CLValueU128(final BigInteger value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(String.valueOf(value));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected String getJsonClType() {

public CLValueU256(final BigInteger value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(String.valueOf(value));
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/casper/sdk/model/clvalue/CLValueU32.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueU32(final Long value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueU512(final BigInteger value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(String.valueOf(value));
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/casper/sdk/model/clvalue/CLValueU64.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueU64(final BigInteger value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(String.valueOf(value));
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/casper/sdk/model/clvalue/CLValueU8.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getJsonClType() {

public CLValueU8(final Byte value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class CLValueURef extends AbstractCLValue<URef, CLTypeURef> {

public CLValueURef(final URef value) throws ValueSerializationException {
this.setValue(value);
this.setParsed(value.getJsonURef());
}

@JsonGetter("cl_type")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/casper/sdk/model/deploy/Deploy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.casper.sdk.model.common.Digest;
import com.casper.sdk.model.deploy.executabledeploy.ExecutableDeployItem;
import com.casper.sdk.model.transaction.AbstractTransaction;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import dev.oak3.sbs4j.SerializerBuffer;
import dev.oak3.sbs4j.exception.ValueSerializationException;
import lombok.*;
Expand All @@ -26,6 +27,7 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonPropertyOrder({"hash", "header", "payment", "session", "approvals"})
public class Deploy extends AbstractTransaction implements CasperSerializableObject {

/** @see DeployHeader */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public class BlockAdded implements EventData {

@JsonProperty("next_era_gas_price")
private int nextEraGasPrice;

public <T extends Block<?,?>> T getBlock() {
//noinspection unchecked
return (T) block;
}
}
Loading