rippled
Loading...
Searching...
No Matches
vault.cpp
1#include <test/jtx/Env.h>
2#include <test/jtx/vault.h>
3
4#include <xrpl/json/json_value.h>
5#include <xrpl/protocol/STAmount.h>
6#include <xrpl/protocol/jss.h>
7
8#include <optional>
9
10namespace ripple {
11namespace test {
12namespace jtx {
13
16{
17 auto keylet = keylet::vault(args.owner.id(), env.seq(args.owner));
18 Json::Value jv;
19 jv[jss::TransactionType] = jss::VaultCreate;
20 jv[jss::Account] = args.owner.human();
21 jv[jss::Asset] = to_json(args.asset);
22 jv[jss::Fee] = STAmount(env.current()->fees().increment).getJson();
23 if (args.flags)
24 jv[jss::Flags] = *args.flags;
25 return {jv, keylet};
26}
27
29Vault::set(SetArgs const& args)
30{
31 Json::Value jv;
32 jv[jss::TransactionType] = jss::VaultSet;
33 jv[jss::Account] = args.owner.human();
34 jv[sfVaultID] = to_string(args.id);
35 return jv;
36}
37
40{
41 Json::Value jv;
42 jv[jss::TransactionType] = jss::VaultDelete;
43 jv[jss::Account] = args.owner.human();
44 jv[sfVaultID] = to_string(args.id);
45 return jv;
46}
47
50{
51 Json::Value jv;
52 jv[jss::TransactionType] = jss::VaultDeposit;
53 jv[jss::Account] = args.depositor.human();
54 jv[sfVaultID] = to_string(args.id);
55 jv[jss::Amount] = to_json(args.amount);
56 return jv;
57}
58
61{
62 Json::Value jv;
63 jv[jss::TransactionType] = jss::VaultWithdraw;
64 jv[jss::Account] = args.depositor.human();
65 jv[sfVaultID] = to_string(args.id);
66 jv[jss::Amount] = to_json(args.amount);
67 return jv;
68}
69
72{
73 Json::Value jv;
74 jv[jss::TransactionType] = jss::VaultClawback;
75 jv[jss::Account] = args.issuer.human();
76 jv[sfVaultID] = to_string(args.id);
77 jv[jss::Holder] = args.holder.human();
78 if (args.amount)
79 jv[jss::Amount] = to_json(*args.amount);
80 return jv;
81}
82
83} // namespace jtx
84} // namespace test
85} // namespace ripple
Represents a JSON value.
Definition json_value.h:130
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STAmount.cpp:753
AccountID id() const
Returns the Account ID.
Definition Account.h:92
std::string const & human() const
Returns the human readable public key.
Definition Account.h:99
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:250
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:312
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:545
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Json::Value to_json(Asset const &asset)
Definition Asset.h:104
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:611
std::optional< STAmount > amount
Definition vault.h:79
std::optional< std::uint32_t > flags
Definition vault.h:29
Json::Value set(SetArgs const &args)
Definition vault.cpp:29
std::tuple< Json::Value, Keylet > create(CreateArgs const &args)
Return a VaultCreate transaction and the Vault's expected keylet.
Definition vault.cpp:15
Json::Value withdraw(WithdrawArgs const &args)
Definition vault.cpp:60
Json::Value del(DeleteArgs const &args)
Definition vault.cpp:39
Json::Value clawback(ClawbackArgs const &args)
Definition vault.cpp:71
Json::Value deposit(DepositArgs const &args)
Definition vault.cpp:49