rippled
offer.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/protocol/jss.h>
21 #include <test/jtx/offer.h>
22 
23 namespace ripple {
24 namespace test {
25 namespace jtx {
26 
29  Account const& account,
30  STAmount const& takerPays,
31  STAmount const& takerGets,
33 {
34  Json::Value jv;
35  jv[jss::Account] = account.human();
36  jv[jss::TakerPays] = takerPays.getJson(JsonOptions::none);
37  jv[jss::TakerGets] = takerGets.getJson(JsonOptions::none);
38  if (flags)
39  jv[jss::Flags] = flags;
40  jv[jss::TransactionType] = jss::OfferCreate;
41  return jv;
42 }
43 
45 offer_cancel(Account const& account, std::uint32_t offerSeq)
46 {
47  Json::Value jv;
48  jv[jss::Account] = account.human();
49  jv[jss::OfferSequence] = offerSeq;
50  jv[jss::TransactionType] = jss::OfferCancel;
51  return jv;
52 }
53 
54 } // namespace jtx
55 } // namespace test
56 } // namespace ripple
ripple::test::jtx::offer
Json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
Definition: offer.cpp:28
ripple::STAmount::getJson
Json::Value getJson(JsonOptions) const override
Definition: STAmount.cpp:655
ripple::test::jtx::offer_cancel
Json::Value offer_cancel(Account const &account, std::uint32_t offerSeq)
Cancel an offer.
Definition: offer.cpp:45
ripple::JsonOptions::none
@ none
ripple::STAmount
Definition: STAmount.h:45
std::uint32_t
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::test::jtx::flags
Match set account flags.
Definition: flags.h:108
ripple::test::jtx::Account
Immutable cryptographic account descriptor.
Definition: Account.h:37
Json::Value
Represents a JSON value.
Definition: json_value.h:145