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