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 Stylus script example to the template #25

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

Conversation

reo101
Copy link

@reo101 reo101 commented Mar 21, 2024

Description

Context

Introduce scripting templates into the boilerplate that can be executed using cargo stylus script (see related cargo-stylus PR here)

Note

The branch is not ready to be merged yet, there’s a couple of commits that out fork is lacking, we’ll merge them in soon
OffchainLabs:main merged!

Changes

  • Add deploy_and_interact script
    • Replaces old counter.rs example
    • Currently relies on a common library, shipped alongside the script, with the intention of moving that library into the cargo-stylus lib crate.
    • The common crate houses utilities for reading network configurations, creating provider and wallet instances, based on those configurations, and a function to aid the deployment of the main contract
      • The deployment helper can be extended to accept a contract name when/if Stylus starts supporting the definition of multiple contracts in a single Stylus project
  • Add Stylus.toml, containing network configurations
  • Remove counter.rs from examples
  • Update README.md to reflect those changes
    • Remove Calling Your Program section
    • Add Deploying + Interacting with scripts section

Checklist

  • I have documented these changes where necessary.
  • I have read the DCO and ensured that these changes comply.
  • I assign this work under its open source licensing.

reo101 and others added 22 commits March 18, 2024 10:34
Includes `common` lib, used throughout all scripts
Scripts can be run using `cargo stylus script run ${SCRIPT_NAME}`
Convert `counter.rs` example into a script
Add a deployment script, building on top of the `cargo-stylus` `deploy` functionality
All scripts (+ `common`) sit in a `cargo` `workspace` (for now) under `./scripts`
Redefine project root to be the first directory containing `.git`
Also remove stray `dbg!` call
`NetworkConfig` -> `Config`
`rest` -> `env`
Change `common::deploy()` to return the programm address
Mainly for `additional_variables`
Also add newline at `Stylus.toml`'s EOF
Also import `eyre::Result` in example script
chore!: docs and example nits and fixes
Also add filetypes (`bash`) to all appropriate code snippets
Exported from `cargo_stylus`
`cargo_stylus::common` -> `cargo_stylus::util::scripts`
…xtraction

Extract away `common` into `cargo-stylus`
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.

2 participants