-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.func
More file actions
47 lines (38 loc) · 1.12 KB
/
main.func
File metadata and controls
47 lines (38 loc) · 1.12 KB
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
#include "lib/stdlib.func";
#include "struct/const.func";
#include "struct/storage.func";
#include "struct/msg.func";
#include "struct/game.func";
#include "struct/admin.func";
#include "struct/get-methods.func";
() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {
slice cs = in_msg_full.begin_parse();
int hash = slice_hash(cs);
throw_if(0, cs~load_uint(4) & 1);
init_data();
slice sender_addr = cs~load_msg_addr();
if (in_msg_body.slice_empty?()) {
game::start(sender_addr, msg_value, hash);
pack_data();
throw(0);
}
int op = in_msg_body~load_uint(32);
int is_admin = equal_slices(sender_addr, db::admin_addr);
if (op == op::add_balance()) {
db::available_balance += msg_value;
pack_data();
throw(0);
}
if (op == op::maintain()) {
throw_if(0xfffe, is_admin == 0);
adm::maintain(in_msg_body);
throw(0);
}
if (op == op::withdraw()) {
throw_if(0xfffd, is_admin == 0);
adm::withdraw();
pack_data();
throw(0);
}
throw(0xffff);
}