ttInvoke part 1

This commit is contained in:
Richard Holland
2022-12-16 10:44:07 +00:00
parent 44425f14f6
commit 8a0635396a
9 changed files with 30 additions and 1 deletions

View File

@@ -441,6 +441,7 @@ target_sources (rippled PRIVATE
src/ripple/app/tx/impl/SetRegularKey.cpp
src/ripple/app/tx/impl/SetHook.cpp
src/ripple/app/tx/impl/ClaimReward.cpp
src/ripple/app/tx/impl/Invoke.cpp
src/ripple/app/tx/impl/SetSignerList.cpp
src/ripple/app/tx/impl/SetTrust.cpp
src/ripple/app/tx/impl/SignerEntries.cpp

View File

@@ -66,7 +66,8 @@ namespace hook
{ttNFTOKEN_CREATE_OFFER, tshROLLBACK },
{ttNFTOKEN_CANCEL_OFFER, tshCOLLECT },
{ttNFTOKEN_ACCEPT_OFFER, tshROLLBACK },
{ttCLAIM_REWARD, tshROLLBACK }
{ttCLAIM_REWARD, tshROLLBACK },
{ttINVOKE, tshROLLBACK }
};

View File

@@ -202,6 +202,7 @@ namespace hook
case ttCHECK_CREATE:
case ttACCOUNT_DELETE:
case ttPAYCHAN_CREATE:
case ttINVOKE:
{
ADD_TSH(*destAcc, canRollback);
break;

View File

@@ -41,6 +41,7 @@
#include <ripple/app/tx/impl/SetSignerList.h>
#include <ripple/app/tx/impl/SetTrust.h>
#include <ripple/app/tx/impl/SetHook.h>
#include <ripple/app/tx/impl/Invoke.h>
namespace ripple {
@@ -153,6 +154,8 @@ invoke_preflight(PreflightContext const& ctx)
return invoke_preflight_helper<NFTokenAcceptOffer>(ctx);
case ttCLAIM_REWARD:
return invoke_preflight_helper<ClaimReward>(ctx);
case ttINVOKE:
return invoke_preflight_helper<Invoke>(ctx);
default:
assert(false);
return {temUNKNOWN, TxConsequences{temUNKNOWN}};
@@ -260,6 +263,8 @@ invoke_preclaim(PreclaimContext const& ctx)
return invoke_preclaim<NFTokenAcceptOffer>(ctx);
case ttCLAIM_REWARD:
return invoke_preclaim<ClaimReward>(ctx);
case ttINVOKE:
return invoke_preclaim<Invoke>(ctx);
default:
assert(false);
return temUNKNOWN;
@@ -328,6 +333,8 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx)
return NFTokenAcceptOffer::calculateBaseFee(view, tx);
case ttCLAIM_REWARD:
return ClaimReward::calculateBaseFee(view, tx);
case ttINVOKE:
return Invoke::calculateBaseFee(view, tx);
default:
assert(false);
return FeeUnit64{0};
@@ -490,6 +497,10 @@ invoke_apply(ApplyContext& ctx)
ClaimReward p(ctx);
return p();
}
case ttINVOKE: {
Invoke p(ctx);
return p();
}
default:
assert(false);
return {temUNKNOWN, false};

View File

@@ -519,6 +519,7 @@ extern SF_VL const sfHookStateData;
extern SF_VL const sfHookReturnString;
extern SF_VL const sfHookParameterName;
extern SF_VL const sfHookParameterValue;
extern SF_VL const sfBlob;
// account
extern SF_ACCOUNT const sfAccount;

View File

@@ -142,6 +142,9 @@ enum TxType : std::uint16_t
/** This transaction resets accumulator/counters and claims a reward for holding an average balance
* from a specified hook */
ttCLAIM_REWARD = 98,
/** This transaction invokes a hook, providing arbitrary data. Essentially as a 0 drop payment. **/
ttINVOKE = 99,
/** This system-generated transaction type is used to update the status of the various amendments.

View File

@@ -270,6 +270,7 @@ CONSTRUCT_TYPED_SFIELD(sfHookStateData, "HookStateData", VL,
CONSTRUCT_TYPED_SFIELD(sfHookReturnString, "HookReturnString", VL, 23);
CONSTRUCT_TYPED_SFIELD(sfHookParameterName, "HookParameterName", VL, 24);
CONSTRUCT_TYPED_SFIELD(sfHookParameterValue, "HookParameterValue", VL, 25);
CONSTRUCT_TYPED_SFIELD(sfBlob, "Blob", VL, 26);
// account
CONSTRUCT_TYPED_SFIELD(sfAccount, "Account", ACCOUNT, 1);

View File

@@ -350,6 +350,15 @@ TxFormats::TxFormats()
{sfTicketSequence, soeOPTIONAL},
},
commonFields);
add(jss::Invoke,
ttINVOKE,
{
{sfBlob, soeOPTIONAL},
{sfHookParameters, soeOPTIONAL},
{sfDestination, soeREQUIRED}
},
commonFields);
}
TxFormats const&

View File

@@ -83,6 +83,7 @@ JSS(HookParameterValue); // field
JSS(HookParameter); // field
JSS(HookGrant); // field
JSS(Invalid); //
JSS(Invoke); // transaction type
JSS(LastLedgerSequence); // in: TransactionSign; field
JSS(LedgerHashes); // ledger type.
JSS(LimitAmount); // field.