optimism-bridge-snt/contracts/SNTOptimismController.sol

73 lines
2.3 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
2023-10-06 15:02:12 +00:00
/**
* @title SNTOptimismController
* @author Ricardo Guilherme Schmidt, r4bbit
* @dev Contract for keeping the SNT token in Optimism.
* It does nothing, but can be replaced by other contract that does something.
2023-07-17 16:59:00 +00:00
*/
contract SNTOptimismController is TokenController, Ownable2Step {
MiniMeBase public snt;
2023-07-17 16:59:00 +00:00
2023-10-06 15:02:12 +00:00
/**
* @param _snt The address of the SNT token
*/
constructor(address payable _snt) {
snt = MiniMeBase(_snt);
2023-07-17 16:59:00 +00:00
}
2023-10-06 15:02:12 +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-10-06 15:02:12 +00:00
/**
* @dev proxyPayment set to reject all Ether.
*/
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-10-06 15:02:12 +00:00
/**
* @dev onTransfer set to accept any transfer
*/
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-10-06 15:02:12 +00:00
/**
* @dev onApprove set to accept any approval
*/
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-10-06 15:02:12 +00:00
/**
* @notice Extract mistakenly sent tokens to this contract.
* @param _token Token contract to recover, 0 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
}