Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eip4 update #214

Merged
merged 9 commits into from
Feb 23, 2023
Merged
12 changes: 6 additions & 6 deletions common/src/main/java/org/ergoplatform/appkit/Eip4Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ public Eip4Token(@Nonnull String id, long amount, @Nonnull String name,
this.description = description;
this.decimals = decimals;

// check if EIP4 specification is fulfilled. It defines that R7 to R9 are null, or
// R7 and R8 are set with R9 being optional. Other combinations are not valid.
if (!(r7 != null && r8 != null || r7 == null && r8 == null && r9 == null)) {
throw new IllegalArgumentException("Either define all of R7 to R9 or none of them");
}

this.r7 = r7;
this.r8 = r8;
this.r9 = r9;
Expand Down Expand Up @@ -274,6 +268,10 @@ public enum AssetType {
* NFT - video artwork
*/
NFT_VIDEO,
/**
* NFT - Artwork collection
*/
ARTWORK_COLLECTION,
/**
* Membership token - threshold signature
*/
Expand All @@ -294,6 +292,8 @@ public byte[] getR7ByteArrayForType() {
return new byte[]{1, 2};
case NFT_VIDEO:
return new byte[]{1, 3};
case ARTWORK_COLLECTION:
return new byte[] {1, 4};
case MEMBERSHIP_THRESHOLD_SIG:
return new byte[]{2, 1};
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,11 @@ else if (linkToContent != null && linkToCoverImage != null)

return eip4Token;
}


public static Eip4Token buildNftArtworkCollectionToken(@Nonnull String id, long amount, @Nonnull String name,
@Nonnull String description, int decimals) {

return new Eip4Token(id, amount, name, description, decimals, ErgoValue.of(Eip4Token.AssetType.NFT_AUDIO.getR7ByteArrayForType()), null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ class OutBoxBuilderImpl(_txB: UnsignedTransactionBuilderImpl) extends OutBoxBuil
val tokenNumOfDecVal = token.getMintingBoxR6
_registers ++= Array(tokenNameVal, tokenDescVal, tokenNumOfDecVal)

// optional registers, but either all of them or none
if (token.getMintingBoxR7 != null && token.getMintingBoxR8 != null) {
_registers ++= Array(token.getMintingBoxR7, token.getMintingBoxR8)
if (token.getMintingBoxR9 != null)
_registers += token.getMintingBoxR9
}
if(token.getMintingBoxR7 != null){
_registers ++= Array(token.getMintingBoxR7)

if(token.getMintingBoxR8 != null){
_registers ++= Array(token.getMintingBoxR8)


if(token.getMintingBoxR9 != null){
_registers ++= Array(token.getMintingBoxR9)
}

}

}
_tokens += token
this
}
Expand Down