-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nftoken_id, nftoken_ids, offer_id fields for NFTokens (#4447)
Three new fields are added to the `Tx` responses for NFTs: 1. `nftoken_id`: This field is included in the `Tx` responses for `NFTokenMint` and `NFTokenAcceptOffer`. This field indicates the `NFTokenID` for the `NFToken` that was modified on the ledger by the transaction. 2. `nftoken_ids`: This array is included in the `Tx` response for `NFTokenCancelOffer`. This field provides a list of all the `NFTokenID`s for the `NFToken`s that were modified on the ledger by the transaction. 3. `offer_id`: This field is included in the `Tx` response for `NFTokenCreateOffer` transactions and shows the OfferID of the `NFTokenOffer` created. The fields make it easier to track specific tokens and offers. The implementation includes code (by @ledhed2222) from the Clio project to extract NFTokenIDs from mint transactions.
- Loading branch information
1 parent
629ed5c
commit 3620ac2
Showing
11 changed files
with
772 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2023 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#ifndef RIPPLE_RPC_NFTSYNTHETICSERIALIZER_H_INCLUDED | ||
#define RIPPLE_RPC_NFTSYNTHETICSERIALIZER_H_INCLUDED | ||
|
||
#include <ripple/protocol/Protocol.h> | ||
#include <ripple/protocol/STBase.h> | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
namespace Json { | ||
class Value; | ||
} | ||
|
||
namespace ripple { | ||
|
||
class TxMeta; | ||
class STTx; | ||
|
||
namespace RPC { | ||
|
||
struct JsonContext; | ||
|
||
/** | ||
Adds common synthetic fields to transaction-related JSON responses | ||
@{ | ||
*/ | ||
void | ||
insertNFTSyntheticInJson( | ||
Json::Value&, | ||
RPC::JsonContext const&, | ||
std::shared_ptr<STTx const> const&, | ||
TxMeta const&); | ||
/** @} */ | ||
|
||
} // namespace RPC | ||
} // namespace ripple | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2023 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#ifndef RIPPLE_RPC_NFTOKENID_H_INCLUDED | ||
#define RIPPLE_RPC_NFTOKENID_H_INCLUDED | ||
|
||
#include <ripple/protocol/Protocol.h> | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
namespace Json { | ||
class Value; | ||
} | ||
|
||
namespace ripple { | ||
|
||
class TxMeta; | ||
class STTx; | ||
|
||
namespace RPC { | ||
|
||
/** | ||
Add a `nftoken_ids` field to the `meta` output parameter. | ||
The field is only added to successful NFTokenMint, NFTokenAcceptOffer, | ||
and NFTokenCancelOffer transactions. | ||
Helper functions are not static because they can be used by Clio. | ||
@{ | ||
*/ | ||
bool | ||
canHaveNFTokenID( | ||
std::shared_ptr<STTx const> const& serializedTx, | ||
TxMeta const& transactionMeta); | ||
|
||
std::optional<uint256> | ||
getNFTokenIDFromPage(TxMeta const& transactionMeta); | ||
|
||
std::vector<uint256> | ||
getNFTokenIDFromDeletedOffer(TxMeta const& transactionMeta); | ||
|
||
void | ||
insertNFTokenID( | ||
Json::Value& response, | ||
std::shared_ptr<STTx const> const& transaction, | ||
TxMeta const& transactionMeta); | ||
/** @} */ | ||
|
||
} // namespace RPC | ||
} // namespace ripple | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2023 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#ifndef RIPPLE_RPC_NFTOKENOFFERID_H_INCLUDED | ||
#define RIPPLE_RPC_NFTOKENOFFERID_H_INCLUDED | ||
|
||
#include <ripple/protocol/Protocol.h> | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
namespace Json { | ||
class Value; | ||
} | ||
|
||
namespace ripple { | ||
|
||
class TxMeta; | ||
class STTx; | ||
|
||
namespace RPC { | ||
|
||
/** | ||
Add an `offer_id` field to the `meta` output parameter. | ||
The field is only added to successful NFTokenCreateOffer transactions. | ||
Helper functions are not static because they can be used by Clio. | ||
@{ | ||
*/ | ||
bool | ||
canHaveNFTokenOfferID( | ||
std::shared_ptr<STTx const> const& serializedTx, | ||
TxMeta const& transactionMeta); | ||
|
||
std::optional<uint256> | ||
getOfferIDFromCreatedOffer(TxMeta const& transactionMeta); | ||
|
||
void | ||
insertNFTokenOfferID( | ||
Json::Value& response, | ||
std::shared_ptr<STTx const> const& transaction, | ||
TxMeta const& transactionMeta); | ||
/** @} */ | ||
|
||
} // namespace RPC | ||
} // namespace ripple | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//------------------------------------------------------------------------------ | ||
/* | ||
This file is part of rippled: https://github.com/ripple/rippled | ||
Copyright (c) 2023 Ripple Labs Inc. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
//============================================================================== | ||
|
||
#include <ripple/rpc/NFTSyntheticSerializer.h> | ||
|
||
#include <ripple/app/ledger/LedgerMaster.h> | ||
#include <ripple/app/ledger/OpenLedger.h> | ||
#include <ripple/app/misc/Transaction.h> | ||
#include <ripple/ledger/View.h> | ||
#include <ripple/net/RPCErr.h> | ||
#include <ripple/protocol/AccountID.h> | ||
#include <ripple/protocol/Feature.h> | ||
#include <ripple/rpc/Context.h> | ||
#include <ripple/rpc/NFTokenID.h> | ||
#include <ripple/rpc/NFTokenOfferID.h> | ||
#include <ripple/rpc/impl/RPCHelpers.h> | ||
#include <boost/algorithm/string/case_conv.hpp> | ||
|
||
namespace ripple { | ||
namespace RPC { | ||
|
||
void | ||
insertNFTSyntheticInJson( | ||
Json::Value& response, | ||
RPC::JsonContext const& context, | ||
std::shared_ptr<STTx const> const& transaction, | ||
TxMeta const& transactionMeta) | ||
{ | ||
insertNFTokenID(response[jss::meta], transaction, transactionMeta); | ||
insertNFTokenOfferID(response[jss::meta], transaction, transactionMeta); | ||
} | ||
|
||
} // namespace RPC | ||
} // namespace ripple |
Oops, something went wrong.