Skip to content

Commit 13a8931

Browse files
committed
chore: deploy utils refactor
1 parent aae6752 commit 13a8931

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

contracts/deploy/utils/deployTokens.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Contract } from "@ethersproject/contracts";
1+
import { Contract } from "ethers";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
3-
import { BigNumber } from "ethers";
3+
import { toBigInt } from "ethers";
44
import { getContractOrDeploy } from "./getContractOrDeploy";
55
import { isMainnet } from ".";
66

77
export const deployERC20AndFaucet = async (
88
hre: HardhatRuntimeEnvironment,
99
deployer: string,
1010
ticker: string,
11-
faucetFundingAmount: BigNumber = hre.ethers.utils.parseUnits("100000")
11+
faucetFundingAmount: bigint = hre.ethers.parseUnits("100000")
1212
): Promise<Contract> => {
1313
const erc20 = await deployERC20(hre, deployer, ticker);
1414
if (!isMainnet(hre.network)) {
@@ -35,7 +35,7 @@ export const deployFaucet = async (
3535
deployer: string,
3636
ticker: string,
3737
erc20: Contract,
38-
faucetFundingAmount: BigNumber
38+
faucetFundingAmount: bigint
3939
): Promise<void> => {
4040
const faucet = await getContractOrDeploy(hre, `${ticker}Faucet`, {
4141
from: deployer,
@@ -45,7 +45,7 @@ export const deployFaucet = async (
4545
});
4646
const faucetBalance = await erc20.balanceOf(faucet.address);
4747
const deployerBalance = await erc20.balanceOf(deployer);
48-
if (deployerBalance.gte(faucetFundingAmount) && faucetBalance.lt(faucetFundingAmount.div(5))) {
48+
if (deployerBalance.gte(faucetFundingAmount) && faucetBalance.lt(faucetFundingAmount / toBigInt(5))) {
4949
// Fund the faucet if deployer has enough tokens and if the faucet has less than 20% of the faucetFundingAmount
5050
console.log(`funding ${ticker}Faucet with ${faucetFundingAmount}`);
5151
await erc20.transfer(faucet.address, faucetFundingAmount);

contracts/deploy/utils/getContractOrDeploy.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import { Contract } from "@ethersproject/contracts";
21
import { DeployOptions } from "hardhat-deploy/types";
32
import { HardhatRuntimeEnvironment } from "hardhat/types";
43
import { deployUpgradable } from "./deployUpgradable";
5-
4+
import { Contract } from "ethers";
65
export const getContractOrDeploy = async (
76
hre: HardhatRuntimeEnvironment,
87
contractName: string,
98
options: DeployOptions
109
): Promise<Contract> => {
11-
let contract = await hre.ethers.getContractOrNull(contractName);
10+
let contract = await hre.ethers.getContractOrNull<Contract>(contractName);
1211
if (!contract) {
1312
console.log(`contract ${contractName} not deployed, deploying now...`);
1413
await hre.deployments.deploy(contractName, options);
15-
contract = await hre.ethers.getContract(contractName);
14+
contract = await hre.ethers.getContract<Contract>(contractName);
1615
} else {
1716
console.log(`contract ${contractName} already deployed`);
1817
}
@@ -24,11 +23,11 @@ export const getContractOrDeployUpgradable = async (
2423
contractName: string,
2524
options: DeployOptions
2625
): Promise<Contract> => {
27-
let contract = await hre.ethers.getContractOrNull(contractName);
26+
let contract = await hre.ethers.getContractOrNull<Contract>(contractName);
2827
if (!contract) {
2928
console.log(`contract ${contractName} not deployed, deploying as upgradable now...`);
3029
await deployUpgradable(hre.deployments, contractName, options);
31-
contract = await hre.ethers.getContract(contractName);
30+
contract = await hre.ethers.getContract<Contract>(contractName);
3231
} else {
3332
console.log(`contract ${contractName} already deployed`);
3433
}

contracts/deploy/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ export const isSkipped = async (network: Network, skip: boolean) => {
3737
return false;
3838
};
3939

40-
export const PNK = (n: number) => ethers.utils.parseUnits(String(n));
41-
export const ETH = (n: number) => ethers.utils.parseUnits(String(n));
40+
export const PNK = (n: number) => ethers.parseUnits(String(n));
41+
export const ETH = (n: number) => ethers.parseUnits(String(n));

contracts/deploy/utils/klerosCoreHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { KlerosCore, KlerosCoreNeo, KlerosCoreUniversity } from "../../typechain-types";
2-
import { BigNumberish } from "ethers";
2+
import { BigNumberish, toBigInt } from "ethers";
33

44
export const changeCurrencyRate = async (
55
core: KlerosCore | KlerosCoreNeo | KlerosCoreUniversity,
@@ -13,7 +13,7 @@ export const changeCurrencyRate = async (
1313
console.log(`core.changeAcceptedFeeTokens(${erc20}, ${accepted})`);
1414
await core.changeAcceptedFeeTokens(erc20, accepted);
1515
}
16-
if (!pnkRate.rateInEth.eq(rateInEth) || pnkRate.rateDecimals !== rateDecimals) {
16+
if (!(pnkRate.rateInEth === toBigInt(rateInEth)) || pnkRate.rateDecimals !== rateDecimals) {
1717
console.log(`core.changeCurrencyRates(${erc20}, ${rateInEth}, ${rateDecimals})`);
1818
await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
1919
}

0 commit comments

Comments
 (0)