diff --git a/example/contracts/Lock.sol b/example/contracts/Lock.sol index 00a50ce..8c3d253 100644 --- a/example/contracts/Lock.sol +++ b/example/contracts/Lock.sol @@ -8,14 +8,14 @@ contract Lock { event Withdrawal(uint amount, uint when); - constructor(uint _unlockTime) payable { + constructor(address _owner, uint _unlockTime) payable { require( block.timestamp < _unlockTime, "Unlock time should be in the future" ); unlockTime = _unlockTime; - owner = payable(msg.sender); + owner = payable(_owner); } function withdraw() public { diff --git a/example/hardhat.config.ts b/example/hardhat.config.ts index 971387b..8c011d5 100644 --- a/example/hardhat.config.ts +++ b/example/hardhat.config.ts @@ -1,6 +1,7 @@ import {HardhatUserConfig, vars} from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; import "@chainsafe/hardhat-ts-artifact-plugin"; +import "@nomicfoundation/hardhat-web3-v4"; import "@chainsafe/hardhat-plugin-multichain-deploy"; import {Environment} from "@buildwithsygma/sygma-sdk-core"; diff --git a/example/package.json b/example/package.json index 651835f..a81176c 100644 --- a/example/package.json +++ b/example/package.json @@ -20,6 +20,7 @@ "@nomicfoundation/hardhat-network-helpers": "^1.0.10", "@nomicfoundation/hardhat-toolbox": "^4.0.0", "@nomicfoundation/hardhat-verify": "^2.0.4", + "@nomicfoundation/hardhat-web3-v4": "^1.0.0", "@typechain/ethers-v6": "^0.5.1", "@typechain/hardhat": "^9.1.0", "@types/chai": "^4.2.0", @@ -34,6 +35,7 @@ "solidity-coverage": "^0.8.7", "ts-node": ">=8.0.0", "typechain": "^8.3.2", - "typescript": ">=4.5.0" + "typescript": ">=4.5.0", + "web3": "^4.5.0" } } diff --git a/example/scripts/deployMultichain.ts b/example/scripts/deployMultichain.ts index ad1714c..a19fb89 100644 --- a/example/scripts/deployMultichain.ts +++ b/example/scripts/deployMultichain.ts @@ -1,27 +1,28 @@ -import { multichain } from "hardhat"; +import { multichain, web3 } from "hardhat"; import { NetworkArguments } from "@chainsafe/hardhat-plugin-multichain-deploy"; async function main(): Promise { const currentTimestampInSeconds = Math.round(Date.now() / 1000); const unlockTime = BigInt(currentTimestampInSeconds + 60); + const [deployer] = await web3.eth.getAccounts(); const networkArguments: NetworkArguments = { sepolia: { - args: [unlockTime], + args: [deployer, unlockTime], initData: { initMethodName: "setName", initMethodArgs: ["sepolia"], }, }, mumbai: { - args: [unlockTime], + args: [deployer, unlockTime], initData: { initMethodName: "setName", initMethodArgs: ["mumbai"], }, }, holesky: { - args: [unlockTime], + args: [deployer, unlockTime], initData: { initMethodName: "setName", initMethodArgs: ["holesky"], diff --git a/example/scripts/deployMultichainBytecode.ts b/example/scripts/deployMultichainBytecode.ts index 14af592..1a5c487 100644 --- a/example/scripts/deployMultichainBytecode.ts +++ b/example/scripts/deployMultichainBytecode.ts @@ -1,28 +1,29 @@ -import { multichain } from "hardhat"; +import { multichain, web3 } from "hardhat"; import { NetworkArguments } from "@chainsafe/hardhat-plugin-multichain-deploy"; import artifact from "../artifacts/contracts/Lock.sol/Lock"; async function main(): Promise { const currentTimestampInSeconds = Math.round(Date.now() / 1000); const unlockTime = BigInt(currentTimestampInSeconds + 60); + const [deployer] = await web3.eth.getAccounts(); const networkArguments: NetworkArguments = { sepolia: { - args: [unlockTime], + args: [deployer, unlockTime], initData: { initMethodName: "setName", initMethodArgs: ["sepolia"], }, }, mumbai: { - args: [unlockTime], + args: [deployer, unlockTime], initData: { initMethodName: "setName", initMethodArgs: ["mumbai"], }, }, holesky: { - args: [unlockTime], + args: [deployer, unlockTime], initData: { initMethodName: "setName", initMethodArgs: ["holesky"], diff --git a/example/scripts/localhost.ts b/example/scripts/localhost.ts index 35f8871..42733fe 100644 --- a/example/scripts/localhost.ts +++ b/example/scripts/localhost.ts @@ -1,25 +1,36 @@ -import { multichain } from "hardhat"; +import { multichain, web3 } from "hardhat"; import { NetworkArguments } from "@chainsafe/hardhat-plugin-multichain-deploy"; async function main(): Promise { const currentTimestampInSeconds = Math.round(Date.now() / 1000); const unlockTime = BigInt(currentTimestampInSeconds + 60); + const [deployer] = await web3.eth.getAccounts(); const { adapterAddress } = await multichain.initLocalEnvironment(); - const networkArguments = ["sepolia", "mumbai", "holesky"].reduce( - (args, networkName) => { - args[networkName] = { - args: [unlockTime], - initData: { - initMethodName: "setName", - initMethodArgs: [networkName], - }, - }; - return args; + const networkArguments: NetworkArguments = { + sepolia: { + args: [deployer, unlockTime], + initData: { + initMethodName: "setName", + initMethodArgs: ["sepolia"], + }, }, - {} as NetworkArguments - ); + mumbai: { + args: [deployer, unlockTime], + initData: { + initMethodName: "setName", + initMethodArgs: ["mumbai"], + }, + }, + holesky: { + args: [deployer, unlockTime], + initData: { + initMethodName: "setName", + initMethodArgs: ["holesky"], + }, + }, + }; await multichain.deployMultichain("Lock", networkArguments, { adapterAddress, diff --git a/yarn.lock b/yarn.lock index 84ecee9..355d6f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7707,6 +7707,7 @@ __metadata: "@nomicfoundation/hardhat-network-helpers": ^1.0.10 "@nomicfoundation/hardhat-toolbox": ^4.0.0 "@nomicfoundation/hardhat-verify": ^2.0.4 + "@nomicfoundation/hardhat-web3-v4": ^1.0.0 "@typechain/ethers-v6": ^0.5.1 "@typechain/hardhat": ^9.1.0 "@types/chai": ^4.2.0 @@ -7722,6 +7723,7 @@ __metadata: ts-node: ">=8.0.0" typechain: ^8.3.2 typescript: ">=4.5.0" + web3: ^4.5.0 languageName: unknown linkType: soft @@ -10374,7 +10376,7 @@ __metadata: languageName: node linkType: hard -"web3@npm:4, web3@npm:^4.3.0": +"web3@npm:4, web3@npm:^4.3.0, web3@npm:^4.5.0": version: 4.5.0 resolution: "web3@npm:4.5.0" dependencies: