Skip to content

Commit

Permalink
New SField flag to override hex input/output formatting to use decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
ximinez committed Oct 3, 2024
1 parent ea887bf commit d8784d5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions include/xrpl/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class SField
sMD_DeleteFinal = 0x04, // final value when it is deleted
sMD_Create = 0x08, // value when it's created
sMD_Always = 0x10, // value when node containing it is affected at all
sMD_BaseTen = 0x20,
sMD_Default =
sMD_ChangeOrig | sMD_ChangeNew | sMD_DeleteFinal | sMD_Create
};
Expand Down
6 changes: 3 additions & 3 deletions src/libxrpl/protocol/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ CONSTRUCT_TYPED_SFIELD(sfXChainClaimID, "XChainClaimID", U
CONSTRUCT_TYPED_SFIELD(sfXChainAccountCreateCount, "XChainAccountCreateCount", UINT64, 21);
CONSTRUCT_TYPED_SFIELD(sfXChainAccountClaimCount, "XChainAccountClaimCount", UINT64, 22);
CONSTRUCT_TYPED_SFIELD(sfAssetPrice, "AssetPrice", UINT64, 23);
CONSTRUCT_TYPED_SFIELD(sfMaximumAmount, "MaximumAmount", UINT64, 24);
CONSTRUCT_TYPED_SFIELD(sfOutstandingAmount, "OutstandingAmount", UINT64, 25);
CONSTRUCT_TYPED_SFIELD(sfMPTAmount, "MPTAmount", UINT64, 26);
CONSTRUCT_TYPED_SFIELD(sfMaximumAmount, "MaximumAmount", UINT64, 24, SField::sMD_BaseTen);
CONSTRUCT_TYPED_SFIELD(sfOutstandingAmount, "OutstandingAmount", UINT64, 25, SField::sMD_BaseTen);
CONSTRUCT_TYPED_SFIELD(sfMPTAmount, "MPTAmount", UINT64, 26, SField::sMD_BaseTen);

// 128-bit
CONSTRUCT_TYPED_SFIELD(sfEmailHash, "EmailHash", UINT128, 1);
Expand Down
3 changes: 1 addition & 2 deletions src/libxrpl/protocol/STInteger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ Json::Value STUInt64::getJson(JsonOptions) const
return str;
};

if (auto const& fName = getFName(); fName == sfMaximumAmount ||
fName == sfOutstandingAmount || fName == sfMPTAmount)
if (auto const& fName = getFName(); fName.shouldMeta(SField::sMD_BaseTen))
{
return convertToString(value_, 10); // Convert to base 10
}
Expand Down
3 changes: 1 addition & 2 deletions src/libxrpl/protocol/STParsedJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ parseLeaf(

std::uint64_t val;

bool const useBase10 = field == sfMaximumAmount ||
field == sfOutstandingAmount || field == sfMPTAmount;
bool const useBase10 = field.shouldMeta(SField::sMD_BaseTen);

// if the field is amount, serialize as base 10
auto [p, ec] = std::from_chars(
Expand Down

0 comments on commit d8784d5

Please sign in to comment.