|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Petra Vault! Please refer to the guidelines to get started. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +These guidelines are intended to help you get started with the project. By following these guidelines, you will be able to understand how to contribute to the project while maintaining the project's security and quality standards. If you would like to contribute, you can visit the [Github Issues](https://github.com/aptos-labs/petra-vault/issues) page to find issues you can help with. |
| 8 | + |
| 9 | +> [!IMPORTANT] |
| 10 | +> If you are looking to add a new feature, please make sure to open an issue first to discuss the feature with the maintainers. Doing so will help avoid rejected/declined pull requests, and ensure that your time is spent on the most relevant work. |
| 11 | +
|
| 12 | +## 1. Cloning the Repository |
| 13 | + |
| 14 | +To clone the repository, you can use the following command on your local machine: |
| 15 | + |
| 16 | +```bash |
| 17 | +git clone https://github.com/aptos-labs/petra-vault.git |
| 18 | +``` |
| 19 | + |
| 20 | +## 2. Installing Runtimes |
| 21 | + |
| 22 | +Petra Vault uses [pnpm](https://pnpm.io/) as its package manager and [Node.js](https://nodejs.org/) as its JavaScript runtime. |
| 23 | + |
| 24 | +It's important to use the correct runtime versions to avoid any issues. The versions are specified in the [`.tool-versions`](../.tool-versions) file to ensure consistency across all developers. |
| 25 | + |
| 26 | +To check your runtime versions, you can use the following command: |
| 27 | + |
| 28 | +```bash |
| 29 | +node -v |
| 30 | +pnpm -v |
| 31 | +``` |
| 32 | + |
| 33 | +If the runtime versions do not align with the versions defined in the [`.tool-versions`](../.tool-versions) file, we recommend that you install the correct runtimes using [mise](https://mise.jdx.dev/), which helps manage multiple versions of development tools. |
| 34 | + |
| 35 | +## 3. Installing Dependencies |
| 36 | + |
| 37 | +Once your runtimes are installed, you can install the project's dependencies through pnpm using the following command: |
| 38 | + |
| 39 | +```bash |
| 40 | +pnpm install |
| 41 | +``` |
| 42 | + |
| 43 | +If you encounter any issues during installation: |
| 44 | + |
| 45 | +- Try deleting the `node_modules` directory |
| 46 | +- Run `pnpm install` again |
| 47 | +- Check if your runtime versions are correct |
| 48 | + |
| 49 | +## 4. Setting Up Environment Variables |
| 50 | + |
| 51 | +Some subdirectories may contain an `.env.example` file. These files are templates that you can use to create your own `.env` file. |
| 52 | + |
| 53 | +To create your own `.env` file, you can use the following command: |
| 54 | + |
| 55 | +```bash |
| 56 | +cp .env.example .env |
| 57 | +``` |
| 58 | + |
| 59 | +This will create a new `.env` file in the directory with the correct environment variable names. Once you have created the `.env` file, make sure to fill in the correct values for the environment variables. For example, here is the `.env.example` file in the `apps/web` directory: |
| 60 | + |
| 61 | +```bash |
| 62 | +# .env.example |
| 63 | + |
| 64 | +NEXT_PUBLIC_ENABLE_REACT_SCAN=0 |
| 65 | + |
| 66 | +# Obtain from: https://developers.aptos.dev |
| 67 | +NEXT_PUBLIC_APTOS_MAINNET_API_KEY=<api_key> |
| 68 | +NEXT_PUBLIC_APTOS_TESTNET_API_KEY=<api_key> |
| 69 | + |
| 70 | +# Obtain from: https://analytics.google.com |
| 71 | +NEXT_PUBLIC_GA4_ID=<ga4_id> |
| 72 | + |
| 73 | +CI=false |
| 74 | +``` |
| 75 | + |
| 76 | +It is important to set these up to avoid any issues such as rate limiting or missing functionality. If you don't have access to certain API keys, please obtain them using the links provided in the `.env.example` file. |
| 77 | + |
| 78 | +## 5. Running Development Servers |
| 79 | + |
| 80 | +To run the development servers, you can use the following command: |
| 81 | + |
| 82 | +```bash |
| 83 | +pnpm dev |
| 84 | +``` |
| 85 | + |
| 86 | +If you need to run the development servers for a specific project, you can use the `--filter` flag: |
| 87 | + |
| 88 | +```bash |
| 89 | +pnpm dev --filter <web|other-project-name> |
| 90 | +``` |
| 91 | + |
| 92 | +Alternatively, you can run the development servers directly from the projects: |
| 93 | + |
| 94 | +```bash |
| 95 | +cd apps/web |
| 96 | +pnpm dev |
| 97 | +``` |
| 98 | + |
| 99 | +Development servers will automatically update as changes are made to the codebase and in their respective directories. |
| 100 | + |
| 101 | +## 6. Running Tests |
| 102 | + |
| 103 | +Petra Vault uses [Vitest](https://vitest.dev/) for unit testing and [Playwright](https://playwright.dev/) for end-to-end testing. |
| 104 | + |
| 105 | +- **Vitest** is used for testing individual components and functions |
| 106 | +- **Playwright** is used for testing complete user flows in a real browser environment |
| 107 | + |
| 108 | +It's important that you have set up all environment variables before running the tests. Make sure to find the `.env.example` file in all projects in `apps/` and create their corresponding `.env` file. |
| 109 | + |
| 110 | +Now that you have set up the environment variables, you can run the tests using the following command from the root directory: |
| 111 | + |
| 112 | +- **Unit Tests:** `pnpm test` |
| 113 | +- **End-to-End Tests:** `pnpm test:e2e` |
| 114 | + |
| 115 | +When adding new features and flows, it's important to create tests that thoroughly cover the new functionality. This helps ensure that: |
| 116 | + |
| 117 | +1. Your code works as expected |
| 118 | +2. Future changes don't break existing functionality |
| 119 | +3. Other developers can understand how your code should behave |
| 120 | + |
| 121 | +## 7. Developer Configurations |
| 122 | + |
| 123 | +Petra Vault uses [Prettier](https://prettier.io/) for formatting and [ESLint](https://eslint.org/) for linting. |
| 124 | + |
| 125 | +- **Prettier** automatically formats your code to maintain consistent style |
| 126 | +- **ESLint** helps catch potential errors and enforce coding standards |
| 127 | + |
| 128 | +You can run these tools using: |
| 129 | + |
| 130 | +- **Prettier:** `pnpm format` |
| 131 | +- **ESLint:** `pnpm lint` |
| 132 | + |
| 133 | +In addition, to edit configurations we've centralized them into subpackages. |
| 134 | + |
| 135 | +- **tsconfig:** `packages/eslint-config` - TypeScript configuration |
| 136 | +- **eslint:** `packages/typescript-config` - ESLint rules and settings |
| 137 | + |
| 138 | +When making changes to the configurations, it's best to make changes to child configurations rather than root configurations, as this ensures that changes are reflected in relevant projects without conflicts. |
| 139 | + |
| 140 | +## 8. Documentation |
| 141 | + |
| 142 | +The project's user-facing documentation is currently being handled through a closed-source repository. To make modifications to the documentation, please coordinate with a maintainer using a [Github Issue](https://github.com/aptos-labs/petra-vault/issues). |
| 143 | + |
| 144 | +## 9. Submitting a Pull Request |
| 145 | + |
| 146 | +When you submit a pull request, GitHub will automatically run checks and tests against your changes. If any of the checks fail: |
| 147 | + |
| 148 | +1. Review the test logs to identify the cause of the failure |
| 149 | +2. Fix the issues in your code |
| 150 | +3. Push the changes to your branch |
| 151 | +4. The checks will automatically re-run |
| 152 | + |
| 153 | +Please ensure all checks pass before requesting a review. |
| 154 | + |
| 155 | +## 10. That's it! |
| 156 | + |
| 157 | +You're all set! If you have any questions, please reach out to a maintainer using a [Github Issue](https://github.com/aptos-labs/petra-vault/issues). We're here to help! |
0 commit comments