-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEmbargo.sol
More file actions
73 lines (58 loc) · 2.63 KB
/
Copy pathEmbargo.sol
File metadata and controls
73 lines (58 loc) · 2.63 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {CurioTreaty} from "contracts/standards/CurioTreaty.sol";
import {CurioERC20} from "contracts/standards/CurioERC20.sol";
import {GetterFacet} from "contracts/facets/GetterFacet.sol";
import {AdminFacet} from "contracts/facets/AdminFacet.sol";
import {Position} from "contracts/libraries/Types.sol";
import {Set} from "contracts/Set.sol";
contract Embargo is CurioTreaty {
Set public sanctionList;
function init(address _diamond) public override {
super.init(_diamond);
sanctionList = new Set();
}
function name() external pure override returns (string memory) {
return "Embargo";
}
function description() external pure override returns (string memory) {
return "Owner of the League can point to which nation the league is sanctioning";
}
// ----------------------------------------------------------
// Set getters
// ----------------------------------------------------------
function getSanctionList() public view returns (uint256[] memory) {
return sanctionList.getAll();
}
// ----------------------------------------------------------
// Owner functions
// ----------------------------------------------------------
function addToSanctionList(uint256 _nationID) public onlyOwner {
sanctionList.add(_nationID);
}
function removeFromSanctionList(uint256 _nationID) public onlyOwner {
sanctionList.remove(_nationID);
}
function removeMember(uint256 _nationID) public onlyOwner {
AdminFacet admin = AdminFacet(diamond);
admin.removeFromTreatyWhitelist(_nationID); // need to be whitelisted again for joining
admin.removeSigner(_nationID);
}
// ----------------------------------------------------------
// Player functions
// ----------------------------------------------------------
function treatyLeave() public override minimumStay(30) {
super.treatyLeave();
}
// ----------------------------------------------------------
// Permission Functions
// ----------------------------------------------------------
function approveTransfer(uint256 _nationID, bytes memory _encodedParams) public view override returns (bool) {
GetterFacet getter = GetterFacet(diamond);
// Disapprove if transfer is to a nation on the sanction list
(uint256 toID, ) = abi.decode(_encodedParams, (uint256, uint256));
uint256 toNationID = getter.getNation(toID);
if (sanctionList.includes(toNationID)) return false;
return super.approveTransfer(_nationID, _encodedParams);
}
}