Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 094244c

Browse files
committed
doc: update contributing guide
1 parent 7c18bea commit 094244c

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

.github/pull_request_template.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
**Issue(s): Close #issue-number
1+
**Issue**: Close #issue-number
22

33
### Description
44

5-
Please provide a brief description of the changes made in this pull request and how they address the related issue.
5+
<!-- Please provide a brief description of the changes made in this pull request and how they address the related issue. -->
66

7-
### Checklist
7+
<!-- Before submitting this PR, please make sure that you read our [Contributing Guidelines](https://github.com/NethermindEth/StarknetByExample/blob/main/CONTRIBUTING.md). Here are some things to check:
88
9-
- [ ] **CI Verifier:** Run `./scripts/cairo_programs_verifier.sh` successfully
10-
- [ ] **Contract Tests:** Added tests to cover the changes
11-
<!-- - [ ] **Deployed Contract (Optional):** If possible, include a Voyager link to a deployed contract on Goerli --> -->
9+
- **CI Verifier:** Run `./scripts/cairo_programs_verifier.sh` successfully
10+
- **Cairo programs**: All snippets should be added under `/listings` directory as a scarb project
11+
- **Markdown files**: All markdown files should be added under `/pages` directory
12+
- **New examples**: If you are adding a new example
13+
- make sure to add the link in the `routes.ts` file
14+
- check that the `Scarb.toml` file has the correct package name, version and only use workspace dependencies
15+
- **Contract Tests:** Added tests to cover the changes -->

CONTRIBUTING.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,47 @@ pnpm i
4343
pnpm dev
4444
```
4545

46+
## Repository Structure
47+
48+
There's both a `listings` and a `pages` directory in the repository. The `listings` directory contains all the Cairo programs used in the book, while the `pages` directory contains the Markdown files that make up the book's content.
49+
The whole repository is a Next.js project, and the `listings` directory is a scarb project.
50+
4651
## Working with Markdown Files
4752

48-
All Markdown files (\*.md) MUST be edited in English. Follow these steps to work locally with Markdown files:
53+
All Markdown files (in `/pages`, \*.md/\*mdx) MUST be edited in English. Follow these steps to work locally with Markdown files:
4954

50-
- Make changes to the desired .md files in your preferred text editor.
55+
- Make changes to the desired Markdown files in your preferred text editor.
5156
- Save the changes, and your browser window should automatically refresh to reflect the updates.
5257
- Once you've finished making your changes, build the application to ensure everything works as expected:
53-
```
54-
pnpm build
55-
```
58+
59+
```
60+
pnpm build
61+
```
62+
5663
- If everything looks good, commit your changes and open a pull request with your modifications.
5764

5865
## Adding a new chapter
5966

60-
- To add a new chapter, create a new markdown file in the `pages` directory. All the Markdown files **MUST** be edited in english. In order to add them to the book, you need to add in the `vocs.config.ts` file.
67+
- To add a new chapter, create a new markdown file in the `pages` directory. All the Markdown files **MUST** be edited in english. In order to add them to the book, you need to edit the `route.ts` file.
6168

6269
- Do not write directly Cairo program inside the markdown files. Instead, use code blocks that import the Cairo programs from the `listings` directory. These programs are bundled into scarb projects, which makes it easier to test and build all programs. See the next section for more details.
6370

6471
Be sure to check for typos with `typos`:
6572

66-
```bash [Terminal]
73+
```bash
6774
cargo install typos-cli
6875
typos src/
6976
```
7077

7178
## Adding a new Cairo program
7279

7380
You can add or modify examples in the `listings` directory. Each listing is a scarb project.
74-
You can find a template of a blank scarb project in the `listings/template` directory.
75-
(You can also use `scarb init` to create a new scarb project, but be sure to remove the generated git repository)
81+
You can use `scarb init` to create a new scarb project, but be sure to remove the generated git repository with `rm -rf .git` and follow the instructions below for the correct `Scarb.toml` configuration.
7682

7783
You can choose to use standard cairo with `cairo-test` or Starknet Foundry with `snforge_std`.
7884
Please use the appropriate `Scarb.toml` configuration. `scarb test` will automatically resolve to `snforge test` if `snforge_std` is in the dependencies.
7985

80-
Here's the required `Scarb.toml` configuration for **Cairo test**:
86+
Here's the required `Scarb.toml` configuration for **cairo-test**:
8187

8288
```toml
8389
[package]
@@ -103,7 +109,6 @@ cairo_test.workspace = true
103109
test.workspace = true
104110

105111
[[target.starknet-contract]]
106-
casm = true
107112
```
108113

109114
Here's the required `Scarb.toml` configuration for **Starknet Foundry**:
@@ -133,13 +138,12 @@ snforge_std.workspace = true
133138
test.workspace = true
134139

135140
[[target.starknet-contract]]
136-
casm = true
137141
```
138142

139143
You also NEED to do the following:
140144

141145
- Remove the generated git repository, `rm -rf .git` (this is important!)
142-
- Double check that the `pkg_name` is the same as the name of the directory
146+
- Double check that the package name is the same as the name of the directory
143147

144148
### Verification script
145149

@@ -149,7 +153,7 @@ These programs are bundled into scarb packages, which makes it easier to test an
149153

150154
To run the script locally, ensure that you are at the root of the repository, and run:
151155

152-
`bash scripts/cairo_programs_verifier.sh`
156+
`./scripts/cairo_programs_verifier.sh`
153157

154158
This will check that all the Cairo programs in the book compile successfully using `scarb build`, that every tests passes using `scarb test`, and that the `scarb fmt -c` command does not identify any formatting issues.
155159

@@ -166,7 +170,6 @@ Every listing needs to have atleast integration tests:
166170
Add your contract in a specific file, you can name it `contract.cairo` or anything else. You can also add other files if needed.
167171

168172
You should add the tests in the same file as the contract, using the `#[cfg(test)]` flag and a `tests` module.
169-
<!-- With the usage of ANCHOR, the tests will not be displayed in the book but can be optionally be displayed by using the `{{#rustdoc_include ...}}` syntax. -->
170173

171174
Here's a sample `lib.cairo` file:
172175

@@ -182,10 +185,12 @@ And in the `contract.cairo` file:
182185
// Write your contract here
183186
// [!endregion contract]
184187
188+
// [!region test]
185189
#[cfg(test)]
186190
mod tests {
187191
// Write your tests for the contract here
188192
}
193+
// [!endregion test]
189194
```
190195

191196
You can use Starknet Foundry to write and run your tests.

0 commit comments

Comments
 (0)