You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 1, 2025. It is now read-only.
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.-->
6
6
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:
8
8
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 -->
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+20-15Lines changed: 20 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,41 +43,47 @@ pnpm i
43
43
pnpm dev
44
44
```
45
45
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
+
46
51
## Working with Markdown Files
47
52
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:
49
54
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.
51
56
- Save the changes, and your browser window should automatically refresh to reflect the updates.
52
57
- 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
+
56
63
- If everything looks good, commit your changes and open a pull request with your modifications.
57
64
58
65
## Adding a new chapter
59
66
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.
61
68
62
69
- 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.
63
70
64
71
Be sure to check for typos with `typos`:
65
72
66
-
```bash [Terminal]
73
+
```bash
67
74
cargo install typos-cli
68
75
typos src/
69
76
```
70
77
71
78
## Adding a new Cairo program
72
79
73
80
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.
76
82
77
83
You can choose to use standard cairo with `cairo-test` or Starknet Foundry with `snforge_std`.
78
84
Please use the appropriate `Scarb.toml` configuration. `scarb test` will automatically resolve to `snforge test` if `snforge_std` is in the dependencies.
79
85
80
-
Here's the required `Scarb.toml` configuration for **Cairo test**:
86
+
Here's the required `Scarb.toml` configuration for **cairo-test**:
81
87
82
88
```toml
83
89
[package]
@@ -103,7 +109,6 @@ cairo_test.workspace = true
103
109
test.workspace = true
104
110
105
111
[[target.starknet-contract]]
106
-
casm = true
107
112
```
108
113
109
114
Here's the required `Scarb.toml` configuration for **Starknet Foundry**:
- 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
143
147
144
148
### Verification script
145
149
@@ -149,7 +153,7 @@ These programs are bundled into scarb packages, which makes it easier to test an
149
153
150
154
To run the script locally, ensure that you are at the root of the repository, and run:
151
155
152
-
`bash scripts/cairo_programs_verifier.sh`
156
+
`./scripts/cairo_programs_verifier.sh`
153
157
154
158
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.
155
159
@@ -166,7 +170,6 @@ Every listing needs to have atleast integration tests:
166
170
Add your contract in a specific file, you can name it `contract.cairo` or anything else. You can also add other files if needed.
167
171
168
172
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. -->
170
173
171
174
Here's a sample `lib.cairo` file:
172
175
@@ -182,10 +185,12 @@ And in the `contract.cairo` file:
182
185
// Write your contract here
183
186
// [!endregion contract]
184
187
188
+
// [!region test]
185
189
#[cfg(test)]
186
190
mod tests {
187
191
// Write your tests for the contract here
188
192
}
193
+
// [!endregion test]
189
194
```
190
195
191
196
You can use Starknet Foundry to write and run your tests.
0 commit comments