From 2817f848e8762ed27895eb3c03be5d85a1fae0e4 Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Sat, 9 Dec 2023 13:10:08 +0000 Subject: [PATCH] . --- src/ripple/app/tx/impl/Cadastre.cpp | 83 +++++++++++++++++++++++++++++ src/ripple/app/tx/impl/Cadastre.h | 57 ++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 src/ripple/app/tx/impl/Cadastre.cpp create mode 100644 src/ripple/app/tx/impl/Cadastre.h diff --git a/src/ripple/app/tx/impl/Cadastre.cpp b/src/ripple/app/tx/impl/Cadastre.cpp new file mode 100644 index 000000000..aa05cae34 --- /dev/null +++ b/src/ripple/app/tx/impl/Cadastre.cpp @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2012, 2013 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 +#include +#include +#include +#include + +namespace ripple { + +TxConsequences +Cadastre::makeTxConsequences(PreflightContext const& ctx) +{ + return TxConsequences{ctx.tx, TxConsequences::normal}; +} + +NotTEC +Cadastre::preflight(PreflightContext const& ctx) +{ + if (auto const ret = preflight1(ctx); !isTesSuccess(ret)) + return ret; + + auto& tx = ctx.tx; + + + + return preflight2(ctx); +} + +TER +Cadastre::preclaim(PreclaimContext const& ctx) +{ + if (!ctx.view.rules().enabled(featureHooks)) + return temDISABLED; + + auto const id = ctx.tx[sfAccount]; + + auto const sle = ctx.view.read(keylet::account(id)); + if (!sle) + return terNO_ACCOUNT; + + if (ctx.tx.isFieldPresent(sfDestination)) + { + if (!ctx.view.exists(keylet::account(ctx.tx[sfDestination]))) + return tecNO_TARGET; + } + + return tesSUCCESS; +} + +TER +Cadastre::doApply() +{ + // everything happens in the hooks! + return tesSUCCESS; +} + +XRPAmount +Cadastre::calculateBaseFee(ReadView const& view, STTx const& tx) +{ + XRPAmount extraFee{0}; + + return Transactor::calculateBaseFee(view, tx) + extraFee; +} + +} // namespace ripple diff --git a/src/ripple/app/tx/impl/Cadastre.h b/src/ripple/app/tx/impl/Cadastre.h new file mode 100644 index 000000000..027430620 --- /dev/null +++ b/src/ripple/app/tx/impl/Cadastre.h @@ -0,0 +1,57 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2014 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_TX_CADASTRE_H_INCLUDED +#define RIPPLE_TX_CADASTRE_H_INCLUDED + +#include +#include +#include +#include + +namespace ripple { + +class Cadastre : public Transactor +{ +public: + static constexpr ConsequencesFactoryType ConsequencesFactory{Normal}; + + explicit Cadastre(ApplyContext& ctx) : Transactor(ctx) + { + } + + static XRPAmount + calculateBaseFee(ReadView const& view, STTx const& tx); + + static TxConsequences + makeTxConsequences(PreflightContext const& ctx); + + static NotTEC + preflight(PreflightContext const& ctx); + + static TER + preclaim(PreclaimContext const& ctx); + + TER + doApply() override; +}; + +} // namespace ripple + +#endif