Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dangell7 committed Dec 13, 2024
1 parent c16b5b9 commit a776736
Show file tree
Hide file tree
Showing 25 changed files with 1,100 additions and 539 deletions.
98 changes: 0 additions & 98 deletions include/xrpl/protocol/Firewall.h

This file was deleted.

31 changes: 15 additions & 16 deletions include/xrpl/protocol/Indexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,6 @@ Keylet
oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;

Keylet
firewall(AccountID const& account) noexcept;

/** A FireallPreauth */
/** @{ */
Keylet
firewallPreauth(
AccountID const& owner,
AccountID const& preauthorized) noexcept;

inline Keylet
firewallPreauth(uint256 const& key) noexcept
{
return {ltFIREWALL_PREAUTH, key};
}
/** @} */
credential(
AccountID const& subject,
AccountID const& issuer,
Expand Down Expand Up @@ -344,6 +329,20 @@ mptoken(uint256 const& mptokenKey)
Keylet
mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;

Keylet
firewall(AccountID const& account) noexcept;

Keylet
withdrawPreauth(
AccountID const& owner,
AccountID const& preauthorized) noexcept;

inline Keylet
withdrawPreauth(uint256 const& key) noexcept
{
return {ltWITHDRAW_PREAUTH, key};
}

} // namespace keylet

// Everything below is deprecated and should be removed in favor of keylets:
Expand Down Expand Up @@ -389,4 +388,4 @@ makeMptID(std::uint32_t sequence, AccountID const& account);

} // namespace ripple

#endif
#endif
11 changes: 0 additions & 11 deletions include/xrpl/protocol/LedgerFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,6 @@ enum LedgerEntryType : std::uint16_t

#undef LEDGER_ENTRY
#pragma pop_macro("LEDGER_ENTRY")

/** A ledger object which tracks FIrewall
\sa keylet::firewall
*/
ltFIREWALL = 0x0046,

/** A ledger object which tracks FIrewall
\sa keylet::firewall
*/
ltFIREWALL_PREAUTH = 0x0047,

//---------------------------------------------------------------------------
/** A special type, matching any ledger entry type.
Expand Down
7 changes: 6 additions & 1 deletion include/xrpl/protocol/STTx.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class STTx final : public STObject, public CountedObject<STTx>
checkSign(RequireFullyCanonicalSig requireCanonicalSig, Rules const& rules)
const;

Expected<void, std::string>
checkFirewallSign(RequireFullyCanonicalSig requireCanonicalSig, Rules const& rules)
const;

// SQL Functions with metadata.
static std::string const&
getMetaSQLInsertReplaceHeader();
Expand All @@ -141,10 +145,11 @@ class STTx final : public STObject, public CountedObject<STTx>

private:
Expected<void, std::string>
checkSingleSign(RequireFullyCanonicalSig requireCanonicalSig) const;
checkSingleSign(STObject const& obj, RequireFullyCanonicalSig requireCanonicalSig) const;

Expected<void, std::string>
checkMultiSign(
STObject const& obj,
RequireFullyCanonicalSig requireCanonicalSig,
Rules const& rules) const;

Expand Down
1 change: 1 addition & 0 deletions include/xrpl/protocol/detail/features.macro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// If you add an amendment here, then do not forget to increment `numFeatures`
// in include/xrpl/protocol/Feature.h.

XRPL_FEATURE(Firewall, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(Credentials, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (AMMv1_2, Supported::yes, VoteBehavior::DefaultNo)
Expand Down
26 changes: 26 additions & 0 deletions include/xrpl/protocol/detail/ledger_entries.macro
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,29 @@ LEDGER_ENTRY(ltCREDENTIAL, 0x0081, Credential, ({
{sfPreviousTxnID, soeREQUIRED},
{sfPreviousTxnLgrSeq, soeREQUIRED},
}))

/** A ledger object which tracks Firewall
\sa keylet::firewall
*/
LEDGER_ENTRY(ltFIREWALL, 0x0046, Firewall, ({
{sfOwner, soeREQUIRED},
{sfIssuer, soeREQUIRED},
{sfAmount, soeOPTIONAL},
{sfTimePeriod, soeOPTIONAL},
{sfTimePeriodStart, soeOPTIONAL},
{sfTotalOut, soeOPTIONAL},
{sfOwnerNode, soeREQUIRED},
{sfPreviousTxnID, soeREQUIRED},
{sfPreviousTxnLgrSeq, soeREQUIRED}
}))

