Skip to content

Commit

Permalink
fix minor changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Manish Dait <[email protected]>
  • Loading branch information
manishdait committed Jan 13, 2025
1 parent 887c6bb commit 01c1e86
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
package com.openelements.hiero.base.data;

import org.jspecify.annotations.NonNull;

import java.util.List;
import java.util.Objects;

public record CustomFee(List<FixedFee> fixedFees, List<FractionalFee> fractionalFees, List<RoyaltyFee> royaltyFees) {
public record CustomFee(
@NonNull List<FixedFee> fixedFees,
@NonNull List<FractionalFee> fractionalFees,
@NonNull List<RoyaltyFee> royaltyFees
) {
public CustomFee {
Objects.requireNonNull(fixedFees, "fixedFees must not be null");
Objects.requireNonNull(fractionalFees, "fractionalFees must not be null");
Objects.requireNonNull(royaltyFees, "royaltyFees must not be null");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
import org.jspecify.annotations.Nullable;

public record FixedFee(long amount, @Nullable AccountId collectorAccountId, @Nullable TokenId denominatingTokenId) {
public FixedFee {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ public record FractionalFee(
@Nullable AccountId collectorAccountId,
@Nullable TokenId denominatingTokenId
) {
public FractionalFee {
if (numeratorAmount < 0) {
throw new IllegalArgumentException("numeratorAmount must be greater than or equal to 0");
}
if (denominatorAmount < 0) {
throw new IllegalArgumentException("denominatorAmount must be greater than or equal to 0");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ public record RoyaltyFee(
@Nullable AccountId collectorAccountId,
@Nullable TokenId denominatingTokenId
) {
public RoyaltyFee {
if (numeratorAmount < 0) {
throw new IllegalArgumentException("numeratorAmount must be greater than or equal to 0");
}
if (denominatorAmount < 0) {
throw new IllegalArgumentException("denominatorAmount must be greater than or equal to 0");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ public Optional<TokenInfo> toTokenInfo(JsonObject jsonObject) {
}

private CustomFee getCustomFee(JsonObject object) {
List<FractionalFee> fractionalFees = null;
List<FixedFee> fixedFees = null;
List<RoyaltyFee> royaltyFees = null;
List<FractionalFee> fractionalFees = List.of();
List<FixedFee> fixedFees = List.of();
List<RoyaltyFee> royaltyFees = List.of();

if (object.containsKey("fixed_fees")) {
JsonArray fixedFeeArray = object.get("fixed_fees").asJsonArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ public Optional<TokenInfo> toTokenInfo(JsonNode node) {
}

private CustomFee getCustomFee(JsonNode node) {
List<FractionalFee> fractionalFees = null;
List<FixedFee> fixedFees = null;
List<RoyaltyFee> royaltyFees = null;
List<FractionalFee> fractionalFees = List.of();
List<FixedFee> fixedFees = List.of();
List<RoyaltyFee> royaltyFees = List.of();

if (node.has("fixed_fees")) {
JsonNode fixedFeeNode = node.get("fixed_fees");
Expand Down

0 comments on commit 01c1e86

Please sign in to comment.