diff --git a/cli/README.md b/cli/README.md index 244d2743..5b44ecbf 100644 --- a/cli/README.md +++ b/cli/README.md @@ -3,7 +3,7 @@ `@perfect-abstractions/compose-cli` scaffolds diamond-based projects using the Compose Library. Supports both Foundry and Hardhat. -## Install +## Install (Soon) ```bash npm install -g @perfect-abstractions/compose-cli diff --git a/cli/src/templates/default/foundry/README.md b/cli/src/templates/default/foundry/README.md index 53f92a0f..795e06aa 100644 --- a/cli/src/templates/default/foundry/README.md +++ b/cli/src/templates/default/foundry/README.md @@ -1,9 +1,67 @@ # {{projectName}} -Foundry diamond starter scaffolded by Compose CLI. +## Compose -## Next steps +Foundry diamond starter scaffolded by the [Compose CLI](https://github.com/Perfect-Abstractions/Compose). Project can use the `@perfect-abstractions/compose` library for diamond infrastructure facets. -1. `forge build` -2. `forge test` -3. `forge script script/Deploy.s.sol:DeployScript --rpc-url --private-key --broadcast` +### How to deploy + +`DeployScript` deploys `CounterFacet`, `DiamondInspectFacet`, and `DiamondUpgradeFacet`, then deploys `Diamond` with those facets and `msg.sender` as the owner. + +### Links +- [Docs](https://compose.diamonds/) +- [GitHub](https://github.com/Perfect-Abstractions/Compose) + +--- + +## Foundry usage + +### Build + +```sh +forge build +``` + +### Test + +```sh +forge test +``` + +### Format + +```sh +forge fmt +``` + +### Gas snapshots + +```sh +forge snapshot +``` + +### Anvil + +```sh +anvil +``` + +### Deploy + +```sh +forge script script/Deploy.s.sol:DeployScript --rpc-url --private-key +``` + +### Cast + +```sh +cast +``` + +### Help + +```sh +forge --help +anvil --help +cast --help +``` \ No newline at end of file diff --git a/cli/src/templates/default/hardhat/ts/minimal/README.md b/cli/src/templates/default/hardhat/ts/minimal/README.md index 6bf1b7af..69224a4b 100644 --- a/cli/src/templates/default/hardhat/ts/minimal/README.md +++ b/cli/src/templates/default/hardhat/ts/minimal/README.md @@ -1,20 +1,34 @@ # {{projectName}} -Minimal diamond starter scaffolded by Compose CLI using Hardhat 3. +Hardhat 3 diamond starter scaffolded by the [Compose CLI](https://github.com/Perfect-Abstractions/Compose). Project can use the `@perfect-abstractions/compose` library for diamond infrastructure facets. - -## What's included? - -The project includes native support for TypeScript, Hardhat scripts, tasks, support for Solidity compilation & tests. - -Compose is directly included as a dependency in the project (even before package publication). - -This starter includes: +Includes: - `contracts/Diamond.sol` using Compose `DiamondMod` and `OwnerMod` -- `contracts/CounterFacet.sol` with `increment`, `getCounter`, and `exportSelectors` - -To deploy a working diamond, deploy `CounterFacet` first, then pass the facet address and owner into `Diamond` constructor. - -## Next steps -1. `npx hardhat compile` -2. `npx hardhat test` +- `contracts/facets/CounterFacet.sol` with `increment`, `getCounter`, and `exportSelectors` + +Deploy each facet contract first, then deploy `Diamond` by passing the facet addresses and the owner address to the constructor. + +### Links +- [Docs](https://hardhat.org/docs/) +- [GitHub](https://github.com/NomicFoundation/hardhat) + +## Hardhat Usage +### Build +```sh +npx hardhat build +``` + +### Test +```sh +npx hardhat test +``` + +### Node +```sh +npx hardhat node +``` + +### Help +```sh +npx hardhat --help +``` \ No newline at end of file diff --git a/cli/src/templates/default/hardhat/ts/mocha-ethers/README.md b/cli/src/templates/default/hardhat/ts/mocha-ethers/README.md index 01fe02be..24cc1a46 100644 --- a/cli/src/templates/default/hardhat/ts/mocha-ethers/README.md +++ b/cli/src/templates/default/hardhat/ts/mocha-ethers/README.md @@ -1,52 +1,57 @@ # {{projectName}} -This project showcases a Hardhat 3 project using `mocha` for tests and `ethers` for Ethereum interactions, scaffolded as a Compose diamond starter. +## Compose -To learn more about the Hardhat 3 Beta, please visit the [Getting Started guide](https://hardhat.org/docs/getting-started#getting-started-with-hardhat-3). To share your feedback, join our [Hardhat 3 Beta](https://hardhat.org/hardhat3-beta-telegram-group) Telegram group or [open an issue](https://github.com/NomicFoundation/hardhat/issues/new) in our GitHub issue tracker. +Hardhat 3 diamond starter scaffolded by the [Compose CLI](https://github.com/Perfect-Abstractions/Compose). Uses `mocha` for TypeScript tests and `ethers` for chain interactions and the `@perfect-abstractions/compose` library for diamond infrastructure facets. -## Project Overview +Includes Foundry-compatible Solidity tests, `mocha` integration tests, simulated networks (including OP-style chains in config), a `Diamond` built with Compose `DiamondMod` and `OwnerMod`, and a simple `CounterFacet`. -This example project includes: +### How to deploy -- A simple Hardhat configuration file. -- Foundry-compatible Solidity unit tests. -- TypeScript integration tests using `mocha` and ethers.js -- Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet. -- A `Diamond` contract using Compose `DiamondMod` and `OwnerMod`. -- Counter facet (`CounterFacet`). +The Ignition module `ignition/modules/Counter.ts` (`CounterDiamondModule`) deploys `CounterFacet`, `DiamondInspectFacet`, and `DiamondUpgradeFacet`, then deploys `Diamond` with those facets and `accounts[0]` as the owner. -## Usage +### Links -### Running Tests +- [Docs](https://compose.diamonds/) +- [GitHub](https://github.com/Perfect-Abstractions/Compose) -To run all the tests in the project, execute the following command: +--- -```shell +## Hardhat usage + +### Build + +```sh +npx hardhat build +``` + +### Test + +```sh npx hardhat test ``` -You can also selectively run the Solidity or `mocha` tests: +Run only Solidity or only Mocha tests: -```shell +```sh npx hardhat test solidity npx hardhat test mocha ``` -### Make a deployment to Sepolia - -This project includes an example Ignition module to deploy the diamond and facets. You can deploy this module to a locally simulated chain or to Sepolia. - -To run the deployment to a local chain: +### Deploy -```shell +Deploy to a local chain: +```sh npx hardhat ignition deploy ignition/modules/Counter.ts ``` To run the deployment to Sepolia, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called `SEPOLIA_PRIVATE_KEY`, which you can use to set the private key of the account you want to use. -You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable. +You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable (less recommended). + +After configuring `SEPOLIA_PRIVATE_KEY` and network in `hardhat.config`: -To set the `SEPOLIA_PRIVATE_KEY` config variable using `hardhat-keystore`: +To set the `SEPOLIA_PRIVATE_KEY` variable using `hardhat-keystore`: ```shell npx hardhat keystore set SEPOLIA_PRIVATE_KEY @@ -57,3 +62,18 @@ After setting the variable, you can run the deployment with the Sepolia network: ```shell npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts ``` + +### Cast + +```sh +cast +``` + +### Help + +```sh +npx hardhat --help +forge --help +anvil --help +cast --help +``` diff --git a/cli/src/templates/default/hardhat/ts/node-runner-viem/README.md b/cli/src/templates/default/hardhat/ts/node-runner-viem/README.md index 4677de91..5fb2ca80 100644 --- a/cli/src/templates/default/hardhat/ts/node-runner-viem/README.md +++ b/cli/src/templates/default/hardhat/ts/node-runner-viem/README.md @@ -1,52 +1,57 @@ # {{projectName}} -This project showcases a Hardhat 3 project using the native Node.js test runner (`node:test`) and the `viem` library for Ethereum interactions, scaffolded as a Compose diamond starter. +## Compose -To learn more about the Hardhat 3 Beta, please visit the [Getting Started guide](https://hardhat.org/docs/getting-started#getting-started-with-hardhat-3). To share your feedback, join our [Hardhat 3 Beta](https://hardhat.org/hardhat3-beta-telegram-group) Telegram group or [open an issue](https://github.com/NomicFoundation/hardhat/issues/new) in our GitHub issue tracker. +Hardhat 3 diamond starter scaffolded by the [Compose CLI](https://github.com/Perfect-Abstractions/Compose). Uses the native Node.js test runner (`node:test`) for TypeScript tests and `viem` for chain interactions and the `@perfect-abstractions/compose` library for diamond infrastructure facets. -## Project Overview +Includes Foundry-compatible Solidity tests, `node:test` integration tests, simulated networks (including OP-style chains in config), a `Diamond` built with Compose `DiamondMod` and `OwnerMod`, and facets (`CounterFacet`, `DiamondInspectFacet`, `DiamondUpgradeFacet`). -This example project includes: +### How to deploy -- A simple Hardhat configuration file. -- Foundry-compatible Solidity unit tests. -- TypeScript integration tests using [`node:test`](nodejs.org/api/test.html), the new Node.js native test runner, and [`viem`](https://viem.sh/). -- Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet. -- A local `Diamond` contract using Compose `DiamondMod` and `OwnerMod`. -- Counter and diamond management facets (`CounterFacet`, `DiamondInspectFacet`, `DiamondUpgradeFacet`). +The Ignition module `ignition/modules/Counter.ts` (`CounterDiamondModule`) deploys `CounterFacet`, `DiamondInspectFacet`, and `DiamondUpgradeFacet`, then deploys `Diamond` with those facets and `accounts[0]` as the owner. -## Usage +### Links -### Running Tests +- [Docs](https://compose.diamonds/) +- [GitHub](https://github.com/Perfect-Abstractions/Compose) -To run all the tests in the project, execute the following command: +--- -```shell +## Hardhat usage + +### Build + +```sh +npx hardhat build +``` + +### Test + +```sh npx hardhat test ``` -You can also selectively run the Solidity or `node:test` tests: +Run only Solidity or only Node.js tests: -```shell +```sh npx hardhat test solidity npx hardhat test nodejs ``` -### Make a deployment to Sepolia - -This project includes an example Ignition module to deploy the diamond and facets. You can deploy this module to a locally simulated chain or to Sepolia. - -To run the deployment to a local chain: +### Deploy -```shell +Deploy to a local chain: +```sh npx hardhat ignition deploy ignition/modules/Counter.ts ``` To run the deployment to Sepolia, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called `SEPOLIA_PRIVATE_KEY`, which you can use to set the private key of the account you want to use. -You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable. +You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable (less recommended). + +After configuring `SEPOLIA_PRIVATE_KEY` and network in `hardhat.config`: -To set the `SEPOLIA_PRIVATE_KEY` config variable using `hardhat-keystore`: +To set the `SEPOLIA_PRIVATE_KEY` variable using `hardhat-keystore`: ```shell npx hardhat keystore set SEPOLIA_PRIVATE_KEY @@ -57,3 +62,18 @@ After setting the variable, you can run the deployment with the Sepolia network: ```shell npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts ``` + +### Cast + +```sh +cast +``` + +### Help + +```sh +npx hardhat --help +forge --help +anvil --help +cast --help +``` diff --git a/website/docs/contribution/cli/templates.mdx b/website/docs/contribution/cli/templates.mdx index fa4fda53..38867f18 100644 --- a/website/docs/contribution/cli/templates.mdx +++ b/website/docs/contribution/cli/templates.mdx @@ -15,7 +15,7 @@ import RelatedDocs from '@site/src/components/docs/RelatedDocs'; # New Template Guide - Learn how to add new project templates to the Compose CLI so contributors can scaffold diamonds and example projects consistently. + Add new project templates to the Compose CLI to scaffold diamonds and example projects. ## When to Add a New Template