Ethers v5 -> v6 migration

Updated dependencies and removed unused ones.
This commit is contained in:
hueso
2025-08-02 21:09:40 -03:00
parent 811d5344a3
commit f924593ee2
18 changed files with 3669 additions and 7066 deletions

View File

@@ -1,6 +1,6 @@
import "@nomicfoundation/hardhat-chai-matchers";
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { expect } from "chai";
import { ethers, network } from "hardhat";
@@ -15,7 +15,7 @@ describe("Reputation", () => {
before("Set signers and reset network", async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[owner] = await (ethers as any).getSigners();
[owner] = await ethers.getSigners();
await network.provider.send("hardhat_reset");
});
@@ -60,7 +60,7 @@ describe("Reputation", () => {
},
{
x: Number.MAX_SAFE_INTEGER,
shouldRevert: "overflow",
expected: curve(Number.MAX_SAFE_INTEGER),
},
{
x: Number.POSITIVE_INFINITY,

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { BigNumber, Signer } from "ethers";
import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { Signer } from "ethers";
import { ethers } from "hardhat";
import keccak256 from "keccak256";
import { MerkleTree } from "merkletreejs";
@@ -14,7 +14,6 @@ import {
import { Call, RepFixture, P2PixAndReputation, DepositArgs, LockArgs, ReleaseArgs } from "./interfaces";
// exported constants
export const getSignerAddrs = (
amount: number,
@@ -23,16 +22,16 @@ export const getSignerAddrs = (
return addrs.slice(0, amount).map(({ address }) => address);
};
export const getBnFrom = (nums: number[]): BigNumber[] => {
const bns = nums.map(num => ethers.BigNumber.from(num));
export const getBnFrom = (nums: number[]): BigInt[] => {
const bns = nums.map(num => BigInt(num));
return bns;
};
export const getLockData = (
addr: string,
locks: BigNumber[][],
locks: BigInt[][],
): Call[] => {
const iface = new ethers.utils.Interface(
const iface = new ethers.Interface(
P2PIX__factory.abi,
);
return locks.map(lock => ({
@@ -72,13 +71,8 @@ export const curve = (x: number): number => {
// exported async functions
export async function repFixture(): Promise<RepFixture> {
const Reputation = await ethers.getContractFactory(
"Reputation",
);
const reputation =
(await Reputation.deploy()) as Reputation;
return { reputation };
const reputation = await ethers.deployContract("Reputation");
return { reputation: await reputation.waitForDeployment() };
}
export async function p2pixFixture(): Promise<P2PixAndReputation> {
@@ -87,30 +81,21 @@ export async function p2pixFixture(): Promise<P2PixAndReputation> {
await ethers.getSigners(),
);
const Reputation = await ethers.getContractFactory(
"Reputation",
);
const reputation =
(await Reputation.deploy()) as Reputation;
const reputation = await ethers.deployContract("Reputation");
const ERC20 = await ethers.getContractFactory("MockToken");
const erc20 = (await ERC20.deploy(
ethers.utils.parseEther("20000000"), // 20M
)) as MockToken;
const erc20 = await ethers.deployContract("MockToken", [
ethers.parseEther("20000000") // 20M
]) as MockToken;
const P2PIX = await ethers.getContractFactory("P2PIX");
const p2pix = (await P2PIX.deploy(
const p2pix = await ethers.deployContract("P2PIX", [
10,
validSigners,
reputation.address,
[erc20.address],
reputation.target,
[erc20.target],
[true],
)) as P2PIX;
]);
const Multicall = await ethers.getContractFactory(
"Multicall",
);
const multicall = (await Multicall.deploy()) as Multicall;
const multicall = await ethers.deployContract("Multicall");
const signers = await ethers.getSigners();
const whitelisted = signers.slice(0, 2);
@@ -126,10 +111,10 @@ export async function p2pixFixture(): Promise<P2PixAndReputation> {
);
return {
multicall,
reputation,
erc20,
p2pix,
multicall: await multicall.waitForDeployment(),
reputation: await reputation.waitForDeployment(),
erc20: await erc20.waitForDeployment(),
p2pix: await p2pix.waitForDeployment(),
merkleRoot,
proof,
};

View File

@@ -1,5 +1,3 @@
import { BigNumber } from "ethers";
import {
MockToken,
Multicall,
@@ -19,29 +17,29 @@ export interface DepositArgs {
pixTarget: string;
allowlistRoot: string;
token: string;
amount: BigNumber;
amount: BigInt;
valid: boolean;
}
export interface LockArgs {
seller: string;
token: string;
amount: BigNumber;
amount: BigInt;
merkleProof: string[];
expiredLocks: BigNumber[];
expiredLocks: BigInt[];
}
export interface ReleaseArgs {
lockID: BigNumber;
lockID: BigInt;
pixTimestamp: string;
signature: string;
}
export interface Lock {
counter: BigNumber;
expirationBlock: BigNumber;
counter: BigInt;
expirationBlock: BigInt;
pixTarget: string;
amount: BigNumber;
amount: BigInt;
token: string;
buyerAddress: string;
seller: string;