diff --git a/crates/sncast/src/helpers/scarb_utils.rs b/crates/sncast/src/helpers/scarb_utils.rs index 89bd1c516a..52d69eb576 100644 --- a/crates/sncast/src/helpers/scarb_utils.rs +++ b/crates/sncast/src/helpers/scarb_utils.rs @@ -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()); } @@ -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] diff --git a/crates/sncast/tests/data/scripts/declare/Scarb.toml b/crates/sncast/tests/data/scripts/declare/Scarb.toml index ffec466e3c..efa89308a1 100644 --- a/crates/sncast/tests/data/scripts/declare/Scarb.toml +++ b/crates/sncast/tests/data/scripts/declare/Scarb.toml @@ -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"] diff --git a/crates/sncast/tests/data/scripts/map_script/contracts/Scarb.toml b/crates/sncast/tests/data/scripts/map_script/contracts/Scarb.toml index 075a67a53f..5355fa5dec 100644 --- a/crates/sncast/tests/data/scripts/map_script/contracts/Scarb.toml +++ b/crates/sncast/tests/data/scripts/map_script/contracts/Scarb.toml @@ -1,5 +1,5 @@ [package] -name = "map" +name = "map1" version = "0.2.0" [dependencies] @@ -9,4 +9,3 @@ starknet = ">=2.4.0" [lib] sierra = false - diff --git a/crates/sncast/tests/data/scripts/map_script/scripts/Scarb.toml b/crates/sncast/tests/data/scripts/map_script/scripts/Scarb.toml index 23fe9ac88b..95eae4f1f4 100644 --- a/crates/sncast/tests/data/scripts/map_script/scripts/Scarb.toml +++ b/crates/sncast/tests/data/scripts/map_script/scripts/Scarb.toml @@ -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"] diff --git a/docs/listings/sncast_overview/crates/map/Scarb.toml b/docs/listings/sncast_overview/crates/map3/Scarb.toml similarity index 94% rename from docs/listings/sncast_overview/crates/map/Scarb.toml rename to docs/listings/sncast_overview/crates/map3/Scarb.toml index 105431aba7..4dec1caab6 100644 --- a/docs/listings/sncast_overview/crates/map/Scarb.toml +++ b/docs/listings/sncast_overview/crates/map3/Scarb.toml @@ -1,5 +1,5 @@ [package] -name = "map" +name = "map3" version = "0.1.0" edition = "2024_07" diff --git a/docs/listings/sncast_overview/crates/map/src/lib.cairo b/docs/listings/sncast_overview/crates/map3/src/lib.cairo similarity index 100% rename from docs/listings/sncast_overview/crates/map/src/lib.cairo rename to docs/listings/sncast_overview/crates/map3/src/lib.cairo diff --git a/docs/listings/sncast_overview/scripts/full_example/Scarb.toml b/docs/listings/sncast_overview/scripts/full_example/Scarb.toml index da360e17f7..e4e6c65dee 100644 --- a/docs/listings/sncast_overview/scripts/full_example/Scarb.toml +++ b/docs/listings/sncast_overview/scripts/full_example/Scarb.toml @@ -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 diff --git a/docs/src/starknet/script.md b/docs/src/starknet/script.md index e0c7ee912f..90657121aa 100644 --- a/docs/src/starknet/script.md +++ b/docs/src/starknet/script.md @@ -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`. @@ -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: @@ -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 ``` @@ -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 . @@ -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 . @@ -142,6 +145,7 @@ $ tree ``` ### 2. scripts disjointed from the workspace with cairo contracts + ```shell $ tree . @@ -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: