Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nkramer44 committed Aug 4, 2023
1 parent 46dcce2 commit c6ed643
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static ImmutableNftInfoResult.Builder builder() {
* @return An {@link NfTokenId}.
*/
@JsonProperty("nft_id")
NfTokenId nfTokenId();
NfTokenId nftId();

/**
* The ledger index of the most recent ledger version where the state of this NFT was modified, as in the NFT was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.Locale;
import java.util.Objects;

/**
* Wrapped immutable classes for providing type-safe objects.
Expand Down Expand Up @@ -334,6 +335,10 @@ public boolean equals(Object obj) {

/**
* A wrapped {@link com.google.common.primitives.UnsignedInteger} containing the TransferFee.
*
* <p>Valid values for this field are between 0 and 50000 inclusive, allowing transfer rates of between 0.00% and
* 50.00% in increments of 0.001. If this field is provided in a {@link NfTokenMint} transaction, the transaction
* MUST have the {@code tfTransferable} flag enabled.
*/
@Value.Immutable
@Wrapped
Expand All @@ -349,10 +354,14 @@ public String toString() {
/**
* Construct {@link TransferFee} as a percentage value.
*
* <p>The given percentage value must have at most 3 decimal places of precision, and must be
* between {@code 0} and {@code 50.000}.</p>
*
* @param percent of type {@link BigDecimal}
* @return {@link TransferFee}
*/
public static TransferFee ofPercent(BigDecimal percent) {
Objects.requireNonNull(percent);
Preconditions.checkArgument(
Math.max(0, percent.stripTrailingZeros().scale()) <= 3,
"Percent value should have a maximum of 3 decimal places."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NftInfoResultTest extends AbstractJsonTest {
@Test
void testJsonWithUri() throws JSONException, JsonProcessingException {
NftInfoResult result = NftInfoResult.builder()
.nfTokenId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000"))
.nftId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000"))
.ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(269)))
.owner(Address.of("rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk"))
.burned(false)
Expand Down Expand Up @@ -51,7 +51,7 @@ void testJsonWithUri() throws JSONException, JsonProcessingException {
@Test
void testJsonWithoutUri() throws JSONException, JsonProcessingException {
NftInfoResult result = NftInfoResult.builder()
.nfTokenId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000"))
.nftId(NfTokenId.of("00080000B4F4AFC5FBCBD76873F18006173D2193467D3EE70000099B00000000"))
.ledgerIndex(LedgerIndex.of(UnsignedInteger.valueOf(269)))
.owner(Address.of("rG9gdNygQ6npA9JvDFWBoeXbiUcTYJnEnk"))
.burned(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ void ofPercent() {
assertThat(TransferFee.ofPercent(BigDecimal.valueOf(50.000)).value()).isEqualTo(UnsignedInteger.valueOf(50_000));
}

@Test
void ofPercentWithNull() {
assertThatThrownBy(() -> TransferFee.ofPercent(null))
.isInstanceOf(NullPointerException.class);
}

@Test
public void transferFeeEquality() {
assertThat(TransferFee.of(UnsignedInteger.ONE)).isEqualTo(TransferFee.of(UnsignedInteger.ONE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void getNftInfo() throws JsonRpcClientErrorException {
params
);

assertThat(nftInfo.nfTokenId()).isEqualTo(params.nfTokenId());
assertThat(nftInfo.nftId()).isEqualTo(params.nfTokenId());
assertThat(nftInfo.owner()).isEqualTo(Address.of("rLpunkscgfzS8so59bUCJBVqZ3eHZue64r"));
assertThat(nftInfo.burned()).isFalse();
assertThat(nftInfo.flags()).isEqualTo(NfTokenFlags.TRANSFERABLE);
Expand Down

0 comments on commit c6ed643

Please sign in to comment.