mirror of
https://github.com/status-im/contracts.git
synced 2025-02-23 03:58:42 +00:00
cleanup unused contracts out of deploy
This commit is contained in:
parent
0bf80a2898
commit
bc447e04f4
@ -11,27 +11,8 @@ module.exports = {
|
||||
"http://localhost:8545"
|
||||
],
|
||||
gas: "auto",
|
||||
strategy: 'explicit',
|
||||
strategy: "explicit",
|
||||
contracts: {
|
||||
MiniMeTokenFactory: {},
|
||||
MiniMeToken: {
|
||||
args:["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
|
||||
},
|
||||
StatusRoot: {
|
||||
instanceOf: "TestStatusNetwork",
|
||||
deploy: true,
|
||||
args: ["0x0", "$MiniMeToken"],
|
||||
"onDeploy": [
|
||||
"await MiniMeToken.methods.changeController(StatusRoot.address).send()",
|
||||
"await StatusRoot.methods.setOpen(true).send()",
|
||||
]
|
||||
},
|
||||
VisibilityStake: {
|
||||
args:["$MiniMeToken", "31104000"],
|
||||
},
|
||||
GroupAccess: {
|
||||
args:["$MiniMeToken"],
|
||||
},
|
||||
MessageTribute: {
|
||||
args:["0x"],
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "../token/ERC20Token.sol";
|
||||
import "../common/MessageSigned.sol";
|
||||
|
||||
|
||||
contract GroupAccess is MessageSigned {
|
||||
|
||||
struct SuscriptionData {
|
||||
uint256 amount;
|
||||
uint256 recurrency;
|
||||
uint256 amountHeld;
|
||||
bool requiresPayment;
|
||||
}
|
||||
|
||||
mapping(bytes32 => uint) private suscriptions;
|
||||
mapping(bytes32 => address) private groupOwnership;
|
||||
mapping(bytes32 => SuscriptionData) private groupSuscriptionInfo;
|
||||
|
||||
event GroupSetup(bytes groupKey, bytes32 groupId);
|
||||
|
||||
ERC20Token public token;
|
||||
|
||||
constructor(ERC20Token _token) public {
|
||||
token = _token;
|
||||
}
|
||||
|
||||
function registerGroup(
|
||||
bytes calldata _groupKey,
|
||||
uint256 _amount,
|
||||
uint256 _recurrency,
|
||||
uint256 _amountHeld,
|
||||
bool _requiresPayment
|
||||
) external {
|
||||
bytes32 groupId = keccak256(abi.encodePacked(address(this), msg.sender, _groupKey));
|
||||
groupOwnership[groupId] = msg.sender;
|
||||
groupSuscriptionInfo[groupId] = SuscriptionData(_amount, _recurrency, _amountHeld, _requiresPayment);
|
||||
emit GroupSetup(_groupKey, groupId);
|
||||
}
|
||||
|
||||
function getSuscriptionInfo(bytes32 groupId) external view
|
||||
returns (uint256 amount, uint256 recurrency, uint256 amountHeld, bool requiresPayment)
|
||||
{
|
||||
SuscriptionData memory susc = groupSuscriptionInfo[groupId];
|
||||
return (susc.amount, susc.recurrency, susc.amountHeld, susc.requiresPayment);
|
||||
}
|
||||
|
||||
function canParticipate(bytes32 _groupId) external view
|
||||
returns (bool)
|
||||
{
|
||||
bytes32 suscriptionHash = getSuscriptionHash(_groupId);
|
||||
|
||||
SuscriptionData memory susc = groupSuscriptionInfo[_groupId];
|
||||
if(token.balanceOf(msg.sender) < susc.amountHeld){
|
||||
return false;
|
||||
}
|
||||
|
||||
return suscriptions[suscriptionHash] > block.timestamp;
|
||||
}
|
||||
|
||||
function suscribe(bytes32 _groupId) external {
|
||||
SuscriptionData memory susc = groupSuscriptionInfo[_groupId];
|
||||
bytes32 suscriptionHash = getSuscriptionHash(_groupId);
|
||||
|
||||
if(susc.requiresPayment){
|
||||
require(token.transferFrom(msg.sender, groupOwnership[_groupId], susc.amount));
|
||||
}
|
||||
|
||||
if(susc.amountHeld > 0)
|
||||
require(token.balanceOf(msg.sender) >= susc.amountHeld);
|
||||
|
||||
suscriptions[suscriptionHash] = now + susc.recurrency;
|
||||
}
|
||||
|
||||
function getSuscriptionHash(bytes32 _groupId)
|
||||
public
|
||||
view
|
||||
returns (bytes32) {
|
||||
return keccak256(
|
||||
abi.encodePacked(
|
||||
address(this),
|
||||
msg.sender,
|
||||
bytes4(keccak256("suscribe(bytes32)")),
|
||||
_groupId
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "../token/ERC20Token.sol";
|
||||
import "../common/Controlled.sol";
|
||||
|
||||
|
||||
contract VisibilityStake is Controlled {
|
||||
|
||||
struct Stake {
|
||||
uint256 amount;
|
||||
uint256 time;
|
||||
}
|
||||
|
||||
ERC20Token public token;
|
||||
uint256 public lockDelay;
|
||||
mapping(bytes32 => uint256) public visibility;
|
||||
mapping(address => mapping (bytes32 => Stake)) public stake;
|
||||
|
||||
constructor(ERC20Token _token, uint256 _lockDelay) public {
|
||||
token = _token;
|
||||
lockDelay = _lockDelay;
|
||||
}
|
||||
|
||||
function deposit(bytes32 _publicKeyHash, uint256 _amount) external {
|
||||
require(token.transferFrom(msg.sender, address(this), _amount), "Transfer error");
|
||||
visibility[_publicKeyHash] += _amount;
|
||||
stake[msg.sender][_publicKeyHash].amount += _amount;
|
||||
stake[msg.sender][_publicKeyHash].time = now;
|
||||
|
||||
}
|
||||
|
||||
function withdraw(bytes32 _publicKeyHash) external {
|
||||
uint256 time = stake[msg.sender][_publicKeyHash].time = now;
|
||||
uint256 amount = stake[msg.sender][_publicKeyHash].amount;
|
||||
require(time != 0 && time > now + lockDelay, "Locked stake");
|
||||
delete stake[msg.sender][_publicKeyHash];
|
||||
if(amount == 0) {
|
||||
return;
|
||||
}
|
||||
require(visibility[_publicKeyHash] > amount, "Not available");
|
||||
visibility[_publicKeyHash] -= amount;
|
||||
}
|
||||
|
||||
function slash(bytes32 _publicKeyHash) external onlyController {
|
||||
uint256 amount = visibility[_publicKeyHash];
|
||||
delete visibility[_publicKeyHash];
|
||||
require(token.transferFrom(address(this), msg.sender, amount), "Transfer error");
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user