Skip to content

Commit dc8a689

Browse files
committed
feature-subscriptions
1 parent e5f7a84 commit dc8a689

22 files changed

+4715
-1
lines changed

include/xrpl/protocol/Indexes.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,19 @@ permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;
349349

350350
Keylet
351351
permissionedDomain(uint256 const& domainID) noexcept;
352+
353+
Keylet
354+
subscription(
355+
AccountID const& account,
356+
AccountID const& dest,
357+
std::uint32_t const& seq) noexcept;
358+
359+
inline Keylet
360+
subscription(uint256 const& key) noexcept
361+
{
362+
return {ltSUBSCRIPTION, key};
363+
}
364+
352365
} // namespace keylet
353366

354367
// Everything below is deprecated and should be removed in favor of keylets:

include/xrpl/protocol/LedgerFormats.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ enum LedgerEntryType : std::uint16_t
6262

6363
#undef LEDGER_ENTRY
6464
#pragma pop_macro("LEDGER_ENTRY")
65-
6665
//---------------------------------------------------------------------------
6766
/** A special type, matching any ledger entry type.
6867

include/xrpl/protocol/detail/features.macro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
// If you add an amendment here, then do not forget to increment `numFeatures`
3333
// in include/xrpl/protocol/Feature.h.
3434

35+
XRPL_FEATURE(Subscription, Supported::no, VoteBehavior::DefaultNo)
3536
XRPL_FIX (PriceOracleOrder, Supported::no, VoteBehavior::DefaultNo)
3637
XRPL_FIX (MPTDeliveredAmount, Supported::no, VoteBehavior::DefaultNo)
3738
XRPL_FIX (AMMClawbackRounding, Supported::yes, VoteBehavior::DefaultNo)

include/xrpl/protocol/detail/ledger_entries.macro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,5 +504,25 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({
504504
// no PermissionedDomainID ever (use MPTIssuance.sfDomainID)
505505
}))
506506

507+
/** A ledger object representing a subscription.
508+
509+
\sa keylet::mptoken
510+
*/
511+
LEDGER_ENTRY(ltSUBSCRIPTION, 0x0085, Subscription, subscription, ({
512+
{sfPreviousTxnID, soeREQUIRED},
513+
{sfPreviousTxnLgrSeq, soeREQUIRED},
514+
{sfSequence, soeREQUIRED},
515+
{sfOwnerNode, soeREQUIRED},
516+
{sfAccount, soeREQUIRED},
517+
{sfDestination, soeREQUIRED},
518+
{sfDestinationTag, soeOPTIONAL},
519+
{sfAmount, soeREQUIRED},
520+
{sfBalance, soeREQUIRED},
521+
{sfFrequency, soeREQUIRED},
522+
{sfNextClaimTime, soeREQUIRED},
523+
{sfExpiration, soeOPTIONAL},
524+
{sfDestinationNode, soeREQUIRED},
525+
}))
526+
507527
#undef EXPAND
508528
#undef LEDGER_ENTRY_DUPLICATE

include/xrpl/protocol/detail/sfields.macro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ TYPED_SFIELD(sfVoteWeight, UINT32, 48)
114114
TYPED_SFIELD(sfFirstNFTokenSequence, UINT32, 50)
115115
TYPED_SFIELD(sfOracleDocumentID, UINT32, 51)
116116
TYPED_SFIELD(sfPermissionValue, UINT32, 52)
117+
TYPED_SFIELD(sfFrequency, UINT32, 53)
118+
TYPED_SFIELD(sfStartTime, UINT32, 54)
119+
TYPED_SFIELD(sfNextClaimTime, UINT32, 55)
117120

