mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
add uritoken helpers
This commit is contained in:
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <test/jtx/flags.h>
|
||||
#include <test/jtx/uritoken.h>
|
||||
|
||||
#include <ripple/protocol/SField.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/jtx/flags.h>
|
||||
#include <test/jtx/uritoken.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
@@ -46,6 +45,67 @@ mint(jtx::Account const& account, std::string const& uri)
|
||||
return jv;
|
||||
}
|
||||
|
||||
void
|
||||
dest::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[sfDestination.jsonName] = dest_.human();
|
||||
}
|
||||
|
||||
void
|
||||
amt::operator()(Env& env, JTx& jt) const
|
||||
{
|
||||
jt.jv[sfAmount.jsonName] = amt_.getJson(JsonOptions::none);
|
||||
}
|
||||
|
||||
Json::Value
|
||||
burn(jtx::Account const& account, std::string const& id)
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = jss::URITokenBurn;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[sfURITokenID.jsonName] = id;
|
||||
return jv;
|
||||
}
|
||||
|
||||
Json::Value
|
||||
sell(
|
||||
jtx::Account const& account,
|
||||
std::string const& id)
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = jss::URITokenCreateSellOffer;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[sfURITokenID.jsonName] = id;
|
||||
return jv;
|
||||
}
|
||||
|
||||
Json::Value
|
||||
cancel(
|
||||
jtx::Account const& account,
|
||||
std::string const& id)
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = jss::URITokenCancelSellOffer;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[sfURITokenID.jsonName] = id;
|
||||
return jv;
|
||||
}
|
||||
|
||||
Json::Value
|
||||
buy(jtx::Account const& account,
|
||||
std::string const& id)
|
||||
{
|
||||
using namespace jtx;
|
||||
Json::Value jv;
|
||||
jv[jss::TransactionType] = jss::URITokenBuy;
|
||||
jv[jss::Account] = account.human();
|
||||
jv[sfURITokenID.jsonName] = id;
|
||||
return jv;
|
||||
}
|
||||
|
||||
} // namespace uritoken
|
||||
} // namespace jtx
|
||||
} // namespace test
|
||||
|
||||
@@ -20,11 +20,12 @@
|
||||
#ifndef RIPPLE_TEST_JTX_URITOKEN_H_INCLUDED
|
||||
#define RIPPLE_TEST_JTX_URITOKEN_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <ripple/protocol/STAmount.h>
|
||||
#include <initializer_list>
|
||||
#include <test/jtx/Account.h>
|
||||
#include <test/jtx/Env.h>
|
||||
#include <test/jtx/owners.h>
|
||||
#include <ripple/basics/strHex.h>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace ripple {
|
||||
namespace test {
|
||||
@@ -38,6 +39,48 @@ tokenid(jtx::Account const& account, std::string const& uri);
|
||||
Json::Value
|
||||
mint(jtx::Account const& account, std::string const& uri);
|
||||
|
||||
/** Sets the optional Destination on an URITokenMint. */
|
||||
class dest
|
||||
{
|
||||
private:
|
||||
jtx::Account dest_;
|
||||
|
||||
public:
|
||||
explicit dest(jtx::Account const& dest) : dest_(dest)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
/** Sets the optional Amount on an URITokenMint. */
|
||||
class amt
|
||||
{
|
||||
private:
|
||||
STAmount amt_;
|
||||
|
||||
public:
|
||||
explicit amt(STAmount const& amt) : amt_(amt)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
operator()(Env&, JTx& jtx) const;
|
||||
};
|
||||
|
||||
Json::Value
|
||||
burn(jtx::Account const& account, std::string const& id);
|
||||
|
||||
Json::Value
|
||||
sell(jtx::Account const& account, std::string const& id);
|
||||
|
||||
Json::Value
|
||||
cancel(jtx::Account const& account, std::string const& id);
|
||||
|
||||
Json::Value
|
||||
buy(jtx::Account const& account, std::string const& id);
|
||||
|
||||
} // namespace uritoken
|
||||
|
||||
} // namespace jtx
|
||||
|
||||
Reference in New Issue
Block a user