Skip to content

Commit a98a962

Browse files
committed
refactor: cleanup
1 parent 5c89431 commit a98a962

File tree

6 files changed

+15
-100
lines changed

6 files changed

+15
-100
lines changed

biome.jsonc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"enabled": true,
2424
"rules": {
2525
"correctness": {
26-
"noConstantCondition": "off",
27-
"noUnusedImports": "off",
26+
"noUnusedImports": "warn",
2827
"noUnusedVariables": "warn"
2928
},
3029
"nursery": {

hardhat.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "@nomicfoundation/hardhat-foundry";
21
import "@nomicfoundation/hardhat-toolbox";
32
import "@primitivefi/hardhat-dodoc";
43
import { config as dotenvConfig } from "dotenv";

package.json

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,31 @@
1010
"biome:check": "biome check .",
1111
"biome:write": "biome check --write . && bun run biome:write:imports",
1212
"biome:write:imports": "biome lint --write --only correctness/noUnusedImports .",
13-
"chain": "hardhat node --no-deploy --export-all ./generated/chain.json --network hardhat",
13+
"chain": "bun hardhat node --no-deploy --export-all ./generated/chain.json --network hardhat",
1414
"clean": "shx rm -rf ./artifacts ./cache ./cache_hardhat ./coverage ./coverage.json ./types && bun typechain",
15-
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
16-
"coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && bun typechain",
17-
"deploy:hardhat-deploy": "hardhat deploy --export-all ./deployments/hardhat_contracts.json",
15+
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true bun hardhat compile",
16+
"coverage": "bun hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && bun typechain",
17+
"deploy:hardhat-deploy": "bun hardhat deploy --export-all ./deployments/hardhat_contracts.json",
1818
"deploy": "bun deploy:hardhat-deploy --network hardhat",
1919
"deploy:network": "bun deploy:hardhat-deploy --network",
20-
"fork": "hardhat node --network hardhat --fork https://mainnet.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad",
20+
"fork": "bun hardhat node --network hardhat --fork https://mainnet.infura.io/v3/460f40a260564ac4a4f4b3fffb032dad",
2121
"lint": "bun lint:sol && bun lint:ts && bun prettier:check",
2222
"lint:sol": "forge fmt --check && bun solhint \"{script,contracts,test}/**/*.sol\"",
2323
"lint:ts": "bun run biome:check",
24-
"networks": "hardhat networks",
24+
"networks": "bun hardhat networks",
2525
"postinstall": "DOTENV_CONFIG_PATH=./.env.example bun typechain",
2626
"prettier:write": "prettier --cache --write \"**/*.{md,yml}\"",
2727
"prettier:check": "prettier --cache --check \"**/*.{md,yml}\"",
28-
"test": "hardhat test",
29-
"test:gas": "REPORT_GAS=true CONTRACT_SIZER=true hardhat test",
30-
"test:trace": "hardhat test --trace",
31-
"test:fulltrace": "hardhat test --fulltrace",
32-
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat typechain",
33-
"verify": "hardhat run scripts/verify.ts --network"
28+
"test": "bun hardhat test",
29+
"test:gas": "REPORT_GAS=true CONTRACT_SIZER=true bun hardhat test",
30+
"typechain": "cross-env TS_NODE_TRANSPILE_ONLY=true bun hardhat typechain",
31+
"verify": "bun hardhat run scripts/verify.ts --network"
3432
},
3533
"devDependencies": {
3634
"@biomejs/biome": "2.2.5",
3735
"@ethersproject/bignumber": "^5.8.0",
3836
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
3937
"@nomicfoundation/hardhat-ethers": "^3.1.0",
40-
"@nomicfoundation/hardhat-foundry": "^1.2.0",
4138
"@nomicfoundation/hardhat-ignition": "^0.15.13",
4239
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.14",
4340
"@nomicfoundation/hardhat-network-helpers": "^1.1.0",
@@ -53,7 +50,6 @@
5350
"@types/mocha": "^10.0.10",
5451
"@types/node": "^24.1.0",
5552
"chai": "5.2.1",
56-
"chalk": "4.1.2",
5753
"cross-env": "^10.0.0",
5854
"dotenv": "^17.2.1",
5955
"ds-test": "github:dapphub/ds-test#e282159d5170298eb2455a6c05280ab5a73a4ef0",

utils/constants.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

utils/contracts.ts

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
// biome-ignore-all lint/suspicious/noExplicitAny: no-reason
22

3-
import chalk from "chalk";
4-
import { type BaseContract, type Contract, type Signer } from "ethers";
3+
import { type Contract, type Signer } from "ethers";
54
import { ethers } from "hardhat";
65

76
import { fromWei } from "./format";
87

9-
import { getExtraGasInfo } from "./misc";
10-
118
/**
129
* Gets a contract instance for the given contract name or ABI, address, and signer.
1310
*
@@ -66,35 +63,6 @@ export async function preDeploy(signerAddress: string, contractName: string): Pr
6663
const { chainId, name } = await ethers.provider.getNetwork();
6764
const ethBalance = await ethers.provider.getBalance(signerAddress);
6865

69-
console.log(` 🛰 Deploying: ${chalk.cyan(contractName)} to Network: ${name} & ChainId: ${chainId}`);
70-
console.log(` 🎭 Deployer: ${chalk.cyan(signerAddress)}, Balance: ${chalk.grey(fromWei(ethBalance ?? 0))} ETH`);
71-
}
72-
73-
/**
74-
* Logs information about the deployment of a contract.
75-
*
76-
* @param contractName - The name of the deployed contract.
77-
* @param contract - The contract instance.
78-
* @returns A promise that resolves to the contract instance that has been deployed.
79-
*/
80-
export async function postDeploy<T extends BaseContract = BaseContract>(contractName: string, contract: T): Promise<T> {
81-
// Wait for the contract to be deployed
82-
await contract.waitForDeployment();
83-
84-
// Get extra gas information of the deployment transaction
85-
let extraGasInfo = "";
86-
const deploymentTransaction = contract.deploymentTransaction();
87-
88-
if (deploymentTransaction) {
89-
extraGasInfo = (await getExtraGasInfo(deploymentTransaction)) ?? "";
90-
}
91-
92-
const contractAddress = await contract.getAddress();
93-
94-
// Log the deployment information
95-
console.log(" 📄", chalk.cyan(contractName), "deployed to:", chalk.magenta(contractAddress));
96-
console.log(" ⛽", chalk.grey(extraGasInfo));
97-
98-
// Return the contract instance
99-
return contract;
66+
console.log(` 🛰 Deploying: ${contractName} to Network: ${name} & ChainId: ${chainId}`);
67+
console.log(` 🎭 Deployer: ${signerAddress}, Balance: ${fromWei(ethBalance ?? 0)} ETH`);
10068
}

utils/misc.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { computeAddress, getAddress, solidityPackedKeccak256, type TransactionResponse } from "ethers";
2-
3-
import { fromWei, toGwei } from "./format";
1+
import { computeAddress, getAddress, solidityPackedKeccak256 } from "ethers";
42

53
/**
64
* Asynchronously sleeps for the specified number of milliseconds.
@@ -22,21 +20,6 @@ export async function delayLog(ms: number): Promise<void> {
2220
await sleep(ms);
2321
}
2422

25-
/**
26-
* Checks if the provided address is valid and returns the checksummed address if valid.
27-
* Otherwise, returns false.
28-
*
29-
* @param value - The address to be checked.
30-
* @returns The checksummed address if valid, or false.
31-
*/
32-
export function isAddress(value: string): string | false {
33-
try {
34-
return getAddress(value);
35-
} catch {
36-
return false;
37-
}
38-
}
39-
4023
/**
4124
* Creates a random checksummed address using the provided salt.
4225
*
@@ -48,28 +31,3 @@ export function createRandomChecksumAddress(salt: string): string {
4831
const checkSummedSignerAddress: string = getAddress(signerAddress);
4932
return checkSummedSignerAddress;
5033
}
51-
52-
/**
53-
* Retrieves necessary gas information of a transaction.
54-
*
55-
* @param tx - The transaction response (e.g., contract deployment or executed transaction).
56-
* @returns A string containing gas information or null if the transaction is falsy or unsuccessful.
57-
*/
58-
export async function getExtraGasInfo(tx: TransactionResponse): Promise<string | null> {
59-
if (!tx) {
60-
return null;
61-
}
62-
63-
const gasPrice = tx.gasPrice;
64-
const gasUsed = tx.gasLimit * gasPrice;
65-
const txReceipt = await tx.wait();
66-
67-
if (!txReceipt) {
68-
return null;
69-
}
70-
71-
const gas = txReceipt.gasUsed;
72-
const extraGasInfo = `${toGwei(gasPrice)} gwei, ${fromWei(gasUsed)} ETH, ${gas} gas, txHash: ${tx.hash}`;
73-
74-
return extraGasInfo;
75-
}

0 commit comments

Comments
 (0)