118121
// 64-bit integers (common)
119122
TYPED_SFIELD(sfIndexNext, UINT64, 1)
@@ -197,6 +200,7 @@ TYPED_SFIELD(sfHookSetTxnID, UINT256, 33)
197200
TYPED_SFIELD(sfDomainID, UINT256, 34)
198201
TYPED_SFIELD(sfVaultID, UINT256, 35)
199202
TYPED_SFIELD(sfParentBatchID, UINT256, 36)
203+
TYPED_SFIELD(sfSubscriptionID, UINT256, 37)
200204

201205
// number (common)
202206
TYPED_SFIELD(sfNumber, NUMBER, 1)

include/xrpl/protocol/detail/transactions.macro

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,28 @@ TRANSACTION(ttBATCH, 71, Batch, Delegation::notDelegatable, ({
526526
{sfBatchSigners, soeOPTIONAL},
527527
}))
528528

529+
/** This transaction type batches together transactions. */
530+
TRANSACTION(ttSUBSCRIPTION_SET, 72, SubscriptionSet, Delegation::delegatable, ({
531+
{sfDestination, soeOPTIONAL},
532+
{sfAmount, soeREQUIRED, soeMPTSupported},
533+
{sfFrequency, soeOPTIONAL},
534+
{sfStartTime, soeOPTIONAL},
535+
{sfExpiration, soeOPTIONAL},
536+
{sfDestinationTag, soeOPTIONAL},
537+
{sfSubscriptionID, soeOPTIONAL},
538+
}))
539+
540+
/** This transaction type batches together transactions. */
541+
TRANSACTION(ttSUBSCRIPTION_CANCEL, 73, SubscriptionCancel, Delegation::delegatable, ({
542+
{sfSubscriptionID, soeREQUIRED},
543+
}))
544+
545+
/** This transaction type batches together transactions. */
546+
TRANSACTION(ttSUBSCRIPTION_CLAIM, 74, SubscriptionClaim, Delegation::delegatable, ({
547+
{sfAmount, soeREQUIRED, soeMPTSupported},
548+
{sfSubscriptionID, soeREQUIRED},
549+
}))
550+
529551
/** This system-generated transaction type is used to update the status of the various amendments.
530552

531553
For details, see: https://xrpl.org/amendments.html

include/xrpl/protocol/jss.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ JSS(Signer); // field.
9999
JSS(Signers); // field.
100100
JSS(SigningPubKey); // field.
101101
JSS(Subject); // in: Credential transactions
102+
JSS(SubscriptionID); // in: Subscription transactions
102103
JSS(TakerGets); // field.
103104
JSS(TakerPays); // field.
104105
JSS(TradingFee); // in/out: AMM trading fee
@@ -283,6 +284,7 @@ JSS(fee_mult_max); // in: TransactionSign
283284
JSS(fee_ref); // out: NetworkOPs, DEPRECATED
284285
JSS(fetch_pack); // out: NetworkOPs
285286
JSS(FIELDS); // out: RPC server_definitions
287+
JSS(Frequency); // in: Subscription transactions
286288
// matches definitions.json format
287289
JSS(first); // out: rpc/Version
288290
JSS(finished);

src/libxrpl/protocol/Indexes.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum class LedgerNameSpace : std::uint16_t {
9696
PERMISSIONED_DOMAIN = 'm',
9797
DELEGATE = 'E',
9898
VAULT = 'V',
99+
SUBSCRIPTION = 'U',
99100

100101
// No longer used or supported. Left here to reserve the space
101102
// to avoid accidental reuse.
@@ -580,6 +581,17 @@ permissionedDomain(uint256 const& domainID) noexcept
580581
return {ltPERMISSIONED_DOMAIN, domainID};
581582
}
582583

584+
Keylet
585+
subscription(
586+
AccountID const& account,
587+
AccountID const& dest,
588+
std::uint32_t const& seq) noexcept
589+
{
590+
return {
591+
ltSUBSCRIPTION,
592+
indexHash(LedgerNameSpace::SUBSCRIPTION, account, dest, seq)};
593+
}
594+
583595
} // namespace keylet
584596

585597
} // namespace ripple

0 commit comments

Comments
 (0)