mirror of
https://github.com/luxfhe/example-confidential-voting.git
synced 2026-10-30 18:13:35 +00:00
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import axios from "axios";
|
|
import { ethers } from "hardhat";
|
|
import hre from "hardhat";
|
|
|
|
import type { Counter } from "../../types/Counter";
|
|
import { waitForBlock } from "../../utils/block";
|
|
|
|
export async function deployCounterFixture(): Promise<{ counter: Counter; address: string }> {
|
|
const signers = await ethers.getSigners();
|
|
const admin = signers[0];
|
|
|
|
const counterFactory = await ethers.getContractFactory("Counter");
|
|
const counter = await counterFactory.connect(admin).deploy();
|
|
// await greeter.waitForDeployment();
|
|
const address = await counter.getAddress();
|
|
return { counter, address };
|
|
}
|
|
|
|
export async function getTokensFromFaucet() {
|
|
if (hre.network.name === "localluxfhe") {
|
|
const signers = await hre.ethers.getSigners();
|
|
|
|
if ((await hre.ethers.provider.getBalance(signers[0].address)).toString() === "0") {
|
|
console.log("Balance for signer is 0 - getting tokens from faucet");
|
|
await axios.get(`http://localhost:6000/faucet?address=${signers[0].address}`);
|
|
await waitForBlock(hre);
|
|
}
|
|
}
|
|
}
|