-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxy_contract.cairo
47 lines (41 loc) · 1.07 KB
/
proxy_contract.cairo
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
%lang starknet
@contract_interface
namespace IBalanceContract {
func increase_balance(amount: felt) {
}
func get_balance() -> (res: felt) {
}
}
@external
func call_increase_balance{syscall_ptr: felt*, range_check_ptr}(
contract_address: felt, amount: felt
) {
IBalanceContract.increase_balance(
contract_address=contract_address, amount=amount
);
return ();
}
@view
func call_get_balance{syscall_ptr: felt*, range_check_ptr}(
contract_address: felt
) -> (res: felt) {
let (res) = IBalanceContract.get_balance(
contract_address=contract_address
);
return (res=res);
}
// Define a local balance variable in our proxy contract.
@storage_var
func balance() -> (res: felt) {
}
@external
func increase_my_balance{syscall_ptr: felt*, range_check_ptr}(
class_hash: felt, amount: felt
) {
// Increase the local balance variable using a function from a
// different contract class by using a library call.
IBalanceContract.library_call_increase_balance(
class_hash=class_hash, amount=amount
);
return ();
}