diff --git a/README.md b/README.md index 05b802d..09c6794 100644 --- a/README.md +++ b/README.md @@ -56,39 +56,45 @@ The repo is structured as a monorepo with `mech-contracts` as the container pack ##### Install all dependencies -``` +```sh yarn install ``` ##### Compile contracts and generate TypeScript interfaces for the SDK and front-end -``` +```sh yarn build ``` ##### Build SDK -``` +```sh yarn build:sdk ``` This step is necessary to make changes in SDK functions available to a locally running front-end. -##### Start front-end +##### Make ENV file. +```sh +cp .env.example .env ``` + +##### Start front-end + +```sh yarn start ``` ##### Run tests -``` +```sh yarn test ``` Tests covers both, the contract logic as well as the SDK functions. -``` +```sh yarn integrationTest ``` diff --git a/deploy/00_deploy_ERC6551Registry.ts b/deploy/00_deploy_ERC6551Registry.ts index 0895365..3883ff0 100644 --- a/deploy/00_deploy_ERC6551Registry.ts +++ b/deploy/00_deploy_ERC6551Registry.ts @@ -49,7 +49,9 @@ const deployERC6551Registry: DeployFunction = async (hre) => { ` ✔ ERC6551 registry contract deployed at ${expectedAddress} (tx hash: ${hash})` ) } - + if (hre.network.name === "hardhat") { + return + } try { await hre.run("verify:verify", { address: expectedAddress, diff --git a/deploy/01_deploy_mastercopy_ERC721Tokenbound.ts b/deploy/01_deploy_mastercopy_ERC721Tokenbound.ts index 46c78dd..307b2cf 100644 --- a/deploy/01_deploy_mastercopy_ERC721Tokenbound.ts +++ b/deploy/01_deploy_mastercopy_ERC721Tokenbound.ts @@ -38,7 +38,9 @@ const deployMastercopyERC721Tokenbound: DeployFunction = async (hre) => { const txHash = await deployERC721TokenboundMechMastercopy(deployerClient) console.log(` ✔ Contract deployed at ${address} (tx hash: ${txHash})`) } - + if (hre.network.name === "hardhat") { + return + } try { await hre.run("verify:verify", { address, diff --git a/deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts b/deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts index dc31aaf..892a604 100644 --- a/deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts +++ b/deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts @@ -38,7 +38,9 @@ const deployMastercopyERC1155Tokenbound: DeployFunction = async (hre) => { await await deployERC1155TokenboundMechMastercopy(deployerClient) console.log(` ✔ Contract deployed at ${address}`) } - + if (hre.network.name === "hardhat") { + return + } try { await hre.run("verify:verify", { address, diff --git a/test/Account.ts b/test/Account.ts index f957d93..9150019 100644 --- a/test/Account.ts +++ b/test/Account.ts @@ -25,6 +25,9 @@ import { deployFactories } from "./utils" export const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" describe("Account base contract", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. diff --git a/test/ERC1155ThresholdMech.ts b/test/ERC1155ThresholdMech.ts index 2096ccb..0963f4c 100644 --- a/test/ERC1155ThresholdMech.ts +++ b/test/ERC1155ThresholdMech.ts @@ -8,6 +8,9 @@ import { ethers } from "hardhat" // advantage or Hardhat Network's snapshot functionality. describe.skip("ERC1155ThresholdMech contract", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. diff --git a/test/ERC1155TokenboundMech.ts b/test/ERC1155TokenboundMech.ts index 99f5799..6dc1344 100644 --- a/test/ERC1155TokenboundMech.ts +++ b/test/ERC1155TokenboundMech.ts @@ -12,6 +12,10 @@ import { ERC1155TokenboundMech__factory } from "../typechain-types" import { deployFactories } from "./utils" describe("ERC1155TokenboundMech contract", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) + // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. diff --git a/test/ERC721TokenboundMech.ts b/test/ERC721TokenboundMech.ts index a054634..13de6db 100644 --- a/test/ERC721TokenboundMech.ts +++ b/test/ERC721TokenboundMech.ts @@ -15,6 +15,9 @@ describe("ERC721TokenboundMech contract", () => { // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) async function deployMech1() { const { deployerClient, erc6551Registry, alice, bob } = await deployFactories() diff --git a/test/Mech.ts b/test/Mech.ts index 8169f60..1eea2af 100644 --- a/test/Mech.ts +++ b/test/Mech.ts @@ -16,6 +16,9 @@ import { deployFactories } from "./utils" const EIP1271_MAGIC_VALUE = "0x1626ba7e" describe("Mech base contract", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. @@ -50,7 +53,7 @@ describe("Mech base contract", () => { ) // deploy mech2 bound to testToken#2 - deployERC721TokenboundMech(deployerClient, { + await deployERC721TokenboundMech(deployerClient, { token: testTokenAddress, tokenId: 2n, from: registryAddress, diff --git a/test/Receiver.ts b/test/Receiver.ts index 96b2bc8..131242b 100644 --- a/test/Receiver.ts +++ b/test/Receiver.ts @@ -13,6 +13,9 @@ import { ERC721TokenboundMech__factory } from "../typechain-types" import { deployFactories } from "./utils" describe("Receiver base contract", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. diff --git a/test/ZodiacMech.ts b/test/ZodiacMech.ts index eab829e..2c2f000 100644 --- a/test/ZodiacMech.ts +++ b/test/ZodiacMech.ts @@ -13,6 +13,9 @@ import { entryPoint, fillUserOp, getUserOpHash, signUserOp } from "./Account" // advantage or Hardhat Network's snapshot functionality. describe.skip("ZodiacMech contract", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. diff --git a/test/deterministicDeployment.ts b/test/deterministicDeployment.ts index 8d5332b..5cc025c 100644 --- a/test/deterministicDeployment.ts +++ b/test/deterministicDeployment.ts @@ -35,6 +35,9 @@ import { import { deployFactories } from "./utils" describe("deterministic deployment", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) describe("calculateERC721TokenboundMechAddress()", () => { it("returns the correct address", async () => { const { deployerClient, erc6551Registry } = await loadFixture( @@ -56,10 +59,10 @@ describe("deterministic deployment", () => { ).to.equal( await erc6551Registry.account( calculateERC721TokenboundMechMastercopyAddress(), + DEFAULT_SALT, deployerClient.chain.id, testTokenAddress, - 1n, - DEFAULT_SALT + 1n ) ) }) @@ -148,10 +151,10 @@ describe("deterministic deployment", () => { ).to.equal( await erc6551Registry.account( calculateERC1155TokenboundMechMastercopyAddress(), + DEFAULT_SALT, deployerClient.chain.id, testTokenAddress, - 1n, - DEFAULT_SALT + 1n ) ) }) @@ -219,7 +222,9 @@ describe("deterministic deployment", () => { describe.skip("deployERC1155ThresholdMech()", () => { it("correctly initializes the mech proxy instance", async () => { - const { alice, deployer } = await loadFixture(deployFactories) + const { alice, deployer, deployerClient } = await loadFixture( + deployFactories + ) const TestToken = await ethers.getContractFactory("ERC1155Token") const testToken = await TestToken.deploy() diff --git a/test/signing.ts b/test/signing.ts index 6da4d5b..193b665 100644 --- a/test/signing.ts +++ b/test/signing.ts @@ -14,6 +14,9 @@ import { ERC721TokenboundMech__factory } from "../typechain-types" import { deployFactories } from "./utils" describe("signing", () => { + before(async () => { + await ethers.provider.send("hardhat_reset", []) + }) // We define a fixture to reuse the same setup in every test. We use // loadFixture to run this setup once, snapshot that state, and reset Hardhat // Network to that snapshot in every test. diff --git a/yarn.lock b/yarn.lock index 33f394d..0e02e4f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1932,7 +1932,7 @@ __metadata: "@erc6551/reference@https://github.com/erc6551/reference.git#commit=a38d3fe531c6c644d4880f41229ef49252804b92": version: 0.2.1 resolution: "@erc6551/reference@https://github.com/erc6551/reference.git#commit=a38d3fe531c6c644d4880f41229ef49252804b92" - checksum: 5e9f17574757fd51b966836e141275f2b4b3cdcdb5a8c287ac260c241861822529806eb5da049f804a20ab76cec24b67c423b8eadb772dbc8b58b2cda42caf29 + checksum: b4688c7ecf1dcd24e7979677bd80fe1397816707b8f70f23f5e05a085a6d42d90c92b8e95b204eba00b252781a76f1e3f219ad13596b3434783f5f2df2c7b495 languageName: node linkType: hard @@ -19974,7 +19974,7 @@ __metadata: languageName: node linkType: hard -"viem@npm:^1.0.0, viem@npm:^1.16.5": +"viem@npm:^1.0.0": version: 1.19.3 resolution: "viem@npm:1.19.3" dependencies: @@ -19995,7 +19995,7 @@ __metadata: languageName: node linkType: hard -"viem@npm:^1.21.4": +"viem@npm:^1.16.5, viem@npm:^1.21.4": version: 1.21.4 resolution: "viem@npm:1.21.4" dependencies: