Skip to content

Commit

Permalink
Merge pull request #335 from /issues/332
Browse files Browse the repository at this point in the history
Issues/332
  • Loading branch information
meywood authored Sep 16, 2024
2 parents eacee23 + f4c2dbc commit 57ba96a
Show file tree
Hide file tree
Showing 19 changed files with 2,167 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* An addressable entity.
* Methods and type signatures supported by a contract.
*
* @author [email protected]
*/
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/com/casper/sdk/model/entity/contract/ByteCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.casper.sdk.model.entity.contract;

import com.casper.sdk.model.key.Tag;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* A container for contract's Wasm bytes
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ByteCode {

/** The type of Byte code */
@JsonProperty("kind")
private ByteCodes kind;
/** Byte code */
@JsonProperty("bytes")
private String bytes;

public enum ByteCodes implements Tag {
/** Empty byte code */
Empty(0),
/** Byte code to be executed with the version 1 Casper execution engine */
V1CasperWasm(1);
private final byte tag;
ByteCodes(final int tag) {
this.tag = (byte) tag;
}
@Override
public byte getByteTag() {
return tag;
}

}
}
25 changes: 25 additions & 0 deletions src/main/java/com/casper/sdk/model/entity/contract/NamedKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.casper.sdk.model.entity.contract;

import com.casper.sdk.model.clvalue.AbstractCLValue;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* A key with a name
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class NamedKey {

@JsonProperty("named_key")
private AbstractCLValue<?,?> namedKey;

@JsonProperty("name")
private AbstractCLValue<?,?> name;

}
48 changes: 48 additions & 0 deletions src/main/java/com/casper/sdk/model/entity/contract/Package.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.casper.sdk.model.entity.contract;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

import java.util.List;

/**
* Package associated with a native contract implementation
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Package {

/** All versions (enabled & disabled) */
@JsonProperty("versions")
private List<Versions> versions;

/** Collection of disabled entity versions.
* The runtime will not permit disabled entity versions to be executed */
@JsonProperty("disabled_versions")
private List<Versions> disabledVersions;

/** Mapping maintaining the set of URefs associated with each "user group".
* This can be used to control access to methods in a particular version of the entity.
* A method is callable by any context which "knows" any of the URefs associated with the method's user group */
@JsonProperty("groups")
private List<String> groups;

/** A flag that determines whether an entity is locked */
@JsonProperty("lock_status")
private PackageStatus lockStatus;

/**
* Determines the lock status of the package
*/
public enum PackageStatus {
// The package is locked and cannot be versioned
Locked,
// The package is unlocked and can be versioned
Unlocked
}
}
26 changes: 26 additions & 0 deletions src/main/java/com/casper/sdk/model/entity/contract/VersionKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.casper.sdk.model.entity.contract;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* Child of {@link Versions}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class VersionKey {

/** Major element of `ProtocolVersion` a `ContractVersion` is compatible with */
@JsonProperty("protocol_version_major")
private int protocolVersionMajor;

/** Automatically incremented value for a contract version within a major `ProtocolVersion` */
@JsonProperty("entity_version")
private int entityVersion;

}
27 changes: 27 additions & 0 deletions src/main/java/com/casper/sdk/model/entity/contract/Versions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.casper.sdk.model.entity.contract;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;


/**
* Child of {@link Package}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Versions {

/** Major element of `ProtocolVersion` combined with `EntityVersion` */
@JsonProperty("entity_version_key")
private VersionKey entityVersionKey;

/** Addressable Entity */
@JsonProperty("addressable_entity_hash")
private String addressableEntityHash;

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.casper.sdk.exception.NoSuchTypeException;
import com.casper.sdk.model.bid.StoredValueBidKind;
import com.casper.sdk.model.transaction.kind.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -26,7 +27,12 @@ public enum StoredValueTypeData {
STORED_VALUE_ERA_INFO("EraInfo", StoredValueEraInfo.class),
STORED_VALUE_BID("Bid", StoredValueBid.class),
STORED_VALUE_BID_KIND("BidKind", StoredValueBidKind.class),
STORED_VALUE_WITHDRAW("Withdraw", StoredValueWithdraw.class);
STORED_VALUE_WITHDRAW("Withdraw", StoredValueWithdraw.class),
STORED_VALUE_BYTECODE("ByteCode", ByteCodeKind.class),
STORED_VALUE_ADDRESSABLE_ENTITY("AddressableEntity", AddressableEntityKind.class),
STORED_VALUE_PACKAGE("Package", PackageKind.class),
STORED_VALUE_NAMED_KEY("NamedKey", NamedKeyKind.class),
STORED_VALUE_ENTRY_POINT("EntryPoint",EntryPointKind .class);

private final String name;
private final Class<?> clazz;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.casper.sdk.model.transaction.kind;

import com.casper.sdk.model.entity.AddressableEntity;
import com.casper.sdk.model.entity.Entity;
import com.casper.sdk.model.storedvalue.StoredValue;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* An AddressableEntityKind
* See {@link AddressableEntity}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AddressableEntityKind implements StoredValue<Entity> {

@JsonProperty("AddressableEntity")
private Entity value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.casper.sdk.model.transaction.kind;

import com.casper.sdk.model.entity.contract.ByteCode;
import com.casper.sdk.model.storedvalue.StoredValue;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* A ByteCode kind
* See {@link ByteCode}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ByteCodeKind implements StoredValue<ByteCode> {

@JsonProperty("ByteCode")
private ByteCode value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.casper.sdk.model.transaction.kind;

import com.casper.sdk.model.contract.EntryPoint;
import com.casper.sdk.model.contract.EntryPointValue;
import com.casper.sdk.model.storedvalue.StoredValue;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* An EntryPointKind
* See {@link EntryPoint}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class EntryPointKind implements StoredValue<EntryPointValue> {

@JsonProperty("EntryPoint")
private EntryPointValue value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.casper.sdk.model.transaction.kind;

import com.casper.sdk.model.entity.contract.NamedKey;
import com.casper.sdk.model.storedvalue.StoredValue;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* A NamedKeyKind
* See {@link NamedKey}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class NamedKeyKind implements StoredValue<NamedKey> {

@JsonProperty("NamedKey")
private NamedKey value;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.casper.sdk.model.transaction.kind;

import com.casper.sdk.model.entity.contract.Package;
import com.casper.sdk.model.storedvalue.StoredValue;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

/**
* A PackageKind
* See {@link Package}
*
* @author [email protected]
*/
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PackageKind implements StoredValue<Package> {

@JsonProperty("Package")
private Package value;

}
Loading

0 comments on commit 57ba96a

Please sign in to comment.