-
Notifications
You must be signed in to change notification settings - Fork 461
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
Chore: monorepo setup #4690
Merged
Chore: monorepo setup #4690
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
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 @@ | ||
v22.11.0 |
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 |
---|---|---|
@@ -1,165 +1,158 @@ | ||
# <img src="https://github.com/user-attachments/assets/b8249113-d515-4c91-a12a-f134813614e8" height="60" valign="middle" alt="Safe{Wallet}" style="background: #fff; padding: 20px; margin: 0 -20px" /> | ||
# Safe Global Monorepo πββοΈ | ||
|
||
[![License](https://img.shields.io/github/license/safe-global/safe-wallet-web)](https://github.com/safe-global/safe-wallet-web/blob/main/LICENSE) | ||
![Tests](https://img.shields.io/github/actions/workflow/status/safe-global/safe-wallet-web/test.yml?branch=main&label=tests) | ||
![GitHub package.json version (branch)](https://img.shields.io/github/package-json/v/safe-global/safe-wallet-web) | ||
[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/safe-global/safe-wallet-web/badge)](https://www.gitpoap.io/gh/safe-global/safe-wallet-web) | ||
## Overview | ||
|
||
Safe{Wallet} is a smart contract wallet for Ethereum and other EVM chains. Based on Gnosis Safe multisig contracts. | ||
Welcome to the Safe Global Monorepo! This repository houses multiple applications and packages managed under a unified | ||
structure using Yarn Workspaces. The monorepo setup simplifies dependency management and ensures consistent development | ||
practices across projects. | ||
|
||
This repository is the frontend of the Safe{Wallet} app. | ||
### Key Components | ||
|
||
## Contributing | ||
|
||
Contributions, be it a bug report or a pull request, are very welcome. Please check our [contribution guidelines](CONTRIBUTING.md) beforehand. | ||
|
||
## Getting started with local development | ||
|
||
### Environment variables | ||
|
||
Create a `.env` file with environment variables. You can use the `.env.example` file as a reference. | ||
|
||
Here's the list of all the environment variables: | ||
- **apps/**: Contains application projects (e.g., `mobile` for the Safe Mobile App). | ||
- **packages/**: Shared libraries and utilities. | ||
- **config/**: Configuration files for the monorepo. | ||
|
||
| Env variable | Description | | ||
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `NEXT_PUBLIC_BRAND_NAME` | The name of the app, defaults to "Wallet fork" | | ||
| `NEXT_PUBLIC_BRAND_LOGO` | The URL of the app logo displayed in the header | | ||
## Getting Started | ||
|
||
| `NEXT_PUBLIC_INFURA_TOKEN` | [Infura](https://docs.infura.io/infura/networks/ethereum/how-to/secure-a-project/project-id) RPC API token | | ||
| `NEXT_PUBLIC_SAFE_APPS_INFURA_TOKEN` | Infura token for Safe Apps, falls back to `NEXT_PUBLIC_INFURA_TOKEN` | | ||
| `NEXT_PUBLIC_IS_PRODUCTION` | Set to `true` to build a minified production app | | ||
| `NEXT_PUBLIC_GATEWAY_URL_PRODUCTION` | The base URL for the [Safe Client Gateway](https://github.com/safe-global/safe-client-gateway) | | ||
| `NEXT_PUBLIC_GATEWAY_URL_STAGING` | The base CGW URL on staging | | ||
| `NEXT_PUBLIC_SAFE_VERSION` | The latest version of the Safe contract, defaults to 1.4.1 | | ||
| `NEXT_PUBLIC_WC_PROJECT_ID` | [WalletConnect v2](https://docs.walletconnect.com/2.0/cloud/relay) project ID | | ||
| `NEXT_PUBLIC_TENDERLY_ORG_NAME` | [Tenderly](https://tenderly.co) org name for Transaction Simulation | | ||
| `NEXT_PUBLIC_TENDERLY_PROJECT_NAME` | Tenderly project name | | ||
| `NEXT_PUBLIC_TENDERLY_SIMULATE_ENDPOINT_URL` | Tenderly simulation URL | | ||
| `NEXT_PUBLIC_BEAMER_ID` | [Beamer](https://www.getbeamer.com) is a news feed for in-app announcements | | ||
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID` | [GTM](https://tagmanager.google.com) project id | | ||
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_DEVELOPMENT_AUTH` | Dev GTM key | | ||
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LATEST_AUTH` | Preview GTM key | | ||
| `NEXT_PUBLIC_GOOGLE_TAG_MANAGER_LIVE_AUTH` | Production GTM key | | ||
| `NEXT_PUBLIC_SENTRY_DSN` | [Sentry](https://sentry.io) id for tracking runtime errors | | ||
| `NEXT_PUBLIC_IS_OFFICIAL_HOST` | Whether it's the official distribution of the app, or a fork; has legal implications. Set to true only if you also update the legal pages like Imprint and Terms of use | | ||
| `NEXT_PUBLIC_REDEFINE_API` | Redefine API base URL | | ||
| `NEXT_PUBLIC_FIREBASE_OPTIONS_PRODUCTION` | Firebase Cloud Messaging (FCM) `initializeApp` options on production | | ||
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_PRODUCTION` | FCM vapid key on production | | ||
| `NEXT_PUBLIC_FIREBASE_OPTIONS_STAGING` | FCM `initializeApp` options on staging | | ||
| `NEXT_PUBLIC_FIREBASE_VAPID_KEY_STAGING` | FCM vapid key on staging | | ||
| `NEXT_PUBLIC_SPINDL_SDK_KEY` | [Spindl](http://spindl.xyz) SDK key | | ||
To get started, ensure you have the required tools installed and follow these steps: | ||
|
||
If you don't provide some of the variables, the corresponding features will be disabled in the UI. | ||
|
||
### Running the app locally | ||
|
||
#### Prerequisites | ||
### Prerequisites | ||
|
||
- **Node.js**: Install the latest stable version from [Node.js](https://nodejs.org/). | ||
- **Yarn**: Use Yarn version 4.5.3 or later | ||
|
||
We use Yarn v4 for package management. If you are running on Node.js v16 or later, you can run: | ||
to install it with the latest node version you can simply do | ||
|
||
```bash | ||
corepack enable | ||
``` | ||
|
||
and then when you run `yarn` in the repository root, it will install the required version of yarn and resolve all | ||
dependencies. | ||
and then just run | ||
|
||
```bash | ||
yarn | ||
``` | ||
|
||
This will install the required version of yarn and resolve all dependencies. | ||
|
||
> [!INFO] | ||
> | ||
> Corepack is a tool to help with managing versions of your package managers. It exposes binary proxies for each | ||
> supported package manager that, when called, will identify whatever package manager is | ||
> Corepack is a tool to help with managing versions of your package managers. It exposes binary proxies for each supported package manager that, when called, will identify whatever package manager is | ||
> configured for the current project, download it if needed, and finally run it. | ||
|
||
Install the dependencies: | ||
### Initial Setup | ||
|
||
1. Clone the repository: | ||
|
||
```bash | ||
yarn | ||
git clone <repo-url> | ||
cd monorepo | ||
``` | ||
|
||
Generate types: | ||
2. Install dependencies: | ||
|
||
```bash | ||
yarn postinstall | ||
yarn install | ||
``` | ||
|
||
Run the development server: | ||
## Monorepo Commands | ||
|
||
Here are some essential commands to help you navigate the monorepo: | ||
|
||
### Workspace Management | ||
|
||
- **Run a script in a specific workspace:** | ||
|
||
```bash | ||
yarn start | ||
yarn workspace <workspace-name> <script> | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the app. | ||
Example: | ||
|
||
## Lint | ||
```bash | ||
yarn workspace @safe-global/web start | ||
``` | ||
|
||
ESLint: | ||
- **Add a dependency to a specific workspace:** | ||
|
||
``` | ||
yarn lint --fix | ||
```bash | ||
yarn workspace <workspace-name> add <package-name> | ||
``` | ||
|
||
Prettier: | ||
- **Remove a dependency from a specific workspace:** | ||
|
||
```bash | ||
yarn workspace <workspace-name> remove <package-name> | ||
``` | ||
yarn prettier | ||
``` | ||
|
||
## Tests | ||
> [!Note] | ||
> | ||
> Yarn treats commands that contain a semicolon as global commands. For example if you have a | ||
compojoom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
> command in a workspace that has a semicolon and there isn't another workspace that has the same command, | ||
> you can run the command without specifying the workspace name. For example: | ||
> | ||
> ```bash | ||
> yarn cypress:open | ||
> ``` | ||
> | ||
> is equivalent to: | ||
> | ||
> ```bash | ||
> yarn workspace @safe-global/web cypress:open | ||
> ``` | ||
|
||
### Linting and Formatting | ||
|
||
Unit tests: | ||
- **Run ESLint across all workspaces:** | ||
|
||
``` | ||
yarn test --watch | ||
```bash | ||
yarn lint | ||
``` | ||
|
||
### Cypress tests | ||
### Testing | ||
|
||
Build a static site: | ||
- **Run unit tests across all workspaces:** | ||
|
||
``` | ||
yarn build | ||
```bash | ||
yarn test | ||
``` | ||
|
||
Serve the static files: | ||
## Contributing | ||
|
||
``` | ||
yarn serve | ||
``` | ||
### Adding a New Workspace | ||
|
||
Launch the Cypress UI: | ||
1. Create a new directory under `apps/` or `packages/`. | ||
2. Add a `package.json` file with the appropriate configuration. | ||
3. Run: | ||
|
||
```bash | ||
yarn install | ||
``` | ||
yarn cypress:open | ||
``` | ||
|
||
You can then choose which e2e tests to run. | ||
Some tests will require signer private keys, please include them in your .env file | ||
|
||
## Component template | ||
### Best Practices | ||
|
||
To create a new component from a template: | ||
- Use Yarn Workspaces commands for managing dependencies. | ||
- Ensure tests and linting pass before pushing changes. | ||
- Follow the commit message guidelines. | ||
|
||
``` | ||
yarn cmp MyNewComponent | ||
``` | ||
### Tools & Configurations | ||
|
||
## Pre-push hooks | ||
- **Husky**: Pre-commit hooks for linting and tests. | ||
- **ESLint & Prettier**: Enforce coding standards and formatting. | ||
- **Jest**: Unit testing framework. | ||
- **Expo**: Mobile app framework for the `mobile` workspace. | ||
- **Next.js**: React framework for the `web` workspace. | ||
|
||
This repo has a pre-push hook that runs the linter (always) and the tests (if the `RUN_TESTS_ON_PUSH` env variable is set to true) | ||
before pushing. If you want to skip the hooks, you can use the `--no-verify` flag. | ||
## Useful Links | ||
|
||
## Frameworks | ||
- [Yarn Workspaces Documentation](https://classic.yarnpkg.com/en/docs/workspaces/) | ||
- [Expo Documentation](https://docs.expo.dev/) | ||
- [Next.js Documentation](https://nextjs.org/docs) | ||
- [Jest Documentation](https://jestjs.io/) | ||
- [ESLint Documentation](https://eslint.org/) | ||
- [Prettier Documentation](https://prettier.io/) | ||
|
||
This app is built using the following frameworks: | ||
--- | ||
|
||
- [Safe Core SDK](https://github.com/safe-global/safe-core-sdk) | ||
- [Safe Gateway SDK](https://github.com/safe-global/safe-gateway-typescript-sdk) | ||
- Next.js | ||
- React | ||
- Redux | ||
- MUI | ||
- ethers.js | ||
- web3-onboard | ||
If you have any questions or run into issues, feel free to open a discussion or contact the maintainers. Happy coding! | ||
π |
File renamed without changes.
File renamed without changes.
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,61 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# types | ||
/src/types/contracts/ | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
.idea | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
# yalc | ||
.yalc | ||
yalc.lock | ||
.env | ||
|
||
/cypress/videos | ||
/cypress/screenshots | ||
/cypress/downloads | ||
|
||
/public/sw.js | ||
/public/sw.js.map | ||
/public/worker-*.js | ||
/public/workbox-*.js | ||
/public/workbox-*.js.map | ||
/public/fallback* | ||
/public/*.js.LICENSE.txt | ||
certificates | ||
*storybook.log | ||
|
||
# Yarn v4 | ||
.yarn/* |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a difference to navigating into an app and running
yarn add <package-name>
there directly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. When you execute the command it would run in the package directory context (meaning root will be the directory). Sometimes the output coloring is a bit off and yarn is adding some prefixes to every line (but I can't tell you when this exactly occurs)