Skip to content

Commit

Permalink
Merge pull request #37 from yan-man/release/v0.1.10-alpha
Browse files Browse the repository at this point in the history
update deploy script to ts;
  • Loading branch information
yan-man authored Jun 15, 2022
2 parents 9f36a67 + 60bc17d commit d3f1f1e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions scripts/deploy.js → scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ContractFactory } from "ethers";
import { run, ethers, network, artifacts } from "hardhat";
import { Artifact } from "hardhat/types";
import { Lottery } from "../typechain-types";

// This is a script for deploying your contracts. You can adapt it to deploy
// yours, or create new ones.
async function main() {
await run("compile");
// This is just a convenience check
if (network.name === "hardhat") {
console.warn(
Expand All @@ -19,8 +25,8 @@ async function main() {

console.log("Account balance:", (await deployer.getBalance()).toString());

const Lottery = await ethers.getContractFactory("Lottery");
const lottery = await Lottery.deploy();
const Lottery: ContractFactory = await ethers.getContractFactory("Lottery");
const lottery: Lottery = (await Lottery.deploy()) as Lottery;
await lottery.deployed();

console.log("Lottery contract address:", lottery.address);
Expand All @@ -29,7 +35,7 @@ async function main() {
saveFrontendFiles(lottery);
}

function saveFrontendFiles(lottery) {
function saveFrontendFiles(lottery: Lottery) {
const fs = require("fs");
const contractsDir = __dirname + "/../frontend/src/contracts";

Expand All @@ -42,7 +48,7 @@ function saveFrontendFiles(lottery) {
JSON.stringify({ Lottery: lottery.address }, undefined, 2)
);

const LotteryArtifact = artifacts.readArtifactSync("Lottery");
const LotteryArtifact: Artifact = artifacts.readArtifactSync("Lottery");

fs.writeFileSync(
contractsDir + "/Lottery.json",
Expand Down

0 comments on commit d3f1f1e

Please sign in to comment.