Skip to content

Commit 57ba96a

Browse files
authored
Merge pull request #335 from /issues/332
Issues/332
2 parents eacee23 + f4c2dbc commit 57ba96a

19 files changed

+2167
-18
lines changed

src/main/java/com/casper/sdk/model/entity/AddressableEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
/**
1111
* An addressable entity.
12+
* Methods and type signatures supported by a contract.
1213
*
1314
1415
*/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.casper.sdk.model.entity.contract;
2+
3+
import com.casper.sdk.model.key.Tag;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.*;
6+
7+
/**
8+
* A container for contract's Wasm bytes
9+
*
10+
11+
*/
12+
@Getter
13+
@Setter
14+
@Builder
15+
@AllArgsConstructor
16+
@NoArgsConstructor
17+
public class ByteCode {
18+
19+
/** The type of Byte code */
20+
@JsonProperty("kind")
21+
private ByteCodes kind;
22+
/** Byte code */
23+
@JsonProperty("bytes")
24+
private String bytes;
25+
26+
public enum ByteCodes implements Tag {
27+
/** Empty byte code */
28+
Empty(0),
29+
/** Byte code to be executed with the version 1 Casper execution engine */
30+
V1CasperWasm(1);
31+
private final byte tag;
32+
ByteCodes(final int tag) {
33+
this.tag = (byte) tag;
34+
}
35+
@Override
36+
public byte getByteTag() {
37+
return tag;
38+
}
39+
40+
}
41+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.casper.sdk.model.entity.contract;
2+
3+
import com.casper.sdk.model.clvalue.AbstractCLValue;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.*;
6+
7+
/**
8+
* A key with a name
9+
*
10+
11+
*/
12+
@Getter
13+
@Setter
14+
@Builder
15+
@AllArgsConstructor
16+
@NoArgsConstructor
17+
public class NamedKey {
18+
19+
@JsonProperty("named_key")
20+
private AbstractCLValue<?,?> namedKey;
21+
22+
@JsonProperty("name")
23+
private AbstractCLValue<?,?> name;
24+
25+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.casper.sdk.model.entity.contract;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.*;
5+
6+
import java.util.List;
7+
8+
/**
9+
* Package associated with a native contract implementation
10+
*
11+
12+
*/
13+
@Getter
14+
@Setter
15+
@Builder
16+
@AllArgsConstructor
17+
@NoArgsConstructor
18+
public class Package {
19+
20+
/** All versions (enabled & disabled) */
21+
@JsonProperty("versions")
22+
private List<Versions> versions;
23+
24+
/** Collection of disabled entity versions.
25+
* The runtime will not permit disabled entity versions to be executed */
26+
@JsonProperty("disabled_versions")
27+
private List<Versions> disabledVersions;
28+
29+
/** Mapping maintaining the set of URefs associated with each "user group".
30+
* This can be used to control access to methods in a particular version of the entity.
31+
* A method is callable by any context which "knows" any of the URefs associated with the method's user group */
32+
@JsonProperty("groups")
33+
private List<String> groups;
34+
35+
/** A flag that determines whether an entity is locked */
36+
@JsonProperty("lock_status")
37+
private PackageStatus lockStatus;
38+
39+
/**
40+
* Determines the lock status of the package
41+
*/
42+
public enum PackageStatus {
43+
// The package is locked and cannot be versioned
44+
Locked,
45+
// The package is unlocked and can be versioned
46+
Unlocked
47+
}
48+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.casper.sdk.model.entity.contract;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.*;
5+
6+
/**
7+
* Child of {@link Versions}
8+
*
9+
10+
*/
11+
@Getter
12+
@Setter
13+
@Builder
14+
@AllArgsConstructor
15+
@NoArgsConstructor
16+
public class VersionKey {
17+
18+
/** Major element of `ProtocolVersion` a `ContractVersion` is compatible with */
19+
@JsonProperty("protocol_version_major")
20+
private int protocolVersionMajor;
21+
22+
/** Automatically incremented value for a contract version within a major `ProtocolVersion` */
23+
@JsonProperty("entity_version")
24+
private int entityVersion;
25+
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.casper.sdk.model.entity.contract;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.*;
5+
6+
7+
/**
8+
* Child of {@link Package}
9+
*
10+
11+
*/
12+
@Getter
13+
@Setter
14+
@Builder
15+
@AllArgsConstructor
16+
@NoArgsConstructor
17+
public class Versions {
18+
19+
/** Major element of `ProtocolVersion` combined with `EntityVersion` */
20+
@JsonProperty("entity_version_key")
21+
private VersionKey entityVersionKey;
22+
23+
/** Addressable Entity */
24+
@JsonProperty("addressable_entity_hash")
25+
private String addressableEntityHash;
26+
27+
}

src/main/java/com/casper/sdk/model/storedvalue/StoredValueTypeData.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.casper.sdk.exception.NoSuchTypeException;
44
import com.casper.sdk.model.bid.StoredValueBidKind;
5+
import com.casper.sdk.model.transaction.kind.*;
56
import lombok.AccessLevel;
67
import lombok.AllArgsConstructor;
78
import lombok.Getter;
@@ -26,7 +27,12 @@ public enum StoredValueTypeData {
2627
STORED_VALUE_ERA_INFO("EraInfo", StoredValueEraInfo.class),
2728
STORED_VALUE_BID("Bid", StoredValueBid.class),
2829
STORED_VALUE_BID_KIND("BidKind", StoredValueBidKind.class),
29-
STORED_VALUE_WITHDRAW("Withdraw", StoredValueWithdraw.class);
30+
STORED_VALUE_WITHDRAW("Withdraw", StoredValueWithdraw.class),
31+
STORED_VALUE_BYTECODE("ByteCode", ByteCodeKind.class),
32+
STORED_VALUE_ADDRESSABLE_ENTITY("AddressableEntity", AddressableEntityKind.class),
33+
STORED_VALUE_PACKAGE("Package", PackageKind.class),
34+
STORED_VALUE_NAMED_KEY("NamedKey", NamedKeyKind.class),
35+
STORED_VALUE_ENTRY_POINT("EntryPoint",EntryPointKind .class);
3036

3137
private final String name;
3238
private final Class<?> clazz;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.casper.sdk.model.transaction.kind;
2+
3+
import com.casper.sdk.model.entity.AddressableEntity;
4+
import com.casper.sdk.model.entity.Entity;
5+
import com.casper.sdk.model.storedvalue.StoredValue;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
import lombok.*;
8+
9+
/**
10+
* An AddressableEntityKind
11+
* See {@link AddressableEntity}
12+
*
13+
14+
*/
15+
@Getter
16+
@Setter
17+
@Builder
18+
@AllArgsConstructor
19+
@NoArgsConstructor
20+
public class AddressableEntityKind implements StoredValue<Entity> {
21+
22+
@JsonProperty("AddressableEntity")
23+
private Entity value;
24+
25+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.casper.sdk.model.transaction.kind;
2+
3+
import com.casper.sdk.model.entity.contract.ByteCode;
4+
import com.casper.sdk.model.storedvalue.StoredValue;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import lombok.*;
7+
8+
/**
9+
* A ByteCode kind
10+
* See {@link ByteCode}
11+
*
12+
13+
*/
14+
@Getter
15+
@Setter
16+
@Builder
17+
@AllArgsConstructor
18+
@NoArgsConstructor
19+
public class ByteCodeKind implements StoredValue<ByteCode> {
20+
21+
@JsonProperty("ByteCode")
22+
private ByteCode value;
23+
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.casper.sdk.model.transaction.kind;
2+
3+
import com.casper.sdk.model.contract.EntryPoint;
4+
import com.casper.sdk.model.contract.EntryPointValue;
5+
import com.casper.sdk.model.storedvalue.StoredValue;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
import lombok.*;
8+
9+
/**
10+
* An EntryPointKind
11+
* See {@link EntryPoint}
12+
*
13+
14+
*/
15+
@Getter
16+
@Setter
17+
@Builder
18+
@AllArgsConstructor
19+
@NoArgsConstructor
20+
public class EntryPointKind implements StoredValue<EntryPointValue> {
21+
22+
@JsonProperty("EntryPoint")
23+
private EntryPointValue value;
24+
25+
}

0 commit comments

Comments
 (0)