Skip to content

Commit

Permalink
test: 2nd fix of files
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Jul 2, 2024
1 parent 8923587 commit 92a6fa9
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cypress/screenshots/
tests/e2e/reports/
**/tests/e2e/artifacts/
**/playbook/artifacts-zk/
**/deployments-zk/
**/playbook/artifacts/
**/playbook/buffer/
**/playbook/cache-zk/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,3 @@
// 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]);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ export default async function (hre: HardhatRuntimeEnvironment) {
console.log(`Deploying contract with arguments: ${JSON.stringify(constructor_arguments)}`);
const deployedContract = await deployer.deploy(artifact, constructor_arguments);

await deployedContract.deployTransaction.wait(2);
await deployedContract.waitForDeployment();

// Show the contract info.
console.log(`Contract "${artifact.contractName}" was deployed to ${deployedContract.address}`);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiTransferETH, deployedContract.address);
await helper.writeFile(
Path.absolutePathToBufferFiles,
Buffer.addressMultiTransferETH,
await deployedContract.getAddress()
);

await verify({ hre, contract: deployedContract, contractConstructorArguments: constructor_arguments, artifact });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {

console.log(`Contract said something like this: ${greetingFromContract}`);

const address = deployedContract.address;
const txHash = deployedContract.deployTransaction.hash;
const address = await deployedContract.getAddress();
const txHash = deployedContract.deploymentTransaction().hash;

await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallMiddle, address);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallMiddle, txHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {
console.error(`Contract said something unexpected: ${newGreetingFromContract}`);
}

const address = deployedContract.address;
const txHash = deployedContract.deployTransaction.hash;
const address = await deployedContract.getAddress();
const txHash = deployedContract.deploymentTransaction().hash;

await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.addressMultiCallRoot, address);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.txMultiCallRoot, txHash);
Expand Down
6 changes: 3 additions & 3 deletions packages/integration-tests/src/playbook/deploy/nftToL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export default async function (hre: HardhatRuntimeEnvironment) {

const myNFT = await deployer.deploy(artifact, contractConstructorArguments);

console.log(`Contract "${artifact.contractName}" was deployed to ${myNFT.address}`);
console.log(`Contract "${artifact.contractName}" was deployed to ${await myNFT.getAddress()}`);

const mintNFT = await myNFT.mintNFT(myNFT.address, Wallets.richWalletAddress);
const mintNFT = await myNFT.mintNFT(await myNFT.getAddress(), Wallets.richWalletAddress);
if (mintNFT) {
console.log(`Contract mint for us!`);
} else {
Expand All @@ -31,5 +31,5 @@ export default async function (hre: HardhatRuntimeEnvironment) {

displayVerificationInfo({ hre, contract: myNFT, contractConstructorArguments, artifact });

await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2, myNFT.address);
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.NFTtoL2, await myNFT.getAddress());
}
5 changes: 2 additions & 3 deletions packages/integration-tests/src/playbook/deploy/use-greeter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as ethers from "ethers";
import { Provider, Wallet } from "zksync-web3";
import { Contract, Provider, Wallet } from "zksync-web3";

import { localConfig } from "../../config";
import { Path, Wallets } from "../../constants";
Expand All @@ -19,7 +18,7 @@ export default async function (hre: HardhatRuntimeEnvironment) {

function getContract(hre: HardhatRuntimeEnvironment, wallet: Wallet) {
const artifact = hre.artifacts.readArtifactSync("Greeter");
contract = new ethers.Contract(greeterContractAddress, artifact.abi, wallet);
contract = new Contract(greeterContractAddress, artifact.abi, wallet);
return contract;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ethers from "ethers";
import { Provider } from "zksync-web3";
import { Provider } from "zksync-ethers";

import { localConfig } from "../../config";
import { Buffer, Path } from "../../constants";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ethers from "ethers";
import * as zksync from "zksync-web3";
import * as zksync from "zksync-ethers";

import { localConfig } from "../../../config";
import { Buffer, Logger, Path, Wallets } from "../../../constants";
Expand All @@ -14,7 +14,7 @@ export const depositERC20 = async function (sum = "0.5", tokenAddress: string, u
const deposit = await syncWallet.deposit({
to: Wallets.richWalletAddress,
token: tokenAddress,
amount: ethers.utils.parseUnits(sum, units),
amount: ethers.parseUnits(sum, units),
approveERC20: true,
l2GasLimit: localConfig.l2GasLimit,
overrides: localConfig.l1GasLimit,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ethers from "ethers";
import * as zksync from "zksync-web3";
import * as zksync from "zksync-ethers";

import { localConfig } from "../../../config";
import { Buffer, Logger, Path, Values } from "../../../constants";
Expand All @@ -13,7 +13,7 @@ export const depositEth = async function (sum: string = Values.txSumETH) {

const deposit = await syncWallet.deposit({
token: zksync.utils.ETH_ADDRESS,
amount: ethers.utils.parseEther(sum),
amount: ethers.parseEther(sum),
l2GasLimit: localConfig.l2GasLimit,
});
await deposit.wait(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { utils } from "ethers";
import * as ethers from "ethers";
import * as path from "path";

import type { ZkSyncArtifact } from "@matterlabs/hardhat-zksync-deploy/dist/types";
Expand Down Expand Up @@ -26,7 +26,7 @@ export default function ({
console.log(`Solc Version: ${(hre.userConfig.solidity as SolcUserConfig).version}`);
console.log(`Source code file path: ${path.join(__dirname, "../", artifact.sourceName)}`);
// Get constructor arguments
const contractInterface = new utils.Interface(artifact.abi);
const contractInterface = new ethers.Interface(artifact.abi);
const constructorArgs = contractInterface.encodeDeploy(contractConstructorArguments);
console.log(`Constructor arguments: ${constructorArgs}`);
}

0 comments on commit 92a6fa9

Please sign in to comment.