1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#pragma once
8

9
#include "../Data.h"
10
#include "Action.h"
11
#include "Prefixes.h"
12

13
#include <nlohmann/json.hpp>
14

15
#include <set>
16
#include <array>
17

18
namespace TW::EOS {
19

20 1
class Signature {
21
public:
22
    Data data;
23
    Type type;
24

25
    static const size_t DataSize = 65;
26
    static const size_t ChecksumSize = 4;
27

28
    Signature(const Data& sig, Type type);
29 1
    virtual ~Signature() { }
30
    void serialize(Data& os) const noexcept;
31
    std::string string() const noexcept;
32
};
33

34
class Extension {
35
public:
36
    uint16_t type;
37
    Data buffer;
38

39
    Extension(uint16_t type, const Data& buffer) : type(type), buffer(buffer) { }
40
    virtual ~Extension() { }
41
    void serialize(Data& os) const noexcept;
42
    nlohmann::json serialize() const noexcept;
43
};
44

45 1
class Transaction {
46
public:
47
    Transaction(const Data& referenceBlockId, int32_t referenceBlockTime);
48

49
    void serialize(Data& os) const noexcept;
50
    nlohmann::json serialize() const;
51

52 1
    inline bool isValid() { return maxNetUsageWords < UINT32_MAX / 8UL; }
53

54
    uint16_t refBlockNumber = 0;
55
    uint32_t refBlockPrefix = 0;
56
    int32_t expiration = 0;
57
    uint32_t maxNetUsageWords = 0;
58
    uint8_t maxCPUUsageInMS = 0;
59
    uint32_t delaySeconds = 0;
60

61
    std::vector<Action> actions;
62
    std::vector<Action> contextFreeActions;
63
    std::vector<Extension> transactionExtensions;
64
    std::vector<Signature> signatures;
65

66
    Data contextFreeData;
67

68
    void setReferenceBlock(const Data& referenceBlockId);
69

70
    static const int32_t ExpirySeconds = 30;
71
};
72
} // namespace TW::EOS

Read our documentation on viewing source code .

Loading