rippled
Loading...
Searching...
No Matches
XChainClaim.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 XChainClaimBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttXCHAIN_CLAIM;
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 XChainClaim");
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_ACCOUNT::type::value_type
79 {
80 return this->tx_->at(sfDestination);
81 }
82
87 [[nodiscard]]
90 {
92 {
93 return this->tx_->at(sfDestinationTag);
94 }
95 return std::nullopt;
96 }
97
102 [[nodiscard]]
103 bool
105 {
106 return this->tx_->isFieldPresent(sfDestinationTag);
107 }
108
113 [[nodiscard]]
114 SF_AMOUNT::type::value_type
115 getAmount() const
116 {
117 return this->tx_->at(sfAmount);
118 }
119};
120
128class XChainClaimBuilder : public TransactionBuilderBase<XChainClaimBuilder>
129{
130public:
141 XChainClaimBuilder(SF_ACCOUNT::type::value_type account,
144)
145 : TransactionBuilderBase<XChainClaimBuilder>(ttXCHAIN_CLAIM, account, sequence, fee)
146 {
147 setXChainBridge(xChainBridge);
148 setXChainClaimID(xChainClaimID);
149 setDestination(destination);
150 setAmount(amount);
151 }
152
159 {
160 if (tx->getTxnType() != ttXCHAIN_CLAIM)
161 {
162 throw std::runtime_error("Invalid transaction type for XChainClaimBuilder");
163 }
164 object_ = *tx;
165 }
166
175 {
176 object_[sfXChainBridge] = value;
177 return *this;
178 }
179
186 {
187 object_[sfXChainClaimID] = value;
188 return *this;
189 }
190
197 {
198 object_[sfDestination] = value;
199 return *this;
200 }
201
208 {
209 object_[sfDestinationTag] = value;
210 return *this;
211 }
212
219 {
220 object_[sfAmount] = value;
221 return *this;
222 }
223
231 build(PublicKey const& publicKey, SecretKey const& secretKey)
232 {
233 sign(publicKey, secretKey);
234 return XChainClaim{std::make_shared<STTx>(std::move(object_))};
235 }
236};
237
238} // 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.
XChainClaimBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
Builder for XChainClaim transactions.
XChainClaimBuilder(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_ACCOUNT::type::value_type > const &destination, 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 XChainClaimBuilder with required fields.
XChainClaimBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (soeREQUIRED)
XChainClaimBuilder & setDestinationTag(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfDestinationTag (soeOPTIONAL)
XChainClaimBuilder(std::shared_ptr< STTx const > tx)
Construct a XChainClaimBuilder from an existing STTx object.
XChainClaim build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the XChainClaim wrapper.
XChainClaimBuilder & setXChainBridge(std::decay_t< typename SF_XCHAIN_BRIDGE::type::value_type > const &value)
Transaction-specific field setters.
XChainClaimBuilder & setXChainClaimID(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfXChainClaimID (soeREQUIRED)
XChainClaimBuilder & setDestination(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfDestination (soeREQUIRED)
Transaction: XChainClaim.
Definition XChainClaim.h:30
SF_XCHAIN_BRIDGE::type::value_type getXChainBridge() const
Get sfXChainBridge (soeREQUIRED)
Definition XChainClaim.h:56
XChainClaim(std::shared_ptr< STTx const > tx)
Construct a XChainClaim transaction wrapper from an existing STTx object.
Definition XChainClaim.h:38
SF_ACCOUNT::type::value_type getDestination() const
Get sfDestination (soeREQUIRED)
Definition XChainClaim.h:78
SF_AMOUNT::type::value_type getAmount() const
Get sfAmount (soeREQUIRED)
SF_UINT64::type::value_type getXChainClaimID() const
Get sfXChainClaimID (soeREQUIRED)
Definition XChainClaim.h:67
static constexpr xrpl::TxType txType
Definition XChainClaim.h:32
bool hasDestinationTag() const
Check if sfDestinationTag is present.
protocol_autogen::Optional< SF_UINT32::type::value_type > getDestinationTag() const
Get sfDestinationTag (soeOPTIONAL)
Definition XChainClaim.h:89
T is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39