Skip to content

Commit

Permalink
WIP trying to fix MSVC compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronek committed Jan 31, 2025
1 parent ad68074 commit 06a8a61
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 64 deletions.
57 changes: 32 additions & 25 deletions src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,53 @@ Expected<MPTID, TER>
MPTokenIssuanceCreate::create(
ApplyView& view,
beast::Journal journal,
MPTCreateArgs const& args)
AccountID const& account,
std::uint32_t sequence,
std::uint32_t flags,
std::optional<std::uint64_t> maxAmount,
std::optional<std::uint8_t> assetScale,
std::optional<std::uint16_t> transferFee,
std::optional<Slice> const& metadata,
std::optional<uint256> domainId)
{
auto const acct = view.peek(keylet::account(args.account));
auto const acct = view.peek(keylet::account(account));
if (!acct)
return Unexpected(tecINTERNAL);

auto mptId = makeMptID(args.sequence, args.account);
auto mptId = makeMptID(sequence, account);
auto const mptIssuanceKeylet = keylet::mptIssuance(mptId);

// create the MPTokenIssuance
{
auto const ownerNode = view.dirInsert(
keylet::ownerDir(args.account),
keylet::ownerDir(account),
mptIssuanceKeylet,
describeOwnerDir(args.account));
describeOwnerDir(account));

if (!ownerNode)
return Unexpected(tecDIR_FULL);

auto mptIssuance = std::make_shared<SLE>(mptIssuanceKeylet);
(*mptIssuance)[sfFlags] = args.flags & ~tfUniversal;
(*mptIssuance)[sfIssuer] = args.account;
(*mptIssuance)[sfFlags] = flags & ~tfUniversal;
(*mptIssuance)[sfIssuer] = account;
(*mptIssuance)[sfOutstandingAmount] = 0;
(*mptIssuance)[sfOwnerNode] = *ownerNode;
(*mptIssuance)[sfSequence] = args.sequence;
(*mptIssuance)[sfSequence] = sequence;

if (args.maxAmount)
(*mptIssuance)[sfMaximumAmount] = *args.maxAmount;
if (maxAmount)
(*mptIssuance)[sfMaximumAmount] = *maxAmount;

if (args.assetScale)
(*mptIssuance)[sfAssetScale] = *args.assetScale;
if (assetScale)
(*mptIssuance)[sfAssetScale] = *assetScale;

if (args.transferFee)
(*mptIssuance)[sfTransferFee] = *args.transferFee;
if (transferFee)
(*mptIssuance)[sfTransferFee] = *transferFee;

if (args.metadata)
(*mptIssuance)[sfMPTokenMetadata] = *args.metadata;
if (metadata)
(*mptIssuance)[sfMPTokenMetadata] = *metadata;

if (args.domainId)
(*mptIssuance)[sfDomainID] = *args.domainId;
if (domainId)
(*mptIssuance)[sfDomainID] = *domainId;

view.insert(mptIssuance);
}
Expand All @@ -133,13 +140,13 @@ MPTokenIssuanceCreate::doApply()
auto result = create(
view(),
j_,
{.account = account_,
.sequence = tx.getSeqProxy().value(),
.flags = tx.getFlags(),
.maxAmount = tx[~sfMaximumAmount],
.assetScale = tx[~sfAssetScale],
.transferFee = tx[~sfTransferFee],
.metadata = tx[~sfMPTokenMetadata]});
account_,
tx.getSeqProxy().value(),
tx.getFlags(),
tx[~sfMaximumAmount],
tx[~sfAssetScale],
tx[~sfTransferFee],
tx[~sfMPTokenMetadata]);
return result ? tesSUCCESS : result.error();
}

Expand Down
24 changes: 11 additions & 13 deletions src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@

