From a1c21a06bc2578ad7162dea2b87d52c4829e130c Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Mon, 31 Mar 2025 16:40:46 +0100 Subject: [PATCH] Rename sfMPTokenIssuanceID in Vault to sfShareMPTID --- include/xrpl/protocol/detail/ledger_entries.macro | 8 ++++---- include/xrpl/protocol/detail/sfields.macro | 1 + include/xrpl/protocol/jss.h | 1 - src/libxrpl/protocol/STLedgerEntry.cpp | 2 -- src/test/app/Vault_test.cpp | 11 +++-------- src/xrpld/app/tx/detail/VaultClawback.cpp | 4 ++-- src/xrpld/app/tx/detail/VaultCreate.cpp | 2 +- src/xrpld/app/tx/detail/VaultDelete.cpp | 2 +- src/xrpld/app/tx/detail/VaultDeposit.cpp | 4 ++-- src/xrpld/app/tx/detail/VaultSet.cpp | 4 ++-- src/xrpld/app/tx/detail/VaultWithdraw.cpp | 4 ++-- src/xrpld/ledger/detail/View.cpp | 7 +++---- src/xrpld/rpc/detail/RPCHelpers.cpp | 2 +- 13 files changed, 22 insertions(+), 30 deletions(-) diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index b75e30d72e..720e621f23 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -475,11 +475,11 @@ LEDGER_ENTRY(ltVAULT, 0x0083, Vault, vault, ({ {sfAccount, soeREQUIRED}, {sfData, soeOPTIONAL}, {sfAsset, soeREQUIRED}, - {sfAssetsTotal, soeREQUIRED}, - {sfAssetsAvailable, soeREQUIRED}, - {sfAssetsMaximum, soeDEFAULT}, + {sfAssetsTotal, soeREQUIRED}, + {sfAssetsAvailable, soeREQUIRED}, + {sfAssetsMaximum, soeDEFAULT}, {sfLossUnrealized, soeREQUIRED}, - {sfMPTokenIssuanceID, soeREQUIRED}, // sfShare + {sfShareMPTID, soeREQUIRED}, {sfWithdrawalPolicy, soeREQUIRED}, // no SharesTotal ever (use MPTIssuance.sfOutstandingAmount) // no PermissionedDomainID ever (use MPTIssuance.sfDomainID) diff --git a/include/xrpl/protocol/detail/sfields.macro b/include/xrpl/protocol/detail/sfields.macro index 07248372c9..65cea1329b 100644 --- a/include/xrpl/protocol/detail/sfields.macro +++ b/include/xrpl/protocol/detail/sfields.macro @@ -155,6 +155,7 @@ TYPED_SFIELD(sfTakerGetsIssuer, UINT160, 4) // 192-bit (common) TYPED_SFIELD(sfMPTokenIssuanceID, UINT192, 1) +TYPED_SFIELD(sfShareMPTID, UINT192, 2) // 256-bit (common) TYPED_SFIELD(sfLedgerHash, UINT256, 1) diff --git a/include/xrpl/protocol/jss.h b/include/xrpl/protocol/jss.h index ba0d771b86..e563c31d50 100644 --- a/include/xrpl/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -89,7 +89,6 @@ JSS(SettleDelay); // in: TransactionSign JSS(SendMax); // in: TransactionSign JSS(Sequence); // in/out: TransactionSign; field. JSS(SetFlag); // field. -JSS(Share); // out: Vault JSS(SharesTotal); // out: Vault JSS(Signer); // field. JSS(Signers); // field. diff --git a/src/libxrpl/protocol/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp index c490fab533..02dcf7ca9b 100644 --- a/src/libxrpl/protocol/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -142,8 +142,6 @@ STLedgerEntry::getJson(JsonOptions options) const if (getType() == ltMPTOKEN_ISSUANCE) ret[jss::mpt_issuance_id] = to_string( makeMptID(getFieldU32(sfSequence), getAccountID(sfIssuer))); - else if (getType() == ltVAULT) - ret[jss::Share] = to_json(MPTIssue(getFieldH192(sfMPTokenIssuanceID))); return ret; } diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index e8ac73daeb..435da8021a 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -873,7 +873,7 @@ class Vault_test : public beast::unit_test::suite // accounts for the issued shares. auto v = env.le(keylet); BEAST_EXPECT(v); - MPTID share = (*v)[sfMPTokenIssuanceID]; + MPTID share = (*v)[sfShareMPTID]; auto issuance = env.le(keylet::mptIssuance(share)); BEAST_EXPECT(issuance); Number outstandingShares = issuance->at(sfOutstandingAmount); @@ -1240,18 +1240,13 @@ class Vault_test : public beast::unit_test::suite BEAST_EXPECT(checkString(sfAssetsMaximum, "1000")); BEAST_EXPECT(checkString(sfAssetsTotal, "50")); BEAST_EXPECT(checkString(sfLossUnrealized, "0")); - BEAST_EXPECT(checkString( - sfMPTokenIssuanceID, strHex(sle->at(sfMPTokenIssuanceID)))); + BEAST_EXPECT( + checkString(sfShareMPTID, strHex(sle->at(sfShareMPTID)))); BEAST_EXPECT(checkString(sfOwner, toBase58(owner.id()))); BEAST_EXPECT(checkInt(sfSequence, sequence)); BEAST_EXPECT( checkInt(sfWithdrawalPolicy, vaultStrategyFirstComeFirstServe)); - // This field is injected in STLedgerEntry::getJson - BEAST_EXPECT( - node.isMember(jss::Share) && node[jss::Share].isObject() && - node[jss::Share] == to_json(sle->at(sfMPTokenIssuanceID))); - // This field is injected in RPC::supplementJson BEAST_EXPECT( node.isMember(jss::SharesTotal) && diff --git a/src/xrpld/app/tx/detail/VaultClawback.cpp b/src/xrpld/app/tx/detail/VaultClawback.cpp index cde04b8331..3a8392a85c 100644 --- a/src/xrpld/app/tx/detail/VaultClawback.cpp +++ b/src/xrpld/app/tx/detail/VaultClawback.cpp @@ -119,7 +119,7 @@ VaultClawback::doApply() if (!vault) return tefINTERNAL; // Enforced in preclaim - auto const mptIssuanceID = (*vault)[sfMPTokenIssuanceID]; + auto const mptIssuanceID = (*vault)[sfShareMPTID]; auto const sleIssuance = view().read(keylet::mptIssuance(mptIssuanceID)); if (!sleIssuance) return tefINTERNAL; @@ -139,7 +139,7 @@ VaultClawback::doApply() STAmount assets, shares; if (amount == beast::zero) { - Asset share = *(*vault)[sfMPTokenIssuanceID]; + Asset share = *(*vault)[sfShareMPTID]; shares = accountHolds( view(), holder, diff --git a/src/xrpld/app/tx/detail/VaultCreate.cpp b/src/xrpld/app/tx/detail/VaultCreate.cpp index 1abfbccdd7..1b61c607c5 100644 --- a/src/xrpld/app/tx/detail/VaultCreate.cpp +++ b/src/xrpld/app/tx/detail/VaultCreate.cpp @@ -199,7 +199,7 @@ VaultCreate::doApply() // Leave default values for AssetTotal and AssetAvailable, both zero. if (auto value = tx[~sfAssetsMaximum]) vault->at(sfAssetsMaximum) = *value; - vault->at(sfMPTokenIssuanceID) = share; + vault->at(sfShareMPTID) = share; if (auto value = tx[~sfData]) vault->at(sfData) = *value; // Required field, default to vaultStrategyFirstComeFirstServe diff --git a/src/xrpld/app/tx/detail/VaultDelete.cpp b/src/xrpld/app/tx/detail/VaultDelete.cpp index 9385bd8da6..9ad0a99858 100644 --- a/src/xrpld/app/tx/detail/VaultDelete.cpp +++ b/src/xrpld/app/tx/detail/VaultDelete.cpp @@ -84,7 +84,7 @@ VaultDelete::doApply() // The operator-> gives the underlying STAccount, // whose value function returns a const&. {.account = vault->at(sfAccount)->value(), - .issuanceID = vault->at(sfMPTokenIssuanceID)})) + .issuanceID = vault->at(sfShareMPTID)})) return ter; // The psuedo-account's directory should have been deleted already. diff --git a/src/xrpld/app/tx/detail/VaultDeposit.cpp b/src/xrpld/app/tx/detail/VaultDeposit.cpp index 785f0991b6..92d9f8a433 100644 --- a/src/xrpld/app/tx/detail/VaultDeposit.cpp +++ b/src/xrpld/app/tx/detail/VaultDeposit.cpp @@ -70,7 +70,7 @@ VaultDeposit::preclaim(PreclaimContext const& ctx) if (isFrozen(ctx.view, account, vaultAsset)) return tecFROZEN; - auto const share = MPTIssue(vault->at(sfMPTokenIssuanceID)); + auto const share = MPTIssue(vault->at(sfShareMPTID)); // Cannot deposit if the shares of the vault are frozen if (isFrozen(ctx.view, account, share)) return tecFROZEN; @@ -126,7 +126,7 @@ VaultDeposit::doApply() auto const assets = ctx_.tx[sfAmount]; // Make sure the depositor can hold shares. - auto const mptIssuanceID = (*vault)[sfMPTokenIssuanceID]; + auto const mptIssuanceID = (*vault)[sfShareMPTID]; auto const sleIssuance = view().read(keylet::mptIssuance(mptIssuanceID)); if (!sleIssuance) return tefINTERNAL; diff --git a/src/xrpld/app/tx/detail/VaultSet.cpp b/src/xrpld/app/tx/detail/VaultSet.cpp index df1aa17f17..404372582d 100644 --- a/src/xrpld/app/tx/detail/VaultSet.cpp +++ b/src/xrpld/app/tx/detail/VaultSet.cpp @@ -86,7 +86,7 @@ VaultSet::preclaim(PreclaimContext const& ctx) if (ctx.tx[sfAccount] != vault->at(sfOwner)) return tecNO_PERMISSION; - auto const mptIssuanceID = (*vault)[sfMPTokenIssuanceID]; + auto const mptIssuanceID = (*vault)[sfShareMPTID]; auto const sleIssuance = ctx.view.read(keylet::mptIssuance(mptIssuanceID)); if (!sleIssuance) return tefINTERNAL; @@ -124,7 +124,7 @@ VaultSet::doApply() if (!vault) return tefINTERNAL; // Enforced in preclaim - auto const mptIssuanceID = (*vault)[sfMPTokenIssuanceID]; + auto const mptIssuanceID = (*vault)[sfShareMPTID]; auto const sleIssuance = view().peek(keylet::mptIssuance(mptIssuanceID)); if (!sleIssuance) return tefINTERNAL; diff --git a/src/xrpld/app/tx/detail/VaultWithdraw.cpp b/src/xrpld/app/tx/detail/VaultWithdraw.cpp index cb106324b7..6734ec9dde 100644 --- a/src/xrpld/app/tx/detail/VaultWithdraw.cpp +++ b/src/xrpld/app/tx/detail/VaultWithdraw.cpp @@ -79,7 +79,7 @@ VaultWithdraw::preclaim(PreclaimContext const& ctx) auto const assets = ctx.tx[sfAmount]; auto const asset = vault->at(sfAsset); - auto const share = vault->at(sfMPTokenIssuanceID); + auto const share = vault->at(sfShareMPTID); if (assets.asset() != asset && assets.asset() != share) return tecWRONG_ASSET; @@ -117,7 +117,7 @@ VaultWithdraw::doApply() if (!vault) return tefINTERNAL; // Enforced in preclaim - auto const mptIssuanceID = (*vault)[sfMPTokenIssuanceID]; + auto const mptIssuanceID = (*vault)[sfShareMPTID]; auto const sleIssuance = view().read(keylet::mptIssuance(mptIssuanceID)); if (!sleIssuance) return tefINTERNAL; diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 8774da02f2..d733b2a004 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -2533,8 +2533,7 @@ assetsToSharesDeposit( assets.asset() == vault->at(sfAsset), "ripple::assetsToSharesDeposit : assets and vault match"); Number assetTotal = vault->at(sfAssetsTotal); - STAmount shares{ - vault->at(sfMPTokenIssuanceID), static_cast(assets)}; + STAmount shares{vault->at(sfShareMPTID), static_cast(assets)}; if (assetTotal == 0) return shares; Number shareTotal = issuance->at(sfOutstandingAmount); @@ -2553,7 +2552,7 @@ assetsToSharesWithdraw( "ripple::assetsToSharesWithdraw : assets and vault match"); Number assetTotal = vault->at(sfAssetsTotal); assetTotal -= vault->at(sfLossUnrealized); - STAmount shares{vault->at(sfMPTokenIssuanceID)}; + STAmount shares{vault->at(sfShareMPTID)}; if (assetTotal == 0) return shares; Number shareTotal = issuance->at(sfOutstandingAmount); @@ -2568,7 +2567,7 @@ sharesToAssetsWithdraw( STAmount const& shares) { XRPL_ASSERT( - shares.asset() == vault->at(sfMPTokenIssuanceID), + shares.asset() == vault->at(sfShareMPTID), "ripple::sharesToAssetsWithdraw : shares and vault match"); Number assetTotal = vault->at(sfAssetsTotal); assetTotal -= vault->at(sfLossUnrealized); diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index eb77715cfe..7136c22e1b 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -160,7 +160,7 @@ supplementJson( vault->getType() == ltVAULT, "ripple::RPC::supplementJson : matching type"); - auto const share = vault->at(sfMPTokenIssuanceID); + auto const share = vault->at(sfShareMPTID); auto const sleIssuance = view.read(keylet::mptIssuance(share)); if (!sleIssuance) return;