Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tools/foundry subchapter #1151

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add tools/foundry subchapter #1151

wants to merge 6 commits into from

Conversation

ZigaMr
Copy link

@ZigaMr ZigaMr commented Feb 20, 2025

This PR adds foundry subchapter to tools.

@ZigaMr ZigaMr requested review from matevz and rube-de February 20, 2025 12:42
Copy link

netlify bot commented Feb 20, 2025

Deploy Preview for oasisprotocol-docs ready!

Name Link
🔨 Latest commit b010a8b
🔍 Latest deploy log https://app.netlify.com/sites/oasisprotocol-docs/deploys/67bdce75441a7c0008ce0c7d
😎 Deploy Preview https://deploy-preview-1151--oasisprotocol-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also mention the forge verify command they can use after the contract is deployed. Details are on the Contract verification page.

@ZigaMr ZigaMr force-pushed the ZigaMr/foundry-docs branch from d082058 to af86c0a Compare February 24, 2025 13:08

## Setup and Configuration

Foundry uses default revm EVM implementation which does not contain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this paragraph under the Installing Sapphire Foundry (Optional) section.

Also:

Suggested change
Foundry uses default revm EVM implementation which does not contain
Foundry uses [revm] EVM implementation which does not contain

and below:

[revm]: https://github.com/bluealloy/revm

Comment on lines +46 to +48
**Sapphire Contracts** package is also provided. It contains
helper solidity contracts and libraries that enable convenient access to
on-chain data and precompiles (rng, signatures, on-chain encryption, etc.).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this under step 3. below.

package using Foundry package manager [soldeer]:

```shell
forge soldeer install @oasisprotocol-sapphire-contracts~0.2.11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version could be omitted right?

Suggested change
forge soldeer install @oasisprotocol-sapphire-contracts~0.2.11
forge soldeer install @oasisprotocol-sapphire-contracts

1. Install the **Sapphire Foundry** soldeer package:

```shell
forge soldeer install @oasisprotocol-sapphire-foundry~0.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
forge soldeer install @oasisprotocol-sapphire-foundry~0.1.0
forge soldeer install @oasisprotocol-sapphire-foundry

forge soldeer install @oasisprotocol-sapphire-foundry~0.1.0
```

2. Add `ffi = true` to your foundry.toml file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. Add `ffi = true` to your foundry.toml file:
2. Add `ffi = true` to your `foundry.toml` file:

Comment on lines +87 to +89
3. Your foundry.toml file should now look like this:

```toml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge 2. and 3.:

Suggested change
3. Your foundry.toml file should now look like this:
```toml
```toml title="foundry.toml"

Comment on lines +148 to +151
```
and then inherit from `SapphireTest` from `BaseSapphireTest.sol`
and override the `setUp()` function:
```solidity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
and then inherit from `SapphireTest` from `BaseSapphireTest.sol`
and override the `setUp()` function:
```solidity
```
and then inherit from `SapphireTest` from `BaseSapphireTest.sol`
and override the `setUp()` function:
```solidity


Forge scripts should run the same way as tests.

## A note on Forks/External RPC nodes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## A note on Forks/External RPC nodes
## A Note on Forks/External RPC Nodes

Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more suggestions.

cargo +nightly build --release
```

## Sapphire specific features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Sapphire specific features
## Sapphire-specific tests

The `@oasisprotocol-sapphire-foundry` package enables
testing with precompiles and encrypted calls.

#### Precompiles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Precompiles
### Precompiles

}
```

#### Encrypted Transactions and Calls
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#### Encrypted Transactions and Calls
### Encrypted Transactions and Calls

3. `vm.broadcastRawTransaction(raw_tx)` to send the raw transaction.


### Forge Tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Forge Tests
### `forge test`


[foundry-example]: https://github.com/oasisprotocol/sapphire-paratime/tree/main/examples/foundry

### Forge Script
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Forge Script
### `forge script`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants