Skip to content

Commit

Permalink
Rename map packages (#2527)
Browse files Browse the repository at this point in the history
Fixes issue with multiple map's in the repo being detected by scarb
  • Loading branch information
Arcticae authored Sep 26, 2024
1 parent 746705b commit 72ea785
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
12 changes: 8 additions & 4 deletions crates/sncast/src/helpers/scarb_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ mod tests {

#[test]
fn test_get_scarb_metadata() {
let metadata = get_scarb_metadata(&"tests/data/contracts/map/Scarb.toml".into());
let metadata =
get_scarb_metadata(&"tests/data/contracts/constructor_with_params/Scarb.toml".into());
assert!(metadata.is_ok());
}

Expand All @@ -208,9 +209,12 @@ mod tests {

#[test]
fn test_get_package_metadata_happy_default() {
let metadata =
get_package_metadata(&"tests/data/contracts/map/Scarb.toml".into(), &None).unwrap();
assert_eq!(metadata.name, "map");
let metadata = get_package_metadata(
&"tests/data/contracts/constructor_with_params/Scarb.toml".into(),
&None,
)
.unwrap();
assert_eq!(metadata.name, "constructor_with_params");
}

#[test]
Expand Down
6 changes: 2 additions & 4 deletions crates/sncast/tests/data/scripts/declare/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ version = "0.1.0"
[dependencies]
starknet = ">=2.3.0"
sncast_std = { path = "../../../../../../sncast_std" }
map = { path = "../map_script/contracts" }
map1 = { path = "../map_script/contracts" }

[lib]
sierra = true
casm = true

[[target.starknet-contract]]
build-external-contracts = [
"map::Mapa",
]
build-external-contracts = ["map1::Mapa"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "map"
name = "map1"
version = "0.2.0"

[dependencies]
Expand All @@ -9,4 +9,3 @@ starknet = ">=2.4.0"

[lib]
sierra = false

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ version = "0.1.0"
[dependencies]
starknet = ">=2.3.0"
sncast_std = { path = "../../../../../../../sncast_std" }
map = { path = "../contracts" }
map1 = { path = "../contracts" }

[lib]
sierra = true
casm = true

[[target.starknet-contract]]
build-external-contracts = [
"map::Mapa",
"map::Mapa2"
]

build-external-contracts = ["map1::Mapa", "map1::Mapa2"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "map"
name = "map3"
version = "0.1.0"
edition = "2024_07"

Expand Down
4 changes: 2 additions & 2 deletions docs/listings/sncast_overview/scripts/full_example/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ edition = "2024_07"
[dependencies]
snforge_std.workspace = true
sncast_std.workspace = true
map = { path = "../../crates/map" }
map3 = { path = "../../crates/map3" }

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

[[target.lib]]
sierra = true
Expand Down
16 changes: 10 additions & 6 deletions docs/src/starknet/script.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

> ⚠️⚠️⚠️ Highly experimental code, a subject to change ⚠️⚠️⚠️
> ⚠️⚠️⚠️ Highly experimental code, a subject to change ⚠️⚠️⚠️
Starknet Foundry cast can be used to run deployment scripts written in Cairo, using `script run` subcommand.
It aims to provide similar functionality to Foundry's `forge script`.
Expand All @@ -22,14 +22,14 @@ contracts from within Cairo, its interface, internals and feature set can change
>
> Example:
>
>```rust
> ```rust
> let declare_result = declare(
> "Map",
> FeeSettings::Eth(EthFeeSettings { max_fee: Option::Some(max_fee) }),
> Option::Some(nonce)
> )
> .expect('declare failed');
>```
> ```
Some of the planned features that will be included in future versions are:
Expand All @@ -54,6 +54,7 @@ to the state file afterwards.
To prevent sncast from using the state file, you can set [the --no-state-file flag](../appendix/sncast/script/run.md#--no-state-file).
A state file is typically named in a following manner:
```
{script name}_{network name}_state.json
```
Expand All @@ -64,6 +65,7 @@ As sncast scripts are just regular scarb packages, there are multiple ways to in
Most common directory structures include:
### 1. `scripts` directory with all the scripts in the same workspace with cairo contracts (default for `sncast script init`)
```shell
$ tree
.
Expand All @@ -81,12 +83,13 @@ $ tree
> 📝 **Note**
> You should add `scripts` to `members` field in your top-level Scarb.toml to be able to run the script from
anywhere in the workspace - otherwise you will have to run the script from within its directory. To learn more consult
[Scarb documentation](https://docs.swmansion.com/scarb/docs/reference/workspaces.html#members).
> anywhere in the workspace - otherwise you will have to run the script from within its directory. To learn more consult
> [Scarb documentation](https://docs.swmansion.com/scarb/docs/reference/workspaces.html#members).
You can also have multiple scripts as separate packages, or multiple modules inside one package, like so:
#### 1a. multiple scripts in one package
```shell
$ tree
.
Expand Down Expand Up @@ -142,6 +145,7 @@ $ tree
```
### 2. scripts disjointed from the workspace with cairo contracts
```shell
$ tree
.
Expand Down Expand Up @@ -218,7 +222,7 @@ status: success
This example script declares, deploys and interacts with an example `MapContract`:
```rust
{{#include ../../listings/sncast_overview/crates/map/src/lib.cairo}}
{{#include ../../listings/sncast_overview/crates/map3/src/lib.cairo}}
```
We prepare a script:
Expand Down

0 comments on commit 72ea785

Please sign in to comment.