From 5bff1cfd97c83e4069aebd7bb17f4d15f47dfa0f Mon Sep 17 00:00:00 2001 From: Bryan Rhee Date: Wed, 24 Jul 2024 12:17:04 +0900 Subject: [PATCH] fix: added missing nft_offer enum --- .../accounts/AccountObjectsRequestParams.java | 6 ++- .../ledger/NfTokenOfferObjectJsonTests.java | 47 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObjectJsonTests.java diff --git a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/accounts/AccountObjectsRequestParams.java b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/accounts/AccountObjectsRequestParams.java index 138cddae1..4eeb799a0 100644 --- a/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/accounts/AccountObjectsRequestParams.java +++ b/xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/accounts/AccountObjectsRequestParams.java @@ -152,7 +152,11 @@ enum AccountObjectType { /** * State account object type. */ - STATE("state"); + STATE("state"), + /** + * NFT offer object type. + */ + NFT_OFFER("nft_offer"); private final String value; diff --git a/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObjectJsonTests.java b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObjectJsonTests.java new file mode 100644 index 000000000..8da7c2f2e --- /dev/null +++ b/xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObjectJsonTests.java @@ -0,0 +1,47 @@ +package org.xrpl.xrpl4j.model.ledger; + +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.xrpl.xrpl4j.model.AbstractJsonTest; +import org.xrpl.xrpl4j.model.flags.NfTokenOfferFlags; +import org.xrpl.xrpl4j.model.transactions.Address; +import org.xrpl.xrpl4j.model.transactions.Hash256; +import org.xrpl.xrpl4j.model.transactions.NfTokenId; +import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.primitives.UnsignedInteger; +import com.google.common.primitives.UnsignedLong; + +class NfTokenOfferObjectJsonTests extends AbstractJsonTest{ + @Test + void testFullJson() throws JSONException, JsonProcessingException { + String json = "{\n" + // + "\"Amount\": \"0\",\n" + // + "\"Destination\": \"rPt4GkSQ2Zi2c8NPSJ6SeLGyernWPvWpf6\",\n" + // + "\"Flags\": 1,\n" + // + "\"LedgerEntryType\": \"NFTokenOffer\",\n" + // + "\"NFTokenID\": \"0008001EFB09BCE5738AE4C7ECEAADD69DB80B16F0DAF7AE619C329B00232900\",\n" + // + "\"NFTokenOfferNode\": \"0\",\n" + // + "\"Owner\": \"rpQqJo7thmNWAJCDne6jp2WreZ9VQgrbAd\",\n" + // + "\"OwnerNode\": \"0\",\n" + // + "\"PreviousTxnID\": \"0B447AB1C8793CB5976E15EC888CA8C8CFF0C1A2865E6F21F3D257372A1E84C5\",\n" + // + "\"PreviousTxnLgrSeq\": 2305005,\n" + // + "\"index\": \"DD5BB396D4901E69CAD478A1CFDEFBC6154E58D9CEF211513376E3C2CE3CEF46\"\n" + // + "}"; + + NfTokenOfferObject nftOffer = NfTokenOfferObject.builder() + .amount(XrpCurrencyAmount.of(UnsignedLong.valueOf("0"))) + .destination(Address.of("rPt4GkSQ2Zi2c8NPSJ6SeLGyernWPvWpf6")) + .flags(NfTokenOfferFlags.of(1)) + .nfTokenId(NfTokenId.of("0008001EFB09BCE5738AE4C7ECEAADD69DB80B16F0DAF7AE619C329B00232900")) + .offerNode("1") + .owner(Address.of("rpQqJo7thmNWAJCDne6jp2WreZ9VQgrbAd")) + .ownerNode("0") + .previousTransactionId(Hash256.of("0B447AB1C8793CB5976E15EC888CA8C8CFF0C1A2865E6F21F3D257372A1E84C5")) + .previousTransactionLedgerSequence(UnsignedInteger.valueOf("2305005")) + .index(Hash256.of("DD5BB396D4901E69CAD478A1CFDEFBC6154E58D9CEF211513376E3C2CE3CEF46")) + .build(); + + assertCanSerializeAndDeserialize(nftOffer, json); + } +}