rippled
Loading...
Searching...
No Matches
XChainCommit.h
1// This file is auto-generated. Do not edit.
2#pragma once
3
4#include <xrpl/protocol/STTx.h>
5#include <xrpl/protocol/STParsedJSON.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/protocol_autogen/TransactionBase.h>
8#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
9#include <xrpl/json/json_value.h>
10
11#include <stdexcept>
12#include <optional>
13
14namespace xrpl::transactions {
15
16class XChainCommitBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttXCHAIN_COMMIT;
33
39 : TransactionBase(std::move(tx))
40 {
41 // Verify transaction type
42 if (tx_->getTxnType() != txType)
43 {
44 throw std::runtime_error("Invalid transaction type for XChainCommit");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
55 SF_XCHAIN_BRIDGE::type::value_type
57 {
58 return this->tx_->at(sfXChainBridge);
59 }
60
65 [[nodiscard]]
66 SF_UINT64::type::value_type
68 {
69 return this->tx_->at(sfXChainClaimID);
70 }
71
76 [[nodiscard]]
77 SF_AMOUNT::type::value_type
78 getAmount() const
79 {
80 return this->tx_->at(sfAmount);
81 }
82
87 [[nodiscard]]
90 {
92 {
93 return this->tx_->at(sfOtherChainDestination);
94 }
95 return std::nullopt;
96 }
97
102 [[nodiscard]]
103 bool
105 {
106 return this->tx_->isFieldPresent(sfOtherChainDestination);
107 }
108};
109
117class XChainCommitBuilder : public TransactionBuilderBase<XChainCommitBuilder>
118{
119public:
129 XChainCommitBuilder(SF_ACCOUNT::type::value_type account,
132)
133 : TransactionBuilderBase<XChainCommitBuilder>(ttXCHAIN_COMMIT, account, sequence, fee)
134 {
135 setXChainBridge(xChainBridge);
136 setXChainClaimID(xChainClaimID);
137 setAmount(amount);
138 }
139
146 {
147 if (tx->getTxnType() != ttXCHAIN_COMMIT)
148 {
149 throw std::runtime_error("Invalid transaction type for XChainCommitBuilder");
150 }
151 object_ = *tx;
152 }
153
162 {
163 object_[sfXChainBridge] = value;
164 return *this;
165 }
166
173 {
174 object_[sfXChainClaimID] = value;
175 return *this;
176 }
177
184 {
185 object_[sfAmount] = value;
186 return *this;
187 }
188
195 {
196 object_[sfOtherChainDestination] = value;
197 return *this;
198 }
199
207 build(PublicKey const& publicKey, SecretKey const& secretKey)
208 {
209 sign(publicKey, secretKey);
210 return XChainCommit{std::make_shared<STTx>(std::move(object_))};
211 }
212};
213
214} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
Base class for all transaction wrapper types.
std::shared_ptr< STTx const > tx_
The underlying transaction object being wrapped.
Base class for all transaction builders.
XChainCommitBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
Builder for XChainCommit transactions.
XChainCommitBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (soeREQUIRED)
XChainCommit build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the XChainCommit wrapper.
XChainCommitBuilder(std::shared_ptr< STTx const > tx)
Construct a XChainCommitBuilder from an existing STTx object.
XChainCommitBuilder & setXChainBridge(std::decay_t< typename SF_XCHAIN_BRIDGE::type::value_type > const &value)
Transaction-specific field setters.
XChainCommitBuilder & setXChainClaimID(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfXChainClaimID (soeREQUIRED)
XChainCommitBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_XCHAIN_BRIDGE::type::value_type > const &xChainBridge, std::decay_t< typename SF_UINT64::type::value_type > const &xChainClaimID, std::decay_t< typename SF_AMOUNT::type::value_type > const &amount, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new XChainCommitBuilder with required fields.
XChainCommitBuilder & setOtherChainDestination(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfOtherChainDestination (soeOPTIONAL)
Transaction: XChainCommit.
SF_XCHAIN_BRIDGE::type::value_type getXChainBridge() const
Get sfXChainBridge (soeREQUIRED)
SF_UINT64::type::value_type getXChainClaimID() const
Get sfXChainClaimID (soeREQUIRED)
bool hasOtherChainDestination() const
Check if sfOtherChainDestination is present.
SF_AMOUNT::type::value_type getAmount() const
Get sfAmount (soeREQUIRED)
XChainCommit(std::shared_ptr< STTx const > tx)
Construct a XChainCommit transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getOtherChainDestination() const
Get sfOtherChainDestination (soeOPTIONAL)
static constexpr xrpl::TxType txType
T is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39