generated from Ernesto-tha-great/morph_starter_kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b186263
Showing
111 changed files
with
36,283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
node_modules | ||
.env | ||
frontend/*/.env | ||
|
||
# IntelliJ project files | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
|
||
*.gitkeep | ||
|
||
# eclipse project file | ||
.settings/ | ||
.classpath | ||
.project | ||
|
||
# NetBeans specific | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
nbactions.xml | ||
nb-configuration.xml | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
|
||
PROPOSAL.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "contract/lib/openzeppelin-contracts"] | ||
path = contract/lib/openzeppelin-contracts | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<!-- TITLE --> | ||
<p align="center"> | ||
<img width="200px" src="https://morphl2brand.notion.site/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Ffcab2c10-8da9-4414-aa63-4998ddf62e78%2F76b87f21-9863-4533-932c-91c593cc741c%2FLogo_Morph_white.jpg?table=block&id=00854626-61f3-4668-8ab1-cb8f3ec0dcb0&spaceId=fcab2c10-8da9-4414-aa63-4998ddf62e78&width=2000&userId=&cache=v2" align="center" alt="Morph" /> | ||
<h2 align="center">Morph Starter Kit</h2> | ||
</p> | ||
</p> | ||
|
||
<!-- TABLE OF CONTENTS --> | ||
|
||
<details> | ||
<summary>Table of Contents</summary> | ||
<ol> | ||
<li> | ||
<a href="#about-the-project">About The Project</a> | ||
<ul> | ||
<li><a href="#built-with">Built With</a></li> | ||
</ul> | ||
</li> | ||
<li> | ||
<ul> | ||
<li><a href="#prerequisites">Prerequisites</a></li> | ||
<li><a href="#installation">Installation</a></li> | ||
</ul> | ||
</li> | ||
<li><a href="#usage">Usage</a></li> | ||
<li><a href="#roadmap">Roadmap</a></li> | ||
<li><a href="#contributing">Contributing</a></li> | ||
<li><a href="#license">License</a></li> | ||
<li><a href="#contact">Contact</a></li> | ||
<li><a href="#acknowledgments">Acknowledgments</a></li> | ||
</ol> | ||
</details> | ||
|
||
<!-- ABOUT THE PROJECT --> | ||
|
||
|
||
## About The Project | ||
|
||
The Morph starter kit helps developers quickly and efficiently, build dApps on the Morph blockchain. It is a comprehensive template for building fullstack dApps. This starter kit is an extension of the [ReactToWeb3 kit](https://github.com/Protocol-Explorer/ReactToWeb3) | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
|
||
## Built With | ||
|
||
Morph starter kit is built with a variety of frameworks and libraries. | ||
|
||
- [Morph](https://www.morphl2.io/) | ||
- [Solidity](https://docs.soliditylang.org/en/v0.8.19/) | ||
- [Next.js](https://nextjs.org/) | ||
- [Foundry](https://book.getfoundry.sh/) | ||
- [walletConnect](https://cloud.walletconnect.com/sign-in) | ||
- [wagmi](https://wagmi.sh/react/getting-started) | ||
- [shadcn](https://ui.shadcn.com/docs/installation/next) | ||
|
||
<p align="right">(<a href="#top">back to top</a>)</p> | ||
|
||
<!-- GETTING STARTED --> | ||
|
||
## Prerequisites | ||
|
||
- Node | ||
- Git | ||
- Foundry | ||
|
||
```bash | ||
cd contract | ||
yarn | ||
``` | ||
|
||
|
||
### Environment Configuration | ||
|
||
#### Contract | ||
In your terminal, run | ||
|
||
```bash | ||
cd contract | ||
yarn | ||
``` | ||
|
||
#### Frontend | ||
|
||
Before you start, you need to set up your environment variables. Create a `.env.local` file in the root directory by running in a new terminal: | ||
|
||
```bash | ||
cp .env.example .env.local | ||
``` | ||
|
||
In the file, update the `NEXT_PUBLIC_PROJECT_ID` variable with your WalletConnect project ID. You can obtain one by registering your project at [WalletConnect Cloud](https://cloud.walletconnect.com/). | ||
|
||
### Install Dependencies | ||
|
||
```bash | ||
npm install | ||
# or | ||
yarn | ||
# or | ||
pnpm install | ||
# or | ||
bun install | ||
``` | ||
|
||
### Running the Development Server | ||
|
||
To run the development server, execute one of the following commands in your terminal: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
``` | ||
|
||
Visit [http://localhost:3000](http://localhost:3000) to see your application in action. Begin by editing `app/page.tsx` to make changes and see them reflected in real time. | ||
|
||
## 🧞 Features | ||
|
||
- **TypeScript**: Utilize the strong typing of TypeScript to write more robust and error-free code. | ||
- **Tailwind CSS**: Style your application efficiently using utility-first CSS. | ||
- **WAGMI Hooks**: Manage blockchain wallet and network interactions with ease. | ||
- **Viem**: Handle on-chain interactions directly within your frontend application. | ||
- **Morph Sepolia Testnet**: Connect to the Morph testnet to develop and test your dApps. | ||
|
||
## ✨ Learning Resources | ||
|
||
- **Morph L2**: Learn more about Morph and its capabilities by visiting [Morph Layer 2 Official Site](https://www.morphl2.io/). | ||
- **Morph Documentation**: For detailed information on how Morph works and how to integrate it into your applications, check out the [Morph Docs](https://docs.morphl2.io/docs/how-morph-works/intro/). | ||
|
||
## 🚀 Deployment | ||
|
||
Deploy your application with ease using platforms like [Vercel](https://vercel.com/), which provides out-of-the-box support for Next.js applications, or [Juno](https://juno.build), which gives you full control over your dApp by enabling its deployment on Web3. Refer to platform-specific guides for details on deploying Next.js applications. | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const inquirer = require("inquirer"); | ||
const shell = require("shelljs"); | ||
const chalk = require("chalk"); | ||
const ora = require("ora"); | ||
const { join } = require("path"); | ||
const fs = require("fs"); | ||
const { ensureDir, readdir } = require("fs-extra"); | ||
|
||
const BASE_URL = "https://github.com/morph-l2/morph_starter_kit.git"; | ||
|
||
const createAsync = async (command) => { | ||
let { projectName } = await inquirer.prompt({ | ||
type: "input", | ||
name: "projectName", | ||
message: "Project name: ", | ||
}); | ||
|
||
const pwd = process.cwd(); | ||
shell.cd(pwd); | ||
shell.exec(`git clone ${BASE_URL} ${projectName}`); | ||
shell.cd(projectName); | ||
|
||
// const packageJsonPath = join(pwd, projectName, "package.json"); | ||
// fs.readFile(packageJsonPath, "utf8", (err, data) => { | ||
// if (err) { | ||
// console.error("Error reading the file:", err); | ||
// return; | ||
// } | ||
|
||
// // Parse the JSON data | ||
// const packageData = JSON.parse(data); | ||
|
||
// // Modify the "name" field | ||
// packageData.name = projectName; | ||
|
||
// // Convert the JSON data back to a string | ||
// const updatedData = JSON.stringify(packageData, null, 2); | ||
|
||
// // Write the updated data back to the package.json file | ||
// fs.writeFile(packageJsonPath, updatedData, "utf8", (err) => { | ||
// if (err) { | ||
// console.error("Error writing to the file:", err); | ||
// return; | ||
// } | ||
// }); | ||
// }); | ||
|
||
shell.exec("rm -rf .git"); | ||
shell.exec("git init --quiet --initial-branch=main"); | ||
shell.exec("git add ."); | ||
|
||
console.log( | ||
chalk.green("\n\n🚀 Your starter project has been successfully created!\n") | ||
); | ||
|
||
console.log("Before you start the project, please follow these steps:\n"); | ||
|
||
console.log(chalk.cyan("1.") + " Rename the file:"); | ||
console.log(chalk.yellow(" .env.template")); | ||
console.log(" to"); | ||
console.log(chalk.yellow(" .env.local\n")); | ||
|
||
console.log( | ||
chalk.cyan("2.") + | ||
" Open the newly renamed " + | ||
chalk.yellow(".env.local") + | ||
" file and add all the required environment variables.\n" | ||
); | ||
|
||
console.log("Once you've done that, you're all set to start your project!\n"); | ||
console.log( | ||
chalk.green( | ||
"Run `npm install` and `npm run dev` from the project folder to start the project\n" | ||
) | ||
); | ||
|
||
console.log( | ||
chalk.green("Thank you for using the Starter Kit!") + | ||
" If you have any questions or need further assistance, please refer to the README or reach out to our team.\n" | ||
); | ||
|
||
console.log(chalk.blue("Happy coding! 🎉\n\n")); | ||
}; | ||
|
||
async function isOutputDirectoryEmpty(outputFolder, force = false) { | ||
const files = await readdir(outputFolder); | ||
// TODO: Add --force option to overwrite existing files | ||
if (files.length > 0 && !force) { | ||
const { value } = await inquirer.prompt({ | ||
name: "value", | ||
type: "confirm", | ||
message: | ||
"Output directory is not empty. Are you sure you want to continue?", | ||
}); | ||
if (!value) { | ||
process.exit(1); | ||
} | ||
} | ||
} | ||
|
||
const loading = (message) => { | ||
return ora(message).start(); | ||
}; | ||
|
||
module.exports = { | ||
createAsync, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#! /usr/bin/env node | ||
console.log("my test CLI"); | ||
const commander = require("commander"); | ||
const { createAsync } = require("./create.js"); | ||
|
||
const program = new commander.Command(); | ||
|
||
let stdin = { | ||
stdin: "", | ||
}; | ||
|
||
program | ||
.command("create") | ||
.option("-t , --template <name>", "Template to use") | ||
.description("Create a new Morph project") | ||
.action(createAsync); | ||
|
||
if (process.stdin.isTTY) { | ||
program.parse(process.argv); | ||
} else { | ||
process.stdin.on("readable", function () { | ||
let chunk = this.read(); | ||
if (chunk !== null) { | ||
stdin.stdin += chunk; | ||
} | ||
}); | ||
process.stdin.on("end", () => program.parse(process.argv)); | ||
} | ||
|
||
process.on("uncaughtException", (err) => { | ||
if (err.code === "EADDRINUSE") { | ||
// console.log('Port already in use'); | ||
return; | ||
} else if (err.message.includes("Timed out while waiting for handshake")) { | ||
// console.log('Ignoring timeout error'); | ||
return; | ||
} else if (err.message.includes("Could not resolve")) { | ||
// console.log('Ignoring DNS Resolution error'); | ||
return; | ||
} else { | ||
console.log("Unhandled exception. Shutting down", err); | ||
} | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PRIVATE_KEY= Your-Private-Key | ||
RPC_URL=https://rpc-quicknode-holesky.morphl2.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: test | ||
|
||
on: workflow_dispatch | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Run Forge build | ||
run: | | ||
forge --version | ||
forge build --sizes | ||
id: build | ||
|
||
- name: Run Forge tests | ||
run: | | ||
forge test -vvv | ||
id: test |
Oops, something went wrong.