Skip to content

Commit

Permalink
chore: updates lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PacificYield committed Dec 6, 2024
1 parent d1139ec commit 78156d9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 29 deletions.
17 changes: 3 additions & 14 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import "@nomicfoundation/hardhat-toolbox";
import "@openzeppelin/hardhat-upgrades";
import dotenv from "dotenv";
import * as fs from "fs-extra";
import "hardhat-deploy";
import "hardhat-ignore-warnings";
import type { HardhatUserConfig, extendProvider } from "hardhat/config";
import { HardhatUserConfig, extendProvider } from "hardhat/config";
import { task } from "hardhat/config";
import type { NetworkUserConfig } from "hardhat/types";
import { resolve } from "path";
Expand Down Expand Up @@ -33,7 +32,7 @@ const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
dotenv.config({ path: resolve(__dirname, dotenvConfigPath) });

// Ensure that we have all the environment variables we need.
let mnemonic: string = process.env.MNEMONIC!;
const mnemonic: string = process.env.MNEMONIC!;

const chainIds = {
zama: 8009,
Expand Down Expand Up @@ -75,17 +74,7 @@ task("coverage").setAction(async (taskArgs, hre, runSuper) => {
await runSuper(taskArgs);
});

function replaceImportStatement(filePath: string, oldImport: string, newImport: string): void {
try {
let fileContent = fs.readFileSync(filePath, "utf-8");
fileContent = fileContent.replace(oldImport, newImport);
fs.writeFileSync(filePath, fileContent, "utf-8");
} catch (error) {
console.error(`Error updating file: ${error}`);
}
}

task("test", async (taskArgs, hre, runSuper) => {
task("test", async (_taskArgs, hre, runSuper) => {
// Run modified test task
if (hre.network.name === "hardhat") {
await setCodeMocked(hre);
Expand Down
4 changes: 3 additions & 1 deletion tasks/mint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

import { MyConfidentialERC20 } from "../types";

task("task:deployConfidentialERC20").setAction(async function (taskArguments: TaskArguments, { ethers }) {
const signers = await ethers.getSigners();
const erc20Factory = await ethers.getContractFactory("MyConfidentialERC20");
Expand All @@ -17,7 +19,7 @@ task("task:mint")

const signers = await ethers.getSigners();

const erc20 = (await ethers.getContractAt("MyConfidentialERC20", ERC20.address)) as any;
const erc20 = (await ethers.getContractAt("MyConfidentialERC20", ERC20.address)) as MyConfidentialERC20;

await erc20.connect(signers[0]).mint(+taskArguments.mint);

Expand Down
6 changes: 3 additions & 3 deletions test/coprocessorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let counterRand = 0;
//const db = new Database('./sql.db'); // on-disk db for debugging
const db = new Database(":memory:");

export function insertSQL(handle: string, clearText: BigInt, replace: boolean = false) {
export function insertSQL(handle: string, clearText: bigint, replace: boolean = false) {
if (replace) {
// this is useful if using snapshots while sampling different random numbers on each revert
db.run("INSERT OR REPLACE INTO ciphertexts (handle, clearText) VALUES (?, ?)", [handle, clearText.toString()]);
Expand All @@ -27,7 +27,7 @@ export function insertSQL(handle: string, clearText: BigInt, replace: boolean =

// Decrypt any handle, bypassing ACL
// WARNING : only for testing or internal use
export const getClearText = async (handle: BigInt): Promise<string> => {
export const getClearText = async (handle: bigint): Promise<string> => {
const handleStr = "0x" + handle.toString(16).padStart(64, "0");

return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -102,7 +102,7 @@ function getRandomBigInt(numBits: number): bigint {
return randomBigInt;
}

function bitwiseNotUintBits(value: BigInt, numBits: number) {
function bitwiseNotUintBits(value: bigint, numBits: number) {
if (typeof value !== "bigint") {
throw new TypeError("The input value must be a BigInt.");
}
Expand Down
12 changes: 3 additions & 9 deletions test/fhevmjsMocked.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { toBigIntBE, toBufferBE } from "bigint-buffer";
import crypto from "crypto";
import dotenv from "dotenv";
import { Wallet, ethers } from "ethers";
import * as fs from "fs";
import hre from "hardhat";
import { Keccak } from "sha3";
import { isAddress } from "web3-validator";

Expand All @@ -16,10 +15,6 @@ import {
import { insertSQL } from "./coprocessorUtils";
import { awaitCoprocessor, getClearText } from "./coprocessorUtils";

const hre = require("hardhat");

const aclAdd = ACL_ADDRESS;

enum Types {
ebool = 0,
euint4,
Expand Down Expand Up @@ -362,7 +357,7 @@ function uint8ArrayToHexString(uint8Array: Uint8Array) {
}

function numberToHex(num: number) {
let hex = num.toString(16);
const hex = num.toString(16);
return hex.length % 2 ? "0" + hex : hex;
}

Expand Down Expand Up @@ -401,10 +396,9 @@ async function computeInputSignatureCopro(
userAddress: string,
contractAddress: string,
): Promise<string> {
let signature: string;
const privKeySigner = PRIVATE_KEY_COPROCESSOR_ACCOUNT;
const coprocSigner = new Wallet(privKeySigner).connect(ethers.provider);
signature = await coprocSign(hash, handlesList, userAddress, contractAddress, coprocSigner);
const signature = await coprocSign(hash, handlesList, userAddress, contractAddress, coprocSigner);
return signature;
}

Expand Down
4 changes: 2 additions & 2 deletions test/gatewayDecrypt/testAsyncDecrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ describe("TestAsyncDecrypt", function () {
const tx2 = await this.contract.connect(this.signers.carol).requestMixed(5, 15);
await tx2.wait();
await awaitAllDecryptionResults();
let yB = await this.contract.yBool();
const yB = await this.contract.yBool();
expect(yB).to.equal(true);
let y = await this.contract.yUint4();
expect(y).to.equal(4);
y = await this.contract.yUint8();
expect(y).to.equal(42);
y = await this.contract.yUint16();
expect(y).to.equal(16);
let yAdd = await this.contract.yAddress();
const yAdd = await this.contract.yAddress();
expect(yAdd).to.equal("0x8ba1f109551bD432803012645Ac136ddd64DBA72");
y = await this.contract.yUint32();
expect(y).to.equal(52); // 5+15+32
Expand Down

0 comments on commit 78156d9

Please sign in to comment.