Lock.fixture.ts 861 B

12345678910111213141516171819202122
  1. import { time } from "@nomicfoundation/hardhat-network-helpers";
  2. import { ethers } from "hardhat";
  3. import type { Lock } from "../../types/Lock";
  4. import type { Lock__factory } from "../../types/factories/Lock__factory";
  5. export async function deployLockFixture() {
  6. const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
  7. const ONE_GWEI = 1_000_000_000;
  8. const lockedAmount = ONE_GWEI;
  9. const unlockTime = (await time.latest()) + ONE_YEAR_IN_SECS;
  10. // Contracts are deployed using the first signer/account by default
  11. const [owner, otherAccount] = await ethers.getSigners();
  12. const Lock = (await ethers.getContractFactory("Lock")) as Lock__factory;
  13. const lock = (await Lock.deploy(unlockTime, { value: lockedAmount })) as Lock;
  14. const lock_address = await lock.getAddress();
  15. return { lock, lock_address, unlockTime, lockedAmount, owner, otherAccount };
  16. }