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 : #ifndef IROHA_SHARED_MODEL_ACCOUNT_HPP
19 : #define IROHA_SHARED_MODEL_ACCOUNT_HPP
20 :
21 : #include "cryptography/hash.hpp"
22 : #include "interfaces/base/model_primitive.hpp"
23 : #include "interfaces/common_objects/types.hpp"
24 : #include "utils/string_builder.hpp"
25 :
26 : namespace shared_model {
27 : namespace interface {
28 :
29 : /**
30 : * User identity information in the system
31 : */
32 : class Account : public ModelPrimitive<Account> {
33 : public:
34 : /**
35 : * @return Identity of user, for fetching data
36 : */
37 : virtual const types::AccountIdType &accountId() const = 0;
38 :
39 : /**
40 : * @return Identity of domain, for fetching data
41 : */
42 : virtual const types::DomainIdType &domainId() const = 0;
43 :
44 : /**
45 : * @return Minimum quorum of signatures needed for transactions
46 : */
47 : virtual types::QuorumType quorum() const = 0;
48 :
49 : /**
50 : * @return JSON data stored in account
51 : */
52 : virtual const types::JsonType &jsonData() const = 0;
53 :
54 : /**
55 : * Stringify the data.
56 : * @return the content of account asset.
57 : */
58 : std::string toString() const override {
59 0 : return detail::PrettyStringBuilder()
60 0 : .init("Account")
61 0 : .append("accountId", accountId())
62 0 : .append("domainId", domainId())
63 0 : .append("quorum", std::to_string(quorum()))
64 0 : .append("json", jsonData())
65 0 : .finalize();
66 0 : }
67 :
68 : /**
69 : * Checks equality of objects inside
70 : * @param rhs - other wrapped value
71 : * @return true, if wrapped objects are same
72 : */
73 : bool operator==(const Account &rhs) const override {
74 2 : return accountId() == rhs.accountId() and domainId() == rhs.domainId()
75 2 : and quorum() == rhs.quorum() and jsonData() == rhs.jsonData();
76 : }
77 : };
78 : } // namespace interface
79 : } // namespace shared_model
80 : #endif // IROHA_SHARED_MODEL_ACCOUNT_HPP
|