Skip to content

Commit 444319f

Browse files
committed
Merge remote-tracking branch 'upstream' into sierra-explanation
2 parents 83fece7 + d2396cc commit 444319f

File tree

110 files changed

+2932
-2423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2932
-2423
lines changed

.github/workflows/verify_cairo_programs.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ on:
44
pull_request:
55
branches:
66
- dev
7+
- main
78
workflow_dispatch:
89

910
jobs:
11+
typos:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: crate-ci/typos@master
16+
1017
compile_and_verify:
1118
runs-on: ubuntu-latest
1219

@@ -19,21 +26,15 @@ jobs:
1926
- name: Configure upstream repository
2027
run: |
2128
git remote add upstream https://github.com/NethermindEth/StarknetByExample
22-
git fetch upstream main
29+
git fetch upstream
2330
2431
- name: Install scarb
2532
uses: software-mansion/setup-scarb@v1
2633

2734
- name: Install snforge
2835
uses: foundry-rs/setup-snfoundry@v3
2936

30-
- name: Run build script
37+
- name: Verify changes
3138
run: |
3239
chmod +x scripts/cairo_programs_verifier.sh
3340
./scripts/cairo_programs_verifier.sh
34-
35-
typos:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v4
39-
- uses: crate-ci/typos@master

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,3 @@ target/*
1717
src/**/*.md
1818

1919
node_modules
20-
21-
22-
# windsurf rules
23-
.windsurfrules

CONTRIBUTING.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
When contributing to this repository, please first discuss the change you wish to make via issue or in the telegram channel before making a change.
44

5-
Join the telegram channel: https://t.me/StarknetByExample
5+
Join the telegram channel: <https://t.me/StarknetByExample>
6+
7+
The release branch is `main`. The development branch is `dev` and is considered stable (but not released yet).
8+
When you want to contribute, please create a new branch from `dev` and open a pull request to merge your changes back into `dev`.
9+
You should never open a pull request to merge your changes directly into `main`.
10+
11+
The `dev` branch is deployed at <https://starknet-by-example-dev.voyager.online/>
612

713
The release branch is `main`. The development branch is `dev` and is considered stable (but not released yet).
814
When you want to contribute, please create a new branch from `dev` and open a pull request to merge your changes back into `dev`.
@@ -86,10 +92,10 @@ typos src/
8692
You can add or modify examples in the `listings` directory. Each listing is a scarb project.
8793
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.
8894

89-
You can choose to use standard cairo with `cairo-test` or Starknet Foundry with `snforge_std`.
95+
We prefer to use Starknet Foundry with `snforge_std`, however you can still use `cairo-test` if desired.
9096
Please use the appropriate `Scarb.toml` configuration. `scarb test` will automatically resolve to `snforge test` if `snforge_std` is in the dependencies.
9197

92-
Here's the required `Scarb.toml` configuration for **cairo-test**:
98+
Here's the required `Scarb.toml` configuration for **Starknet Foundry**:
9399

94100
```toml
95101
[package]
@@ -109,15 +115,21 @@ starknet.workspace = true
109115
# erc20 = { path = "../../getting-started/erc20" }
110116

111117
[dev-dependencies]
112-
cairo_test.workspace = true
118+
assert_macros.workspace = true
119+
snforge_std.workspace = true
113120

114121
[scripts]
115122
test.workspace = true
116123

117124
[[target.starknet-contract]]
118125
```
119126

120-
Here's the required `Scarb.toml` configuration for **Starknet Foundry**:
127+
You also **NEED** to do the following:
128+
129+
- Remove the generated git repository, `rm -rf .git` (this is important!)
130+
- Double check that the package name is the same as the name of the directory
131+
132+
Here's the required `Scarb.toml` configuration for **cairo-test**:
121133

122134
```toml
123135
[package]
@@ -137,20 +149,14 @@ starknet.workspace = true
137149
# erc20 = { path = "../../getting-started/erc20" }
138150

139151
[dev-dependencies]
140-
assert_macros.workspace = true
141-
snforge_std.workspace = true
152+
cairo_test.workspace = true
142153

143154
[scripts]
144155
test.workspace = true
145156

146157
[[target.starknet-contract]]
147158
```
148159

149-
You also NEED to do the following:
150-
151-
- Remove the generated git repository, `rm -rf .git` (this is important!)
152-
- Double check that the package name is the same as the name of the directory
153-
154160
### Verification script
155161

156162
The current book has script that verifies the compilation of all Cairo programs in the book.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Starknet by Example
22

3+
Dev preview at: https://starknet-by-example-dev.voyager.online/
4+
35
## Description
46

