Skip to content

Commit

Permalink
ergovalue-types: scala.Short,Int,Long,Boolean removed
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Apr 14, 2022
1 parent ec61e5c commit 7e508da
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@

import java.math.BigInteger;

import scala.Int;
import scala.Long;
import special.collection.Coll;
import special.sigma.BigInt;

public class ErgoValueTest {

@Test
public void testTypeDeclarations() {
ErgoValue<Int> intErgoValue = ErgoValue.of(1);
ErgoValue<Integer> intErgoValue = ErgoValue.of(1);
ErgoValue<Long> longErgoValue = ErgoValue.of(0L);
ErgoValue<Byte> byteErgoValue = ErgoValue.of((byte) 1);
ErgoValue<BigInt> bigIntErgoValue = ErgoValue.of(BigInteger.ZERO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface Eip29Attachment {
/**
* @return returns full ErgoValue for this attachment, to use for register 9 of out boxes
*/
ErgoValue<Tuple2<Coll<Byte>, Tuple2<scala.Int, Coll<Byte>>>> getErgoValue();
ErgoValue<Tuple2<Coll<Byte>, Tuple2<Integer, Coll<Byte>>>> getErgoValue();

/**
* @return array R4-R9 to use with OutboxBuilder#registers
Expand Down
16 changes: 8 additions & 8 deletions common/src/main/java/org/ergoplatform/appkit/ErgoType.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
public class ErgoType<T> {
private static ErgoType<Byte> _byte = new ErgoType(RType.ByteType());
private static ErgoType<scala.Short> _short = new ErgoType(RType.ShortType());
private static ErgoType<scala.Int> _integer = new ErgoType(RType.IntType());
private static ErgoType<scala.Long> _long = new ErgoType(RType.LongType());
private static ErgoType<scala.Boolean> _boolean = new ErgoType(RType.BooleanType());
private static ErgoType<Short> _short = new ErgoType(RType.ShortType());
private static ErgoType<Integer> _integer = new ErgoType(RType.IntType());
private static ErgoType<Long> _long = new ErgoType(RType.LongType());
private static ErgoType<Boolean> _boolean = new ErgoType(RType.BooleanType());
private static ErgoType<BigInt> _bigInt = new ErgoType(JavaHelpers.BigIntRType());
private static ErgoType<Unit> _unit = new ErgoType(RType.UnitType());
private static ErgoType<GroupElement> _groupElement = new ErgoType(JavaHelpers.GroupElementRType());
Expand Down Expand Up @@ -53,13 +53,13 @@ public boolean equals(Object obj) {

static public ErgoType<Byte> byteType() { return _byte; }

static public ErgoType<scala.Short> shortType() { return _short; }
static public ErgoType<Short> shortType() { return _short; }

static public ErgoType<scala.Int> integerType() { return _integer; }
static public ErgoType<Integer> integerType() { return _integer; }

static public ErgoType<scala.Long> longType() { return _long; }
static public ErgoType<Long> longType() { return _long; }

static public ErgoType<scala.Boolean> booleanType() { return _boolean; }
static public ErgoType<Boolean> booleanType() { return _boolean; }

static public ErgoType<BigInt> bigIntType() { return _bigInt; }

Expand Down
8 changes: 4 additions & 4 deletions common/src/main/java/org/ergoplatform/appkit/ErgoValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ static public ErgoValue<Byte> of(byte value) {
return new ErgoValue(Iso.jbyteToByte().to(Byte.valueOf(value)), ErgoType.byteType());
}

static public ErgoValue<scala.Short> of(short value) {
static public ErgoValue<Short> of(short value) {
return new ErgoValue(Iso.jshortToShort().to(Short.valueOf(value)), ErgoType.shortType());
}

static public ErgoValue<scala.Int> of(int value) {
static public ErgoValue<Integer> of(int value) {
return new ErgoValue(Iso.jintToInt().to(value), ErgoType.integerType());
}

static public ErgoValue<scala.Long> of(long value) {
static public ErgoValue<Long> of(long value) {
return new ErgoValue(Iso.jlongToLong().to(Long.valueOf(value)), ErgoType.longType());
}

static public ErgoValue<scala.Boolean> of(boolean value) {
static public ErgoValue<Boolean> of(boolean value) {
return new ErgoValue(Iso.jboolToBool().to(Boolean.valueOf(value)), ErgoType.booleanType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public int getTypeRawValue() {
}

@Override
public ErgoValue<Tuple2<Coll<Byte>, Tuple2<scala.Int, Coll<Byte>>>> getErgoValue() {
ErgoValue<Tuple2<scala.Int, Coll<Byte>>> contentPair = ErgoValue.pairOf(
public ErgoValue<Tuple2<Coll<Byte>, Tuple2<Integer, Coll<Byte>>>> getErgoValue() {
ErgoValue<Tuple2<Integer, Coll<Byte>>> contentPair = ErgoValue.pairOf(
ErgoValue.of(getTypeRawValue()),
ErgoValue.of(attachmentContent));
return ErgoValue.pairOf(ErgoValue.of(MAGIC_BYTES), contentPair);
Expand Down Expand Up @@ -77,11 +77,11 @@ public static Eip29Attachment createFromErgoValue(ErgoValue<?> r9) {
throw new IllegalArgumentException(illegalArgumentException + r9.toHex());
}

return createFromAttachmentTuple((Tuple2<scala.Int, Coll<Byte>>) attachmentValue);
return createFromAttachmentTuple((Tuple2<Integer, Coll<Byte>>) attachmentValue);
}

private static Eip29Attachment createFromAttachmentTuple(Tuple2<scala.Int, Coll<Byte>> attachmentTuple) {
Integer typeConstant = (Integer)(Object)attachmentTuple._1;
private static Eip29Attachment createFromAttachmentTuple(Tuple2<Integer, Coll<Byte>> attachmentTuple) {
Integer typeConstant = attachmentTuple._1;
GenericEip29Attachment.Type attachmentType = GenericEip29Attachment.Type.fromTypeRawValue(typeConstant);
byte[] attachmentContent = ScalaHelpers.collByteToByteArray(attachmentTuple._2);

Expand Down Expand Up @@ -123,7 +123,7 @@ public static GenericEip29Attachment.PlainTextAttachment buildForText(String tex
* Attachment containing list of attachments
*/
public static class MultiAttachment extends GenericEip29Attachment {
private final Tuple2<scala.Int, Coll<Byte>>[] attachmentList;
private final Tuple2<Integer, Coll<Byte>>[] attachmentList;

private MultiAttachment(byte[] attachmentContent) {
super(Type.MULTI_ATTACHMENT.toTypeRawValue(), attachmentContent);
Expand All @@ -136,7 +136,7 @@ private MultiAttachment(byte[] attachmentContent) {
attachmentList = (Tuple2[]) ((Coll<?>) attachmentTuples.getValue()).toArray();
}

private MultiAttachment(byte[] attachmentContent, Tuple2<scala.Int, Coll<Byte>>[] attachmentList) {
private MultiAttachment(byte[] attachmentContent, Tuple2<Integer, Coll<Byte>>[] attachmentList) {
super(Type.MULTI_ATTACHMENT.toTypeRawValue(), attachmentContent);
this.attachmentList = attachmentList;
}
Expand All @@ -160,12 +160,12 @@ public int getAttachmentCount() {
* @return object representing a multi attachment
*/
public static GenericEip29Attachment.MultiAttachment buildForList(List<Eip29Attachment> attachments) {
List<Tuple2<scala.Int, Coll<Byte>>> attachmentTuples = new ArrayList<>(attachments.size());
List<Tuple2<Integer, Coll<Byte>>> attachmentTuples = new ArrayList<>(attachments.size());
for (Eip29Attachment attachment : attachments) {
attachmentTuples.add(attachment.getErgoValue().getValue()._2);
}
Tuple2<scala.Int, Coll<Byte>>[] tupleArray = attachmentTuples.toArray(new Tuple2[]{});
ErgoValue<Coll<Tuple2<scala.Int, Coll<Byte>>>> ergoValue = ErgoValue.of(tupleArray, ErgoType.pairType(ErgoType.integerType(), ErgoType.collType(ErgoType.byteType())));
Tuple2<Integer, Coll<Byte>>[] tupleArray = attachmentTuples.toArray(new Tuple2[]{});
ErgoValue<Coll<Tuple2<Integer, Coll<Byte>>>> ergoValue = ErgoValue.of(tupleArray, ErgoType.pairType(ErgoType.integerType(), ErgoType.collType(ErgoType.byteType())));

return new MultiAttachment(ergoValue.toHex().getBytes(StandardCharsets.UTF_8), tupleArray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ object JavaHelpers {

implicit val TokenIdRType: RType[TokenId] = RType.arrayRType[Byte].asInstanceOf[RType[TokenId]]
implicit val JByteRType: RType[JByte] = RType.ByteType.asInstanceOf[RType[JByte]]

implicit val JShortRType: RType[JShort] = RType.ShortType.asInstanceOf[RType[JShort]]
implicit val JIntRType: RType[JInt] = RType.IntType.asInstanceOf[RType[JInt]]
implicit val JLongRType: RType[JLong] = RType.LongType.asInstanceOf[RType[JLong]]
implicit val JBooleanRType: RType[JBoolean] = RType.BooleanType.asInstanceOf[RType[JBoolean]]

val HeaderRType: RType[Header] = special.sigma.HeaderRType
val PreHeaderRType: RType[special.sigma.PreHeader] = special.sigma.PreHeaderRType

Expand Down

0 comments on commit 7e508da

Please sign in to comment.