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 8 commits into
base: main
Choose a base branch
from
Open

Add tools/foundry subchapter #1151

wants to merge 8 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 1be90bf
🔍 Latest deploy log https://app.netlify.com/sites/oasisprotocol-docs/deploys/67cb4a3099068d00083c76cb
😎 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
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

Copy link
Author

Choose a reason for hiding this comment

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

I couldn't find a way to make it work without specifying version. The suggested change returns an error, and in soldeer/foundry docs, version is always mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, Soldeer needs a version, there is nothing similar like @latest
To omit the version in the cmd line, the foundry.toml would to be updated first with the dependencies, then you could use forge soldeer install.

Copy link
Author

Choose a reason for hiding this comment

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

Since these are step-by-step instructions I think it's better to leave it as is. forge soldeer install shortcut and foundry.toml are already mentioned in the later section.

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.

Comment on lines 53 to 64

```toml
[profile.default]
src = "src"
out = "out"
libs = ["lib", "dependencies"]
ffi = true

[dependencies]
"@oasisprotocol-sapphire-contracts" = "0.2.11"
"@oasisprotocol-sapphire-foundry" = "0.1.0"
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```toml
[profile.default]
src = "src"
out = "out"
libs = ["lib", "dependencies"]
ffi = true
[dependencies]
"@oasisprotocol-sapphire-contracts" = "0.2.11"
"@oasisprotocol-sapphire-foundry" = "0.1.0"
```
```toml title="foundry.toml"
[profile.default]
src = "src"
out = "out"
libs = ["lib", "dependencies"]
// highlight-start
ffi = true
[dependencies]
"@oasisprotocol-sapphire-contracts" = "0.2.11"
"@oasisprotocol-sapphire-foundry" = "0.1.0"
// highlight-end

Copy link
Author

Choose a reason for hiding this comment

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

Added highlighting.

Comment on lines 66 to 70
- `ffi = true` enables `vm.ffi()` ([foreign function interface]) which is used to call rust bindings
which contain the precompile and decryption logic.

- `"dependencies"` is a list of dependencies that are required for the project.
We use Foundry package manager [soldeer] to install these dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `ffi = true` enables `vm.ffi()` ([foreign function interface]) which is used to call rust bindings
which contain the precompile and decryption logic.
- `"dependencies"` is a list of dependencies that are required for the project.
We use Foundry package manager [soldeer] to install these dependencies.
- `ffi = true` enables `vm.ffi()` ([foreign function interface]) which is used to call rust bindings
which contain the precompile and decryption logic.
- `"dependencies"` is a list of dependencies that are required for the project.
We use Foundry package manager [soldeer] to install these dependencies.

Copy link
Author

Choose a reason for hiding this comment

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

Added indentation.

package using Foundry package manager [soldeer]:

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

Choose a reason for hiding this comment

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

Yes, Soldeer needs a version, there is nothing similar like @latest
To omit the version in the cmd line, the foundry.toml would to be updated first with the dependencies, then you could use forge soldeer install.

helper solidity contracts and libraries that enable convenient access to
on-chain data and precompiles (rng, signatures, on-chain encryption, etc.).
After intializing the project, we can install the **Sapphire Contracts**
package using Foundry package manager [soldeer]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
package using Foundry package manager [soldeer]:
package using Foundry package manager [Soldeer]:

nitpick - lets keep product names capitalized

available in the default revm.
When using `forge script` on an external RPC node or a fork,
precompiles are available through the `vm.rpcUrl()` cheatcode.
To disable simulation on integrated revm make sure to disable
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused, does simulation make sense with Sapphire?
At what point you wouldn't use --no-simulation?
If you use forge script without an external RPC, how do you use the precompiles?

## Verification with Foundry

After contracts are deployed, you can verify them with Sourcify.
Check out the [verification with foundry] section for more details.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Check out the [verification with foundry] section for more details.
Check out the [Verification with Foundry] section for more details.

nitpick - keep capitalization like in the header

[gasless transactions]: ../sapphire/develop/gasless
[key]: ../sapphire/develop/concept
[examples/foundry]: https://github.com/oasisprotocol/sapphire-paratime/tree/main/examples/foundry
[verification with foundry]: ./verification/#verification-with-foundry
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[verification with foundry]: ./verification/#verification-with-foundry
[Verification with Foundry]: ./verification/#verification-with-foundry

[examples/foundry]: https://github.com/oasisprotocol/sapphire-paratime/tree/main/examples/foundry
[verification with foundry]: ./verification/#verification-with-foundry
[foreign function interface]: https://book.getfoundry.sh/cheatcodes/ffi
[soldeer]: https://book.getfoundry.sh/projects/soldeer?highlight=soldeer#soldeer-as-a-package-manager
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[soldeer]: https://book.getfoundry.sh/projects/soldeer?highlight=soldeer#soldeer-as-a-package-manager
[Soldeer]: https://book.getfoundry.sh/projects/soldeer?highlight=soldeer#soldeer-as-a-package-manager

[foreign function interface]: https://book.getfoundry.sh/cheatcodes/ffi
[soldeer]: https://book.getfoundry.sh/projects/soldeer?highlight=soldeer#soldeer-as-a-package-manager
[Oasis Web3 gateway]: ../../node/web3.mdx
[revm]: https://github.com/bluealloy/revm
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[revm]: https://github.com/bluealloy/revm
[Revm]: https://github.com/bluealloy/revm

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