Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0
4 : */
5 : #include <memory>
6 :
7 : #include "model/generators/query_generator.hpp"
8 :
9 : namespace iroha {
10 : namespace model {
11 : namespace generators {
12 :
13 : void QueryGenerator::setQueryMetaData(std::shared_ptr<Query> query,
14 : ts64_t timestamp,
15 : std::string creator,
16 : uint64_t query_counter) {
17 0 : query->creator_account_id = creator;
18 0 : query->query_counter = query_counter;
19 0 : query->created_ts = timestamp;
20 0 : }
21 :
22 : std::shared_ptr<GetAccount> QueryGenerator::generateGetAccount(
23 : ts64_t timestamp,
24 : std::string creator,
25 : uint64_t query_counter,
26 : std::string account_id) {
27 4 : auto query = std::make_shared<GetAccount>();
28 4 : query->created_ts = timestamp;
29 4 : query->creator_account_id = creator;
30 4 : query->account_id = account_id;
31 4 : query->query_counter = query_counter;
32 4 : return query;
33 4 : }
34 :
35 : std::shared_ptr<GetAccountAssets>
36 : QueryGenerator::generateGetAccountAssets(ts64_t timestamp,
37 : std::string creator,
38 : uint64_t query_counter,
39 : std::string account_id,
40 : std::string asset_id) {
41 2 : auto query = std::make_shared<GetAccountAssets>();
42 2 : query->created_ts = timestamp;
43 2 : query->creator_account_id = creator;
44 2 : query->query_counter = query_counter;
45 2 : query->account_id = account_id;
46 2 : return query;
47 2 : }
48 :
49 : std::shared_ptr<GetAccountDetail>
50 : QueryGenerator::generateGetAccountDetail(ts64_t timestamp,
51 : std::string creator,
52 : uint64_t query_counter,
53 : std::string account_id,
54 : std::string creator_account_id) {
55 1 : auto query = std::make_shared<GetAccountDetail>();
56 1 : query->created_ts = timestamp;
57 1 : query->creator_account_id = creator;
58 1 : query->query_counter = query_counter;
59 1 : query->account_id = account_id;
60 1 : query->creator_account_id = creator_account_id;
61 1 : return query;
62 1 : }
63 :
64 : std::shared_ptr<GetSignatories> QueryGenerator::generateGetSignatories(
65 : ts64_t timestamp,
66 : std::string creator,
67 : uint64_t query_counter,
68 : std::string account_id) {
69 2 : auto query = std::make_shared<GetSignatories>();
70 2 : query->created_ts = timestamp;
71 2 : query->creator_account_id = creator;
72 2 : query->query_counter = query_counter;
73 2 : query->account_id = account_id;
74 2 : return query;
75 2 : }
76 :
77 : std::shared_ptr<GetAccountTransactions>
78 : QueryGenerator::generateGetAccountTransactions(ts64_t timestamp,
79 : std::string creator,
80 : uint64_t query_counter,
81 : std::string account_id) {
82 2 : auto query = std::make_shared<GetAccountTransactions>();
83 2 : query->created_ts = timestamp;
84 2 : query->creator_account_id = creator;
85 2 : query->query_counter = query_counter;
86 2 : query->account_id = account_id;
87 2 : return query;
88 2 : }
89 :
90 : std::shared_ptr<GetAccountAssetTransactions>
91 : QueryGenerator::generateGetAccountAssetTransactions(
92 : ts64_t timestamp,
93 : std::string creator,
94 : uint64_t query_counter,
95 : std::string account_id,
96 : std::string asset_id) {
97 0 : auto query = std::make_shared<GetAccountAssetTransactions>();
98 0 : query->created_ts = timestamp;
99 0 : query->creator_account_id = creator;
100 0 : query->query_counter = query_counter;
101 0 : query->account_id = account_id;
102 0 : query->asset_id = asset_id;
103 0 : return query;
104 0 : }
105 :
106 : std::shared_ptr<GetTransactions> QueryGenerator::generateGetTransactions(
107 : ts64_t timestamp,
108 : const std::string &creator,
109 : uint64_t query_counter,
110 : const std::vector<iroha::hash256_t> &tx_hashes) {
111 3 : auto query = std::make_shared<GetTransactions>();
112 3 : query->created_ts = timestamp;
113 3 : query->creator_account_id = creator;
114 3 : query->query_counter = query_counter;
115 3 : query->tx_hashes = tx_hashes;
116 3 : return query;
117 3 : }
118 :
119 : std::shared_ptr<GetAssetInfo> QueryGenerator::generateGetAssetInfo() {
120 2 : auto query = std::make_shared<GetAssetInfo>("coin#test");
121 2 : query->created_ts = 0;
122 2 : query->creator_account_id = "admin@test";
123 2 : query->query_counter = 0;
124 2 : return query;
125 2 : }
126 :
127 : std::shared_ptr<GetRoles> QueryGenerator::generateGetRoles() {
128 2 : auto query = std::make_shared<GetRoles>();
129 2 : query->created_ts = 0;
130 2 : query->creator_account_id = "admin@test";
131 2 : query->query_counter = 0;
132 2 : return query;
133 2 : }
134 :
135 : std::shared_ptr<GetRolePermissions>
136 : QueryGenerator::generateGetRolePermissions() {
137 2 : auto query = std::make_shared<GetRolePermissions>("admin");
138 2 : query->created_ts = 0;
139 2 : query->creator_account_id = "admin@test";
140 2 : query->query_counter = 0;
141 2 : return query;
142 2 : }
143 :
144 : } // namespace generators
145 : } // namespace model
146 : } // namespace iroha
|