Line data Source code
1 : /**
2 : * Copyright Soramitsu Co., Ltd. 2018 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 : #ifndef IROHA_TRANSACTION_STATUS_BUILDER_HPP
19 : #define IROHA_TRANSACTION_STATUS_BUILDER_HPP
20 :
21 : #include "interfaces/common_objects/account_asset.hpp"
22 :
23 : namespace shared_model {
24 : namespace builder {
25 :
26 : // TODO: kamilsa 09.02.2018 IR-1087 Improve transaction status builder, so
27 : // that it is not allowed to set more than one status and transaction hash
28 : // is set before build method is invoked
29 : /**
30 : * Builder to construct transaction status object
31 : * @tparam BuilderImpl
32 : */
33 : template <typename BuilderImpl>
34 : class DEPRECATED TransactionStatusBuilder {
35 : public:
36 : std::shared_ptr<shared_model::interface::TransactionResponse> build() {
37 9 : return clone(builder_.build());
38 0 : }
39 :
40 : TransactionStatusBuilder statelessValidationSuccess() {
41 1 : TransactionStatusBuilder copy(*this);
42 1 : copy.builder_ = this->builder_.statelessValidationSuccess();
43 1 : return copy;
44 1 : }
45 :
46 : TransactionStatusBuilder statelessValidationFailed() {
47 1 : TransactionStatusBuilder copy(*this);
48 1 : copy.builder_ = this->builder_.statelessValidationFailed();
49 1 : return copy;
50 1 : }
51 :
52 : TransactionStatusBuilder mstPending() {
53 : TransactionStatusBuilder copy(*this);
54 : copy.builder_ = this->builder_.mstPending();
55 : return copy;
56 : }
57 :
58 : TransactionStatusBuilder enoughSignaturesCollected() {
59 : TransactionStatusBuilder copy(*this);
60 : copy.builder_ = this->builder_.enoughSignaturesCollected();
61 : return copy;
62 : }
63 :
64 : TransactionStatusBuilder statefulValidationSuccess() {
65 1 : TransactionStatusBuilder copy(*this);
66 1 : copy.builder_ = this->builder_.statefulValidationSuccess();
67 1 : return copy;
68 1 : }
69 :
70 : TransactionStatusBuilder statefulValidationFailed() {
71 1 : TransactionStatusBuilder copy(*this);
72 1 : copy.builder_ = this->builder_.statefulValidationFailed();
73 1 : return copy;
74 1 : }
75 :
76 : TransactionStatusBuilder committed() {
77 1 : TransactionStatusBuilder copy(*this);
78 1 : copy.builder_ = this->builder_.committed();
79 1 : return copy;
80 1 : }
81 :
82 : TransactionStatusBuilder notReceived() {
83 2 : TransactionStatusBuilder copy(*this);
84 2 : copy.builder_ = this->builder_.notReceived();
85 2 : return copy;
86 2 : }
87 :
88 : TransactionStatusBuilder mstExpired() {
89 1 : TransactionStatusBuilder copy(*this);
90 1 : copy.builder_ = this->builder_.mstExpired();
91 1 : return copy;
92 1 : }
93 :
94 : TransactionStatusBuilder txHash(const crypto::Hash &hash) {
95 8 : TransactionStatusBuilder copy(*this);
96 8 : copy.builder_ = this->builder_.txHash(hash);
97 8 : return copy;
98 8 : }
99 :
100 : TransactionStatusBuilder statelessErrorOrCmdName(
101 : const std::string &name) {
102 : TransactionStatusBuilder copy(*this);
103 : copy.builder_ = this->builder_.statelessErrorOrCmdName(name);
104 : return copy;
105 : }
106 :
107 : TransactionStatusBuilder failedCmdIndex(size_t index) {
108 : TransactionStatusBuilder copy(*this);
109 : copy.builder_ = this->builder_.failedCmdIndex(index);
110 : return copy;
111 : }
112 :
113 : TransactionStatusBuilder errorCode(uint32_t code) {
114 : TransactionStatusBuilder copy(*this);
115 : copy.builder_ = this->builder_.errorCode(code);
116 : return copy;
117 : }
118 :
119 : private:
120 : BuilderImpl builder_;
121 : };
122 :
123 : } // namespace builder
124 : } // namespace shared_model
125 :
126 : #endif // IROHA_TRANSACTION_STATUS_BUILDER_HPP
|