Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
3 : * http://soramitsu.co.jp
4 : *
5 : * Licensed under the Apache License, Version 2.0 (the "License");
6 : * you may not use this file except in compliance with the License.
7 : * You may obtain a copy of the License at
8 : *
9 : * http://www.apache.org/licenses/LICENSE-2.0
10 : *
11 : * Unless required by applicable law or agreed to in writing, software
12 : * distributed under the License is distributed on an "AS IS" BASIS,
13 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 : * See the License for the specific language governing permissions and
15 : * limitations under the License.
16 : */
17 :
18 : #include "bindings/model_transaction_builder.hpp"
19 :
20 : namespace shared_model {
21 : namespace bindings {
22 : ModelTransactionBuilder::ModelTransactionBuilder() {
23 0 : *this = creatorAccountId("").createdTime(0).quorum(1);
24 0 : }
25 :
26 : ModelTransactionBuilder ModelTransactionBuilder::creatorAccountId(
27 : const interface::types::AccountIdType &account_id) {
28 0 : return ModelTransactionBuilder(builder_.creatorAccountId(account_id));
29 0 : }
30 :
31 : ModelTransactionBuilder ModelTransactionBuilder::createdTime(
32 : interface::types::TimestampType created_time) {
33 0 : return ModelTransactionBuilder(builder_.createdTime(created_time));
34 0 : }
35 :
36 : ModelTransactionBuilder ModelTransactionBuilder::quorum(
37 : interface::types::QuorumType quorum) {
38 0 : return ModelTransactionBuilder(builder_.quorum(quorum));
39 0 : }
40 :
41 : ModelTransactionBuilder ModelTransactionBuilder::batchMeta(
42 : interface::types::BatchType type,
43 : const std::vector<interface::types::HashType> &hashes) {
44 0 : return ModelTransactionBuilder(builder_.batchMeta(type, hashes));
45 0 : }
46 :
47 : ModelTransactionBuilder ModelTransactionBuilder::addAssetQuantity(
48 : const interface::types::AssetIdType &asset_id,
49 : const std::string &amount) {
50 0 : return ModelTransactionBuilder(
51 0 : builder_.addAssetQuantity(asset_id, amount));
52 0 : }
53 :
54 : ModelTransactionBuilder ModelTransactionBuilder::addPeer(
55 : const interface::types::AddressType &address,
56 : const interface::types::PubkeyType &peer_key) {
57 0 : return ModelTransactionBuilder(builder_.addPeer(address, peer_key));
58 0 : }
59 :
60 : ModelTransactionBuilder ModelTransactionBuilder::addSignatory(
61 : const interface::types::AddressType &account_id,
62 : const interface::types::PubkeyType &public_key) {
63 0 : return ModelTransactionBuilder(
64 0 : builder_.addSignatory(account_id, public_key));
65 0 : }
66 :
67 : ModelTransactionBuilder ModelTransactionBuilder::removeSignatory(
68 : const interface::types::AddressType &account_id,
69 : const interface::types::PubkeyType &public_key) {
70 0 : return ModelTransactionBuilder(
71 0 : builder_.removeSignatory(account_id, public_key));
72 0 : }
73 :
74 : ModelTransactionBuilder ModelTransactionBuilder::appendRole(
75 : const interface::types::AccountIdType &account_id,
76 : const interface::types::RoleIdType &role_name) {
77 0 : return ModelTransactionBuilder(
78 0 : builder_.appendRole(account_id, role_name));
79 0 : }
80 :
81 : ModelTransactionBuilder ModelTransactionBuilder::createAsset(
82 : const interface::types::AssetNameType &asset_name,
83 : const interface::types::DomainIdType &domain_id,
84 : interface::types::PrecisionType precision) {
85 0 : return ModelTransactionBuilder(
86 0 : builder_.createAsset(asset_name, domain_id, precision));
87 0 : }
88 :
89 : ModelTransactionBuilder ModelTransactionBuilder::createAccount(
90 : const interface::types::AccountNameType &account_name,
91 : const interface::types::AddressType &domain_id,
92 : const interface::types::PubkeyType &main_pubkey) {
93 0 : return ModelTransactionBuilder(
94 0 : builder_.createAccount(account_name, domain_id, main_pubkey));
95 0 : }
96 :
97 : ModelTransactionBuilder ModelTransactionBuilder::createDomain(
98 : const interface::types::AddressType &domain_id,
99 : const interface::types::RoleIdType &default_role) {
100 0 : return ModelTransactionBuilder(
101 0 : builder_.createDomain(domain_id, default_role));
102 0 : }
103 :
104 : ModelTransactionBuilder ModelTransactionBuilder::createRole(
105 : const interface::types::RoleIdType &role_name,
106 : const interface::RolePermissionSet &permissions) {
107 0 : return ModelTransactionBuilder(
108 0 : builder_.createRole(role_name, permissions));
109 0 : }
110 :
111 : ModelTransactionBuilder ModelTransactionBuilder::detachRole(
112 : const interface::types::AccountIdType &account_id,
113 : const interface::types::RoleIdType &role_name) {
114 0 : return ModelTransactionBuilder(
115 0 : builder_.detachRole(account_id, role_name));
116 0 : }
117 :
118 : ModelTransactionBuilder ModelTransactionBuilder::grantPermission(
119 : const interface::types::AccountIdType &account_id,
120 : interface::permissions::Grantable permission) {
121 0 : return ModelTransactionBuilder(
122 0 : builder_.grantPermission(account_id, permission));
123 0 : }
124 :
125 : ModelTransactionBuilder ModelTransactionBuilder::revokePermission(
126 : const interface::types::AccountIdType &account_id,
127 : interface::permissions::Grantable permission) {
128 0 : return ModelTransactionBuilder(
129 0 : builder_.revokePermission(account_id, permission));
130 0 : }
131 :
132 : ModelTransactionBuilder ModelTransactionBuilder::setAccountDetail(
133 : const interface::types::AccountIdType &account_id,
134 : const interface::types::AccountDetailKeyType &key,
135 : const interface::types::AccountDetailValueType &value) {
136 0 : return ModelTransactionBuilder(
137 0 : builder_.setAccountDetail(account_id, key, value));
138 0 : }
139 :
140 : ModelTransactionBuilder ModelTransactionBuilder::setAccountQuorum(
141 : const interface::types::AddressType &account_id,
142 : interface::types::QuorumType quorum) {
143 0 : return ModelTransactionBuilder(
144 0 : builder_.setAccountQuorum(account_id, quorum));
145 0 : }
146 :
147 : ModelTransactionBuilder ModelTransactionBuilder::subtractAssetQuantity(
148 : const interface::types::AssetIdType &asset_id,
149 : const std::string &amount) {
150 0 : return ModelTransactionBuilder(
151 0 : builder_.subtractAssetQuantity(asset_id, amount));
152 0 : }
153 :
154 : ModelTransactionBuilder ModelTransactionBuilder::transferAsset(
155 : const interface::types::AccountIdType &src_account_id,
156 : const interface::types::AccountIdType &dest_account_id,
157 : const interface::types::AssetIdType &asset_id,
158 : const std::string &description,
159 : const std::string &amount) {
160 0 : return ModelTransactionBuilder(builder_.transferAsset(
161 0 : src_account_id, dest_account_id, asset_id, description, amount));
162 0 : }
163 :
164 : proto::UnsignedWrapper<proto::Transaction>
165 : ModelTransactionBuilder::build() {
166 0 : return builder_.build();
167 : }
168 : } // namespace bindings
169 : } // namespace shared_model
|