Skip to content

Commit a2e6c9d

Browse files
committed
Add v2 macros migration guide
commit-id:d5868aee
1 parent cf5fcb2 commit a2e6c9d

File tree

5 files changed

+451
-1
lines changed

5 files changed

+451
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ jobs:
325325
name: Test Building Docs
326326
runs-on: ubuntu-latest
327327
env:
328-
MDBOOK_VERSION: 0.4.31
328+
MDBOOK_VERSION: 0.4.52
329329
steps:
330330
- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
331331
with:

docs/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [First Steps with Starknet Foundry](getting-started/first-steps.md)
99
* [Scarb](getting-started/scarb.md)
1010
* [Project Configuration](projects/configuration.md)
11+
* [`snforge` 0.47.0 Migration Guide](getting-started/0-47-0-migration-guide.md)
1112

1213
---
1314

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# `snforge` 0.47.0 Migration Guide
2+
3+
Starting from version 0.47.0, `snforge` will by default work only with Scarb versions 2.12 or newer.
4+
This is due to the migration to the Scarb V2 version of procedural macros, which are used to handle arguments like `#[test]`
5+
in `snforge`.
6+
Thanks to this migration, tools like the Cairo plugin for VSCode will start showing better, more descriptive
7+
errors.
8+
9+
To continue using `snforge` you will need to perform different actions depending on your Scarb version.
10+
11+
## Scarb Versions >= 2.12.0
12+
13+
For Scarb versions >= 2.12.0, we recommend upgrading your `snforge_std` dependency to the one matching your `snforge`
14+
installation (0.47.0 at the time of writing this doc).
15+
16+
In your `Scarb.toml` file, update the dependency:
17+
18+
```toml
19+
[dev-dependencies]
20+
snforge_std = "0.47.0"
21+
```
22+
23+
No further action is required.
24+
25+
## Scarb Versions < 2.12.0
26+
27+
> 📝 **Note**
28+
>
29+
> We recommend upgrading to at least Scarb 2.12.0, as the steps outlined below will stop being supported soon.
30+
31+
For Scarb versions < 2.12.0 it is still possible to continue using the latest `snforge`.
32+
We now publish a new package `snforge_std_deprecated`, supporting versions < 2.12.0.
33+
34+
> ⚠️ **Warning**
35+
>
36+
> `snforge_std_deprecated` may not provide full functionality in comparison to `snforge_std`.
37+
38+
First, in your `Scarb.toml`, remove the `snforge_std` dependency and add `snforge_std_deprecated`:
39+
40+
```diff
41+
[dev-dependencies]
42+
- snforge_std = "0.46.0"
43+
+ snforge_std_deprecated = "0.47.0"
44+
```
45+
46+
Next, replace all kinds of imports in your code from `snforge_std` to `snforge_std_deprecated`:
47+
48+
```diff
49+
// Replace use statements
50+
- use snforge_std::{ContractClassTrait, start_cheat_caller_address};
51+
+ use snforge_std_deprecated::{ContractClassTrait, start_cheat_caller_address};
52+
53+
// Replace full path usages
54+
- let result = snforge_std::declare("MyContract").unwrap();
55+
+ let result = snforge_std_deprecated::declare("MyContract").unwrap();
56+
```

docs/theme/header.hbs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div class="migration-banner">
2+
<p>
3+
<strong>Important:</strong> If you're upgrading snforge to version 0.47.0 or later, please read the
4+
<a href="{{ path_to_root }}getting-started/0-47-0-migration-guide.html">0.47.0 Migration Guide</a>.
5+
</p>
6+
</div>
7+
8+
<style>
9+
.migration-banner {
10+
position: relative;
11+
z-index: 100;
12+
background-color: #f8d7da;
13+
color: #721c24;
14+
border: 0.0625rem solid #f5c6cb;
15+
border-radius: 0;
16+
text-align: center;
17+
padding: 5rem 1rem 0 1rem;
18+
width: calc(100% + 8px + var(--page-padding));
19+
margin-left: calc((8px + var(--page-padding)) * -1);
20+
}
21+
22+
.migration-banner a {
23+
color: #721c24;
24+
font-weight: bold;
25+
text-decoration: underline;
26+
}
27+
</style>

0 commit comments

Comments
 (0)