/** A ledger object which tracks WithdrawPreauth
\sa keylet::WithdrawPreauth
*/
LEDGER_ENTRY(ltWITHDRAW_PREAUTH, 0x0047, WithdrawPreauth, ({
{sfAccount, soeREQUIRED},
{sfAuthorize, soeREQUIRED},
{sfOwnerNode, soeREQUIRED},
{sfPreviousTxnID, soeREQUIRED},
{sfPreviousTxnLgrSeq, soeREQUIRED},
}))
5 changes: 5 additions & 0 deletions include/xrpl/protocol/detail/sfields.macro
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ TYPED_SFIELD(sfEmitGeneration, UINT32, 46)
TYPED_SFIELD(sfVoteWeight, UINT32, 48)
TYPED_SFIELD(sfFirstNFTokenSequence, UINT32, 50)
TYPED_SFIELD(sfOracleDocumentID, UINT32, 51)
TYPED_SFIELD(sfTimePeriod, UINT32, 52)
TYPED_SFIELD(sfTimePeriodStart, UINT32, 53)

// 64-bit integers (common)
TYPED_SFIELD(sfIndexNext, UINT64, 1)
Expand Down Expand Up @@ -230,6 +232,7 @@ TYPED_SFIELD(sfPrice, AMOUNT, 28)
TYPED_SFIELD(sfSignatureReward, AMOUNT, 29)
TYPED_SFIELD(sfMinAccountCreateAmount, AMOUNT, 30)
TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31)
TYPED_SFIELD(sfTotalOut, AMOUNT, 32)

// variable length (common)
TYPED_SFIELD(sfPublicKey, VL, 1)
Expand Down Expand Up @@ -346,6 +349,7 @@ UNTYPED_SFIELD(sfXChainClaimAttestationCollectionElement, OBJECT, 30)
UNTYPED_SFIELD(sfXChainCreateAccountAttestationCollectionElement, OBJECT, 31)
UNTYPED_SFIELD(sfPriceData, OBJECT, 32)
UNTYPED_SFIELD(sfCredential, OBJECT, 33)
UNTYPED_SFIELD(sfFirewallSigner, OBJECT, 34)

// array of objects (common)
// ARRAY/1 is reserved for end of array
Expand Down Expand Up @@ -375,3 +379,4 @@ UNTYPED_SFIELD(sfPriceDataSeries, ARRAY, 24)
UNTYPED_SFIELD(sfAuthAccounts, ARRAY, 25)
UNTYPED_SFIELD(sfAuthorizeCredentials, ARRAY, 26)
UNTYPED_SFIELD(sfUnauthorizeCredentials, ARRAY, 27)
UNTYPED_SFIELD(sfFirewallSigners, ARRAY, 28, SField::sMD_Default, SField::notSigning)
22 changes: 22 additions & 0 deletions include/xrpl/protocol/detail/transactions.macro
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,28 @@ TRANSACTION(ttCREDENTIAL_DELETE, 60, CredentialDelete, ({
{sfCredentialType, soeREQUIRED},
}))

/** This transaction type creates an WithdrawPreauth instance */
TRANSACTION(ttWITHDRAW_PREAUTH, 61, WithdrawPreauth, ({
{sfAuthorize, soeOPTIONAL},
{sfUnauthorize, soeOPTIONAL},
{sfPublicKey, soeREQUIRED},
{sfSignature, soeREQUIRED},
}))

