Skip to content

0.2.0-alpha.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 02 May 14:27
· 1064 commits to main since this release
25f716a

Scarb 0.2.0-alpha.1

Note: This version is not yet supported on Starknet! Scarb v0.2 will target Starknet v0.12. If you want to develop contracts deployable to current Starknet v0.11, please stick with Scarb v0.1.


Welcome to the release notes for Scarb v0.2! Here's what has changed these two weeks:

  • Cairo 1.0.0-rc0 - we have updated Cairo to the latest release
  • Cairo LS now comes bundled with Scarb - editor plugins now get access to the always-working revision of the LSP
  • Conditional compilation - #[cfg(target: 'starknet-contract')]
  • Work towards compiler plugins
    • Breaking change: the Compiler interface has been redone

Cairo LS now comes bundled with Scarb

The cairo-lang-language-server crate from Starkware implements a language server (refered to as Cairo LS) used by the Cairo extension for Visual Studio Code.

Since this release, the Cairo LS comes bundled into Scarb as a subcommand under cairo-language-server name (see Subcommands for more information). The Cairo extension is now capable of detecting and using the bundled Cairo LS binary. This allows Scarb to ensure both the extension and itself work with the same version of Cairo language, providing more consistent developer experience to extension users. There is no longer need to install the language server separately from Scarb.

Conditional compilation

Conditionally compiled source code is source code that may or may not be considered a part of the source code depending on certain conditions. Source code can be conditionally compiled using the cfg attribute.

The cfg attribute conditionally includes the thing it is attached to based on a configuration predicate. If the predicate is true, the item is rewritten to not have the cfg attribute on it. Otherwise, the item is removed from the source code.

For example, this attribute can be used to provide different implementations of a function depending on current Scarb target:

#[cfg(target: 'lib')]
fn example() -> felt252 {
    42
}

#[cfg(target: 'starknet-contract')]
fn example() -> felt252 {
    512
}

Which configuration options are set is determined statically during the compilation of the compilation unit of the compiled package. It is not possible to set a configuration option from within the source code of the package being compiled.

See Conditional Compilation reference page for more information.

Work towards compiler plugins

As part of our roadmap, we plan to support user defined Cairo compiler plugins, ideally distributed outside of Scarb source code and required as package dependencies. While this feature is not fully implemented yet, this release includes some ground work required to make this goal achievable in the future.

Cairo plugin is a special Scarb package that defines a cairo-plugin target and provides additional interface for instantiating compiler Semantic plugins. When using Scarb as a library, Cairo plugins can now be defined with configuration builder. If not specified otherwise, Scarb comes with predefined StarkNet Cairo plugin. The mechanism for requiring Cairo plugins as package dependencies or compiling them in Scarb runtime is not implemented yet.

See RFC: Scarb compiler plugins for more information.

Minor changes

  1. We have added a documentation page about using Scarb in CI workflows. It starts with a template usage for GitHub Actions, GitLab CI and CircleCI.
  2. scarb --version will now explicitly tell you if you're running a published Cairo version pulled from crates.io.

Cairo version

This version of Scarb comes with Cairo v1.0.0-rc0.

What's Changed

New Contributors

Full Changelog: v0.2.0-alpha.0...v0.2.0-alpha.1