This commit is contained in:
yinyiqian1
2026-07-16 15:26:56 -04:00
committed by Mayukha Vadari
parent 0534494c38
commit 448a590b4a
2 changed files with 58 additions and 0 deletions

View File

@@ -162,6 +162,32 @@ public:
return this->tx_->isFieldPresent(sfTransferFee);
}
/**
* @brief Get sfImmutableFlags (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getImmutableFlags() const
{
if (hasImmutableFlags())
{
return this->tx_->at(sfImmutableFlags);
}
return std::nullopt;
}
/**
* @brief Check if sfImmutableFlags is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasImmutableFlags() const
{
return this->tx_->isFieldPresent(sfImmutableFlags);
}
/**
* @brief Get sfIssuerEncryptionKey (SoeOptional)
* @return The field value, or std::nullopt if not present.
@@ -314,6 +340,17 @@ public:
return *this;
}
/**
* @brief Set sfImmutableFlags (SoeOptional)
* @return Reference to this builder for method chaining.
*/
MPTokenIssuanceSetBuilder&
setImmutableFlags(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfImmutableFlags] = value;
return *this;
}
/**
* @brief Set sfIssuerEncryptionKey (SoeOptional)
* @return Reference to this builder for method chaining.

View File

@@ -34,6 +34,7 @@ TEST(TransactionsMPTokenIssuanceSetTests, BuilderSettersRoundTrip)
auto const domainIDValue = canonical_UINT256();
auto const mPTokenMetadataValue = canonical_VL();
auto const transferFeeValue = canonical_UINT16();
auto const immutableFlagsValue = canonical_UINT32();
auto const issuerEncryptionKeyValue = canonical_VL();
auto const auditorEncryptionKeyValue = canonical_VL();
@@ -49,6 +50,7 @@ TEST(TransactionsMPTokenIssuanceSetTests, BuilderSettersRoundTrip)
builder.setDomainID(domainIDValue);
builder.setMPTokenMetadata(mPTokenMetadataValue);
builder.setTransferFee(transferFeeValue);
builder.setImmutableFlags(immutableFlagsValue);
builder.setIssuerEncryptionKey(issuerEncryptionKeyValue);
builder.setAuditorEncryptionKey(auditorEncryptionKeyValue);
@@ -106,6 +108,14 @@ TEST(TransactionsMPTokenIssuanceSetTests, BuilderSettersRoundTrip)
EXPECT_TRUE(tx.hasTransferFee());
}
{
auto const& expected = immutableFlagsValue;
auto const actualOpt = tx.getImmutableFlags();
ASSERT_TRUE(actualOpt.has_value()) << "Optional field sfImmutableFlags should be present";
expectEqualField(expected, *actualOpt, "sfImmutableFlags");
EXPECT_TRUE(tx.hasImmutableFlags());
}
{
auto const& expected = issuerEncryptionKeyValue;
auto const actualOpt = tx.getIssuerEncryptionKey();
@@ -143,6 +153,7 @@ TEST(TransactionsMPTokenIssuanceSetTests, BuilderFromStTxRoundTrip)
auto const domainIDValue = canonical_UINT256();
auto const mPTokenMetadataValue = canonical_VL();
auto const transferFeeValue = canonical_UINT16();
auto const immutableFlagsValue = canonical_UINT32();
auto const issuerEncryptionKeyValue = canonical_VL();
auto const auditorEncryptionKeyValue = canonical_VL();
@@ -158,6 +169,7 @@ TEST(TransactionsMPTokenIssuanceSetTests, BuilderFromStTxRoundTrip)
initialBuilder.setDomainID(domainIDValue);
initialBuilder.setMPTokenMetadata(mPTokenMetadataValue);
initialBuilder.setTransferFee(transferFeeValue);
initialBuilder.setImmutableFlags(immutableFlagsValue);
initialBuilder.setIssuerEncryptionKey(issuerEncryptionKeyValue);
initialBuilder.setAuditorEncryptionKey(auditorEncryptionKeyValue);
@@ -212,6 +224,13 @@ TEST(TransactionsMPTokenIssuanceSetTests, BuilderFromStTxRoundTrip)
expectEqualField(expected, *actualOpt, "sfTransferFee");
}
{
auto const& expected = immutableFlagsValue;
auto const actualOpt = rebuiltTx.getImmutableFlags();
ASSERT_TRUE(actualOpt.has_value()) << "Optional field sfImmutableFlags should be present";
expectEqualField(expected, *actualOpt, "sfImmutableFlags");
}
{
auto const& expected = issuerEncryptionKeyValue;
auto const actualOpt = rebuiltTx.getIssuerEncryptionKey();
@@ -291,6 +310,8 @@ TEST(TransactionsMPTokenIssuanceSetTests, OptionalFieldsReturnNullopt)
EXPECT_FALSE(tx.getMPTokenMetadata().has_value());
EXPECT_FALSE(tx.hasTransferFee());
EXPECT_FALSE(tx.getTransferFee().has_value());
EXPECT_FALSE(tx.hasImmutableFlags());
EXPECT_FALSE(tx.getImmutableFlags().has_value());
EXPECT_FALSE(tx.hasIssuerEncryptionKey());
EXPECT_FALSE(tx.getIssuerEncryptionKey().has_value());
EXPECT_FALSE(tx.hasAuditorEncryptionKey());