1- import hre from "hardhat" ;
1+ import { network } from "hardhat" ;
22import { expect } from "chai" ;
33// import { parseEther } from "ethers";
4- import { DiceGame , RiggedRoll , RiggedRoll__factory } from "../typechain-types" ;
5- import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers" ;
6-
7- const { ethers } = hre ;
4+ import type { DiceGame , RiggedRoll , RiggedRoll__factory } from "../types/ethers-contracts/index.js" ;
5+ import type { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/types" ;
86
97describe ( "🚩 Challenge: 🎲 Dice Game" , function ( ) {
8+ let ethers : Awaited < ReturnType < typeof network . create > > [ "ethers" ] ;
9+ let provider : Awaited < ReturnType < typeof network . create > > [ "ethers" ] [ "provider" ] ;
10+
1011 let diceGame : DiceGame ;
1112 let riggedRoll : RiggedRoll ;
1213 let deployer : HardhatEthersSigner ;
13- const { provider } = ethers ;
1414
1515 const rollAmountString = "0.002" ;
16- const rollAmount = ethers . parseEther ( rollAmountString ) ;
16+ let rollAmount : bigint ;
17+
18+ before ( async function ( ) {
19+ ( { ethers } = await network . create ( ) ) ;
20+ provider = ethers . provider ;
21+ rollAmount = ethers . parseEther ( rollAmountString ) ;
22+ } ) ;
1723
1824 async function deployContracts ( ) {
1925 [ deployer ] = await ethers . getSigners ( ) ;
2026 const DiceGame = await ethers . getContractFactory ( "DiceGame" ) ;
21- diceGame = await DiceGame . deploy ( ) ;
27+ diceGame = ( await DiceGame . deploy ( ) ) as unknown as DiceGame ;
2228
2329 const contractAddress = process . env . CONTRACT_ADDRESS ;
2430 let contractArtifact ;
@@ -29,8 +35,8 @@ describe("🚩 Challenge: 🎲 Dice Game", function () {
2935 }
3036
3137 const diceGameAddress = await diceGame . getAddress ( ) ;
32- const RiggedRoll = ( await ethers . getContractFactory ( contractArtifact ) ) as RiggedRoll__factory ;
33- riggedRoll = await RiggedRoll . deploy ( diceGameAddress ) ;
38+ const RiggedRoll = ( await ethers . getContractFactory ( contractArtifact ) ) as unknown as RiggedRoll__factory ;
39+ riggedRoll = ( await RiggedRoll . deploy ( diceGameAddress ) ) as unknown as RiggedRoll ;
3440 }
3541
3642 async function fundRiggedContract ( ) {
0 commit comments