-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.tact
48 lines (42 loc) · 1.49 KB
/
2.tact
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
import "@stdlib/deploy";
/*
TASK 2 - Proxy
Create a contract that forwards all received TONs
to the admin contract (whose address is set in init_store).
Message from this proxy contract to the admin contract should contain:
- Address of user who sent original message (should be stored in the outcoming body's data/bits)
- Original message that proxy smart contract received from user (should be stored in the outcoming body's first ref)
Also, if admin contract decides to reject message (if it sends to the proxy "Refund" message with opcode=0x44),
proxy contract needs to forward all TONs (attached to Refund message) back to the user.
User address will be provided in Refund message body as "sender".
In refund transaction, it is important to have a check that the refund message came from the admin address
fijdgdkfg
*/
message(0x44) Refund {
queryId: Int as uint64;
sender: Address;
}
contract Task2 with Deployable {
admin: Address;
init(admin: Address) {
self.admin = admin;
}
receive(msg: Refund) {
require(sender() == self.admin, "");
send(SendParameters{
to: msg.sender,
bounce: false,
value: 0,
mode: SendRemainingValue + SendIgnoreErrors
});
}
receive(msg: Slice) {
send(SendParameters{
to: self.admin,
bounce: false,
value: 0,
mode: SendRemainingValue + SendIgnoreErrors,
body: beginCell().storeAddress(sender()).storeRef(beginCell().storeSlice(msg).endCell()).endCell()
});
}
}