Skip to content

Commit

Permalink
spec updatedates
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Oct 30, 2023
1 parent c35a890 commit 8ba79b5
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 22 deletions.
8 changes: 1 addition & 7 deletions src/ripple/app/tx/impl/CFTokenIssuanceCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ CFTokenIssuanceCreate::preflight(PreflightContext const& ctx)
TER
CFTokenIssuanceCreate::preclaim(PreclaimContext const& ctx)
{
// if a CFT issuance with this asset code already exists - error
if (ctx.view.exists(
keylet::cftIssuance(ctx.tx[sfAccount], ctx.tx[sfAssetCode])))
return tecDUPLICATE;

return tesSUCCESS;
}

Expand All @@ -79,7 +74,7 @@ CFTokenIssuanceCreate::doApply()
if (mPriorBalance < view().fees().accountReserve((*acct)[sfOwnerCount] + 1))
return tecINSUFFICIENT_RESERVE;

auto const cftID = keylet::cftIssuance(account_, ctx_.tx[sfAssetCode]);
auto const cftID = keylet::cftIssuance(account_, ctx_.tx.getSeqProxy().value());

// create the CFT
{
Expand All @@ -92,7 +87,6 @@ CFTokenIssuanceCreate::doApply()
auto cft = std::make_shared<SLE>(cftID);
(*cft)[sfFlags] = ctx_.tx.getFlags() & ~tfUniversalMask;
(*cft)[sfIssuer] = account_;
(*cft)[sfAssetCode] = ctx_.tx[sfAssetCode];
(*cft)[sfOutstandingAmount] = 0;
(*cft)[sfLockedAmount] = 0;
(*cft)[sfOwnerNode] = *ownerNode;
Expand Down
8 changes: 7 additions & 1 deletion src/ripple/protocol/Indexes.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ Keylet
did(AccountID const& account) noexcept;

Keylet
cftIssuance(AccountID const& issuer, uint160 const& asset) noexcept;
cftIssuance(AccountID const& issuer, std::uint32_t seq) noexcept;

inline Keylet
cftIssuance(uint256 const& issuance)
{
return {ltCFTOKEN_ISSUANCE, issuance};
}
} // namespace keylet

// Everything below is deprecated and should be removed in favor of keylets:
Expand Down
1 change: 0 additions & 1 deletion src/ripple/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ extern SF_UINT160 const sfTakerPaysCurrency;
extern SF_UINT160 const sfTakerPaysIssuer;
extern SF_UINT160 const sfTakerGetsCurrency;
extern SF_UINT160 const sfTakerGetsIssuer;
extern SF_UINT160 const sfAssetCode;

// 256-bit (common)
extern SF_UINT256 const sfLedgerHash;
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/protocol/impl/Indexes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ did(AccountID const& account) noexcept
}

Keylet
cftIssuance(AccountID const& issuer, uint160 const& asset) noexcept
cftIssuance(AccountID const& issuer, std::uint32_t seq) noexcept
{
return {
ltCFTOKEN_ISSUANCE,
indexHash(LedgerNameSpace::CFTOKEN_ISSUANCE, issuer, asset)};
indexHash(LedgerNameSpace::CFTOKEN_ISSUANCE, issuer, seq)};
}

} // namespace keylet
Expand Down
1 change: 0 additions & 1 deletion src/ripple/protocol/impl/LedgerFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ LedgerFormats::LedgerFormats()
{sfIssuer, soeREQUIRED},
{sfTransferFee, soeDEFAULT},
{sfOwnerNode, soeREQUIRED},
{sfAssetCode, soeREQUIRED},
{sfAssetScale, soeDEFAULT},
{sfMaximumAmount, soeOPTIONAL},
{sfOutstandingAmount, soeREQUIRED},
Expand Down
1 change: 0 additions & 1 deletion src/ripple/protocol/impl/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ CONSTRUCT_TYPED_SFIELD(sfTakerPaysCurrency, "TakerPaysCurrency", UINT160,
CONSTRUCT_TYPED_SFIELD(sfTakerPaysIssuer, "TakerPaysIssuer", UINT160, 2);
CONSTRUCT_TYPED_SFIELD(sfTakerGetsCurrency, "TakerGetsCurrency", UINT160, 3);
CONSTRUCT_TYPED_SFIELD(sfTakerGetsIssuer, "TakerGetsIssuer", UINT160, 4);
CONSTRUCT_TYPED_SFIELD(sfAssetCode, "AssetCode", UINT160, 5);

// 256-bit (common)
CONSTRUCT_TYPED_SFIELD(sfLedgerHash, "LedgerHash", UINT256, 1);
Expand Down
1 change: 0 additions & 1 deletion src/ripple/protocol/impl/TxFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ TxFormats::TxFormats()
add(jss::CFTokenIssuanceCreate,
ttCFTOKEN_ISSUANCE_CREATE,
{
{sfAssetCode, soeREQUIRED},
{sfAssetScale, soeOPTIONAL},
{sfTransferFee, soeOPTIONAL},
{sfMaximumAmount, soeOPTIONAL},
Expand Down
4 changes: 2 additions & 2 deletions src/test/app/CFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CFToken_test : public beast::unit_test::suite

BEAST_EXPECT(env.ownerCount(master) == 0);

env(cft::create(master, "0158415500000000C1F76FF6ECB0BAC600000000"),
env(cft::create(master),
ter(temDISABLED));
env.close();

Expand All @@ -54,7 +54,7 @@ class CFToken_test : public beast::unit_test::suite
BEAST_EXPECT(env.ownerCount(master) == 0);

env(cft::create(
master, "0158415500000000C1F76FF6ECB0BAC600000000"));
master));
env.close();

BEAST_EXPECT(env.ownerCount(master) == 1);
Expand Down
2 changes: 1 addition & 1 deletion src/test/jtx/cft.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace cft {

/** Issue a CFT. */
Json::Value
create(jtx::Account const& account, std::string const& asset);
create(jtx::Account const& account);

} // namespace cft

Expand Down
6 changes: 1 addition & 5 deletions src/test/jtx/impl/cft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ namespace jtx {
namespace cft {

Json::Value
create(jtx::Account const& account, std::string const& asset)
create(jtx::Account const& account)
{
auto const assetCurrency = to_currency(asset);
assert(assetCurrency != noCurrency());

Json::Value jv;
jv[sfAccount.jsonName] = account.human();
jv[sfAssetCode.jsonName] = ripple::to_string(assetCurrency);
jv[sfTransactionType.jsonName] = jss::CFTokenIssuanceCreate;
return jv;
}
Expand Down

0 comments on commit 8ba79b5

Please sign in to comment.