mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-23 15:20:54 +00:00
refactor: Enable clang-tidy readability-identifier-naming check (#6571)
This commit is contained in:
@@ -68,9 +68,9 @@ AMM::AMM(
|
||||
std::uint16_t tfee,
|
||||
std::uint32_t fee,
|
||||
std::optional<std::uint32_t> flags,
|
||||
std::optional<jtx::seq> seq,
|
||||
std::optional<jtx::msig> ms,
|
||||
std::optional<ter> const& ter,
|
||||
std::optional<jtx::Seq> seq,
|
||||
std::optional<jtx::Msig> ms,
|
||||
std::optional<Ter> const& ter,
|
||||
bool close)
|
||||
: env_(env)
|
||||
, creatorAccount_(std::move(account))
|
||||
@@ -93,7 +93,7 @@ AMM::AMM(
|
||||
Account const& account,
|
||||
STAmount const& asset1,
|
||||
STAmount const& asset2,
|
||||
ter const& ter,
|
||||
Ter const& ter,
|
||||
bool log,
|
||||
bool close)
|
||||
: AMM(env,
|
||||
@@ -132,17 +132,17 @@ AMM::AMM(
|
||||
{
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::createJv(
|
||||
AccountID const& account,
|
||||
STAmount const& asset1,
|
||||
STAmount const& asset2,
|
||||
std::uint16_t const& tfee)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::Account] = to_string(account);
|
||||
jv[jss::Amount] = asset1.getJson(JsonOptions::none);
|
||||
jv[jss::Amount2] = asset2.getJson(JsonOptions::none);
|
||||
jv[jss::Amount] = asset1.getJson(JsonOptions::KNone);
|
||||
jv[jss::Amount2] = asset2.getJson(JsonOptions::KNone);
|
||||
jv[jss::TradingFee] = tfee;
|
||||
jv[jss::TransactionType] = jss::AMMCreate;
|
||||
|
||||
@@ -153,10 +153,10 @@ AMM::createJv(
|
||||
AMM::create(
|
||||
std::uint32_t tfee,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<jtx::seq> const& seq,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<jtx::Seq> const& seq,
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
Json::Value jv = createJv(creatorAccount_, asset1_, asset2_, tfee);
|
||||
json::Value jv = createJv(creatorAccount_, asset1_, asset2_, tfee);
|
||||
if (flags)
|
||||
jv[jss::Flags] = *flags;
|
||||
if (fee_ != 0)
|
||||
@@ -179,7 +179,7 @@ AMM::create(
|
||||
return {};
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::ammRpcInfo(
|
||||
std::optional<AccountID> const& account,
|
||||
std::optional<std::string> const& ledgerIndex,
|
||||
@@ -189,7 +189,7 @@ AMM::ammRpcInfo(
|
||||
bool ignoreParams,
|
||||
unsigned apiVersion) const
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
if (account)
|
||||
jv[jss::account] = to_string(*account);
|
||||
if (ledgerIndex)
|
||||
@@ -199,25 +199,25 @@ AMM::ammRpcInfo(
|
||||
if (asset1 || asset2)
|
||||
{
|
||||
if (asset1)
|
||||
jv[jss::asset] = STIssue(sfAsset, *asset1).getJson(JsonOptions::none);
|
||||
jv[jss::asset] = STIssue(sfAsset, *asset1).getJson(JsonOptions::KNone);
|
||||
if (asset2)
|
||||
jv[jss::asset2] = STIssue(sfAsset2, *asset2).getJson(JsonOptions::none);
|
||||
jv[jss::asset2] = STIssue(sfAsset2, *asset2).getJson(JsonOptions::KNone);
|
||||
}
|
||||
else if (!ammAccount)
|
||||
{
|
||||
jv[jss::asset] = STIssue(sfAsset, asset1_.asset()).getJson(JsonOptions::none);
|
||||
jv[jss::asset2] = STIssue(sfAsset2, asset2_.asset()).getJson(JsonOptions::none);
|
||||
jv[jss::asset] = STIssue(sfAsset, asset1_.asset()).getJson(JsonOptions::KNone);
|
||||
jv[jss::asset2] = STIssue(sfAsset2, asset2_.asset()).getJson(JsonOptions::KNone);
|
||||
}
|
||||
if (ammAccount)
|
||||
jv[jss::amm_account] = to_string(*ammAccount);
|
||||
}
|
||||
auto jr =
|
||||
(apiVersion == RPC::apiInvalidVersion
|
||||
(apiVersion == RPC::kAPI_INVALID_VERSION
|
||||
? env_.rpc("json", "amm_info", to_string(jv))
|
||||
: env_.rpc(apiVersion, "json", "amm_info", to_string(jv)));
|
||||
if (jr.isObject() && jr.isMember(jss::result) && jr[jss::result].isMember(jss::status))
|
||||
return jr[jss::result];
|
||||
return Json::nullValue;
|
||||
return json::NullValue;
|
||||
}
|
||||
|
||||
std::tuple<STAmount, STAmount, STAmount>
|
||||
@@ -232,8 +232,8 @@ AMM::balances(Asset const& asset1, Asset const& asset2, std::optional<AccountID>
|
||||
ammAccountID,
|
||||
asset1,
|
||||
asset2,
|
||||
FreezeHandling::fhIGNORE_FREEZE,
|
||||
AuthHandling::ahIGNORE_AUTH,
|
||||
FreezeHandling::IgnoreFreeze,
|
||||
AuthHandling::IgnoreAuth,
|
||||
env_.journal);
|
||||
auto const lptAMMBalance = account
|
||||
? ammLPHolds(*env_.current(), *amm, *account, env_.journal)
|
||||
@@ -262,11 +262,7 @@ AMM::getLPTokensBalance(std::optional<AccountID> const& account) const
|
||||
if (account)
|
||||
{
|
||||
return accountHolds(
|
||||
*env_.current(),
|
||||
*account,
|
||||
lptIssue_,
|
||||
FreezeHandling::fhZERO_IF_FROZEN,
|
||||
env_.journal)
|
||||
*env_.current(), *account, lptIssue_, FreezeHandling::ZeroIfFrozen, env_.journal)
|
||||
.iou();
|
||||
}
|
||||
if (auto const amm = env_.current()->read(keylet::amm(asset1_.asset(), asset2_.asset())))
|
||||
@@ -338,10 +334,10 @@ AMM::expectAmmRpcInfo(
|
||||
STAmount const& asset2,
|
||||
IOUAmount const& balance,
|
||||
std::optional<AccountID> const& account,
|
||||
std::optional<std::string> const& ledger_index,
|
||||
std::optional<std::string> const& ledgerIndex,
|
||||
std::optional<AccountID> const& ammAccount) const
|
||||
{
|
||||
auto const jv = ammRpcInfo(account, ledger_index, std::nullopt, std::nullopt, ammAccount);
|
||||
auto const jv = ammRpcInfo(account, ledgerIndex, std::nullopt, std::nullopt, ammAccount);
|
||||
return expectAmmInfo(asset1, asset2, balance, jv);
|
||||
}
|
||||
|
||||
@@ -350,7 +346,7 @@ AMM::expectAmmInfo(
|
||||
STAmount const& asset1,
|
||||
STAmount const& asset2,
|
||||
IOUAmount const& balance,
|
||||
Json::Value const& jvRes) const
|
||||
json::Value const& jvRes) const
|
||||
{
|
||||
if (!jvRes.isMember(jss::amm))
|
||||
return false;
|
||||
@@ -374,30 +370,30 @@ AMM::expectAmmInfo(
|
||||
}
|
||||
|
||||
void
|
||||
AMM::setTokens(Json::Value& jv, std::optional<std::pair<Asset, Asset>> const& assets)
|
||||
AMM::setTokens(json::Value& jv, std::optional<std::pair<Asset, Asset>> const& assets)
|
||||
{
|
||||
if (assets)
|
||||
{
|
||||
jv[jss::Asset] = STIssue(sfAsset, assets->first).getJson(JsonOptions::none);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, assets->second).getJson(JsonOptions::none);
|
||||
jv[jss::Asset] = STIssue(sfAsset, assets->first).getJson(JsonOptions::KNone);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, assets->second).getJson(JsonOptions::KNone);
|
||||
}
|
||||
else
|
||||
{
|
||||
jv[jss::Asset] = STIssue(sfAsset, asset1_.asset()).getJson(JsonOptions::none);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, asset2_.asset()).getJson(JsonOptions::none);
|
||||
jv[jss::Asset] = STIssue(sfAsset, asset1_.asset()).getJson(JsonOptions::KNone);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, asset2_.asset()).getJson(JsonOptions::KNone);
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::depositJv(DepositArg const& arg)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
if (!arg.account || !arg.assets)
|
||||
Throw<std::runtime_error>("AMM::depositJv: account or assets not set");
|
||||
|
||||
jv[jss::Account] = arg.account->human();
|
||||
jv[jss::Asset] = STIssue(sfAsset, arg.assets->first).getJson(JsonOptions::none);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, arg.assets->second).getJson(JsonOptions::none);
|
||||
jv[jss::Asset] = STIssue(sfAsset, arg.assets->first).getJson(JsonOptions::KNone);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, arg.assets->second).getJson(JsonOptions::KNone);
|
||||
if (arg.tokens)
|
||||
arg.tokens->tokens().setJson(jv[jss::LPTokenOut]);
|
||||
if (arg.asset1In)
|
||||
@@ -450,7 +446,7 @@ AMM::deposit(
|
||||
LPToken tokens,
|
||||
std::optional<STAmount> const& asset1In,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
return deposit(
|
||||
account,
|
||||
@@ -472,7 +468,7 @@ AMM::deposit(
|
||||
std::optional<STAmount> const& asset2In,
|
||||
std::optional<STAmount> const& maxEP,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
if (asset2In && maxEP)
|
||||
Throw<std::runtime_error>("Invalid options: asset2In and maxEP");
|
||||
@@ -498,13 +494,13 @@ AMM::deposit(
|
||||
std::optional<STAmount> const& maxEP,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<std::pair<Asset, Asset>> const& assets,
|
||||
std::optional<jtx::seq> const& seq,
|
||||
std::optional<jtx::Seq> const& seq,
|
||||
std::optional<std::uint16_t> const& tfee,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
auto const acct = account ? account : creatorAccount_;
|
||||
auto const lpTokens = getLPTokensBalance(acct);
|
||||
Json::Value jv = depositJv(
|
||||
json::Value jv = depositJv(
|
||||
{.account = acct,
|
||||
.tokens = tokens ? tokens->tokens(lptIssue_) : tokens,
|
||||
.asset1In = asset1In,
|
||||
@@ -535,15 +531,15 @@ AMM::deposit(DepositArg const& arg)
|
||||
arg.err);
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::withdrawJv(WithdrawArg const& arg)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
if (!arg.account || !arg.assets)
|
||||
Throw<std::runtime_error>("AMM::withdrawJv: account or assets not set");
|
||||
jv[jss::Account] = arg.account->human();
|
||||
jv[jss::Asset] = STIssue(sfAsset, arg.assets->first).getJson(JsonOptions::none);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, arg.assets->second).getJson(JsonOptions::none);
|
||||
jv[jss::Asset] = STIssue(sfAsset, arg.assets->first).getJson(JsonOptions::KNone);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, arg.assets->second).getJson(JsonOptions::KNone);
|
||||
if (arg.tokens)
|
||||
arg.tokens->tokens().setJson(jv[jss::LPTokenIn]);
|
||||
if (arg.asset1Out)
|
||||
@@ -591,7 +587,7 @@ AMM::withdraw(
|
||||
std::optional<LPToken> const& tokens,
|
||||
std::optional<STAmount> const& asset1Out,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
return withdraw(
|
||||
account,
|
||||
@@ -611,7 +607,7 @@ AMM::withdraw(
|
||||
STAmount const& asset1Out,
|
||||
std::optional<STAmount> const& asset2Out,
|
||||
std::optional<LPToken> const& maxEP,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
if (asset2Out && maxEP)
|
||||
Throw<std::runtime_error>("Invalid options: asset2Out and maxEP");
|
||||
@@ -636,12 +632,12 @@ AMM::withdraw(
|
||||
std::optional<LPToken> const& maxEP,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<std::pair<Asset, Asset>> const& assets,
|
||||
std::optional<jtx::seq> const& seq,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<jtx::Seq> const& seq,
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
auto const acct = account ? account : creatorAccount_;
|
||||
auto const lpTokens = getLPTokensBalance(acct);
|
||||
Json::Value jv = withdrawJv({
|
||||
json::Value jv = withdrawJv({
|
||||
.account = acct,
|
||||
.tokens = tokens ? tokens->tokens(lptIssue_) : tokens,
|
||||
.asset1Out = asset1Out,
|
||||
@@ -671,15 +667,15 @@ AMM::withdraw(WithdrawArg const& arg)
|
||||
arg.err);
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::voteJv(VoteArg const& arg)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
if (!arg.account || !arg.assets)
|
||||
Throw<std::runtime_error>("AMM::withdrawJv: account or assets not set");
|
||||
jv[jss::Account] = arg.account->human();
|
||||
jv[jss::Asset] = STIssue(sfAsset, arg.assets->first).getJson(JsonOptions::none);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, arg.assets->second).getJson(JsonOptions::none);
|
||||
jv[jss::Asset] = STIssue(sfAsset, arg.assets->first).getJson(JsonOptions::KNone);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, arg.assets->second).getJson(JsonOptions::KNone);
|
||||
jv[jss::TradingFee] = arg.tfee;
|
||||
if (arg.flags)
|
||||
jv[jss::Flags] = *arg.flags;
|
||||
@@ -694,11 +690,11 @@ AMM::vote(
|
||||
std::optional<Account> const& account,
|
||||
std::uint32_t feeVal,
|
||||
std::optional<std::uint32_t> const& flags,
|
||||
std::optional<jtx::seq> const& seq,
|
||||
std::optional<jtx::Seq> const& seq,
|
||||
std::optional<std::pair<Asset, Asset>> const& assets,
|
||||
std::optional<ter> const& ter)
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
Json::Value jv = voteJv({
|
||||
json::Value jv = voteJv({
|
||||
.account = account ? account : creatorAccount_,
|
||||
.tfee = feeVal,
|
||||
.flags = flags,
|
||||
@@ -715,7 +711,7 @@ AMM::vote(VoteArg const& arg)
|
||||
vote(arg.account, arg.tfee, arg.flags, arg.seq, arg.assets, arg.err);
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::bid(BidArg const& arg)
|
||||
{
|
||||
if (auto const amm = env_.current()->read(keylet::amm(asset1_.asset(), asset2_.asset())))
|
||||
@@ -726,14 +722,14 @@ AMM::bid(BidArg const& arg)
|
||||
if (amm->isFieldPresent(sfAuctionSlot))
|
||||
{
|
||||
auto const& auctionSlot =
|
||||
safe_downcast<STObject const&>(amm->peekAtField(sfAuctionSlot));
|
||||
safeDowncast<STObject const&>(amm->peekAtField(sfAuctionSlot));
|
||||
lastPurchasePrice_ = auctionSlot[sfPrice].iou();
|
||||
}
|
||||
}
|
||||
bidMin_ = std::nullopt;
|
||||
bidMax_ = std::nullopt;
|
||||
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::Account] = arg.account ? arg.account->human() : creatorAccount_.human();
|
||||
setTokens(jv, arg.assets);
|
||||
auto getBid = [&](auto const& bid) {
|
||||
@@ -762,11 +758,11 @@ AMM::bid(BidArg const& arg)
|
||||
}
|
||||
if (!arg.authAccounts.empty())
|
||||
{
|
||||
Json::Value accounts(Json::arrayValue);
|
||||
json::Value accounts(json::ArrayValue);
|
||||
for (auto const& account : arg.authAccounts)
|
||||
{
|
||||
Json::Value acct;
|
||||
Json::Value authAcct;
|
||||
json::Value acct;
|
||||
json::Value authAcct;
|
||||
acct[jss::Account] = account.human();
|
||||
authAcct[jss::AuthAccount] = acct;
|
||||
accounts.append(authAcct);
|
||||
@@ -799,9 +795,9 @@ AMM::clawback(ClawbackArg const& arg)
|
||||
|
||||
void
|
||||
AMM::submit(
|
||||
Json::Value const& jv,
|
||||
std::optional<jtx::seq> const& seq,
|
||||
std::optional<ter> const& ter)
|
||||
json::Value const& jv,
|
||||
std::optional<jtx::Seq> const& seq,
|
||||
std::optional<Ter> const& ter)
|
||||
{
|
||||
if (log_)
|
||||
std::cout << jv.toStyledString();
|
||||
@@ -855,7 +851,7 @@ AMM::expectAuctionSlot(auto&& cb) const
|
||||
if (amm->isFieldPresent(sfAuctionSlot))
|
||||
{
|
||||
auto const& auctionSlot =
|
||||
safe_downcast<STObject const&>(amm->peekAtField(sfAuctionSlot));
|
||||
safeDowncast<STObject const&>(amm->peekAtField(sfAuctionSlot));
|
||||
if (auctionSlot.isFieldPresent(sfAccount))
|
||||
{
|
||||
// This could fail in pre-fixInnerObjTemplate tests
|
||||
@@ -874,13 +870,13 @@ AMM::expectAuctionSlot(auto&& cb) const
|
||||
return false;
|
||||
}
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
AMM::deleteJv(AccountID const& account, Asset const& asset1, Asset const& asset2)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::Account] = to_string(account);
|
||||
jv[jss::Asset] = STIssue(sfAsset, asset1).getJson(JsonOptions::none);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, asset2).getJson(JsonOptions::none);
|
||||
jv[jss::Asset] = STIssue(sfAsset, asset1).getJson(JsonOptions::KNone);
|
||||
jv[jss::Asset2] = STIssue(sfAsset, asset2).getJson(JsonOptions::KNone);
|
||||
|
||||
jv[jss::TransactionType] = jss::AMMDelete;
|
||||
|
||||
@@ -888,9 +884,9 @@ AMM::deleteJv(AccountID const& account, Asset const& asset1, Asset const& asset2
|
||||
}
|
||||
|
||||
void
|
||||
AMM::ammDelete(AccountID const& account, std::optional<ter> const& ter)
|
||||
AMM::ammDelete(AccountID const& account, std::optional<Ter> const& ter)
|
||||
{
|
||||
Json::Value jv = deleteJv(account, asset1_.asset(), asset2_.asset());
|
||||
json::Value jv = deleteJv(account, asset1_.asset(), asset2_.asset());
|
||||
if (fee_ != 0)
|
||||
jv[jss::Fee] = std::to_string(fee_);
|
||||
submit(jv, std::nullopt, ter);
|
||||
@@ -898,7 +894,7 @@ AMM::ammDelete(AccountID const& account, std::optional<ter> const& ter)
|
||||
|
||||
namespace amm {
|
||||
|
||||
Json::Value
|
||||
json::Value
|
||||
ammClawback(
|
||||
Account const& issuer,
|
||||
Account const& holder,
|
||||
@@ -906,14 +902,14 @@ ammClawback(
|
||||
Asset const& asset2,
|
||||
std::optional<STAmount> const& amount)
|
||||
{
|
||||
Json::Value jv;
|
||||
json::Value jv;
|
||||
jv[jss::TransactionType] = jss::AMMClawback;
|
||||
jv[jss::Account] = issuer.human();
|
||||
jv[jss::Holder] = holder.human();
|
||||
jv[jss::Asset] = to_json(asset);
|
||||
jv[jss::Asset2] = to_json(asset2);
|
||||
jv[jss::Asset] = toJson(asset);
|
||||
jv[jss::Asset2] = toJson(asset2);
|
||||
if (amount)
|
||||
jv[jss::Amount] = amount->getJson(JsonOptions::none);
|
||||
jv[jss::Amount] = amount->getJson(JsonOptions::KNone);
|
||||
|
||||
return jv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user