Skip to content

Commit 971d16b

Browse files
committed
fix: updates autogen files
1 parent a6a05b5 commit 971d16b

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

include/xrpl/protocol_autogen/transactions/VaultDelete.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@ class VaultDelete : public TransactionBase
5757
{
5858
return this->tx_->at(sfVaultID);
5959
}
60+
61+
/**
62+
* @brief Get sfMemoData (soeOPTIONAL)
63+
* @return The field value, or std::nullopt if not present.
64+
*/
65+
[[nodiscard]]
66+
protocol_autogen::Optional<SF_VL::type::value_type>
67+
getMemoData() const
68+
{
69+
if (hasMemoData())
70+
{
71+
return this->tx_->at(sfMemoData);
72+
}
73+
return std::nullopt;
74+
}
75+
76+
/**
77+
* @brief Check if sfMemoData is present.
78+
* @return True if the field is present, false otherwise.
79+
*/
80+
[[nodiscard]]
81+
bool
82+
hasMemoData() const
83+
{
84+
return this->tx_->isFieldPresent(sfMemoData);
85+
}
6086
};
6187

6288
/**
@@ -112,6 +138,17 @@ class VaultDeleteBuilder : public TransactionBuilderBase<VaultDeleteBuilder>
112138
return *this;
113139
}
114140

141+
/**
142+
* @brief Set sfMemoData (soeOPTIONAL)
143+
* @return Reference to this builder for method chaining.
144+
*/
145+
VaultDeleteBuilder&
146+
setMemoData(std::decay_t<typename SF_VL::type::value_type> const& value)
147+
{
148+
object_[sfMemoData] = value;
149+
return *this;
150+
}
151+
115152
/**
116153
* @brief Build and return the VaultDelete wrapper.
117154
* @param publicKey The public key for signing.

src/tests/libxrpl/protocol_autogen/transactions/VaultDeleteTests.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ TEST(TransactionsVaultDeleteTests, BuilderSettersRoundTrip)
3030

3131
// Transaction-specific field values
3232
auto const vaultIDValue = canonical_UINT256();
33+
auto const memoDataValue = canonical_VL();
3334

3435
VaultDeleteBuilder builder{
3536
accountValue,
@@ -39,6 +40,7 @@ TEST(TransactionsVaultDeleteTests, BuilderSettersRoundTrip)
3940
};
4041

4142
// Set optional fields
43+
builder.setMemoData(memoDataValue);
4244

4345
auto tx = builder.build(publicKey, secretKey);
4446

@@ -62,6 +64,14 @@ TEST(TransactionsVaultDeleteTests, BuilderSettersRoundTrip)
6264
}
6365

6466
// Verify optional fields
67+
{
68+
auto const& expected = memoDataValue;
69+
auto const actualOpt = tx.getMemoData();
70+
ASSERT_TRUE(actualOpt.has_value()) << "Optional field sfMemoData should be present";
71+
expectEqualField(expected, *actualOpt, "sfMemoData");
72+
EXPECT_TRUE(tx.hasMemoData());
73+
}
74+
6575
}
6676

6777
// 2 & 4) Start from an STTx, construct a builder from it, build a new wrapper,
@@ -79,6 +89,7 @@ TEST(TransactionsVaultDeleteTests, BuilderFromStTxRoundTrip)
7989

8090
// Transaction-specific field values
8191
auto const vaultIDValue = canonical_UINT256();
92+
auto const memoDataValue = canonical_VL();
8293

8394
// Build an initial transaction
8495
VaultDeleteBuilder initialBuilder{
@@ -88,6 +99,7 @@ TEST(TransactionsVaultDeleteTests, BuilderFromStTxRoundTrip)
8899
feeValue
89100
};
90101

102+
initialBuilder.setMemoData(memoDataValue);
91103

92104
auto initialTx = initialBuilder.build(publicKey, secretKey);
93105

@@ -112,6 +124,13 @@ TEST(TransactionsVaultDeleteTests, BuilderFromStTxRoundTrip)
112124
}
113125

114126
// Verify optional fields
127+
{
128+
auto const& expected = memoDataValue;
129+
auto const actualOpt = rebuiltTx.getMemoData();
130+
ASSERT_TRUE(actualOpt.has_value()) << "Optional field sfMemoData should be present";
131+
expectEqualField(expected, *actualOpt, "sfMemoData");
132+
}
133+
115134
}
116135

117136
// 3) Verify wrapper throws when constructed from wrong transaction type.
@@ -142,5 +161,35 @@ TEST(TransactionsVaultDeleteTests, BuilderThrowsOnWrongTxType)
142161
EXPECT_THROW(VaultDeleteBuilder{wrongTx.getSTTx()}, std::runtime_error);
143162
}
144163

164+
// 5) Build with only required fields and verify optional fields return nullopt.
165+
TEST(TransactionsVaultDeleteTests, OptionalFieldsReturnNullopt)
166+
{
167+
// Generate a deterministic keypair for signing
168+
auto const [publicKey, secretKey] =
169+
generateKeyPair(KeyType::secp256k1, generateSeed("testVaultDeleteNullopt"));
170+
171+
// Common transaction fields
172+
auto const accountValue = calcAccountID(publicKey);
173+
std::uint32_t const sequenceValue = 3;
174+
auto const feeValue = canonical_AMOUNT();
175+
176+
// Transaction-specific required field values
177+
auto const vaultIDValue = canonical_UINT256();
178+
179+
VaultDeleteBuilder builder{
180+
accountValue,
181+
vaultIDValue,
182+
sequenceValue,
183+
feeValue
184+
};
185+
186+
// Do NOT set optional fields
187+
188+
auto tx = builder.build(publicKey, secretKey);
189+
190+
// Verify optional fields are not present
191+
EXPECT_FALSE(tx.hasMemoData());
192+
EXPECT_FALSE(tx.getMemoData().has_value());
193+
}
145194

146195
}

0 commit comments

Comments
 (0)