Skip to content

Commit

Permalink
chore: split snforge/cairo-test scarb config
Browse files Browse the repository at this point in the history
  • Loading branch information
julio4 committed Sep 19, 2024
1 parent 99118f5 commit 68e8d7b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
37 changes: 34 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ You can add or modify examples in the `listings` directory. Each listing is a sc
You can find a template of a blank scarb project in the `listings/template` directory.
(You can also use `scarb init` to create a new scarb project, but be sure to remove the generated git repository)

Here's the required `Scarb.toml` configuration:
You can choose to use standard cairo with `cairo-test` or Starknet Foundry with `snforge_std`.
Please use the appropriate `Scarb.toml` configuration. `scarb test` will automatically resolve to `snforge test` if `snforge_std` is in the dependencies.

Here's the required `Scarb.toml` configuration for **Cairo test**:

```toml
[package]
Expand All @@ -74,8 +77,6 @@ version.workspace = true
[dependencies]
starknet.workspace = true
# Uncomment the following lines if you want to use additional dependencies:
# Starknet Foundry:
# snforge_std.workspace = true
# OpenZeppelin:
# openzeppelin.workspace = true

Expand All @@ -92,6 +93,36 @@ test.workspace = true
casm = true
```

Here's the required `Scarb.toml` configuration for **Starknet Foundry**:

```toml
[package]
name = "pkg_name"
version.workspace = true

# Specify that this can be used as a dependency in another scarb project:
[lib]

[dependencies]
starknet.workspace = true
snforge_std.workspace = true
# Uncomment the following lines if you want to use additional dependencies:
# OpenZeppelin:
# openzeppelin.workspace = true

# If you want to use another Starknet By Example's listing, you can add it as a dependency like this:
# erc20 = { path = "../../getting-started/erc20" }

[dev-dependencies]
assert_macros.workspace = true

[scripts]
test.workspace = true

[[target.starknet-contract]]
casm = true
```

You also NEED to do the following:

- Remove the generated git repository, `rm -rf .git` (this is important!)
Expand Down
6 changes: 5 additions & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ members = [
"listings/templates/*",
]

[workspace.scripts]
test = "$(git rev-parse --show-toplevel)/scripts/test_resolver.sh"

[workspace.tool.snforge]

[workspace.dependencies]
starknet = "2.8.2"
cairo_test = "2.8.2"
openzeppelin = "0.16.0"
assert_macros = "2.8.2"
snforge_std = "0.30.0"
openzeppelin = "0.16.0"
components = { path = "listings/applications/components" }

[workspace.package]
Expand Down
2 changes: 1 addition & 1 deletion listings/applications/advanced_factory/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ snforge_std.workspace = true
crowdfunding = { path = "../crowdfunding" }

[dev-dependencies]
cairo_test.workspace = true
assert_macros.workspace = true

[scripts]
test.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion listings/applications/crowdfunding/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ components.workspace = true
snforge_std.workspace = true

[dev-dependencies]
cairo_test.workspace = true
assert_macros.workspace = true

[scripts]
test.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion listings/applications/nft_dutch_auction/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ starknet.workspace = true
snforge_std.workspace = true

[dev-dependencies]
cairo_test.workspace = true
assert_macros.workspace = true

[scripts]
test.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion listings/applications/timelock/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ openzeppelin.workspace = true
components.workspace = true

[dev-dependencies]
cairo_test.workspace = true
assert_macros.workspace = true

[scripts]
test.workspace = true
Expand Down

0 comments on commit 68e8d7b

Please sign in to comment.