|
5 | 5 | #include <governance/common.h> |
6 | 6 | #include <governance/governance.h> |
7 | 7 |
|
| 8 | +#include <rpc/util.h> |
8 | 9 | #include <util/check.h> |
9 | 10 |
|
10 | 11 | #include <univalue.h> |
11 | 12 |
|
| 13 | +RPCResult CGovernanceManager::GetJsonHelp(const std::string& key, bool optional) |
| 14 | +{ |
| 15 | + return {RPCResult::Type::OBJ, key, optional, key.empty() ? "" : "Count of governance objects and votes", |
| 16 | + { |
| 17 | + {RPCResult::Type::NUM, "objects_total", "Total number of all governance objects"}, |
| 18 | + {RPCResult::Type::NUM, "proposals", "Number of governance proposals"}, |
| 19 | + {RPCResult::Type::NUM, "triggers", "Number of triggers"}, |
| 20 | + {RPCResult::Type::NUM, "other", "Total number of unknown governance objects"}, |
| 21 | + {RPCResult::Type::NUM, "erased", "Number of removed (expired) objects"}, |
| 22 | + {RPCResult::Type::NUM, "votes", "Total number of votes"}, |
| 23 | + }}; |
| 24 | +} |
| 25 | + |
12 | 26 | UniValue CGovernanceManager::ToJson() const |
13 | 27 | { |
14 | 28 | LOCK(cs_store); |
@@ -41,12 +55,43 @@ UniValue CGovernanceManager::ToJson() const |
41 | 55 | return jsonObj; |
42 | 56 | } |
43 | 57 |
|
| 58 | +RPCResult CGovernanceObject::GetJsonHelp(const std::string& key, bool optional) |
| 59 | +{ |
| 60 | + return Governance::Object::GetJsonHelp(key, optional); |
| 61 | +} |
| 62 | + |
44 | 63 | UniValue CGovernanceObject::ToJson() const |
45 | 64 | { |
46 | 65 | return m_obj.ToJson(); |
47 | 66 | } |
48 | 67 |
|
49 | 68 | namespace Governance { |
| 69 | +RPCResult Object::GetJsonHelp(const std::string& key, bool optional) |
| 70 | +{ |
| 71 | + return {RPCResult::Type::OBJ, key, optional, key.empty() ? "" : "Object info", |
| 72 | + { |
| 73 | + {RPCResult::Type::STR_HEX, "objectHash", "Hash of proposal object"}, |
| 74 | + {RPCResult::Type::STR_HEX, "parentHash", "Hash of the parent object (root node has a hash of 0)"}, |
| 75 | + GetRpcResult("collateralHash"), |
| 76 | + {RPCResult::Type::NUM, "createdAt", "Proposal creation timestamp"}, |
| 77 | + {RPCResult::Type::NUM, "revision", "Proposal revision number"}, |
| 78 | + {RPCResult::Type::OBJ, "data", "", { |
| 79 | + // Fields emitted through GetDataAsPlainString(), read by CProposalValidator |
| 80 | + {RPCResult::Type::STR, "end_epoch", /*optional=*/true, "Proposal end timestamp"}, |
| 81 | + {RPCResult::Type::STR, "name", /*optional=*/true, "Proposal name"}, |
| 82 | + {RPCResult::Type::STR, "payment_address", /*optional=*/true, "Proposal payment address"}, |
| 83 | + {RPCResult::Type::STR, "payment_amount", /*optional=*/true, "Proposal payment amount"}, |
| 84 | + {RPCResult::Type::STR, "start_epoch", /*optional=*/true, "Proposal start timestamp"}, |
| 85 | + {RPCResult::Type::STR, "type", /*optional=*/true, "Object type"}, |
| 86 | + {RPCResult::Type::STR, "url", /*optional=*/true, "Proposal URL"}, |
| 87 | + // Failure case for GetDataAsPlainString() |
| 88 | + {RPCResult::Type::STR, "plain", /*optional=*/true, "Governance object data as string"}, |
| 89 | + // Always emitted by ToJson() |
| 90 | + {RPCResult::Type::STR_HEX, "hex", "Governance object data as hex"}, |
| 91 | + }}, |
| 92 | + }}; |
| 93 | +} |
| 94 | + |
50 | 95 | UniValue Object::ToJson() const |
51 | 96 | { |
52 | 97 | UniValue obj(UniValue::VOBJ); |
|
0 commit comments