Skip to content

Commit

Permalink
Installation docs and installation script (foundry-rs#115)
Browse files Browse the repository at this point in the history
Co-authored-by: Wojciech Szymczyk <[email protected]>
  • Loading branch information
piotmag769 and THenry14 authored Jul 18, 2023
1 parent 7327e7b commit 140c38b
Show file tree
Hide file tree
Showing 26 changed files with 569 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To run tests scripts, you have to install:
- [asdf](https://asdf-vm.com/guide/getting-started.html)
- [starknet-devnet](https://0xspaceshard.github.io/starknet-devnet/docs/intro)

> ⚠️ Make sure you run `./scripts/prepare-for-tests.sh` after setting up the development environment, otherwise the
> ⚠️ Make sure you run `./scripts/prepare_for_tests.sh` after setting up the development environment, otherwise the
> tests will fail.
Before creating a contribution, make sure your code passes the following checks
Expand Down
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ Starknet Foundry, like its [Ethereum counterpart](https://github.com/foundry-rs/
- [Cast](https://github.com/foundry-rs/starknet-foundry/tree/master/starknet-foundry/crates/cast): All-in-one tool for
interacting with Starknet smart contracts, sending transactions and getting chain data.

## Installation

To install Starknet Foundry, run:

```shell
$ curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/install.sh | sh
```

You can also specify a version you wish to install:

```shell
$ curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/install.sh | sh -s -- -v 0.1.0
```

To verify that the Starknet Foundry is installed correctly, run `snforge --version` and `sncast --version`.


## Features

- Fast testing framework `Forge` written in Rust
Expand Down Expand Up @@ -67,4 +84,4 @@ Starknet Foundry is under active development, and we appreciate any help from th
the [contribution guidelines](./CONTRIBUTING.md).

Check out [development guide](https://foundry-rs.github.io/starknet-foundry/development/environment-setup.html) for
local environment setup guide.
local environment setup guide.
2 changes: 1 addition & 1 deletion benchmarks/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
TOOLCHAINS = [
# name, command, cairo version
("protostar", ["protostar", "test"], 1),
("forge", ["forge"], 2),
("forge", ["snforge"], 2),
("cairo_test", ["scarb", "cairo-test"], 2),
]

Expand Down
2 changes: 1 addition & 1 deletion docs/book.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[book]
authors = ["Starknet-Foundry"]
authors = ["Starknet Foundry"]
language = "en"
multilingual = false
src = "src"
Expand Down
1 change: 0 additions & 1 deletion docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

# Projects

* [Project Templates](projects/template.md)
* [Project Configuration](projects/configuration.md)

# Forge overview
Expand Down
2 changes: 1 addition & 1 deletion docs/src/development/environment-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ It is not possible to run tests without these installed.

## Running Tests

> ⚠️ Make sure you run `./scripts/prepare-for-tests.sh` after setting up the development environment, otherwise the
> ⚠️ Make sure you run `./scripts/prepare_for_tests.sh` after setting up the development environment, otherwise the
> tests will fail.
Tests can be run with:
Expand Down
10 changes: 5 additions & 5 deletions docs/src/getting-started/first-steps.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# First Steps With Starknet-Foundry
# First Steps With Starknet Foundry

In this section we provide an overview of Starknet-Foundry `forge` command line tool. We demonstrate how to create a
new project, compile, and test it.
In this section we provide an overview of Starknet Foundry `forge` command line tool.
We demonstrate how to create a new project, compile, and test it.

To start a new project with Starknet-Foundry, clone the template repository
To start a new project with Starknet Foundry, clone the template repository

```shell
$ git clone https://github.com/foundry-rs/starknet_forge_template.git
Expand All @@ -30,7 +30,7 @@ $ tree . -L 1
And run tests with `forge`

```shell
$ forge
$ snforge
Collected 2 test(s) and 2 test file(s)
Running 0 test(s) from src/lib.cairo
Running 2 test(s) from tests/test_contract.cairo
Expand Down
12 changes: 11 additions & 1 deletion docs/src/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ To use Starknet Foundry, you need [Scarb](https://docs.swmansion.com/scarb/docs/
You can find what version of Scarb is compatible with your version of Starknet Foundry in [release notes](https://github.com/foundry-rs/starknet-foundry/releases).

### Install via installation script
1. Open a terminal and run the following command:
```shell
$ curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/install.sh | sh
```
2. To verify that the Starknet Foundry is installed correctly, run `snforge --version` and `sncast --version`.
In some cases, you may need to close and reopen the terminal.

TODO: https://github.com/foundry-rs/starknet-foundry/pull/115
You can also specify a version you wish to install:

```shell
$ curl -L https://raw.githubusercontent.com/foundry-rs/starknet-foundry/master/install.sh | sh -s -- -v 0.1.0
```

## How to build Starknet Foundry from source code
If you are unable to install Starknet Foundry using the instructions above, you can try building it from the [source code](https://github.com/foundry-rs/starknet-foundry) as follows:
Expand Down
4 changes: 2 additions & 2 deletions docs/src/projects/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defined in the profile.
> the rest of them using CLI flags. You can also override parameters from the configuration using CLI flags.
```shell
$ cast --profile myprofile \
$ sncast --profile myprofile \
call \
--contract-address 0x38b7b9507ccf73d79cb42c2cc4e58cf3af1248f342112879bfdf5aa4f606cc9 \
--function get \
Expand Down Expand Up @@ -78,7 +78,7 @@ url = "http://127.0.0.1:5050/rpc"
That way, you can omit passing `--profile` parameter:
```shell
$ cast call \
$ sncast call \
--contract-address 0x38b7b9507ccf73d79cb42c2cc4e58cf3af1248f342112879bfdf5aa4f606cc9 \
--function get \
--calldata 0x0 \
Expand Down
1 change: 0 additions & 1 deletion docs/src/projects/template.md

This file was deleted.

6 changes: 3 additions & 3 deletions docs/src/starknet/call.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

Starknet Foundry cast supports calling smart contracts on a given network with the `cast call` command.
Starknet Foundry cast supports calling smart contracts on a given network with the `sncast call` command.

The basic inputs that you need for this command are:

Expand All @@ -17,7 +17,7 @@ For a detailed CLI description, see the [call command reference](../appendix/cas
### With [profiles](../projects/configuration.md#Cast)

```shell
$ cast call \
$ sncast call \
--profile testnet \
--contract-address 0x4a739ab73aa3cac01f9da5d55f49fb67baee4919224454a2e3f85b16462a911 \
--function some_function \
Expand All @@ -30,7 +30,7 @@ response: [FieldElement { inner: 0x000000000000000000000000000000000000000000000
### Without profiles
```shell
$ cast \
$ sncast \
--rpc_url http://127.0.0.1:5050 \
--network testnet \
call \
Expand Down
2 changes: 1 addition & 1 deletion docs/src/starknet/declare.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ First make sure that you have created a [`Scarb.toml`](../projects/template.md)
Then run:

```shell
$ cast --account myuser \
$ sncast --account myuser \
--network testnet \
--url http://127.0.0.1:5050/rpc \
declare \
Expand Down
4 changes: 2 additions & 2 deletions docs/src/starknet/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

Starknet Foundry cast supports deploying smart contracts to a given network with the `cast deploy` command.
Starknet Foundry cast supports deploying smart contracts to a given network with the `sncast deploy` command.

It works by invoking a [Universal Deployer Contract](https://docs.openzeppelin.com/contracts-cairo/0.6.1/udc), which deploys the contract with the given class hash and constructor arguments.

Expand All @@ -13,7 +13,7 @@ For detailed CLI description, see [deploy command reference](../appendix/cast/de
After [declaring your contract](./declare.md), you can deploy it the following way:

```shell
$ cast deploy --class-hash 0x8448a68b5ea1affc45e3fd4b8b480ea36a51dc34e337a16d2567d32d0c6f8a
$ sncast deploy --class-hash 0x8448a68b5ea1affc45e3fd4b8b480ea36a51dc34e337a16d2567d32d0c6f8a
command: Deploy
contract_address: 0x301316d47a81b39c5e27cca4a7b8ca4773edbf1103218588d6da4d3ed53035a
transaction_hash: 0x64a62a000240e034d1862c2bbfa154aac6a8195b4b2e570f38bf4fd47a5ab1e
Expand Down
6 changes: 3 additions & 3 deletions docs/src/starknet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Starknet Foundry `cast` is a command line tool for performing Starknet RPC calls
## How to use cast

To use cast, run the cast command followed by a subcommand (see [available commands](../appendix/cast.md)):
To use cast, run the `sncast` command followed by a subcommand (see [available commands](../appendix/cast.md)):
```shell
$ cast <subcommand>
$ sncast <subcommand>
```

If `Scarb.toml` is present and configured with `[tool.cast]`, `url`, `network` and `account` name will be taken from it. You can, however, overwrite their values by supplying them as flags directly to `cast` cli.
Expand All @@ -22,7 +22,7 @@ If `Scarb.toml` is present and configured with `[tool.cast]`, `url`, `network` a
Let's use `cast` to call a contract's function:

```shell
$ cast --account myotheruser \
$ sncast --account myotheruser \
--network testnet \
--url http://127.0.0.1:5050/rpc \
call \
Expand Down
8 changes: 4 additions & 4 deletions docs/src/starknet/invoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Overview

Starknet Foundry cast supports invoking smart contracts on a given network with the `cast invoke` command.
Starknet Foundry cast supports invoking smart contracts on a given network with the `sncast invoke` command.

In most cases you have to provide:
In most cases, you have to provide:

- Contract address
- Function name
Expand All @@ -17,7 +17,7 @@ For detailed CLI description, see [invoke command reference](../appendix/cast/in
### Without profiles

```shell
$ cast \
$ sncast \
--rpc_url http://127.0.0.1:5050 \
--network testnet \
--account example_user \
Expand All @@ -34,7 +34,7 @@ $ cast \
### With [profiles](../projects/configuration.md#Cast)

```shell
$ cast invoke \
$ sncast invoke \
--profile testnet \
--contract-address 0x4a739ab73aa3cac01f9da5d55f49fb67baee4919224454a2e3f85b16462a911 \
--function "some_function" \
Expand Down
6 changes: 3 additions & 3 deletions docs/src/testing/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn call_and_invoke() {
```
```shell
$ forge
$ snforge
Collected 1 test(s) and 1 test file(s)
Running 1 test(s) from src/lib.cairo
[PASS] using_dispatchers::using_dispatchers::call_and_invoke
Expand Down Expand Up @@ -112,7 +112,7 @@ fn failing() {
```

```shell
$ forge
$ snforge
Collected 1 test(s) and 1 test file(s)
Running 1 test(s) from src/lib.cairo
[FAIL] src::failing
Expand Down Expand Up @@ -147,7 +147,7 @@ fn handling_errors() {
Now the test passes as expected.
```shell
$ forge
$ snforge
Collected 1 test(s) and 1 test file(s)
Running 1 test(s) from src/lib.cairo
[PASS] src::handling_errors
Expand Down
2 changes: 1 addition & 1 deletion docs/src/testing/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_print() {
Running tests will include prints in the output:

```shell
$ forge
$ snforge
Collected 1 test(s) and 2 test file(s)
Running 0 test(s) from src/lib.cairo
Running 1 test(s) from tests/test_print.cairo
Expand Down
6 changes: 3 additions & 3 deletions docs/src/testing/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ fn test_sum() {
It is a common practice to keep your unit tests in the same file as the tested code. If you prefer, you can also put
test code in a separate file anywhere in the project directory.
Now run forge using command:
Now run forge using a command:
```shell
$ forge
$ snforge
Collected 1 test(s) and 1 test file(s)
Running 1 test(s) from src/lib.cairo
[PASS] src::test_sum
Expand Down Expand Up @@ -57,7 +57,7 @@ fn failing() {
```

```shell
$ forge
$ snforge
Collected 1 test(s) and 1 test file(s)
Running 1 test(s) from src/lib.cairo
[FAIL] src::failing
Expand Down
Loading

0 comments on commit 140c38b

Please sign in to comment.