rippled
Loading...
Searching...
No Matches
delegate.cpp
1#include <test/jtx/delegate.h>
2
3#include <xrpl/protocol/jss.h>
4
5namespace ripple {
6namespace test {
7namespace jtx {
8
9namespace delegate {
10
12set(jtx::Account const& account,
13 jtx::Account const& authorize,
14 std::vector<std::string> const& permissions)
15{
16 Json::Value jv;
17 jv[jss::TransactionType] = jss::DelegateSet;
18 jv[jss::Account] = account.human();
19 jv[sfAuthorize.jsonName] = authorize.human();
20 Json::Value permissionsJson(Json::arrayValue);
21 for (auto const& permission : permissions)
22 {
23 Json::Value permissionValue;
24 permissionValue[sfPermissionValue.jsonName] = permission;
25 Json::Value permissionObj;
26 permissionObj[sfPermission.jsonName] = permissionValue;
27 permissionsJson.append(permissionObj);
28 }
29
30 jv[sfPermissions.jsonName] = permissionsJson;
31
32 return jv;
33}
34
36entry(jtx::Env& env, jtx::Account const& account, jtx::Account const& authorize)
37{
38 Json::Value jvParams;
39 jvParams[jss::ledger_index] = jss::validated;
40 jvParams[jss::delegate][jss::account] = account.human();
41 jvParams[jss::delegate][jss::authorize] = authorize.human();
42 return env.rpc("json", "ledger_entry", to_string(jvParams));
43}
44
45} // namespace delegate
46} // namespace jtx
47} // namespace test
48} // namespace ripple
Represents a JSON value.
Definition json_value.h:130
Value & append(Value const &value)
Append value to array at the end.
Immutable cryptographic account descriptor.
Definition Account.h:20
std::string const & human() const
Returns the human readable public key.
Definition Account.h:99
A transaction testing environment.
Definition Env.h:102
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition Env.h:772
@ arrayValue
array value (ordered list)
Definition json_value.h:25
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:446
Json::Value entry(jtx::Env &env, jtx::Account const &account, jtx::Account const &authorize)
Definition delegate.cpp:36
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
bool set(T &target, std::string const &name, Section const &section)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:611