Skip to content

Commit 95ef81a

Browse files
committed
Merge branch 'main' of github.com:XRPLF/xrpl4j into releases/v3.1
2 parents 11e231e + 7823236 commit 95ef81a

File tree

11 files changed

+389
-39
lines changed

11 files changed

+389
-39
lines changed

Diff for: xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/BuyOffer.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.immutables.value.Value;
2727
import org.xrpl.xrpl4j.model.flags.NfTokenOfferFlags;
2828
import org.xrpl.xrpl4j.model.transactions.Address;
29+
import org.xrpl.xrpl4j.model.transactions.CurrencyAmount;
2930
import org.xrpl.xrpl4j.model.transactions.Hash256;
3031
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
3132

@@ -48,12 +49,12 @@ static ImmutableBuyOffer.Builder builder() {
4849
}
4950

5051
/**
51-
* The amount offered to buy the NFT for {@link XrpCurrencyAmount}.
52+
* The amount offered to buy the NFT.
5253
*
53-
* @return The {@link XrpCurrencyAmount}.
54+
* @return The {@link CurrencyAmount}.
5455
*/
5556
@JsonProperty("Amount")
56-
XrpCurrencyAmount amount();
57+
CurrencyAmount amount();
5758

5859
/**
5960
* A set of boolean {@link NfTokenOfferFlags} containing options

Diff for: xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/client/nft/SellOffer.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,12 +26,11 @@
2626
import org.immutables.value.Value;
2727
import org.xrpl.xrpl4j.model.flags.NfTokenOfferFlags;
2828
import org.xrpl.xrpl4j.model.transactions.Address;
29+
import org.xrpl.xrpl4j.model.transactions.CurrencyAmount;
2930
import org.xrpl.xrpl4j.model.transactions.Hash256;
30-
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
3131

3232
/**
33-
* An Offer returned in an {@link SellOffer} list.
34-
* This offer is related to NfTokens.
33+
* An Offer returned in an {@link SellOffer} list. This offer is related to NfTokens.
3534
*/
3635
@Value.Immutable
3736
@JsonSerialize(as = ImmutableSellOffer.class)
@@ -48,16 +47,15 @@ static ImmutableSellOffer.Builder builder() {
4847
}
4948

5049
/**
51-
* The amount offered to buy the NFT for {@link XrpCurrencyAmount}.
50+
* The amount offered to sell the NFT.
5251
*
53-
* @return The {@link XrpCurrencyAmount}.
52+
* @return The {@link CurrencyAmount}.
5453
*/
5554
@JsonProperty("Amount")
56-
XrpCurrencyAmount amount();
55+
CurrencyAmount amount();
5756

5857
/**
59-
* A set of boolean {@link NfTokenOfferFlags} containing options
60-
* enabled for this object.
58+
* A set of boolean {@link NfTokenOfferFlags} containing options enabled for this object.
6159
*
6260
* @return The {@link NfTokenOfferFlags} for this object.
6361
*/

Diff for: xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/ledger/NfTokenOfferObject.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.immutables.value.Value;
2828
import org.xrpl.xrpl4j.model.flags.NfTokenOfferFlags;
2929
import org.xrpl.xrpl4j.model.transactions.Address;
30+
import org.xrpl.xrpl4j.model.transactions.CurrencyAmount;
3031
import org.xrpl.xrpl4j.model.transactions.Hash256;
3132
import org.xrpl.xrpl4j.model.transactions.NfTokenId;
3233
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
@@ -63,12 +64,12 @@ default LedgerEntryType ledgerEntryType() {
6364
}
6465

6566
/**
66-
* The amount of XRP, in drops, expected or offered for the token.
67+
* The amount expected or offered for the token.
6768
*
68-
* @return The {@link XrpCurrencyAmount}.
69+
* @return The {@link CurrencyAmount}.
6970
*/
7071
@JsonProperty("Amount")
71-
XrpCurrencyAmount amount();
72+
CurrencyAmount amount();
7273

