-
Notifications
You must be signed in to change notification settings - Fork 9
/
proxy.fc
33 lines (32 loc) · 1.16 KB
/
proxy.fc
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
() recv_internal(cell in_msg_cell, slice payload) {
var cs = in_msg_cell.begin_parse();
var flags = cs~load_uint(4); ;; int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
slice s_addr = cs~load_msg_addr();
slice master_address = get_data().begin_parse().skip_bits(64);
if(equal_slices(master_address, s_addr)) {
if(payload.slice_bits()) {
slice destination = payload~load_msg_addr();
cell proxied_payload = payload~load_ref();
builder msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(destination)
.store_grams(0)
.store_uint(1, 1 + 4 + 4 + 64 + 32 + 1 + 1)
.store_ref(proxied_payload);
send_raw_message(msg.end_cell(), 64);
}
}
else {
raw_reserve(1000000000, 2);
builder msg = begin_cell()
.store_uint(0x18, 6)
.store_slice(master_address)
.store_grams(0)
.store_uint(0, 1 + 4 + 4 + 64 + 32 + 1 + 1)
.store_slice(s_addr) ;; TODO potentially too much data for cell
;; however in all elector response it should be enough
.store_uint(flags, 4)
.store_slice(payload);
send_raw_message(msg.end_cell(), 128);
}
}