57
Starknet by Example is a collection of examples of how to use the [Cairo](https://github.com/starkware-libs/cairo) programming language to create smart contracts on Starknet.

Scarb.lock

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22
version = 1
33

44
[[package]]
5-
name = "advanced_factory"
5+
name = "account_spending_limits"
66
version = "0.1.0"
77
dependencies = [
8-
"components",
9-
"crowdfunding",
8+
"openzeppelin",
109
"snforge_std",
1110
]
1211

1312
[[package]]
14-
name = "bytearray"
15-
version = "0.1.0"
16-
17-
[[package]]
18-
name = "cairo_cheatsheet"
13+
name = "advanced_factory"
1914
version = "0.1.0"
15+
dependencies = [
16+
"components",
17+
"crowdfunding",
18+
"snforge_std",
19+
]
2020

2121
[[package]]
2222
name = "calling_other_contracts"
2323
version = "0.1.0"
24+
dependencies = [
25+
"snforge_std",
26+
]
2427

2528
[[package]]
2629
name = "coin_flip"
@@ -56,10 +59,16 @@ dependencies = [
5659
[[package]]
5760
name = "constructor"
5861
version = "0.1.0"
62+
dependencies = [
63+
"snforge_std",
64+
]
5965

6066
[[package]]
6167
name = "counter"
6268
version = "0.1.0"
69+
dependencies = [
70+
"snforge_std",
71+
]
6372

6473
[[package]]
6574
name = "crowdfunding"
@@ -71,8 +80,11 @@ dependencies = [
7180
]
7281

7382
[[package]]
74-
name = "custom_type_serde"
83+
name = "custom_type_entrypoints"
7584
version = "0.1.0"
85+
dependencies = [
86+
"snforge_std",
87+
]
7688

7789
[[package]]
7890
name = "ecdsa_verification"
@@ -85,10 +97,16 @@ version = "0.1.0"
8597
[[package]]
8698
name = "errors"
8799
version = "0.1.0"
100+
dependencies = [
101+
"snforge_std",
102+
]
88103

89104
[[package]]
90105
name = "events"
91106
version = "0.1.0"
107+
dependencies = [
108+
"snforge_std",
109+
]
92110

93111
[[package]]
94112
name = "factory"
@@ -102,17 +120,16 @@ version = "0.1.0"
102120
name = "hash_trait"
103121
version = "0.1.0"
104122

105-
[[package]]
106-
name = "interfaces_traits"
107-
version = "0.1.0"
108-
109123
[[package]]
110124
name = "library_calls"
111125
version = "0.1.0"
112126

113127
[[package]]
114128
name = "mappings"
115129
version = "0.1.0"
130+
dependencies = [
131+
"snforge_std",
132+
]
116133

117134
[[package]]
118135
name = "merkle_tree"
@@ -296,6 +313,9 @@ dependencies = [
296313
[[package]]
297314
name = "storage"
298315
version = "0.1.0"
316+
dependencies = [
317+
"snforge_std",
318+
]
299319

300320
[[package]]
301321
name = "store_using_packing"
@@ -304,6 +324,9 @@ version = "0.1.0"
304324
[[package]]
305325
name = "storing_custom_types"
306326
version = "0.1.0"
327+
dependencies = [
328+
"snforge_std",
329+
]
307330

308331
[[package]]
309332
name = "struct_as_mapping_key"
@@ -329,10 +352,16 @@ version = "0.1.0"
329352
[[package]]
330353
name = "variables"
331354
version = "0.1.0"
355+
dependencies = [
356+
"snforge_std",
357+
]
332358

333359
[[package]]
334360
name = "visibility"
335361
version = "0.1.0"
362+
dependencies = [
363+
"snforge_std",
364+
]
336365

337366
[[package]]
338367
name = "write_to_any_slot"

components/useTracking.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { useEffect } from "react";
2+
3+
const CLARITY_ID = "q6bz69wquw";
4+
5+
export const useTracking = () => {
6+
useEffect(() => {
7+
const script = document.createElement("script");
8+
script.type = "text/javascript";
9+
script.text = `
10+
(function(c,l,a,r,i,t,y){
11+
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
12+
t=l.createElement(r);t.async=1;
13+
t.src="https://www.clarity.ms/tag/"+i;
14+
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
15+
})(window, document, "clarity", "script", "${CLARITY_ID}");
16+
`;
17+
document.head.appendChild(script);
18+
return () => {
19+
document.head.removeChild(script);
20+
};
21+
}, []);
22+
};

footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function Footer() {
88
/>
99
<div className="footer_text text-xs flex flex-col items-center">
1010
<span>Released under the MIT License.</span>
11-
<span>© 2024 Nethermind. All Rights Reserved</span>
11+
<span>© 2025 Nethermind. All Rights Reserved</span>
1212
</div>
1313
</div>
1414
);

layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { useSidebarToggle } from "./components/useSidebarToggle";
2+
import { useTracking } from "./components/useTracking";
23

34
export default function Root({ children }: { children: React.ReactNode }) {
5+
useTracking();
46
useSidebarToggle();
57
return <div className="page-wrapper">{children}</div>;
68
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Code generated by scarb DO NOT EDIT.
2+
version = 1
3+
4+
[[package]]
5+
name = "aa_tutorial"
6+
version = "0.1.0"
7+
dependencies = [
8+
"openzeppelin",
9+
"snforge_std",
10+
]
11+
12+
[[package]]
13+
name = "openzeppelin"
14+
version = "0.9.0"
15+
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.9.0#364db5b1aecc1335d2e65db887291d19aa28937d"
16+
17+
[[package]]
18+
name = "snforge_std"
19+
version = "0.25.0"
20+
source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.25.0#5b366e24821e530fea97f11b211d220e8493fbea"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "account_spending_limits"
3+
version.workspace = true
4+
edition.workspace = true
5+
6+
[dependencies]
7+
starknet.workspace = true
8+
openzeppelin.workspace = true
9+
10+
[dev-dependencies]
11+
assert_macros.workspace = true
12+
snforge_std.workspace = true
13+
14+
[scripts]
15+
test.workspace = true
16+
17+
[[target.starknet-contract]]
18+
build-external-contracts = ["openzeppelin_presets::erc20::ERC20Upgradeable"]

0 commit comments

Comments
 (0)