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_SHARED_MODEL_ACCOUNT_ASSET_HPP
7 : #define IROHA_SHARED_MODEL_ACCOUNT_ASSET_HPP
8 :
9 : #include "interfaces/base/model_primitive.hpp"
10 : #include "interfaces/common_objects/amount.hpp"
11 : #include "interfaces/common_objects/types.hpp"
12 : #include "utils/string_builder.hpp"
13 :
14 : namespace shared_model {
15 : namespace interface {
16 :
17 : /**
18 : * Representation of wallet in system
19 : */
20 : class AccountAsset : public ModelPrimitive<AccountAsset> {
21 : public:
22 : /**
23 : * @return Identity of user, for fetching data
24 : */
25 : virtual const types::AccountIdType &accountId() const = 0;
26 :
27 : /**
28 : * @return Identity of asset, for fetching data
29 : */
30 : virtual const types::AssetIdType &assetId() const = 0;
31 :
32 : /**
33 : * @return Current balance
34 : */
35 : virtual const Amount &balance() const = 0;
36 :
37 : /**
38 : * Stringify the data.
39 : * @return the content of account asset.
40 : */
41 : std::string toString() const override {
42 0 : return detail::PrettyStringBuilder()
43 0 : .init("AccountAsset")
44 0 : .append("accountId", accountId())
45 0 : .append("assetId", assetId())
46 0 : .append("balance", balance().toString())
47 0 : .finalize();
48 0 : }
49 :
50 : /**
51 : * Checks equality of objects inside
52 : * @param rhs - other wrapped value
53 : * @return true, if wrapped objects are same
54 : */
55 : bool operator==(const ModelType &rhs) const override {
56 0 : return accountId() == rhs.accountId() and assetId() == rhs.assetId()
57 0 : and balance() == rhs.balance();
58 : }
59 : };
60 : } // namespace interface
61 : } // namespace shared_model
62 : #endif // IROHA_SHARED_MODEL_ACCOUNT_ASSET_HPP
|