Skip to content

Commit 91806c9

Browse files
committed
Fix compatibility with latest libxrpl
1 parent 6af560d commit 91806c9

10 files changed

Lines changed: 65 additions & 33 deletions

File tree

src/data/AmendmentCenter.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ struct Amendments {
147147
REGISTER(Sponsor);
148148
REGISTER(fixCleanup3_3_0);
149149

150+
// These amendments are added because of libxrpl 3.4.0, but they are not necessarily supported
151+
// in Clio yet
152+
REGISTER(fixCleanup3_4_0);
153+
150154
// Obsolete but supported by libxrpl
151155
REGISTER(CryptoConditionsSuite);
152156
REGISTER(NonFungibleTokensV1);

src/feed/impl/TransactionFeed.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#include <xrpl/protocol/Issue.h>
2222
#include <xrpl/protocol/LedgerFormats.h>
2323
#include <xrpl/protocol/LedgerHeader.h>
24-
#include <xrpl/protocol/NFTSyntheticSerializer.h>
24+
#include <xrpl/protocol/NFTokenID.h>
25+
#include <xrpl/protocol/NFTokenOfferID.h>
2526
#include <xrpl/protocol/SField.h>
2627
#include <xrpl/protocol/STObject.h>
2728
#include <xrpl/protocol/TER.h>
@@ -214,7 +215,8 @@ TransactionFeed::pub(
214215
rpc::insertMPTIssuanceID(txnPubobj, tx, metaPubobj, meta);
215216

216217
json::Value nftJson;
217-
xrpl::RPC::insertNFTSyntheticInJson(nftJson, tx, *meta);
218+
xrpl::insertNFTokenID(nftJson[xrpl::jss::meta], tx, *meta);
219+
xrpl::insertNFTokenOfferID(nftJson[xrpl::jss::meta], tx, *meta);
218220
auto const nftBoostJson = rpc::toBoostJson(nftJson).as_object();
219221
if (nftBoostJson.contains(JS(meta)) && nftBoostJson.at(JS(meta)).is_object()) {
220222
auto& metaObjInPub = pubObj.at(JS(meta)).as_object();

src/rpc/Errors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace rpc {
2828
* @brief Stream a Status in human readable form.
2929
*
3030
* Declared in rpcspec but implemented here: rendering a code needs Clio's
31-
* getErrorInfo table and xrpl::RPC::getErrorInfo.
31+
* getErrorInfo table and xrpl::rpc::getErrorInfo.
3232
*
3333
* @param stream The stream to write to
3434
* @param status The status to write
@@ -46,7 +46,7 @@ operator<<(std::ostream& stream, Status const& status)
4646
if (!status.message.empty()) {
4747
stream << ", Message: " << status.message;
4848
} else {
49-
stream << ", Message: " << xrpl::RPC::getErrorInfo(err).message;
49+
stream << ", Message: " << xrpl::rpc::getErrorInfo(err).message;
5050
}
5151
},
5252
[&stream, &status](ClioError err) {
@@ -176,7 +176,7 @@ makeError(
176176
)
177177
{
178178
boost::json::object json;
179-
auto const& info = xrpl::RPC::getErrorInfo(err);
179+
auto const& info = xrpl::rpc::getErrorInfo(err);
180180

181181
json["error"] = customError.value_or(info.token.cStr()).data();
182182
json["error_code"] = static_cast<uint32_t>(err);

src/rpc/RPCHelpers.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <boost/algorithm/string/case_conv.hpp>
1717
#include <boost/asio/spawn.hpp>
18-
#include <boost/format/free_funcs.hpp>
18+
#include <boost/format.hpp>
1919
#include <boost/json/array.hpp>
2020
#include <boost/json/object.hpp>
2121
#include <boost/json/parse.hpp>
@@ -45,7 +45,8 @@
4545
#include <xrpl/protocol/LedgerFormats.h>
4646
#include <xrpl/protocol/LedgerHeader.h>
4747
#include <xrpl/protocol/MPTIssue.h>
48-
#include <xrpl/protocol/NFTSyntheticSerializer.h>
48+
#include <xrpl/protocol/NFTokenID.h>
49+
#include <xrpl/protocol/NFTokenOfferID.h>
4950
#include <xrpl/protocol/Protocol.h>
5051
#include <xrpl/protocol/PublicKey.h>
5152
#include <xrpl/protocol/Rate.h>
@@ -248,7 +249,8 @@ toExpandedJson(
248249

249250
if (nftEnabled == NFTokenjson::ENABLE) {
250251
json::Value nftJson;
251-
xrpl::RPC::insertNFTSyntheticInJson(nftJson, txn, *meta);
252+
xrpl::insertNFTokenID(nftJson[xrpl::jss::meta], txn, *meta);
253+
xrpl::insertNFTokenOfferID(nftJson[xrpl::jss::meta], txn, *meta);
252254
// if there is no nft fields, the nftJson will be {"meta":null}
253255
auto const nftBoostJson = toBoostJson(nftJson).as_object();
254256
if (nftBoostJson.contains(JS(meta)) and nftBoostJson.at(JS(meta)).is_object()) {

src/rpc/handlers/AccountInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ AccountInfoHandler::process(AccountInfoHandler::Input const& input, Context cons
4040

4141
if (!input.account && !input.ident) {
4242
return Error{
43-
Status{RippledError::RpcInvalidParams, xrpl::RPC::missingFieldMessage(JS(account))}
43+
Status{RippledError::RpcInvalidParams, xrpl::rpc::missingFieldMessage(JS(account))}
4444
};
4545
}
4646

src/rpc/handlers/LedgerEntry.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <xrpl/protocol/SField.h>
2828
#include <xrpl/protocol/STLedgerEntry.h>
2929
#include <xrpl/protocol/STXChainBridge.h>
30+
#include <xrpl/protocol/SeqProxy.h>
3031
#include <xrpl/protocol/Serializer.h>
3132
#include <xrpl/protocol/UintTypes.h>
3233
#include <xrpl/protocol/jss.h>
@@ -71,9 +72,13 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons
7172
);
7273

7374
// NOLINTBEGIN(bugprone-unchecked-optional-access)
74-
key =
75-
xrpl::keylet::offer(*id, boost::json::value_to<std::uint32_t>(input.offer->at(JS(seq))))
76-
.key;
75+
key = xrpl::keylet::offer(
76+
*id,
77+
xrpl::SeqProxy::rawSequence(
78+
boost::json::value_to<std::uint32_t>(input.offer->at(JS(seq)))
79+
)
80+
)
81+
.key;
7782
// NOLINTEND(bugprone-unchecked-optional-access)
7883
} else if (input.rippleStateAccount) {
7984
auto const id1 =
@@ -96,7 +101,12 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons
96101
);
97102
key =
98103
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
99-
xrpl::keylet::escrow(*id, util::integralValueAs<uint32_t>(input.escrow->at(JS(seq))))
104+
xrpl::keylet::escrow(
105+
*id,
106+
xrpl::SeqProxy::rawSequence(
107+
util::integralValueAs<uint32_t>(input.escrow->at(JS(seq)))
108+
)
109+
)
100110
.key;
101111
} else if (input.depositPreauth) {
102112
auto const owner = util::parseBase58Wrapper<xrpl::AccountID>(
@@ -137,10 +147,13 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons
137147
boost::json::value_to<std::string>(input.ticket->at(JS(account)))
138148
);
139149

140-
key = xrpl::getTicketIndex(
141-
*id, // NOLINT(bugprone-unchecked-optional-access)
142-
util::integralValueAs<uint32_t>(input.ticket->at(JS(ticket_seq)))
143-
);
150+
key = xrpl::keylet::ticket(
151+
*id, // NOLINT(bugprone-unchecked-optional-access)
152+
xrpl::SeqProxy::rawTicket(
153+
util::integralValueAs<uint32_t>(input.ticket->at(JS(ticket_seq)))
154+
)
155+
)
156+
.key;
144157
} else if (input.amm) {
145158
auto const getIssuerFromJson = [](auto const& assetJson) {
146159
// the field check has been done in validator
@@ -204,27 +217,27 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons
204217
);
205218
auto const seq = util::integralValueAs<uint32_t>(input.permissionedDomain->at(JS(seq)));
206219
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
207-
key = xrpl::keylet::permissionedDomain(*account, seq).key;
220+
key = xrpl::keylet::permissionedDomain(*account, xrpl::SeqProxy::rawSequence(seq)).key;
208221
} else if (input.vault) {
209222
auto const account = xrpl::parseBase58<xrpl::AccountID>(
210223
boost::json::value_to<std::string>(input.vault->at(JS(owner)))
211224
);
212225
auto const seq = util::integralValueAs<uint32_t>(input.vault->at(JS(seq)));
213226
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
214-
key = xrpl::keylet::vault(*account, seq).key;
227+
key = xrpl::keylet::vault(*account, xrpl::SeqProxy::rawSequence(seq)).key;
215228
} else if (input.loanBroker) {
216229
auto const account = xrpl::parseBase58<xrpl::AccountID>(
217230
boost::json::value_to<std::string>(input.loanBroker->at(JS(owner)))
218231
);
219232
auto const seq = util::integralValueAs<uint32_t>(input.loanBroker->at(JS(seq)));
220233
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
221-
key = xrpl::keylet::loanBroker(*account, seq).key;
234+
key = xrpl::keylet::loanBroker(*account, xrpl::SeqProxy::rawSequence(seq)).key;
222235
} else if (input.loan) {
223236
auto const id = xrpl::uint256{
224237
boost::json::value_to<std::string>(input.loan->at(JS(loan_broker_id))).data()
225238
};
226239
auto const seq = util::integralValueAs<uint32_t>(input.loan->at(JS(loan_seq)));
227-
key = xrpl::keylet::loan(id, seq).key;
240+
key = xrpl::keylet::loan(id, xrpl::SeqProxy::rawSequence(seq)).key;
228241
} else if (input.delegate) {
229242
auto const account = xrpl::parseBase58<xrpl::AccountID>(
230243
boost::json::value_to<std::string>(input.delegate->at(JS(account)))

src/rpc/handlers/ServerInfo.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class BaseServerInfoHandler {
103103
std::chrono::time_point<std::chrono::system_clock> time = std::chrono::system_clock::now();
104104
std::chrono::seconds uptime = {};
105105
std::string clioVersion = util::build::getClioVersionString();
106-
std::string xrplVersion = xrpl::BuildInfo::getVersionString();
106+
std::string xrplVersion = xrpl::build_info::getVersionString();
107107
std::optional<boost::json::object> rippledInfo = std::nullopt;
108108
ValidatedLedgerSection validatedLedger = {};
109109
CacheSection cache = {};

src/rpc/handlers/VaultInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <xrpl/protocol/SField.h>
1919
#include <xrpl/protocol/STBase.h>
2020
#include <xrpl/protocol/STLedgerEntry.h>
21+
#include <xrpl/protocol/SeqProxy.h>
2122
#include <xrpl/protocol/Serializer.h>
2223
#include <xrpl/protocol/jss.h>
2324

@@ -96,7 +97,7 @@ VaultInfoHandler::process(VaultInfoHandler::Input const& input, Context const& c
9697
return std::unexpected{Status{RippledError::RpcEntryNotFound}};
9798
}
9899

99-
return xrpl::keylet::vault(*accountID, *input.tnxSequence);
100+
return xrpl::keylet::vault(*accountID, xrpl::SeqProxy::rawSequence(*input.tnxSequence));
100101
}
101102
xrpl::uint256 nodeIndex;
102103
if (nodeIndex.parseHex(*input.vaultID))

tests/unit/rpc/handlers/LedgerEntryTests.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <xrpl/protocol/STLedgerEntry.h>
3030
#include <xrpl/protocol/STObject.h>
3131
#include <xrpl/protocol/STXChainBridge.h>
32+
#include <xrpl/protocol/SeqProxy.h>
3233
#include <xrpl/protocol/Serializer.h>
3334
#include <xrpl/protocol/UintTypes.h>
3435

@@ -2816,7 +2817,7 @@ generateTestValuesForNormalPathTest()
28162817
}})JSON",
28172818
kAccount
28182819
),
2819-
.expectedIndex = xrpl::keylet::escrow(account1, 1).key,
2820+
.expectedIndex = xrpl::keylet::escrow(account1, xrpl::SeqProxy::rawSequence(1)).key,
28202821
.mockedEntity = createEscrowLedgerObject(kAccount, kAccount2)
28212822
},
28222823
NormalPathTestBundle{
@@ -2924,7 +2925,7 @@ generateTestValuesForNormalPathTest()
29242925
}})JSON",
29252926
kAccount
29262927
),
2927-
.expectedIndex = xrpl::getTicketIndex(account1, 2),
2928+
.expectedIndex = xrpl::keylet::ticket(account1, xrpl::SeqProxy::rawTicket(2)).key,
29282929
.mockedEntity = createTicketLedgerObject(kAccount, 0)
29292930
},
29302931
NormalPathTestBundle{
@@ -2939,7 +2940,7 @@ generateTestValuesForNormalPathTest()
29392940
}})JSON",
29402941
kAccount
29412942
),
2942-
.expectedIndex = xrpl::keylet::offer(account1, 2).key,
2943+
.expectedIndex = xrpl::keylet::offer(account1, xrpl::SeqProxy::rawSequence(2)).key,
29432944
.mockedEntity = createOfferLedgerObject(
29442945
kAccount,
29452946
100,
@@ -3281,7 +3282,7 @@ generateTestValuesForNormalPathTest()
32813282
.expectedIndex = xrpl::keylet::permissionedDomain(
32823283
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
32833284
*xrpl::parseBase58<xrpl::AccountID>(kAccount),
3284-
kRangeMax
3285+
xrpl::SeqProxy::rawSequence(kRangeMax)
32853286
)
32863287
.key,
32873288
.mockedEntity =
@@ -3324,7 +3325,11 @@ generateTestValuesForNormalPathTest()
33243325
),
33253326
.expectedIndex =
33263327
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
3327-
xrpl::keylet::vault(*xrpl::parseBase58<xrpl::AccountID>(kAccount), kRangeMax).key,
3328+
xrpl::keylet::vault(
3329+
*xrpl::parseBase58<xrpl::AccountID>(kAccount),
3330+
xrpl::SeqProxy::rawSequence(kRangeMax)
3331+
)
3332+
.key,
33283333
.mockedEntity = createVault(
33293334
kAccount,
33303335
kAccount,
@@ -3367,7 +3372,7 @@ generateTestValuesForNormalPathTest()
33673372
.expectedIndex = xrpl::keylet::loanBroker(
33683373
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
33693374
*xrpl::parseBase58<xrpl::AccountID>(kAccount),
3370-
kRangeMax
3375+
xrpl::SeqProxy::rawSequence(kRangeMax)
33713376
)
33723377
.key,
33733378
.mockedEntity = createLoanBroker(
@@ -3400,7 +3405,8 @@ generateTestValuesForNormalPathTest()
34003405
}})JSON",
34013406
kIndex1
34023407
),
3403-
.expectedIndex = xrpl::keylet::loan(xrpl::uint256{kIndex1}, 1).key,
3408+
.expectedIndex =
3409+
xrpl::keylet::loan(xrpl::uint256{kIndex1}, xrpl::SeqProxy::rawSequence(1)).key,
34043410
.mockedEntity = createLoan(
34053411
kAccount, xrpl::uint256{kIndex1}, 1, 1000, 86400, 100, xrpl::uint256{0}, 0
34063412
)
@@ -3552,7 +3558,10 @@ TEST_F(RPCLedgerEntryTest, Vault_BinaryFalse)
35523558

