Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addresses minor inconviences. #34

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
4 changes: 3 additions & 1 deletion deploy/00_deploy_ERC6551Registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion deploy/01_deploy_mastercopy_ERC721Tokenbound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion deploy/02_deploy_mastercopy_ERC1155Tokenbound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions test/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions test/ERC1155ThresholdMech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions test/ERC1155TokenboundMech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions test/ERC721TokenboundMech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion test/Mech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions test/Receiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions test/ZodiacMech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 10 additions & 5 deletions test/deterministicDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -56,10 +59,10 @@ describe("deterministic deployment", () => {
).to.equal(
await erc6551Registry.account(
calculateERC721TokenboundMechMastercopyAddress(),
DEFAULT_SALT,
deployerClient.chain.id,
testTokenAddress,
1n,
DEFAULT_SALT
1n
)
)
})
Expand Down Expand Up @@ -148,10 +151,10 @@ describe("deterministic deployment", () => {
).to.equal(
await erc6551Registry.account(
calculateERC1155TokenboundMechMastercopyAddress(),
DEFAULT_SALT,
deployerClient.chain.id,
testTokenAddress,
1n,
DEFAULT_SALT
1n
)
)
})
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions test/signing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Loading