optimism-bridge-snt/contracts/SNTPlaceHolder.sol

82 lines
3.2 KiB
Solidity
Raw Normal View History

2023-07-17 16:59:00 +00:00
// SPDX-License-Identifier: GPL-3.0
2023-09-26 14:34:28 +00:00
pragma solidity ^0.8.18;
import { TokenController } from "@vacp2p/minime/contracts/TokenController.sol";
2023-10-03 14:50:09 +00:00
import { MiniMeBase } from "@vacp2p/minime/contracts/MiniMeBase.sol";
import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol";
2023-07-17 16:59:00 +00:00
/*
Copyright 2017, Jordi Baylina
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// @title SNTPlaceholder Contract
/// @author Jordi Baylina
/// @dev The SNTPlaceholder contract will take control over the SNT after the contribution
/// is finalized and before the Status Network is deployed.
/// The contract allows for SNT transfers and transferFrom and implements the
/// logic for transferring control of the token to the network when the offering
/// asks it to do so.
contract SNTPlaceHolder is TokenController, Ownable2Step {
MiniMeBase public snt;
2023-07-17 16:59:00 +00:00
constructor(address payable _snt) {
snt = MiniMeBase(_snt);
2023-07-17 16:59:00 +00:00
}
/// @notice The owner of this contract can change the controller of the SNT token
/// Please, be sure that the owner is a trusted agent or 0x0 address.
/// @param _newController The address of the new controller
2023-09-26 14:34:28 +00:00
function changeController(address payable _newController) public onlyOwner {
2023-07-17 16:59:00 +00:00
snt.changeController(_newController);
emit ControllerChanged(_newController);
}
2023-09-26 14:34:28 +00:00
2023-07-17 16:59:00 +00:00
//////////
// MiniMe Controller Interface functions
//////////
// In between the offering and the network. Default settings for allowing token transfers.
2023-09-26 14:34:28 +00:00
function proxyPayment(address) public payable override returns (bool) {
2023-07-17 16:59:00 +00:00
return false;
}
2023-09-26 14:34:28 +00:00
function onTransfer(address, address, uint256) public pure override returns (bool) {
2023-07-17 16:59:00 +00:00
return true;
}
2023-09-26 14:34:28 +00:00
function onApprove(address, address, uint256) public pure override returns (bool) {
2023-07-17 16:59:00 +00:00
return true;
}
2023-09-26 15:14:43 +00:00
/// @notice This method can be used by the controller to extract mistakenly
/// sent tokens to this contract.
/// @param _token The address of the token contract that you want to recover
/// set to 0 in case you want to extract ether.
function claimTokens(MiniMeBase _token) public onlyOwner {
2023-09-26 15:14:43 +00:00
if (address(_token) == address(0)) {
payable(owner()).transfer(address(this).balance);
2023-09-26 15:14:43 +00:00
return;
}
uint256 balance = _token.balanceOf(address(this));
_token.transfer(owner(), balance);
emit ClaimedTokens(address(_token), owner(), balance);
2023-09-26 15:14:43 +00:00
}
2023-07-17 16:59:00 +00:00
event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount);
event ControllerChanged(address indexed _newController);
2023-09-26 14:34:28 +00:00
}