Skip to content

Commit 72ea785

Browse files
authored
Rename map packages (#2527)
Fixes issue with multiple map's in the repo being detected by scarb
1 parent 746705b commit 72ea785

File tree

8 files changed

+26
-25
lines changed

8 files changed

+26
-25
lines changed

crates/sncast/src/helpers/scarb_utils.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ mod tests {
194194

195195
#[test]
196196
fn test_get_scarb_metadata() {
197-
let metadata = get_scarb_metadata(&"tests/data/contracts/map/Scarb.toml".into());
197+
let metadata =
198+
get_scarb_metadata(&"tests/data/contracts/constructor_with_params/Scarb.toml".into());
198199
assert!(metadata.is_ok());
199200
}
200201

@@ -208,9 +209,12 @@ mod tests {
208209

209210
#[test]
210211
fn test_get_package_metadata_happy_default() {
211-
let metadata =
212-
get_package_metadata(&"tests/data/contracts/map/Scarb.toml".into(), &None).unwrap();
213-
assert_eq!(metadata.name, "map");
212+
let metadata = get_package_metadata(
213+
&"tests/data/contracts/constructor_with_params/Scarb.toml".into(),
214+
&None,
215+
)
216+
.unwrap();
217+
assert_eq!(metadata.name, "constructor_with_params");
214218
}
215219

216220
#[test]

crates/sncast/tests/data/scripts/declare/Scarb.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ version = "0.1.0"
55
[dependencies]
66
starknet = ">=2.3.0"
77
sncast_std = { path = "../../../../../../sncast_std" }
8-
map = { path = "../map_script/contracts" }
8+
map1 = { path = "../map_script/contracts" }
99

1010
[lib]
1111
sierra = true
1212
casm = true
1313

1414
[[target.starknet-contract]]
15-
build-external-contracts = [
16-
"map::Mapa",
17-
]
15+
build-external-contracts = ["map1::Mapa"]
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "map"
2+
name = "map1"
33
version = "0.2.0"
44

55
[dependencies]
@@ -9,4 +9,3 @@ starknet = ">=2.4.0"
99

1010
[lib]
1111
sierra = false
12-

crates/sncast/tests/data/scripts/map_script/scripts/Scarb.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ version = "0.1.0"
55
[dependencies]
66
starknet = ">=2.3.0"
77
sncast_std = { path = "../../../../../../../sncast_std" }
8-
map = { path = "../contracts" }
8+
map1 = { path = "../contracts" }
99

1010
[lib]
1111
sierra = true
1212
casm = true
1313

1414
[[target.starknet-contract]]
15-
build-external-contracts = [
16-
"map::Mapa",
17-
"map::Mapa2"
18-
]
19-
15+
build-external-contracts = ["map1::Mapa", "map1::Mapa2"]

docs/listings/sncast_overview/crates/map/Scarb.toml renamed to docs/listings/sncast_overview/crates/map3/Scarb.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "map"
2+
name = "map3"
33
version = "0.1.0"
44
edition = "2024_07"
55

docs/listings/sncast_overview/scripts/full_example/Scarb.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ edition = "2024_07"
88
[dependencies]
99
snforge_std.workspace = true
1010
sncast_std.workspace = true
11-
map = { path = "../../crates/map" }
11+
map3 = { path = "../../crates/map3" }
1212

1313
[[target.starknet-contract]]
14-
build-external-contracts = ["map::MapContract"]
14+
build-external-contracts = ["map3::MapContract"]
1515

1616
[[target.lib]]
1717
sierra = true

docs/src/starknet/script.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
> ⚠️⚠️⚠️ Highly experimental code, a subject to change ⚠️⚠️⚠️
5+
> ⚠️⚠️⚠️ Highly experimental code, a subject to change ⚠️⚠️⚠️
66
77
Starknet Foundry cast can be used to run deployment scripts written in Cairo, using `script run` subcommand.
88
It aims to provide similar functionality to Foundry's `forge script`.
@@ -22,14 +22,14 @@ contracts from within Cairo, its interface, internals and feature set can change
2222
>
2323
> Example:
2424
>
25-
>```rust
25+
> ```rust
2626
> let declare_result = declare(
2727
> "Map",
2828
> FeeSettings::Eth(EthFeeSettings { max_fee: Option::Some(max_fee) }),
2929
> Option::Some(nonce)
3030
> )
3131
> .expect('declare failed');
32-
>```
32+
> ```
3333
3434
Some of the planned features that will be included in future versions are:
3535
@@ -54,6 +54,7 @@ to the state file afterwards.
5454
To prevent sncast from using the state file, you can set [the --no-state-file flag](../appendix/sncast/script/run.md#--no-state-file).
5555
5656
A state file is typically named in a following manner:
57+
5758
```
5859
{script name}_{network name}_state.json
5960
```
@@ -64,6 +65,7 @@ As sncast scripts are just regular scarb packages, there are multiple ways to in
6465
Most common directory structures include:
6566
6667
### 1. `scripts` directory with all the scripts in the same workspace with cairo contracts (default for `sncast script init`)
68+
6769
```shell
6870
$ tree
6971
.
@@ -81,12 +83,13 @@ $ tree
8183
8284
> 📝 **Note**
8385
> You should add `scripts` to `members` field in your top-level Scarb.toml to be able to run the script from
84-
anywhere in the workspace - otherwise you will have to run the script from within its directory. To learn more consult
85-
[Scarb documentation](https://docs.swmansion.com/scarb/docs/reference/workspaces.html#members).
86+
> anywhere in the workspace - otherwise you will have to run the script from within its directory. To learn more consult
87+
> [Scarb documentation](https://docs.swmansion.com/scarb/docs/reference/workspaces.html#members).
8688
8789
You can also have multiple scripts as separate packages, or multiple modules inside one package, like so:
8890
8991
#### 1a. multiple scripts in one package
92+
9093
```shell
9194
$ tree
9295
.
@@ -142,6 +145,7 @@ $ tree
142145
```
143146
144147
### 2. scripts disjointed from the workspace with cairo contracts
148+
145149
```shell
146150
$ tree
147151
.
@@ -218,7 +222,7 @@ status: success
218222
This example script declares, deploys and interacts with an example `MapContract`:
219223
220224
```rust
221-
{{#include ../../listings/sncast_overview/crates/map/src/lib.cairo}}
225+
{{#include ../../listings/sncast_overview/crates/map3/src/lib.cairo}}
222226
```
223227
224228
We prepare a script:

0 commit comments

Comments
 (0)