forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
78 deletions.
There are no files selected for viewing
38 changes: 5 additions & 33 deletions
38
tests/integration_tests/hardhat/contracts/FeeCollector.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
contract FeeCollector { | ||
event TokensMinted(address indexed to, uint256 amount); | ||
|
||
contract FeeCollector { | ||
address public owner; | ||
uint256 public balance; | ||
|
||
event TransferReceived(address _from, uint _amount); | ||
event TransferSent(address _from, address _destAddr, uint _amount); | ||
|
||
constructor() { | ||
owner = msg.sender; | ||
function mint(uint256 amount) public payable { | ||
emit TokensMinted(msg.sender, amount); | ||
} | ||
|
||
receive() external payable { | ||
balance += msg.value; | ||
emit TransferReceived(msg.sender, msg.value); | ||
} | ||
|
||
function withdraw(uint amount, address payable destAddr) public { | ||
require(msg.sender == owner, "Only owner can withdraw funds"); | ||
require(amount <= balance, "Insufficient funds"); | ||
|
||
destAddr.transfer(amount); | ||
balance -= amount; | ||
emit TransferSent(msg.sender, destAddr, amount); | ||
} | ||
|
||
function transferERC20(IERC20 token, address to, uint256 amount) public { | ||
require(msg.sender == owner, "Only owner can withdraw funds"); | ||
uint256 erc20balance = token.balanceOf(address(this)); | ||
require(amount <= erc20balance, "balance is low"); | ||
token.transfer(to, amount); | ||
emit TransferSent(msg.sender, to, amount); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters