From ffee81ba7f523bbac0bf3836f49d19cfa313d67a Mon Sep 17 00:00:00 2001 From: Gabriel Cardona Date: Fri, 21 May 2021 16:34:47 -0700 Subject: [PATCH 01/11] * Add typescript deps * Port to typescript --- hardhat.config.js => hardhat.config.ts | 29 ++++++++++------------ package.json | 13 +++++++--- scripts/deploy.js | 33 -------------------------- scripts/deploy.ts | 20 ++++++++++++++++ 4 files changed, 43 insertions(+), 52 deletions(-) rename hardhat.config.js => hardhat.config.ts (72%) delete mode 100644 scripts/deploy.js create mode 100644 scripts/deploy.ts diff --git a/hardhat.config.js b/hardhat.config.ts similarity index 72% rename from hardhat.config.js rename to hardhat.config.ts index e974ed6..f747725 100644 --- a/hardhat.config.js +++ b/hardhat.config.ts @@ -1,29 +1,26 @@ -require("@nomiclabs/hardhat-waffle"); -require("@nomiclabs/hardhat-ethers"); +import { task } from "hardhat/config" +import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers" +import { BigNumber } from "ethers" +import "@nomiclabs/hardhat-waffle" -// This is a sample Hardhat task. To learn how to create your own go to -// https://hardhat.org/guides/create-task.html -task("accounts", "Prints the list of accounts", async () => { - const accounts = await ethers.getSigners(); +task("accounts", "Prints the list of accounts", async (args, hre): Promise => { + const accounts: SignerWithAddress[] = await hre.ethers.getSigners() for (const account of accounts) { - console.log(account.address); + console.log(account.address) } }); -task("balances", "Prints the list of AVAX account balances", async () => { - const accounts = await ethers.getSigners(); +task("balances", "Prints the list of AVAX account balances", async (args, hre): Promise => { + const accounts: SignerWithAddress[] = await hre.ethers.getSigners() for (const account of accounts) { - balance = await ethers.provider.getBalance(account.address); - console.log(account.address, "has balance", balance.toString()); + const balance: BigNumber = await hre.ethers.provider.getBalance(account.address) + console.log(`${account.address} has balance ${balance.toString()}`) } }); -/** - * @type import('hardhat/config').HardhatUserConfig - */ -module.exports = { +export default { solidity: { compilers: [ { @@ -78,4 +75,4 @@ module.exports = { accounts: [] } } -}; +} diff --git a/package.json b/package.json index 207f315..1803077 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,16 @@ "@nomiclabs/hardhat-ethers": "^2.0.1", "@nomiclabs/hardhat-waffle": "^2.0.1", "@openzeppelin/contracts": "^3.4.0", + "@types/chai": "^4.2.18", + "@types/mocha": "^8.2.2", + "@types/node": "^15.6.0", "avalanche": "3.2.0", - "chai": "^4.2.0", + "chai": "^4.3.4", "ethereum-waffle": "^3.2.1", "ethereumjs-tx": "^2.1.2", "ethers": "^5.0.24", - "hardhat": "^2.0.6", + "hardhat": "2.3.0", + "ts-node": "^9.1.1", "web3": "^1.3.1" }, "version": "1.0.0", @@ -27,7 +31,7 @@ "console": "npx hardhat console", "pretest": "yarn compile", "test": "npx hardhat test", - "deploy": "npx hardhat run scripts/deploy.js", + "deploy": "npx hardhat run scripts/deploy.ts", "send-avax": "npx hardhat run scripts/sendAvax.js", "lint": "prettier ./test/**/*.ts --check", "prepublishOnly": "yarn test", @@ -35,5 +39,8 @@ "accounts": "npx hardhat accounts", "balances": "npx hardhat balances", "fund-cchain-addresses": "npx hardhat run scripts/fund-cchain-addresses.js" + }, + "dependencies": { + "typescript": "^4.2.4" } } diff --git a/scripts/deploy.js b/scripts/deploy.js deleted file mode 100644 index 072f44f..0000000 --- a/scripts/deploy.js +++ /dev/null @@ -1,33 +0,0 @@ -// We require the Hardhat Runtime Environment explicitly here. This is optional -// but useful for running the script in a standalone fashion through `node