-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathContest.cpp
136 lines (115 loc) · 3.17 KB
/
Contest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "ProposalRoot.hpp"
#include "MultiBallot.hpp"
#include <tvm/contract.hpp>
#include <tvm/smart_switcher.hpp>
#include <tvm/contract_handle.hpp>
#include <tvm/emit.hpp>
#include <tvm/default_support_functions.hpp>
using namespace tvm;
using namespace schema;
static constexpr unsigned TIMESTAMP_DELAY = 1800;
using replay_protection_t = replay_attack_protection::timestamp<TIMESTAMP_DELAY>;
__interface [[no_pubkey]] ITestContest {
[[internal, noaccept, dyn_chain_parse]]
void constructor(bytes title, bytes link, uint256 hash, address juryAddr,
dict_array<uint256> juryKeys, uint64 startsIn, uint64 lastsFor, uint64 votingWindow,
uint256 sendApprovalGrams) = 777;
[[internal, noaccept]]
void sendApproval();
// ============== getters ==============
[[getter]]
bytes getTitle();
[[getter]]
bytes getLink();
[[getter]]
uint256 getHash();
[[getter]]
address getJuryAddr();
[[getter]]
dict_array<uint256> getJuryKeys();
[[getter]]
uint64 getStartsIn();
[[getter]]
uint64 getLastsFor();
[[getter]]
uint64 getVotingWindow();
};
struct DTestContest {
bytes title_;
bytes link_;
uint256 hash_;
address juryAddr_;
dict_array<uint256> juryKeys_;
uint64 startsIn_;
uint64 lastsFor_;
uint64 votingWindow_;
handle<IProposalRoot> proposal_;
Grams sendApprovalGrams_;
};
__interface ETestContest {
};
class TestContest final : public smart_interface<ITestContest>, public DTestContest {
public:
__always_inline
void constructor(bytes title, bytes link, uint256 hash, address juryAddr,
dict_array<uint256> juryKeys, uint64 startsIn, uint64 lastsFor, uint64 votingWindow,
uint256 sendApprovalGrams) {
title_ = title;
link_ = link;
hash_ = hash;
juryAddr_ = juryAddr;
juryKeys_ = juryKeys;
startsIn_ = startsIn;
lastsFor_ = lastsFor;
votingWindow_ = votingWindow;
proposal_ = handle<IProposalRoot>{ int_sender() };
sendApprovalGrams_ = sendApprovalGrams.get();
}
__always_inline
void sendApproval() {
proposal_(sendApprovalGrams_).contestApproved();
}
// ========== getters ==========
__always_inline
bytes getTitle() {
return title_;
}
__always_inline
bytes getLink() {
return link_;
}
__always_inline
uint256 getHash() {
return hash_;
}
__always_inline
address getJuryAddr() {
return juryAddr_;
}
__always_inline
dict_array<uint256> getJuryKeys() {
return juryKeys_;
}
__always_inline
uint64 getStartsIn() {
return startsIn_;
}
__always_inline
uint64 getLastsFor() {
return lastsFor_;
}
__always_inline
uint64 getVotingWindow() {
return votingWindow_;
}
public:
// ==================== Support methods =========================== //
// default processing of unknown messages
__always_inline static int _fallback(cell msg, slice msg_body) {
return 0;
}
DEFAULT_SUPPORT_FUNCTIONS(ITestContest, replay_protection_t);
};
DEFINE_JSON_ABI(ITestContest, DTestContest, ETestContest);
// ----------------------------- Main entry functions ---------------------- //
DEFAULT_MAIN_ENTRY_FUNCTIONS(TestContest, ITestContest, DTestContest, TIMESTAMP_DELAY)