Skip to content

Commit

Permalink
test: 2nd fix of files refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Jul 2, 2024
1 parent 92a6fa9 commit f71886e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 1,140 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
// File @openzeppelin/contracts/token/ERC20/[email protected]

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Address.sol";

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;


contract TokenF2L2 {
// Declare the using directive on the contract scope
using SafeERC20 for IERC20;
using Address for address payable;

//Be able to receive any funds to the contract
receive() external payable {
pay();
}

function pay() public payable {
emit Paid(msg.sender, msg.value, block.timestamp);
}

function getBalance() public view returns (uint) {
return address(this).balance;
}

address public owner;

constructor(address _owner) {
owner = _owner;
}

event Paid(address indexed _from, uint _amount, uint _timestamp);

modifier onlyOwner() {
require(owner == msg.sender, "You are not the owner");
_; // continue
}

function multiTransfer(
address[] memory _recivers,
address[] memory _tokenAddresses,
uint256[] memory _tokenAmounts
) public payable onlyOwner {
// Check that the length of the tokenAddresses array is equal to the length of the tokenAmounts array
require(_tokenAddresses.length == _tokenAmounts.length, "Arrays must have the same length");
require(_tokenAddresses.length == _recivers.length, "Arrays must have the same length");

// Iterate over the arrays and transfer the specified amount of each token
for (uint i = 0; i < _tokenAddresses.length; i++) {
if (_tokenAddresses[i] == address(0)) {
payable(_recivers[i]).sendValue(_tokenAmounts[i]);
} else {
// Cast the token address to an IERC20 contract to access its safeTransfer function
IERC20 token = IERC20(_tokenAddresses[i]);

// Attempt to transfer the specified amount of the token
token.safeTransfer(_recivers[i], _tokenAmounts[i]);
}
}
}
}

This file was deleted.

Loading

0 comments on commit f71886e

Please sign in to comment.