-
Notifications
You must be signed in to change notification settings - Fork 0
/
EverscaleEventConfiguration.sol
129 lines (99 loc) · 3.9 KB
/
EverscaleEventConfiguration.sol
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
pragma ton-solidity >= 0.39.0;
pragma AbiHeader expire;
import './interfaces/IEverscaleEvent.sol';
import "./interfaces/IEverscaleEventConfiguration.sol";
import './EverscaleTransferTokenEvent.sol';
import './utils/ErrorCodes.sol';
import './utils/MsgFlag.sol';
import './utils/TransferUtils.sol';
contract EverscaleEventConfiguration is IEverscaleEventConfiguration, TransferUtils {
address _owner;
BasicConfiguration public _basicConfiguration;
EverscaleEventConfiguration public _networkConfiguration;
constructor(address owner, BasicConfiguration basicConfiguration, EverscaleEventConfiguration networkConfiguration) public {
tvm.accept();
_owner = owner;
_basicConfiguration = basicConfiguration;
_networkConfiguration = networkConfiguration;
}
modifier onlyOwner {
require(msg.sender == _owner);
_;
}
function setConfiguration(BasicConfiguration basicConfiguration, EverscaleEventConfiguration networkConfiguration) public onlyOwner {
_basicConfiguration = basicConfiguration;
_networkConfiguration = networkConfiguration;
msg.sender.transfer({value:0, flag:64});
}
function buildEventInitData(
IEverscaleEvent.EverscaleEventVoteData eventVoteData
) internal view returns(
IEverscaleEvent.EverscaleEventInitData eventInitData
) {
eventInitData.voteData = eventVoteData;
eventInitData.configuration = address(this);
eventInitData.bridge = _basicConfiguration.bridge;
}
function deployEvent(
IEverscaleEvent.EverscaleEventVoteData eventVoteData
) override external reserveBalance {
require(msg.sender == _networkConfiguration.eventEmitter, ErrorCodes.SENDER_IS_NOT_EVENT_EMITTER);
require(msg.value >= _basicConfiguration.eventInitialBalance, ErrorCodes.TOO_LOW_DEPLOY_VALUE);
//todo check
require(
eventVoteData.eventTimestamp >= _networkConfiguration.startTimestamp,
ErrorCodes.EVENT_TIMESTAMP_LESS_THAN_START
);
if (_networkConfiguration.endTimestamp != 0) {
require(
eventVoteData.eventTimestamp <= _networkConfiguration.endTimestamp,
ErrorCodes.EVENT_TIMESTAMP_HIGHER_THAN_END
);
}
IEverscaleEvent.EverscaleEventInitData eventInitData = buildEventInitData(eventVoteData);
address eventContract = deriveEventAddress(eventVoteData);
emit NewEventContract(eventContract);
new EverscaleTransferTokenEvent{
value: 0,
flag: MsgFlag.ALL_NOT_RESERVED,
code: _basicConfiguration.eventCode,
pubkey: 0,
varInit: {
eventInitData: eventInitData
}
}(msg.sender);
}
function deriveEventAddress(
IEverscaleEvent.EverscaleEventVoteData eventVoteData
)
override
public
view
responsible
returns (
address eventContract
) {
IEverscaleEvent.EverscaleEventInitData eventInitData = buildEventInitData(eventVoteData);
TvmCell stateInit = tvm.buildStateInit({
contr: EverscaleTransferTokenEvent,
varInit: {
eventInitData: eventInitData
},
pubkey: 0,
code: _basicConfiguration.eventCode
});
return {value: 0, flag: MsgFlag.REMAINING_GAS} address(tvm.hash(stateInit));
}
function getDetails() override public view responsible returns(
BasicConfiguration basicConfiguration,
EverscaleEventConfiguration networkConfiguration
) {
return {value: 0, flag: MsgFlag.REMAINING_GAS}(
_basicConfiguration,
_networkConfiguration
);
}
function getType() override public pure responsible returns(EventType _type) {
return {value: 0, flag: MsgFlag.REMAINING_GAS} EventType.Everscale;
}
}