7374
/**
7475
* {@link Address} of the source account that created and owns the offer.

Diff for: xrpl4j-core/src/main/java/org/xrpl/xrpl4j/model/transactions/metadata/MetaNfTokenOfferObject.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.xrpl.xrpl4j.model.ledger.ImmutableNfTokenOfferObject;
3131
import org.xrpl.xrpl4j.model.ledger.LedgerObject;
3232
import org.xrpl.xrpl4j.model.transactions.Address;
33+
import org.xrpl.xrpl4j.model.transactions.CurrencyAmount;
3334
import org.xrpl.xrpl4j.model.transactions.Hash256;
3435
import org.xrpl.xrpl4j.model.transactions.NfTokenId;
3536
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
@@ -46,12 +47,12 @@
4647
public interface MetaNfTokenOfferObject extends MetaLedgerObject {
4748

4849
/**
49-
* The amount of XRP, in drops, expected or offered for the token.
50+
* The amount expected or offered for the token.
5051
*
51-
* @return The {@link XrpCurrencyAmount}.
52+
* @return The {@link CurrencyAmount}.
5253
*/
5354
@JsonProperty("Amount")
54-
Optional<XrpCurrencyAmount> amount();
55+
Optional<CurrencyAmount> amount();
5556

5657
/**
5758
* {@link Address} of the source account that created and owns the offer.

Diff for: xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenOfferObjectJsonTests.java

+41-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,14 +29,14 @@
2929
import org.xrpl.xrpl4j.model.ledger.NfTokenOfferObject;
3030
import org.xrpl.xrpl4j.model.transactions.Address;
3131
import org.xrpl.xrpl4j.model.transactions.Hash256;
32+
import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount;
3233
import org.xrpl.xrpl4j.model.transactions.NfTokenId;
3334
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
3435

35-
public class NfTokenOfferObjectJsonTests extends AbstractJsonTest {
36+
public class NfTokenOfferObjectJsonTests extends AbstractJsonTest {
3637

3738
@Test
38-
public void testJson() throws JsonProcessingException, JSONException {
39-
39+
public void testJsonWithXrpAmount() throws JsonProcessingException, JSONException {
4040
NfTokenOfferObject object = NfTokenOfferObject.builder()
4141
.amount(XrpCurrencyAmount.ofDrops(10000))
4242
.destination(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"))
@@ -60,4 +60,40 @@ public void testJson() throws JsonProcessingException, JSONException {
6060

6161
assertCanSerializeAndDeserialize(object, json);
6262
}
63+
64+
@Test
65+
public void testJsonWithIssuedCurrencyAmount() throws JsonProcessingException, JSONException {
66+
NfTokenOfferObject object = NfTokenOfferObject.builder()
67+
.amount(
68+
IssuedCurrencyAmount.builder()
69+
.currency("USD")
70+
.issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys"))
71+
.value("10")
72+
.build()
73+
)
74+
.destination(Address.of("rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn"))
75+
.owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW"))
76+
.previousTransactionId(Hash256.of("E3FE6EA3D48F0C2B639448020EA4F03D4F4F8FFDB243A852A0F59177921B4879"))
77+
.previousTransactionLedgerSequence(UnsignedInteger.valueOf(14090896))
78+
.nfTokenId(NfTokenId.of("000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65"))
79+
.flags(NfTokenOfferFlags.BUY_TOKEN)
80+
.build();
81+
82+
String json = "{\n" +
83+
" \"Flags\": 1,\n" +
84+
" \"Amount\": {" +
85+
" \"currency\": \"USD\",\n" +
86+
" \"issuer\": \"rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys\"," +
87+
" \"value\": \"10\"" +
88+
" },\n" +
89+
" \"Owner\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" +
90+
" \"NFTokenID\": \"000B013A95F14B0044F78A264E41713C64B5F89242540EE208C3098E00000D65\",\n" +
91+
" \"Destination\": \"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn\",\n" +
92+
" \"PreviousTxnID\": \"E3FE6EA3D48F0C2B639448020EA4F03D4F4F8FFDB243A852A0F59177921B4879\",\n" +
93+
" \"PreviousTxnLgrSeq\": 14090896,\n" +
94+
" \"LedgerEntryType\": \"NFTokenOffer\"\n" +
95+
"}";
96+
97+
assertCanSerializeAndDeserialize(object, json);
98+
}
6399
}

Diff for: xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NfTokenSellOffersResultTest.java

+45-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,6 +27,7 @@
2727
import org.xrpl.xrpl4j.model.flags.NfTokenOfferFlags;
2828
import org.xrpl.xrpl4j.model.transactions.Address;
2929
import org.xrpl.xrpl4j.model.transactions.Hash256;
30+
import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount;
3031
import org.xrpl.xrpl4j.model.transactions.NfTokenId;
3132
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
3233

@@ -36,8 +37,7 @@
3637
public class NfTokenSellOffersResultTest extends AbstractJsonTest {
3738

3839
@Test
39-
public void test() throws JsonProcessingException, JSONException {
40-
40+
public void testWithXrpAmount() throws JsonProcessingException, JSONException {
4141
SellOffer sellOffer = SellOffer.builder()
4242
.amount(XrpCurrencyAmount.ofDrops(1000))
4343
.owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW"))
@@ -67,4 +67,45 @@ public void test() throws JsonProcessingException, JSONException {
6767

6868
assertCanSerializeAndDeserialize(params, json);
6969
}
70+
71+
@Test
72+
public void testWithIssuedCurrencyAmount() throws JsonProcessingException, JSONException {
73+
SellOffer sellOffer = SellOffer.builder()
74+
.amount(IssuedCurrencyAmount.builder()
75+
.issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys"))
76+
.currency("USD")
77+
.value("100")
78+
.build()
79+
)
80+
.owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW"))
81+
.flags(NfTokenOfferFlags.AUTHORIZED)
82+
.nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007"))
83+
.build();
84+
85+
List<SellOffer> list = new ArrayList<>();
86+
list.add(sellOffer);
87+
88+
NftSellOffersResult params = NftSellOffersResult.builder()
89+
.nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007"))
90+
.offers(list)
91+
.build();
92+
93+
String offer = "{\n" +
94+
" \"Flags\": 2,\n" +
95+
" \"Amount\": {\n" +
96+
" \"issuer\": \"rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys\",\n" +
97+
" \"currency\": \"USD\",\n" +
98+
" \"value\": \"100\"\n" +
99+
" },\n" +
100+
" \"owner\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" +
101+
" \"nft_offer_index\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" +
102+
"}";
103+
104+
String json = "{\n" +
105+
" \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" +
106+
" \"offers\": [" + offer + "]\n" +
107+
"}";
108+
109+
assertCanSerializeAndDeserialize(params, json);
110+
}
70111
}

Diff for: xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersRequestParamsTest.java

+22-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,15 +21,17 @@
2121
*/
2222