35533559
auto const vaultKey =
35543560
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
3555-
xrpl::keylet::vault(*xrpl::parseBase58<xrpl::AccountID>(kAccount), kRangeMax).key;
3561+
xrpl::keylet::vault(
3562+
*xrpl::parseBase58<xrpl::AccountID>(kAccount), xrpl::SeqProxy::rawSequence(kRangeMax)
3563+
)
3564+
.key;
35563565

35573566
xrpl::STLedgerEntry const sle{
35583567
xrpl::SerialIter{
@@ -3602,7 +3611,7 @@ TEST_F(RPCLedgerEntryTest, LoanBroker_BinaryFalse)
36023611
auto const loanBrokerKey = xrpl::keylet::loanBroker(
36033612
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
36043613
*xrpl::parseBase58<xrpl::AccountID>(kAccount),
3605-
kRangeMax
3614+
xrpl::SeqProxy::rawSequence(kRangeMax)
36063615
)
36073616
.key;
36083617

tests/unit/rpc/handlers/VaultInfoTests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <xrpl/basics/base_uint.h>
1717
#include <xrpl/protocol/Indexes.h>
1818
#include <xrpl/protocol/LedgerHeader.h>
19+
#include <xrpl/protocol/SeqProxy.h>
1920

2021
#include <cstdint>
2122
#include <optional>
@@ -456,7 +457,7 @@ TEST_F(RPCVaultInfoHandlerTest, ValidVaultObjectQueryByOwnerAndSeq)
456457
auto const accountRoot = createAccountRootObject(kAccount, 0, kSeq, 200, 2, kIndex1, 2);
457458
auto const account = getAccountIdWithString(kAccount);
458459
auto const accountKeylet = xrpl::keylet::account(account).key;
459-
auto const vaultKeylet = xrpl::keylet::vault(account, kSeq).key;
460+
auto const vaultKeylet = xrpl::keylet::vault(account, xrpl::SeqProxy::rawSequence(kSeq)).key;
460461
auto const mptIssuance = xrpl::keylet::mptokenIssuance(mptSharesID).key;
461462

462463
EXPECT_CALL(*backend_, doFetchLedgerObject(accountKeylet, kSeq, _))

0 commit comments

Comments
 (0)