namespace ripple {

struct MPTCreateArgs
{
AccountID const& account;
std::uint32_t sequence;
std::uint32_t flags = 0;
std::optional<std::uint64_t> maxAmount{};
std::optional<std::uint8_t> assetScale{};
std::optional<std::uint16_t> transferFee{};
std::optional<Slice> const& metadata{};
std::optional<uint256> domainId{};
};

class MPTokenIssuanceCreate : public Transactor
{
public:
Expand All @@ -54,7 +42,17 @@ class MPTokenIssuanceCreate : public Transactor
doApply() override;

static Expected<MPTID, TER>
create(ApplyView& view, beast::Journal journal, MPTCreateArgs const& args);
create(
ApplyView& view,
beast::Journal journal,
AccountID const& account,
std::uint32_t sequence,
std::uint32_t flags = 0,
std::optional<std::uint64_t> maxAmount = {},
std::optional<std::uint8_t> assetScale = {},
std::optional<std::uint16_t> transferFee = {},
std::optional<Slice> const& metadata = {},
std::optional<uint256> domainId = {});
};

} // namespace ripple
Expand Down
14 changes: 6 additions & 8 deletions src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ TER
MPTokenIssuanceDestroy::destroy(
ApplyView& view,
beast::Journal journal,
MPTDestroyArgs const& args)
AccountID const account,
MPTID issuanceID)
{
auto const mpt = view.peek(keylet::mptIssuance(args.issuanceID));
auto const mpt = view.peek(keylet::mptIssuance(issuanceID));
if (!mpt)
return tecOBJECT_NOT_FOUND;

if ((*mpt)[sfIssuer] != args.account)
if ((*mpt)[sfIssuer] != account)
return tecNO_PERMISSION;
auto const& issuer = args.account;
auto const& issuer = account;

if ((*mpt)[~sfOutstandingAmount] != 0)
return tecHAS_OBLIGATIONS;
Expand All @@ -92,10 +93,7 @@ TER
MPTokenIssuanceDestroy::doApply()
{
return destroy(
view(),
j_,
{.account = ctx_.tx[sfAccount],
.issuanceID = ctx_.tx[sfMPTokenIssuanceID]});
view(), j_, ctx_.tx[sfAccount], ctx_.tx[sfMPTokenIssuanceID]);
}

} // namespace ripple
9 changes: 2 additions & 7 deletions src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@

namespace ripple {

struct MPTDestroyArgs
{
AccountID const& account;
MPTID issuanceID;
};

class MPTokenIssuanceDestroy : public Transactor
{
public:
Expand All @@ -49,7 +43,8 @@ class MPTokenIssuanceDestroy : public Transactor
destroy(
ApplyView& view,
beast::Journal journal,
MPTDestroyArgs const& args);
AccountID const account,
MPTID issuanceID);

TER
doApply() override;
Expand Down
15 changes: 8 additions & 7 deletions src/xrpld/app/tx/detail/VaultCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ VaultCreate::doApply()
auto maybeShare = MPTokenIssuanceCreate::create(
view(),
j_,
{
.account = pseudoId,
.sequence = 1,
.flags = mptFlags,
.metadata = tx[~sfMPTokenMetadata],
.domainId = tx[~sfDomainID],
});
pseudoId,
1,
mptFlags,
{},
{},
{},
tx[~sfMPTokenMetadata],
tx[~sfDomainID]);
if (!maybeShare)
return maybeShare.error();
auto& share = *maybeShare;
Expand Down
5 changes: 1 addition & 4 deletions src/xrpld/app/tx/detail/VaultDelete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ VaultDelete::doApply()

// Destroy the share issuance.
if (auto ter = MPTokenIssuanceDestroy::destroy(
view(),
j_,
{.account = vault->at(sfAccount),
.issuanceID = vault->at(sfMPTokenIssuanceID)}))
view(), j_, vault->at(sfAccount), vault->at(sfMPTokenIssuanceID)))
return ter;

// The psuedo-account's directory should have been deleted already.
Expand Down

0 comments on commit 06a8a61

Please sign in to comment.