mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 08:46:46 +00:00
- Create a new SField metadata enum, sMD_NeedsAsset, which indicates the field should be associated with an Asset so it can be rounded. - Add a new STTakesAsset intermediate class to handle the Asset association to a derived ST class. Currently only used in STNumber, but could be used by other types in the future. - Add "associateAsset" which takes an SLE and an Asset, finds the sMD_NeedsAsset fields, and associates the Asset to them. In the case of STNumber, that both stores the Asset, and rounds the value immediately. - Transactors only need to add a call to associateAsset _after_ all of the STNumbers have been set. Unfortunately, the inner workings of STObject do not do the association correctly with uninitialized fields. - When serializing an STNumber that has an Asset, round it before serializing. - Add an override of roundToAsset, which rounds a Number value in place to an Asset, but without any additional scale. - Update and fix a bunch of Loan-related tests to accommodate the expanded Number class. - (Not all tests are fixed yet.)
30 lines
499 B
C++
30 lines
499 B
C++
#ifndef XRPL_PROTOCOL_STTAKESASSET_H_INCLUDED
|
|
#define XRPL_PROTOCOL_STTAKESASSET_H_INCLUDED
|
|
|
|
#include <xrpl/protocol/Asset.h>
|
|
#include <xrpl/protocol/STBase.h>
|
|
|
|
namespace ripple {
|
|
|
|
class STTakesAsset : public STBase
|
|
{
|
|
protected:
|
|
std::optional<Asset> asset_;
|
|
|
|
public:
|
|
using STBase::STBase;
|
|
using STBase::operator=;
|
|
|
|
virtual void
|
|
associateAsset(Asset const& a);
|
|
};
|
|
|
|
class STLedgerEntry;
|
|
|
|
void
|
|
associateAsset(STLedgerEntry& sle, Asset const& asset);
|
|
|
|
} // namespace ripple
|
|
|
|
#endif
|