Skip to content

Commit

Permalink
test: fix for multitransfer and l1
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Jul 2, 2024
1 parent 7760757 commit d20f4fd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";

import { localConfig } from "../../config";
import { Buffer, Path } from "../../constants";
import { Helper } from "../../helper";
import getWallet from "../utils/getWallet";
Expand Down
22 changes: 11 additions & 11 deletions packages/integration-tests/src/playbook/deploy/deploy-paymaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ export default async function (hre: HardhatRuntimeEnvironment) {
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.paymasterDeployTx, deployTransaction.hash);

// TODO: fix
// await (
// await deployer.zkWallet.sendTransaction({
// to: paymaster.address,
// value: parseEther("0.03"),
// })
// ).wait();
await (
await deployer.zkWallet.sendTransaction({
to: paymaster.address,
value: parseEther("0.03"),
})
).wait();

// await // We will give the empty wallet 3 units of the token:
// (await erc20.mint(emptyWallet.address, 3)).wait();
await // We will give the empty wallet 3 units of the token:
(await erc20.mint(emptyWallet.address, 3)).wait();

// console.log("Minted 3 tokens for the empty wallet");
// console.log(`Done!`);
console.log("Minted 3 tokens for the empty wallet");
console.log(`Done!`);

// return deployTransaction.hash;
return deployTransaction.hash;
}
16 changes: 8 additions & 8 deletions packages/integration-tests/src/playbook/deploy/erc20toL1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { Helper } from "../../helper";
const helper = new Helper();
async function main() {
// TODO: fix
// const [deployer] = await ethers.getSigners();
// console.log("Deploying contracts with the account:", deployer.address);
// const weiAmount = (await deployer.getBalance()).toString();
// console.log("Account balance:", await ethers.utils.formatEther(weiAmount));
// const contract = await ethers.getContractFactory("L1");
// const token = await contract.deploy(Wallets.richWalletAddress, localConfig.l1GasLimit);
// const contractAddress = await token.getAddress();
// await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L1, contractAddress);
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
const weiAmount = (await deployer.getBalance()).toString();
console.log("Account balance:", await ethers.utils.formatEther(weiAmount));
const contract = await ethers.getContractFactory("L1");
const token = await contract.deploy(Wallets.richWalletAddress, localConfig.l1GasLimit);
const contractAddress = await token.getAddress();
await helper.writeFile(Path.absolutePathToBufferFiles, Buffer.L1, contractAddress);
}

main()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";

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

import { localConfig } from "../../config";
import { Buffer, Path, Token, Wallets } from "../../constants";
Expand All @@ -21,9 +21,9 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
const customTokenI = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2);
const customTokenII = await helper.readFile(Path.absolutePathToBufferFiles, Buffer.L2deposited);
// amount of funds
const ethAmount = ethers.utils.parseEther("0.0001");
const customTokenIAmount = ethers.utils.parseUnits("0.01", 18);
const customTokenIIAmount = ethers.utils.parseUnits("0.01", 18);
const ethAmount = ethers.parseEther("0.0001");
const customTokenIAmount = ethers.parseUnits("0.01", 18);
const customTokenIIAmount = ethers.parseUnits("0.01", 18);

console.log(`Running deploy script for the contract`);

Expand All @@ -34,12 +34,12 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
const attachedContract = await hre.ethers.getContractAt(contractName, contractAddress, signer);

// top up the contract / transfer
const ethTransfer = await makeTransfer(etherAddress, ethers.utils.parseEther("0.101"));
const customToken1Transfer = await makeTransfer(customTokenI, ethers.utils.parseUnits("1", 18));
const customToken2Transfer = await makeTransfer(customTokenII, ethers.utils.parseUnits("1", 18));
const ethTransfer = await makeTransfer(etherAddress, ethers.parseEther("0.101"));
const customToken1Transfer = await makeTransfer(customTokenI, ethers.parseUnits("1", 18));
const customToken2Transfer = await makeTransfer(customTokenII, ethers.parseUnits("1", 18));
const multiTransferResult = await makeMultiTransfer();

async function makeTransfer(token: string, amount: ethers.BigNumber) {
async function makeTransfer(token: string, amount: ethers.BigNumberish) {
const transfer = await wallet.transfer({
to: contractAddress,
token: token,
Expand All @@ -54,6 +54,7 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen
return transferReceipt.transactionHash;
}

// TODO FIX
//call the deployed contract.
async function makeMultiTransfer() {
const transferFromContract = await attachedContract.multiTransfer(
Expand All @@ -73,24 +74,19 @@ export default async function callMultiTransferETH(hre: HardhatRuntimeEnvironmen

// Show the contract balance
console.log(
`Getting ETH balance from contract API: "${ethers.utils.formatUnits(
await provider.getBalance(contractAddress),
18
)}"`
`Getting ETH balance from contract API: "${ethers.formatUnits(await provider.getBalance(contractAddress), 18)}"`
);

// Show the balance of wallets
console.log(`balance of wallet 1 is: "${ethers.formatUnits(await provider.getBalance(richWalletAddress), 18)}" ETH`);
console.log(
`balance of wallet 1 is: "${ethers.utils.formatUnits(await provider.getBalance(richWalletAddress), 18)}" ETH`
);
console.log(
`balance of wallet 2 is: "${ethers.utils.formatUnits(
`balance of wallet 2 is: "${ethers.formatUnits(
await provider.getBalance(mainWalletAddress, "latest", customTokenI),
18
)}" Custom token I`
);
console.log(
`balance of wallet 3 is: "${ethers.utils.formatUnits(
`balance of wallet 3 is: "${ethers.formatUnits(
await provider.getBalance(secondaryWalletAddress, "latest", customTokenII),
18
)}" Custom token II`
Expand Down

0 comments on commit d20f4fd

Please sign in to comment.