2323
import com.fasterxml.jackson.core.JsonProcessingException;
24+
import com.google.common.primitives.UnsignedInteger;
2425
import org.json.JSONException;
2526
import org.junit.jupiter.api.Test;
2627
import org.xrpl.xrpl4j.model.AbstractJsonTest;
28+
import org.xrpl.xrpl4j.model.transactions.Marker;
2729
import org.xrpl.xrpl4j.model.transactions.NfTokenId;
2830

2931
public class NftBuyOffersRequestParamsTest extends AbstractJsonTest {
3032

3133
@Test
32-
public void test() throws JsonProcessingException, JSONException {
34+
public void testWithRequiredValue() throws JsonProcessingException, JSONException {
3335
NftBuyOffersRequestParams params = NftBuyOffersRequestParams.builder()
3436
.nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007"))
3537
.build();
@@ -40,4 +42,21 @@ public void test() throws JsonProcessingException, JSONException {
4042

4143
assertCanSerializeAndDeserialize(params, json);
4244
}
45+
46+
@Test
47+
public void testWithAllValues() throws JsonProcessingException, JSONException {
48+
NftBuyOffersRequestParams params = NftBuyOffersRequestParams.builder()
49+
.nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007"))
50+
.limit(UnsignedInteger.valueOf(10L))
51+
.marker(Marker.of("123"))
52+
.build();
53+
54+
String json = "{\n" +
55+
" \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" +
56+
" \"limit\": 10,\n" +
57+
" \"marker\": \"123\"\n" +
58+
" }";
59+
60+
assertCanSerializeAndDeserialize(params, json);
61+
}
4362
}

Diff for: xrpl4j-core/src/test/java/org/xrpl/xrpl4j/model/client/nft/NftBuyOffersResultTest.java

+46-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
1111
* You may obtain a copy of the License at
12-
*
12+
*
1313
* http://www.apache.org/licenses/LICENSE-2.0
14-
*
14+
*
1515
* Unless required by applicable law or agreed to in writing, software
1616
* distributed under the License is distributed on an "AS IS" BASIS,
1717
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,6 +27,7 @@
2727
import org.xrpl.xrpl4j.model.flags.NfTokenOfferFlags;
2828
import org.xrpl.xrpl4j.model.transactions.Address;
2929
import org.xrpl.xrpl4j.model.transactions.Hash256;
30+
import org.xrpl.xrpl4j.model.transactions.IssuedCurrencyAmount;
3031
import org.xrpl.xrpl4j.model.transactions.NfTokenId;
3132
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
3233

@@ -36,7 +37,7 @@
3637
public class NftBuyOffersResultTest extends AbstractJsonTest {
3738

3839
@Test
39-
public void test() throws JsonProcessingException, JSONException {
40+
public void testWithXrpCurrencyAmount() throws JsonProcessingException, JSONException {
4041

4142
BuyOffer buyOffer = BuyOffer.builder()
4243
.amount(XrpCurrencyAmount.ofDrops(1000))
@@ -67,4 +68,46 @@ public void test() throws JsonProcessingException, JSONException {
6768

6869
assertCanSerializeAndDeserialize(params, json);
6970
}
71+
72+
@Test
73+
public void testWithIssuedCurrencyAmount() throws JsonProcessingException, JSONException {
74+
75+
BuyOffer buyOffer = BuyOffer.builder()
76+
.amount(IssuedCurrencyAmount.builder()
77+
.issuer(Address.of("rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys"))
78+
.currency("USD")
79+
.value("100")
80+
.build()
81+
)
82+
.owner(Address.of("rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW"))
83+
.flags(NfTokenOfferFlags.BUY_TOKEN)
84+
.nftOfferIndex(Hash256.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007"))
85+
.build();
86+
87+
List<BuyOffer> list = new ArrayList<>();
88+
list.add(buyOffer);
89+
90+
NftBuyOffersResult params = NftBuyOffersResult.builder()
91+
.nfTokenId(NfTokenId.of("000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007"))
92+
.offers(list)
93+
.build();
94+
95+
String offer = "{\n" +
96+
" \"Flags\": 1,\n" +
97+
" \"Amount\": {\n" +
98+
" \"issuer\": \"rsjYGpMWQeNBXbUTkVz4ZKzHefgZSr6rys\",\n" +
99+
" \"currency\": \"USD\",\n" +
100+
" \"value\": \"100\"\n" +
101+
" },\n" +
102+
" \"owner\": \"rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW\",\n" +
103+
" \"nft_offer_index\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\"\n" +
104+
"}";
105+
106+
String json = "{\n" +
107+
" \"nft_id\": \"000100001E962F495F07A990F4ED55ACCFEEF365DBAA76B6A048C0A200000007\",\n" +
108+
" \"offers\": [" + offer + "]\n" +
109+
"}";
110+
111+
assertCanSerializeAndDeserialize(params, json);
112+
}
70113
}

0 commit comments

Comments
 (0)