From 684d5becaae410c007164890b2ebe240ea293152 Mon Sep 17 00:00:00 2001 From: nikola-bozin-txfusion <147805948+nikola-bozin-txfusion@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:47:33 +0200 Subject: [PATCH] fix: update zksync-ethers import syntax (#1421) --- examples/zksync-ethers-example/deploy/001_deploy.ts | 7 +++++++ examples/zksync-ethers-example/deploy/002_deploy.ts | 7 +++++++ packages/hardhat-zksync-ethers/src/extension-generator.ts | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/zksync-ethers-example/deploy/001_deploy.ts b/examples/zksync-ethers-example/deploy/001_deploy.ts index 291679f53..5a425e597 100644 --- a/examples/zksync-ethers-example/deploy/001_deploy.ts +++ b/examples/zksync-ethers-example/deploy/001_deploy.ts @@ -47,4 +47,11 @@ export default async function (hre: HardhatRuntimeEnvironment) { const tx2 = await greeter.setGreeting('Hello, world again with name!'); await tx2.wait(); console.info(chalk.green(`Greeter greeting set to: ${await greeter.greet()}`)); + + const newContractFactory = new hre.zksyncEthers.ContractFactory(artifact.abi, artifact.bytecode, wallet); + const deployedContract = await newContractFactory.deploy("Hello World with new contract factory."); + console.info(chalk.green(`Contract with new ContractFactory deployed to ${await deployedContract.getAddress()}`)) + + const newContract = new hre.zksyncEthers.Contract(await deployedContract.getAddress(),artifact.abi,wallet); + console.info(await newContract.greet()); } diff --git a/examples/zksync-ethers-example/deploy/002_deploy.ts b/examples/zksync-ethers-example/deploy/002_deploy.ts index 954737be7..c179af93a 100644 --- a/examples/zksync-ethers-example/deploy/002_deploy.ts +++ b/examples/zksync-ethers-example/deploy/002_deploy.ts @@ -99,4 +99,11 @@ export default async function (hre: HardhatRuntimeEnvironment) { console.info(chalk.green(`Greeter from getContractAt set to: ${await contract3.greet()}`)); const contract3Runner = contract3.runner as Signer; console.info(chalk.green('Runner from getContractAt set to: ', await contract3Runner.getAddress())); + + const newContractFactory = new hre.ethers.ContractFactory(artifact.abi, artifact.bytecode, signer); + const deployedContract = await newContractFactory.deploy("Hello World with new contract factory."); + console.info(chalk.green(`Contract with new ContractFactory deployed to ${await deployedContract.getAddress()}`)) + + const newContract = new hre.ethers.Contract(await deployedContract.getAddress(),artifact.abi,signer); + console.info(await newContract.greet()); } diff --git a/packages/hardhat-zksync-ethers/src/extension-generator.ts b/packages/hardhat-zksync-ethers/src/extension-generator.ts index 07a629181..440815740 100644 --- a/packages/hardhat-zksync-ethers/src/extension-generator.ts +++ b/packages/hardhat-zksync-ethers/src/extension-generator.ts @@ -25,7 +25,7 @@ export class ZkSyncGenerator implements Generator { public populateExtension(): any { return lazyObject(() => { - const { zksyncEthers } = require('zksync-ethers'); + const zksyncEthers = require('zksync-ethers'); const { ethWeb3Provider, zkWeb3Provider } = createProviders(this._hre); const { ethers } = require('ethers');