/** This transaction type creates an Firewall instance */
TRANSACTION(ttFIREWALL_SET, 62, FirewallSet, ({
{sfIssuer, soeOPTIONAL},
{sfAuthorize, soeOPTIONAL},
{sfAmount, soeOPTIONAL},
{sfTimePeriod, soeOPTIONAL},
{sfFirewallSigners, soeOPTIONAL},
}))

// /** This transaction type deletes an Firewall instance */
// TRANSACTION(ttFIREWALL_DELETE, 63, FirewallDelete, ({
// {sfSignature, soeREQUIRED},
// }))


/** This system-generated transaction type is used to update the status of the various amendments.

Expand Down
3 changes: 3 additions & 0 deletions include/xrpl/protocol/jss.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ JSS(EPrice); // in: AMM Deposit option
JSS(Escrow); // ledger type.
JSS(Fee); // in/out: TransactionSign; field.
JSS(FeeSettings); // ledger type.
JSS(Firewall); // ledger type.
JSS(Flags); // in/out: TransactionSign; field.
JSS(Holder); // field.
JSS(Invalid); //
Expand Down Expand Up @@ -307,6 +308,8 @@ JSS(fee_level); // out: AccountInfo
JSS(fee_mult_max); // in: TransactionSign
JSS(fee_ref); // out: NetworkOPs, DEPRECATED
JSS(fetch_pack); // out: NetworkOPs
JSS(firewall); // in: LedgerEntry
JSS(withdraw_preauth); // in: LedgerEntry
JSS(FIELDS); // out: RPC server_definitions
// matches definitions.json format
JSS(first); // out: rpc/Version
Expand Down
31 changes: 16 additions & 15 deletions src/libxrpl/protocol/Indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ enum class LedgerNameSpace : std::uint16_t {
XCHAIN_CREATE_ACCOUNT_CLAIM_ID = 'K',
DID = 'I',
ORACLE = 'R',
FIREWALL = 'F',
FIREWALL_PREAUTH = 'G',
MPTOKEN_ISSUANCE = '~',
MPTOKEN = 't',
CREDENTIAL = 'D',
FIREWALL = 'F',
WITHDRAW_PREAUTH = 'G',

// No longer used or supported. Left here to reserve the space
// to avoid accidental reuse.
Expand Down Expand Up @@ -484,18 +484,6 @@ oracle(AccountID const& account, std::uint32_t const& documentID) noexcept
}

Keylet
firewall(AccountID const& account) noexcept
{
return {ltFIREWALL, indexHash(LedgerNameSpace::FIREWALL, account)};
}

Keylet
firewallPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept
{
return {
ltFIREWALL_PREAUTH,
indexHash(LedgerNameSpace::FIREWALL_PREAUTH, owner, preauthorized)};

mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept
{
return mptIssuance(makeMptID(seq, issuer));
Expand Down Expand Up @@ -531,9 +519,22 @@ credential(
return {
ltCREDENTIAL,
indexHash(LedgerNameSpace::CREDENTIAL, subject, issuer, credType)};
}

Keylet
firewall(AccountID const& account) noexcept
{
return {ltFIREWALL, indexHash(LedgerNameSpace::FIREWALL, account)};
}

Keylet
withdrawPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept
{
return {
ltWITHDRAW_PREAUTH,
indexHash(LedgerNameSpace::WITHDRAW_PREAUTH, owner, preauthorized)};
}

} // namespace keylet

} // namespace ripple
} // namespace ripple
8 changes: 8 additions & 0 deletions src/libxrpl/protocol/InnerObjectFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ InnerObjectFormats::InnerObjectFormats()
{sfIssuer, soeREQUIRED},
{sfCredentialType, soeREQUIRED},
});

add(sfFirewallSigner.jsonName.c_str(),
sfFirewallSigner.getCode(),
{
{sfAccount, soeREQUIRED},
{sfSigningPubKey, soeREQUIRED},
{sfTxnSignature, soeREQUIRED},
});
}

InnerObjectFormats const&
Expand Down
Loading

0 comments on commit a776736

Please sign in to comment.