-
Notifications
You must be signed in to change notification settings - Fork 114
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
5 changed files
with
60 additions
and
1,140 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
packages/integration-tests/src/playbook/contracts/MultiTransfer.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,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]); | ||
} | ||
} | ||
} | ||
} |
69 changes: 0 additions & 69 deletions
69
...egration-tests/src/playbook/deployments-zk/zkSyncLocal/contracts/Greeter.sol/Greeter.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.