/
PaymentFacet.sol
46 lines (40 loc) · 1.37 KB
/
PaymentFacet.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
45
46
// SPDX-License-Identifier: MIT
pragma solidity 0.8.3;
import "../interfaces/IPayment.sol";
import "../libraries/LibDiamond.sol";
import "../libraries/LibPayment.sol";
contract PaymentFacet is IPayment {
/// @notice Adds/removes a payment token
/// @param _token The target token
/// @param _status Whether the token will be added or removed
function setPaymentToken(address _token, bool _status) external override {
require(_token != address(0), "PaymentFacet: _token must not be 0x0");
LibDiamond.enforceIsContractOwner();
LibPayment.updatePaymentToken(_token, _status);
emit SetPaymentToken(_token, _status);
}
/// @notice Gets whether the payment token is supported
/// @param _token The target token
function supportsPaymentToken(address _token)
external
view
override
returns (bool)
{
return LibPayment.containsPaymentToken(_token);
}
/// @notice Gets the total amount of token payments
function totalPaymentTokens() external view override returns (uint256) {
return LibPayment.tokensCount();
}
/// @notice Gets the payment token at a given index
/// @param _index The token index
function paymentTokenAt(uint256 _index)
external
view
override
returns (address)
{
return LibPayment.tokenAt(_index);
}
}