Skip to content

Commit 4959aa4

Browse files
committed
Add v2 macros migration guide
commit-id:d5868aee
1 parent eca5545 commit 4959aa4

File tree

4 files changed

+450
-0
lines changed

4 files changed

+450
-0
lines changed

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 support 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 of 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 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_compatibility`, supporting versions < 2.12.0.
33+
34+
> 📝 **Note**
35+
>
36+
> `snforge_std_compatibility` 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_compatibility`.
39+
40+
```diff
41+
[dev-dependencies]
42+
- snforge_std = "0.46.0"
43+
+ snforge_std_compatibility = "0.47.0"
44+
```
45+
46+
Next, replace all kinds of imports in your code from `snforge_std` to `snforge_std_compatibility`
47+
48+
```diff
49+
// Replace use statements
50+
- use snforge_std::{ContractClassTrait, start_cheat_caller_address};
51+
+ use snforge_std_compatibility::{ContractClassTrait, start_cheat_caller_address};
52+
53+
// Replace full path usages
54+
- let result = snforge_std::declare("MyContract").unwrap();
55+
+ let result = snforge_std_compatibility::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)