Commit 451064a4 authored by Conner Fromknecht's avatar Conner Fromknecht

feat: make Teleportr contract inherit from Ownable

parent 3bba6e11
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title TeleportrDeposit
*
* Shout out to 0xclem for providing the inspiration for this contract:
* https://github.com/0xclem/teleportr/blob/main/contracts/BridgeDeposit.sol
*/
contract TeleportrDeposit {
address public owner;
contract TeleportrDeposit is Ownable {
uint256 public minDepositAmount;
uint256 public maxDepositAmount;
uint256 public maxBalance;
uint256 public totalDeposits;
// Events
event OwnerSet(address indexed oldOwner, address indexed newOwner);
event MinDepositAmountSet(uint256 previousAmount, uint256 newAmount);
event MaxDepositAmountSet(uint256 previousAmount, uint256 newAmount);
event MaxBalanceSet(uint256 previousBalance, uint256 newBalance);
event BalanceWithdrawn(address indexed owner, uint256 balance);
event EtherReceived(uint256 indexed depositId, address indexed emitter, uint256 indexed amount);
// Modifiers
modifier isOwner() {
require(msg.sender == owner, "Caller is not owner");
_;
}
constructor(
uint256 _minDepositAmount,
uint256 _maxDepositAmount,
uint256 _maxBalance
) {
owner = msg.sender;
minDepositAmount = _minDepositAmount;
maxDepositAmount = _maxDepositAmount;
maxBalance = _maxBalance;
totalDeposits = 0;
emit OwnerSet(address(0), msg.sender);
emit MinDepositAmountSet(0, _minDepositAmount);
emit MaxDepositAmountSet(0, _maxDepositAmount);
emit MaxBalanceSet(0, _maxBalance);
......@@ -59,29 +51,25 @@ contract TeleportrDeposit {
}
// Send the contract's balance to the owner
function withdrawBalance() external isOwner {
function withdrawBalance() external onlyOwner {
address _owner = owner();
uint256 _balance = address(this).balance;
emit BalanceWithdrawn(owner, _balance);
payable(owner).transfer(_balance);
emit BalanceWithdrawn(_owner, _balance);
payable(_owner).transfer(_balance);
}
// Setters
function setMinAmount(uint256 _minDepositAmount) external isOwner {
function setMinAmount(uint256 _minDepositAmount) external onlyOwner {
emit MinDepositAmountSet(minDepositAmount, _minDepositAmount);
minDepositAmount = _minDepositAmount;
}
function setMaxAmount(uint256 _maxDepositAmount) external isOwner {
function setMaxAmount(uint256 _maxDepositAmount) external onlyOwner {
emit MaxDepositAmountSet(maxDepositAmount, _maxDepositAmount);
maxDepositAmount = _maxDepositAmount;
}
function setOwner(address newOwner) external isOwner {
emit OwnerSet(owner, newOwner);
owner = newOwner;
}
function setMaxBalance(uint256 _maxBalance) external isOwner {
function setMaxBalance(uint256 _maxBalance) external onlyOwner {
emit MaxBalanceSet(maxBalance, _maxBalance);
maxBalance = _maxBalance;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment