forked from zama-ai/fhevm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPayment.sol
44 lines (35 loc) · 1.74 KB
/
Payment.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
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;
import "../lib/FHEVMConfig.sol";
import "../lib/Impl.sol";
interface IFHEPayment {
function depositETH(address account) external payable;
function withdrawETH(uint256 amount, address receiver) external;
function getAvailableDepositsETH(address account) external view returns (uint256);
}
library Payment {
function depositForAccount(address account, uint256 amount) internal {
FHEVMConfig.FHEVMConfigStruct storage $ = Impl.getFHEVMConfig();
IFHEPayment($.FHEPaymentAddress).depositETH{value: amount}(account);
}
function depositForThis(uint256 amount) internal {
FHEVMConfig.FHEVMConfigStruct storage $ = Impl.getFHEVMConfig();
IFHEPayment($.FHEPaymentAddress).depositETH{value: amount}(address(this));
}
function withdrawToAccount(address account, uint256 amount) internal {
FHEVMConfig.FHEVMConfigStruct storage $ = Impl.getFHEVMConfig();
IFHEPayment($.FHEPaymentAddress).withdrawETH(amount, account);
}
function withdrawToThis(uint256 amount) internal {
FHEVMConfig.FHEVMConfigStruct storage $ = Impl.getFHEVMConfig();
IFHEPayment($.FHEPaymentAddress).withdrawETH(amount, address(this));
}
function getDepositedBalanceOfAccount(address account) internal view returns (uint256) {
FHEVMConfig.FHEVMConfigStruct storage $ = Impl.getFHEVMConfig();
return IFHEPayment($.FHEPaymentAddress).getAvailableDepositsETH(account);
}
function getDepositedBalanceOfThis() internal view returns (uint256) {
FHEVMConfig.FHEVMConfigStruct storage $ = Impl.getFHEVMConfig();
return IFHEPayment($.FHEPaymentAddress).getAvailableDepositsETH(address(this));
}
}